documentation.d.ts 3.5 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076810778107881079810808108181082810838108481085810868108781088810898109081091810928109381094810958109681097810988109981100811018110281103811048110581106811078110881109811108111181112811138111481115811168111781118811198112081121811228112381124811258112681127811288112981130811318113281133811348113581136811378113881139811408114181142811438114481145811468114781148811498115081151811528115381154811558115681157811588115981160811618116281163811648116581166811678116881169811708117181172811738117481175811768117781178811798118081181811828118381184811858118681187811888118981190811918119281193811948119581196811978119881199812008120181202812038120481205812068120781208812098121081211812128121381214812158121681217812188121981220812218122281223812248122581226812278122881229812308123181232812338123481235812368123781238812398124081241812428124381244812458124681247812488124981250812518125281253812548125581256812578125881259812608126181262812638126481265812668126781268812698127081271812728127381274812758127681277812788127981280812818128281283812848128581286812878128881289812908129181292812938129481295812968129781298812998130081301813028130381304813058130681307813088130981310813118131281313813148131581316813178131881319813208132181322813238132481325813268132781328813298133081331813328133381334813358133681337813388133981340813418134281343813448134581346813478134881349813508135181352813538135481355813568135781358813598136081361813628136381364813658136681367813688136981370813718137281373813748137581376813778137881379813808138181382813838138481385813868138781388813898139081391813928139381394813958139681397813988139981400814018140281403814048140581406814078140881409814108141181412814138141481415814168141781418814198142081421814228142381424814258142681427814288142981430814318143281433814348143581436814378143881439814408144181442814438144481445814468144781448814498145081451814528145381454814558145681457814588145981460814618146281463814648146581466814678146881469814708147181472814738147481475814768147781478814798148081481814828148381484814858148681487814888148981490814918149281493814948149581496814978149881499815008150181502815038150481505815068150781508815098151081511815128151381514815158151681517815188151981520815218152281523815248152581526815278152881529815308153181532815338153481535815368153781538815398154081541815428154381544815458154681547815488154981550815518155281553815548155581556815578155881559815608156181562815638156481565815668156781568815698157081571815728157381574815758157681577815788157981580815818158281583815848158581586815878158881589815908159181592815938159481595815968159781598815998160081601816028160381604816058160681607816088160981610816118161281613816148161581616816178161881619816208162181622816238162481625816268162781628816298163081631816328163381634816358163681637816388163981640816418164281643816448164581646816478164881649816508165181652816538165481655816568165781658816598166081661816628166381664816658166681667816688166981670816718167281673816748167581676816778167881679816808168181682816838168481685816868168781688816898169081691816928169381694816958169681697816988169981700817018170281703817048170581706817078170881709817108171181712817138171481715817168171781718817198172081721817228172381724817258172681727817288172981730817318173281733817348173581736817378173881739817408174181742817438174481745817468174781748817498175081751817528175381754817558175681757817588175981760817618176281763817648176581766817678176881769817708177181772817738177481775817768177781778817798178081781817828178381784817858178681787817888178981790817918179281793817948179581796817978179881799818008180181802818038180481805818068180781808818098181081811818128181381814818158181681817818188181981820818218182281823818248182581826818278182881829818308183181832818338183481835818368183781838818398184081841818428184381844818458184681847818488184981850818518185281853818548185581856818578185881859818608186181862818638186481865818668186781868818698187081871818728187381874818758187681877818788187981880818818188281883818848188581886818878188881889818908189181892818938189481895818968189781898818998190081901819028190381904819058190681907819088190981910819118191281913819148191581916819178191881919819208192181922819238192481925819268192781928819298193081931819328193381934819358193681937819388193981940819418194281943819448194581946819478194881949819508195181952819538195481955819568195781958819598196081961819628196381964819658196681967819688196981970819718197281973819748197581976819778197881979819808198181982819838198481985819868198781988819898199081991819928199381994819958199681997819988199982000820018200282003820048200582006820078200882009820108201182012820138201482015820168201782018820198202082021820228202382024820258202682027820288202982030820318203282033820348203582036820378203882039820408204182042820438204482045820468204782048820498205082051820528205382054820558205682057820588205982060820618206282063820648206582066820678206882069820708207182072820738207482075820768207782078820798208082081820828208382084820858208682087820888208982090820918209282093820948209582096820978209882099821008210182102821038210482105821068210782108821098211082111821128211382114821158211682117821188211982120821218212282123821248212582126821278212882129821308213182132821338213482135821368213782138821398214082141821428214382144821458214682147821488214982150821518215282153821548215582156821578215882159821608216182162821638216482165821668216782168821698217082171821728217382174821758217682177821788217982180821818218282183821848218582186821878218882189821908219182192821938219482195821968219782198821998220082201822028220382204822058220682207822088220982210822118221282213822148221582216822178221882219822208222182222822238222482225822268222782228822298223082231822328223382234822358223682237822388223982240822418224282243822448224582246822478224882249822508225182252822538225482255822568225782258822598226082261822628226382264822658226682267822688226982270822718227282273822748227582276822778227882279822808228182282822838228482285822868228782288822898229082291822928229382294822958229682297822988229982300823018230282303823048230582306823078230882309823108231182312823138231482315823168231782318823198232082321823228232382324823258232682327823288232982330823318233282333823348233582336823378233882339823408234182342823438234482345823468234782348823498235082351823528235382354823558235682357823588235982360823618236282363823648236582366823678236882369823708237182372823738237482375823768237782378823798238082381823828238382384823858238682387823888238982390823918239282393823948239582396823978239882399824008240182402824038240482405824068240782408824098241082411824128241382414824158241682417824188241982420824218242282423824248242582426824278242882429824308243182432824338243482435824368243782438824398244082441824428244382444824458244682447824488244982450824518245282453824548245582456824578245882459824608246182462824638246482465824668246782468824698247082471824728247382474824758247682477824788247982480824818248282483824848248582486824878248882489824908249182492824938249482495824968249782498824998250082501825028250382504825058250682507825088250982510825118251282513825148251582516825178251882519825208252182522825238252482525825268252782528825298253082531825328253382534825358253682537825388253982540825418254282543825448254582546825478254882549825508255182552825538255482555825568255782558825598256082561825628256382564825658256682567825688256982570825718257282573825748257582576825778257882579825808258182582825838258482585825868258782588825898259082591825928259382594825958259682597825988259982600826018260282603826048260582606826078260882609826108261182612826138261482615826168261782618826198262082621826228262382624826258262682627826288262982630826318263282633826348263582636826378263882639826408264182642826438264482645826468264782648826498265082651826528265382654826558265682657826588265982660826618266282663826648266582666826678266882669826708267182672826738267482675826768267782678826798268082681826828268382684826858268682687826888268982690826918269282693826948269582696826978269882699827008270182702827038270482705827068270782708827098271082711827128271382714827158271682717827188271982720827218272282723827248272582726827278272882729827308273182732827338273482735827368273782738827398274082741827428274382744827458274682747827488274982750827518275282753827548275582756827578275882759827608276182762827638276482765827668276782768827698277082771827728277382774827758277682777827788277982780827818278282783827848278582786827878278882789827908279182792827938279482795827968279782798827998280082801828028280382804828058280682807828088280982810828118281282813828148281582816828178281882819828208282182822828238282482825828268282782828828298283082831828328283382834828358283682837828388283982840828418284282843828448284582846828478284882849828508285182852828538285482855828568285782858828598286082861828628286382864828658286682867828688286982870828718287282873828748287582876828778287882879828808288182882828838288482885828868288782888828898289082891828928289382894828958289682897828988289982900829018290282903829048290582906829078290882909829108291182912829138291482915829168291782918829198292082921829228292382924829258292682927829288292982930829318293282933829348293582936829378293882939829408294182942829438294482945829468294782948829498295082951829528295382954829558295682957829588295982960829618296282963829648296582966829678296882969829708297182972829738297482975829768297782978829798298082981829828298382984829858298682987829888298982990829918299282993829948299582996829978299882999830008300183002830038300483005830068300783008830098301083011830128301383014830158301683017830188301983020830218302283023830248302583026830278302883029830308303183032830338303483035830368303783038830398304083041830428304383044830458304683047830488304983050830518305283053830548305583056830578305883059830608306183062830638306483065830668306783068830698307083071830728307383074830758307683077830788307983080830818308283083830848308583086830878308883089830908309183092830938309483095830968309783098830998310083101831028310383104831058310683107831088310983110831118311283113831148311583116831178311883119831208312183122831238312483125831268312783128831298313083131831328313383134831358313683137831388313983140831418314283143831448314583146831478314883149831508315183152831538315483155831568315783158831598316083161831628316383164831658316683167831688316983170831718317283173831748317583176831778317883179831808318183182831838318483185831868318783188831898319083191831928319383194831958319683197831988319983200832018320283203832048320583206832078320883209832108321183212832138321483215832168321783218832198322083221832228322383224832258322683227832288322983230832318323283233832348323583236832378323883239832408324183242832438324483245832468324783248832498325083251832528325383254832558325683257832588325983260832618326283263832648326583266832678326883269832708327183272832738327483275832768327783278832798328083281832828328383284832858328683287832888328983290832918329283293832948329583296832978329883299833008330183302833038330483305833068330783308833098331083311833128331383314833158331683317833188331983320833218332283323833248332583326833278332883329833308333183332833338333483335833368333783338833398334083341833428334383344833458334683347833488334983350833518335283353833548335583356833578335883359833608336183362833638336483365833668336783368833698337083371833728337383374833758337683377833788337983380833818338283383833848338583386833878338883389833908339183392833938339483395833968339783398833998340083401834028340383404834058340683407834088340983410834118341283413834148341583416834178341883419834208342183422834238342483425834268342783428834298343083431834328343383434834358343683437834388343983440834418344283443834448344583446834478344883449834508345183452834538345483455834568345783458834598346083461834628346383464834658346683467834688346983470834718347283473834748347583476834778347883479834808348183482834838348483485834868348783488834898349083491834928349383494834958349683497834988349983500835018350283503835048350583506835078350883509835108351183512835138351483515835168351783518835198352083521835228352383524835258352683527835288352983530835318353283533835348353583536835378353883539835408354183542835438354483545835468354783548835498355083551835528355383554835558355683557835588355983560835618356283563835648356583566835678356883569835708357183572835738357483575835768357783578835798358083581835828358383584835858358683587835888358983590835918359283593835948359583596835978359883599836008360183602836038360483605836068360783608836098361083611836128361383614836158361683617836188361983620836218362283623836248362583626836278362883629836308363183632836338363483635836368363783638836398364083641836428364383644836458364683647836488364983650836518365283653836548365583656836578365883659836608366183662836638366483665836668366783668836698367083671836728367383674836758367683677836788367983680836818368283683836848368583686836878368883689836908369183692836938369483695836968369783698836998370083701837028370383704837058370683707837088370983710837118371283713837148371583716837178371883719837208372183722837238372483725837268372783728837298373083731837328373383734837358373683737837388373983740837418374283743837448374583746837478374883749837508375183752837538375483755837568375783758837598376083761837628376383764837658376683767837688376983770837718377283773837748377583776837778377883779837808378183782837838378483785837868378783788837898379083791837928379383794837958379683797837988379983800838018380283803838048380583806838078380883809838108381183812838138381483815838168381783818838198382083821838228382383824838258382683827838288382983830838318383283833838348383583836838378383883839838408384183842838438384483845838468384783848838498385083851838528385383854838558385683857838588385983860838618386283863838648386583866838678386883869838708387183872838738387483875838768387783878838798388083881838828388383884838858388683887838888388983890838918389283893838948389583896838978389883899839008390183902839038390483905839068390783908839098391083911839128391383914839158391683917839188391983920839218392283923839248392583926839278392883929839308393183932839338393483935839368393783938839398394083941839428394383944839458394683947839488394983950839518395283953839548395583956839578395883959839608396183962839638396483965839668396783968839698397083971839728397383974839758397683977839788397983980839818398283983839848398583986839878398883989839908399183992839938399483995839968399783998839998400084001840028400384004840058400684007840088400984010840118401284013840148401584016840178401884019840208402184022840238402484025840268402784028840298403084031840328403384034840358403684037840388403984040840418404284043840448404584046840478404884049840508405184052840538405484055840568405784058840598406084061840628406384064840658406684067840688406984070840718407284073840748407584076840778407884079840808408184082840838408484085840868408784088840898409084091840928409384094840958409684097840988409984100841018410284103841048410584106841078410884109841108411184112841138411484115841168411784118841198412084121841228412384124841258412684127841288412984130841318413284133841348413584136841378413884139841408414184142841438414484145841468414784148841498415084151841528415384154841558415684157841588415984160841618416284163841648416584166841678416884169841708417184172841738417484175841768417784178841798418084181841828418384184841858418684187841888418984190841918419284193841948419584196841978419884199842008420184202842038420484205842068420784208842098421084211842128421384214842158421684217842188421984220842218422284223842248422584226842278422884229842308423184232842338423484235842368423784238842398424084241842428424384244842458424684247842488424984250842518425284253842548425584256842578425884259842608426184262842638426484265842668426784268842698427084271842728427384274842758427684277842788427984280842818428284283842848428584286842878428884289842908429184292842938429484295842968429784298842998430084301843028430384304843058430684307843088430984310843118431284313843148431584316843178431884319843208432184322843238432484325843268432784328843298433084331843328433384334843358433684337843388433984340843418434284343843448434584346843478434884349843508435184352843538435484355843568435784358843598436084361843628436384364843658436684367843688436984370843718437284373843748437584376843778437884379843808438184382843838438484385843868438784388843898439084391843928439384394843958439684397843988439984400844018440284403844048440584406844078440884409844108441184412844138441484415844168441784418844198442084421844228442384424844258442684427844288442984430844318443284433844348443584436844378443884439844408444184442844438444484445844468444784448844498445084451844528445384454844558445684457844588445984460844618446284463844648446584466844678446884469844708447184472844738447484475844768447784478844798448084481844828448384484844858448684487844888448984490844918449284493844948449584496844978449884499845008450184502845038450484505845068450784508845098451084511845128451384514845158451684517845188451984520845218452284523845248452584526845278452884529845308453184532845338453484535845368453784538845398454084541845428454384544845458454684547845488454984550845518455284553845548455584556845578455884559845608456184562845638456484565845668456784568845698457084571845728457384574845758457684577845788457984580845818458284583845848458584586845878458884589845908459184592845938459484595845968459784598845998460084601846028460384604846058460684607846088460984610846118461284613846148461584616846178461884619846208462184622846238462484625846268462784628846298463084631846328463384634846358463684637846388463984640846418464284643846448464584646846478464884649846508465184652846538465484655846568465784658846598466084661846628466384664846658466684667846688466984670846718467284673846748467584676846778467884679846808468184682846838468484685846868468784688846898469084691846928469384694846958469684697846988469984700847018470284703847048470584706847078470884709847108471184712847138471484715847168471784718847198472084721847228472384724847258472684727847288472984730847318473284733847348473584736847378473884739847408474184742847438474484745847468474784748847498475084751847528475384754847558475684757847588475984760847618476284763847648476584766847678476884769847708477184772847738477484775847768477784778847798478084781847828478384784847858478684787847888478984790847918479284793847948479584796847978479884799848008480184802848038480484805848068480784808848098481084811848128481384814848158481684817848188481984820848218482284823848248482584826848278482884829848308483184832848338483484835848368483784838848398484084841848428484384844848458484684847848488484984850848518485284853848548485584856848578485884859848608486184862848638486484865848668486784868848698487084871848728487384874848758487684877848788487984880848818488284883848848488584886848878488884889848908489184892848938489484895848968489784898848998490084901849028490384904849058490684907849088490984910849118491284913849148491584916849178491884919849208492184922849238492484925849268492784928849298493084931849328493384934849358493684937849388493984940849418494284943849448494584946849478494884949849508495184952849538495484955849568495784958849598496084961849628496384964849658496684967849688496984970849718497284973849748497584976849778497884979849808498184982849838498484985849868498784988849898499084991849928499384994849958499684997849988499985000850018500285003850048500585006850078500885009850108501185012850138501485015850168501785018850198502085021850228502385024850258502685027850288502985030850318503285033850348503585036850378503885039850408504185042850438504485045850468504785048850498505085051850528505385054850558505685057850588505985060850618506285063850648506585066850678506885069850708507185072850738507485075850768507785078850798508085081850828508385084850858508685087850888508985090850918509285093850948509585096850978509885099851008510185102851038510485105851068510785108851098511085111851128511385114851158511685117851188511985120851218512285123851248512585126851278512885129851308513185132851338513485135851368513785138851398514085141851428514385144851458514685147851488514985150851518515285153851548515585156851578515885159851608516185162851638516485165851668516785168851698517085171851728517385174851758517685177851788517985180851818518285183851848518585186851878518885189851908519185192851938519485195851968519785198851998520085201852028520385204852058520685207852088520985210852118521285213852148521585216852178521885219852208522185222852238522485225852268522785228852298523085231852328523385234852358523685237852388523985240852418524285243852448524585246852478524885249852508525185252852538525485255852568525785258852598526085261852628526385264852658526685267852688526985270852718527285273852748527585276852778527885279852808528185282852838528485285852868528785288852898529085291852928529385294852958529685297852988529985300853018530285303853048530585306853078530885309853108531185312853138531485315853168531785318853198532085321853228532385324853258532685327853288532985330853318533285333853348533585336853378533885339853408534185342853438534485345853468534785348853498535085351853528535385354853558535685357853588535985360853618536285363853648536585366853678536885369853708537185372853738537485375853768537785378853798538085381853828538385384853858538685387853888538985390853918539285393853948539585396853978539885399854008540185402854038540485405854068540785408854098541085411854128541385414854158541685417854188541985420854218542285423854248542585426854278542885429854308543185432854338543485435854368543785438854398544085441854428544385444854458544685447854488544985450854518545285453854548545585456854578545885459854608546185462854638546485465854668546785468854698547085471854728547385474854758547685477854788547985480854818548285483854848548585486854878548885489854908549185492854938549485495854968549785498854998550085501855028550385504855058550685507855088550985510855118551285513855148551585516855178551885519855208552185522855238552485525855268552785528855298553085531855328553385534855358553685537855388553985540855418554285543855448554585546855478554885549855508555185552855538555485555855568555785558855598556085561855628556385564855658556685567855688556985570855718557285573855748557585576855778557885579855808558185582855838558485585855868558785588855898559085591855928559385594855958559685597855988559985600856018560285603856048560585606856078560885609856108561185612856138561485615856168561785618856198562085621856228562385624856258562685627856288562985630856318563285633856348563585636856378563885639856408564185642856438564485645856468564785648856498565085651856528565385654856558565685657856588565985660856618566285663856648566585666856678566885669856708567185672856738567485675
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. get observers(): Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Check if the document object exists
  289. * @returns true if the document object exists
  290. */
  291. static IsDocumentAvailable(): boolean;
  292. /**
  293. * Extracts text content from a DOM element hierarchy
  294. * @param element defines the root element
  295. * @returns a string
  296. */
  297. static GetDOMTextContent(element: HTMLElement): string;
  298. }
  299. }
  300. declare module BABYLON {
  301. /**
  302. * Logger used througouht the application to allow configuration of
  303. * the log level required for the messages.
  304. */
  305. export class Logger {
  306. /**
  307. * No log
  308. */
  309. static readonly NoneLogLevel: number;
  310. /**
  311. * Only message logs
  312. */
  313. static readonly MessageLogLevel: number;
  314. /**
  315. * Only warning logs
  316. */
  317. static readonly WarningLogLevel: number;
  318. /**
  319. * Only error logs
  320. */
  321. static readonly ErrorLogLevel: number;
  322. /**
  323. * All logs
  324. */
  325. static readonly AllLogLevel: number;
  326. private static _LogCache;
  327. /**
  328. * Gets a value indicating the number of loading errors
  329. * @ignorenaming
  330. */
  331. static errorsCount: number;
  332. /**
  333. * Callback called when a new log is added
  334. */
  335. static OnNewCacheEntry: (entry: string) => void;
  336. private static _AddLogEntry;
  337. private static _FormatMessage;
  338. private static _LogDisabled;
  339. private static _LogEnabled;
  340. private static _WarnDisabled;
  341. private static _WarnEnabled;
  342. private static _ErrorDisabled;
  343. private static _ErrorEnabled;
  344. /**
  345. * Log a message to the console
  346. */
  347. static Log: (message: string) => void;
  348. /**
  349. * Write a warning message to the console
  350. */
  351. static Warn: (message: string) => void;
  352. /**
  353. * Write an error message to the console
  354. */
  355. static Error: (message: string) => void;
  356. /**
  357. * Gets current log cache (list of logs)
  358. */
  359. static get LogCache(): string;
  360. /**
  361. * Clears the log cache
  362. */
  363. static ClearLogCache(): void;
  364. /**
  365. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  366. */
  367. static set LogLevels(level: number);
  368. }
  369. }
  370. declare module BABYLON {
  371. /** @hidden */
  372. export class _TypeStore {
  373. /** @hidden */
  374. static RegisteredTypes: {
  375. [key: string]: Object;
  376. };
  377. /** @hidden */
  378. static GetClass(fqdn: string): any;
  379. }
  380. }
  381. declare module BABYLON {
  382. /**
  383. * Helper to manipulate strings
  384. */
  385. export class StringTools {
  386. /**
  387. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  388. * @param str Source string
  389. * @param suffix Suffix to search for in the source string
  390. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  391. */
  392. static EndsWith(str: string, suffix: string): boolean;
  393. /**
  394. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  395. * @param str Source string
  396. * @param suffix Suffix to search for in the source string
  397. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  398. */
  399. static StartsWith(str: string, suffix: string): boolean;
  400. /**
  401. * Decodes a buffer into a string
  402. * @param buffer The buffer to decode
  403. * @returns The decoded string
  404. */
  405. static Decode(buffer: Uint8Array | Uint16Array): string;
  406. /**
  407. * Encode a buffer to a base64 string
  408. * @param buffer defines the buffer to encode
  409. * @returns the encoded string
  410. */
  411. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  412. /**
  413. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  414. * @param num the number to convert and pad
  415. * @param length the expected length of the string
  416. * @returns the padded string
  417. */
  418. static PadNumber(num: number, length: number): string;
  419. }
  420. }
  421. declare module BABYLON {
  422. /**
  423. * Class containing a set of static utilities functions for deep copy.
  424. */
  425. export class DeepCopier {
  426. /**
  427. * Tries to copy an object by duplicating every property
  428. * @param source defines the source object
  429. * @param destination defines the target object
  430. * @param doNotCopyList defines a list of properties to avoid
  431. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  432. */
  433. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  434. }
  435. }
  436. declare module BABYLON {
  437. /**
  438. * Class containing a set of static utilities functions for precision date
  439. */
  440. export class PrecisionDate {
  441. /**
  442. * Gets either window.performance.now() if supported or Date.now() else
  443. */
  444. static get Now(): number;
  445. }
  446. }
  447. declare module BABYLON {
  448. /** @hidden */
  449. export class _DevTools {
  450. static WarnImport(name: string): string;
  451. }
  452. }
  453. declare module BABYLON {
  454. /**
  455. * Interface used to define the mechanism to get data from the network
  456. */
  457. export interface IWebRequest {
  458. /**
  459. * Returns client's response url
  460. */
  461. responseURL: string;
  462. /**
  463. * Returns client's status
  464. */
  465. status: number;
  466. /**
  467. * Returns client's status as a text
  468. */
  469. statusText: string;
  470. }
  471. }
  472. declare module BABYLON {
  473. /**
  474. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  475. */
  476. export class WebRequest implements IWebRequest {
  477. private _xhr;
  478. /**
  479. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  480. * i.e. when loading files, where the server/service expects an Authorization header
  481. */
  482. static CustomRequestHeaders: {
  483. [key: string]: string;
  484. };
  485. /**
  486. * Add callback functions in this array to update all the requests before they get sent to the network
  487. */
  488. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  489. private _injectCustomRequestHeaders;
  490. /**
  491. * Gets or sets a function to be called when loading progress changes
  492. */
  493. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  494. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  495. /**
  496. * Returns client's state
  497. */
  498. get readyState(): number;
  499. /**
  500. * Returns client's status
  501. */
  502. get status(): number;
  503. /**
  504. * Returns client's status as a text
  505. */
  506. get statusText(): string;
  507. /**
  508. * Returns client's response
  509. */
  510. get response(): any;
  511. /**
  512. * Returns client's response url
  513. */
  514. get responseURL(): string;
  515. /**
  516. * Returns client's response as text
  517. */
  518. get responseText(): string;
  519. /**
  520. * Gets or sets the expected response type
  521. */
  522. get responseType(): XMLHttpRequestResponseType;
  523. set responseType(value: XMLHttpRequestResponseType);
  524. /** @hidden */
  525. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  526. /** @hidden */
  527. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  528. /**
  529. * Cancels any network activity
  530. */
  531. abort(): void;
  532. /**
  533. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  534. * @param body defines an optional request body
  535. */
  536. send(body?: Document | BodyInit | null): void;
  537. /**
  538. * Sets the request method, request URL
  539. * @param method defines the method to use (GET, POST, etc..)
  540. * @param url defines the url to connect with
  541. */
  542. open(method: string, url: string): void;
  543. /**
  544. * Sets the value of a request header.
  545. * @param name The name of the header whose value is to be set
  546. * @param value The value to set as the body of the header
  547. */
  548. setRequestHeader(name: string, value: string): void;
  549. /**
  550. * Get the string containing the text of a particular header's value.
  551. * @param name The name of the header
  552. * @returns The string containing the text of the given header name
  553. */
  554. getResponseHeader(name: string): Nullable<string>;
  555. }
  556. }
  557. declare module BABYLON {
  558. /**
  559. * File request interface
  560. */
  561. export interface IFileRequest {
  562. /**
  563. * Raised when the request is complete (success or error).
  564. */
  565. onCompleteObservable: Observable<IFileRequest>;
  566. /**
  567. * Aborts the request for a file.
  568. */
  569. abort: () => void;
  570. }
  571. }
  572. declare module BABYLON {
  573. /**
  574. * Define options used to create a render target texture
  575. */
  576. export class RenderTargetCreationOptions {
  577. /**
  578. * Specifies is mipmaps must be generated
  579. */
  580. generateMipMaps?: boolean;
  581. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  582. generateDepthBuffer?: boolean;
  583. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  584. generateStencilBuffer?: boolean;
  585. /** Defines texture type (int by default) */
  586. type?: number;
  587. /** Defines sampling mode (trilinear by default) */
  588. samplingMode?: number;
  589. /** Defines format (RGBA by default) */
  590. format?: number;
  591. }
  592. }
  593. declare module BABYLON {
  594. /** Defines the cross module used constants to avoid circular dependncies */
  595. export class Constants {
  596. /** Defines that alpha blending is disabled */
  597. static readonly ALPHA_DISABLE: number;
  598. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  599. static readonly ALPHA_ADD: number;
  600. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  601. static readonly ALPHA_COMBINE: number;
  602. /** Defines that alpha blending is DEST - SRC * DEST */
  603. static readonly ALPHA_SUBTRACT: number;
  604. /** Defines that alpha blending is SRC * DEST */
  605. static readonly ALPHA_MULTIPLY: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  607. static readonly ALPHA_MAXIMIZED: number;
  608. /** Defines that alpha blending is SRC + DEST */
  609. static readonly ALPHA_ONEONE: number;
  610. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  611. static readonly ALPHA_PREMULTIPLIED: number;
  612. /**
  613. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  614. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  615. */
  616. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  617. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  618. static readonly ALPHA_INTERPOLATE: number;
  619. /**
  620. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  621. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  622. */
  623. static readonly ALPHA_SCREENMODE: number;
  624. /**
  625. * Defines that alpha blending is SRC + DST
  626. * Alpha will be set to SRC ALPHA + DST ALPHA
  627. */
  628. static readonly ALPHA_ONEONE_ONEONE: number;
  629. /**
  630. * Defines that alpha blending is SRC * DST ALPHA + DST
  631. * Alpha will be set to 0
  632. */
  633. static readonly ALPHA_ALPHATOCOLOR: number;
  634. /**
  635. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  636. */
  637. static readonly ALPHA_REVERSEONEMINUS: number;
  638. /**
  639. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  640. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  641. */
  642. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  643. /**
  644. * Defines that alpha blending is SRC + DST
  645. * Alpha will be set to SRC ALPHA
  646. */
  647. static readonly ALPHA_ONEONE_ONEZERO: number;
  648. /**
  649. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  650. * Alpha will be set to DST ALPHA
  651. */
  652. static readonly ALPHA_EXCLUSION: number;
  653. /** Defines that alpha blending equation a SUM */
  654. static readonly ALPHA_EQUATION_ADD: number;
  655. /** Defines that alpha blending equation a SUBSTRACTION */
  656. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  657. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  658. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  659. /** Defines that alpha blending equation a MAX operation */
  660. static readonly ALPHA_EQUATION_MAX: number;
  661. /** Defines that alpha blending equation a MIN operation */
  662. static readonly ALPHA_EQUATION_MIN: number;
  663. /**
  664. * Defines that alpha blending equation a DARKEN operation:
  665. * It takes the min of the src and sums the alpha channels.
  666. */
  667. static readonly ALPHA_EQUATION_DARKEN: number;
  668. /** Defines that the ressource is not delayed*/
  669. static readonly DELAYLOADSTATE_NONE: number;
  670. /** Defines that the ressource was successfully delay loaded */
  671. static readonly DELAYLOADSTATE_LOADED: number;
  672. /** Defines that the ressource is currently delay loading */
  673. static readonly DELAYLOADSTATE_LOADING: number;
  674. /** Defines that the ressource is delayed and has not started loading */
  675. static readonly DELAYLOADSTATE_NOTLOADED: number;
  676. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  677. static readonly NEVER: number;
  678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  679. static readonly ALWAYS: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  681. static readonly LESS: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  683. static readonly EQUAL: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  685. static readonly LEQUAL: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  687. static readonly GREATER: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  689. static readonly GEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  691. static readonly NOTEQUAL: number;
  692. /** Passed to stencilOperation to specify that stencil value must be kept */
  693. static readonly KEEP: number;
  694. /** Passed to stencilOperation to specify that stencil value must be replaced */
  695. static readonly REPLACE: number;
  696. /** Passed to stencilOperation to specify that stencil value must be incremented */
  697. static readonly INCR: number;
  698. /** Passed to stencilOperation to specify that stencil value must be decremented */
  699. static readonly DECR: number;
  700. /** Passed to stencilOperation to specify that stencil value must be inverted */
  701. static readonly INVERT: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  703. static readonly INCR_WRAP: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  705. static readonly DECR_WRAP: number;
  706. /** Texture is not repeating outside of 0..1 UVs */
  707. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  708. /** Texture is repeating outside of 0..1 UVs */
  709. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  710. /** Texture is repeating and mirrored */
  711. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  712. /** ALPHA */
  713. static readonly TEXTUREFORMAT_ALPHA: number;
  714. /** LUMINANCE */
  715. static readonly TEXTUREFORMAT_LUMINANCE: number;
  716. /** LUMINANCE_ALPHA */
  717. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  718. /** RGB */
  719. static readonly TEXTUREFORMAT_RGB: number;
  720. /** RGBA */
  721. static readonly TEXTUREFORMAT_RGBA: number;
  722. /** RED */
  723. static readonly TEXTUREFORMAT_RED: number;
  724. /** RED (2nd reference) */
  725. static readonly TEXTUREFORMAT_R: number;
  726. /** RG */
  727. static readonly TEXTUREFORMAT_RG: number;
  728. /** RED_INTEGER */
  729. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  730. /** RED_INTEGER (2nd reference) */
  731. static readonly TEXTUREFORMAT_R_INTEGER: number;
  732. /** RG_INTEGER */
  733. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  734. /** RGB_INTEGER */
  735. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  736. /** RGBA_INTEGER */
  737. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  738. /** UNSIGNED_BYTE */
  739. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  740. /** UNSIGNED_BYTE (2nd reference) */
  741. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  742. /** FLOAT */
  743. static readonly TEXTURETYPE_FLOAT: number;
  744. /** HALF_FLOAT */
  745. static readonly TEXTURETYPE_HALF_FLOAT: number;
  746. /** BYTE */
  747. static readonly TEXTURETYPE_BYTE: number;
  748. /** SHORT */
  749. static readonly TEXTURETYPE_SHORT: number;
  750. /** UNSIGNED_SHORT */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  752. /** INT */
  753. static readonly TEXTURETYPE_INT: number;
  754. /** UNSIGNED_INT */
  755. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  756. /** UNSIGNED_SHORT_4_4_4_4 */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  758. /** UNSIGNED_SHORT_5_5_5_1 */
  759. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  760. /** UNSIGNED_SHORT_5_6_5 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  762. /** UNSIGNED_INT_2_10_10_10_REV */
  763. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  764. /** UNSIGNED_INT_24_8 */
  765. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  766. /** UNSIGNED_INT_10F_11F_11F_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  768. /** UNSIGNED_INT_5_9_9_9_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  770. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  771. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  772. /** nearest is mag = nearest and min = nearest and no mip */
  773. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  774. /** mag = nearest and min = nearest and mip = none */
  775. static readonly TEXTURE_NEAREST_NEAREST: number;
  776. /** Bilinear is mag = linear and min = linear and no mip */
  777. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  778. /** mag = linear and min = linear and mip = none */
  779. static readonly TEXTURE_LINEAR_LINEAR: number;
  780. /** Trilinear is mag = linear and min = linear and mip = linear */
  781. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  782. /** Trilinear is mag = linear and min = linear and mip = linear */
  783. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  784. /** mag = nearest and min = nearest and mip = nearest */
  785. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  786. /** mag = nearest and min = linear and mip = nearest */
  787. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  788. /** mag = nearest and min = linear and mip = linear */
  789. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = linear and mip = none */
  791. static readonly TEXTURE_NEAREST_LINEAR: number;
  792. /** nearest is mag = nearest and min = nearest and mip = linear */
  793. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  794. /** mag = linear and min = nearest and mip = nearest */
  795. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  796. /** mag = linear and min = nearest and mip = linear */
  797. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  798. /** Bilinear is mag = linear and min = linear and mip = nearest */
  799. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = none */
  801. static readonly TEXTURE_LINEAR_NEAREST: number;
  802. /** Explicit coordinates mode */
  803. static readonly TEXTURE_EXPLICIT_MODE: number;
  804. /** Spherical coordinates mode */
  805. static readonly TEXTURE_SPHERICAL_MODE: number;
  806. /** Planar coordinates mode */
  807. static readonly TEXTURE_PLANAR_MODE: number;
  808. /** Cubic coordinates mode */
  809. static readonly TEXTURE_CUBIC_MODE: number;
  810. /** Projection coordinates mode */
  811. static readonly TEXTURE_PROJECTION_MODE: number;
  812. /** Skybox coordinates mode */
  813. static readonly TEXTURE_SKYBOX_MODE: number;
  814. /** Inverse Cubic coordinates mode */
  815. static readonly TEXTURE_INVCUBIC_MODE: number;
  816. /** Equirectangular coordinates mode */
  817. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  818. /** Equirectangular Fixed coordinates mode */
  819. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  820. /** Equirectangular Fixed Mirrored coordinates mode */
  821. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  822. /** Offline (baking) quality for texture filtering */
  823. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  824. /** High quality for texture filtering */
  825. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  826. /** Medium quality for texture filtering */
  827. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  828. /** Low quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  830. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  831. static readonly SCALEMODE_FLOOR: number;
  832. /** Defines that texture rescaling will look for the nearest power of 2 size */
  833. static readonly SCALEMODE_NEAREST: number;
  834. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  835. static readonly SCALEMODE_CEILING: number;
  836. /**
  837. * The dirty texture flag value
  838. */
  839. static readonly MATERIAL_TextureDirtyFlag: number;
  840. /**
  841. * The dirty light flag value
  842. */
  843. static readonly MATERIAL_LightDirtyFlag: number;
  844. /**
  845. * The dirty fresnel flag value
  846. */
  847. static readonly MATERIAL_FresnelDirtyFlag: number;
  848. /**
  849. * The dirty attribute flag value
  850. */
  851. static readonly MATERIAL_AttributesDirtyFlag: number;
  852. /**
  853. * The dirty misc flag value
  854. */
  855. static readonly MATERIAL_MiscDirtyFlag: number;
  856. /**
  857. * The all dirty flag value
  858. */
  859. static readonly MATERIAL_AllDirtyFlag: number;
  860. /**
  861. * Returns the triangle fill mode
  862. */
  863. static readonly MATERIAL_TriangleFillMode: number;
  864. /**
  865. * Returns the wireframe mode
  866. */
  867. static readonly MATERIAL_WireFrameFillMode: number;
  868. /**
  869. * Returns the point fill mode
  870. */
  871. static readonly MATERIAL_PointFillMode: number;
  872. /**
  873. * Returns the point list draw mode
  874. */
  875. static readonly MATERIAL_PointListDrawMode: number;
  876. /**
  877. * Returns the line list draw mode
  878. */
  879. static readonly MATERIAL_LineListDrawMode: number;
  880. /**
  881. * Returns the line loop draw mode
  882. */
  883. static readonly MATERIAL_LineLoopDrawMode: number;
  884. /**
  885. * Returns the line strip draw mode
  886. */
  887. static readonly MATERIAL_LineStripDrawMode: number;
  888. /**
  889. * Returns the triangle strip draw mode
  890. */
  891. static readonly MATERIAL_TriangleStripDrawMode: number;
  892. /**
  893. * Returns the triangle fan draw mode
  894. */
  895. static readonly MATERIAL_TriangleFanDrawMode: number;
  896. /**
  897. * Stores the clock-wise side orientation
  898. */
  899. static readonly MATERIAL_ClockWiseSideOrientation: number;
  900. /**
  901. * Stores the counter clock-wise side orientation
  902. */
  903. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  904. /**
  905. * Nothing
  906. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  907. */
  908. static readonly ACTION_NothingTrigger: number;
  909. /**
  910. * On pick
  911. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  912. */
  913. static readonly ACTION_OnPickTrigger: number;
  914. /**
  915. * On left pick
  916. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_OnLeftPickTrigger: number;
  919. /**
  920. * On right pick
  921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnRightPickTrigger: number;
  924. /**
  925. * On center pick
  926. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  927. */
  928. static readonly ACTION_OnCenterPickTrigger: number;
  929. /**
  930. * On pick down
  931. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnPickDownTrigger: number;
  934. /**
  935. * On double pick
  936. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnDoublePickTrigger: number;
  939. /**
  940. * On pick up
  941. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPickUpTrigger: number;
  944. /**
  945. * On pick out.
  946. * This trigger will only be raised if you also declared a OnPickDown
  947. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  948. */
  949. static readonly ACTION_OnPickOutTrigger: number;
  950. /**
  951. * On long press
  952. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  953. */
  954. static readonly ACTION_OnLongPressTrigger: number;
  955. /**
  956. * On pointer over
  957. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnPointerOverTrigger: number;
  960. /**
  961. * On pointer out
  962. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnPointerOutTrigger: number;
  965. /**
  966. * On every frame
  967. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnEveryFrameTrigger: number;
  970. /**
  971. * On intersection enter
  972. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  973. */
  974. static readonly ACTION_OnIntersectionEnterTrigger: number;
  975. /**
  976. * On intersection exit
  977. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  978. */
  979. static readonly ACTION_OnIntersectionExitTrigger: number;
  980. /**
  981. * On key down
  982. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  983. */
  984. static readonly ACTION_OnKeyDownTrigger: number;
  985. /**
  986. * On key up
  987. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  988. */
  989. static readonly ACTION_OnKeyUpTrigger: number;
  990. /**
  991. * Billboard mode will only apply to Y axis
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  994. /**
  995. * Billboard mode will apply to all axes
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  998. /**
  999. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1002. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1003. * Test order :
  1004. * Is the bounding sphere outside the frustum ?
  1005. * If not, are the bounding box vertices outside the frustum ?
  1006. * It not, then the cullable object is in the frustum.
  1007. */
  1008. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1009. /** Culling strategy : Bounding Sphere Only.
  1010. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1011. * It's also less accurate than the standard because some not visible objects can still be selected.
  1012. * Test : is the bounding sphere outside the frustum ?
  1013. * If not, then the cullable object is in the frustum.
  1014. */
  1015. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1016. /** Culling strategy : Optimistic Inclusion.
  1017. * This in an inclusion test first, then the standard exclusion test.
  1018. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1019. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1020. * Anyway, it's as accurate as the standard strategy.
  1021. * Test :
  1022. * Is the cullable object bounding sphere center in the frustum ?
  1023. * If not, apply the default culling strategy.
  1024. */
  1025. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1026. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1027. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1028. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1029. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1030. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1031. * Test :
  1032. * Is the cullable object bounding sphere center in the frustum ?
  1033. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1034. */
  1035. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1036. /**
  1037. * No logging while loading
  1038. */
  1039. static readonly SCENELOADER_NO_LOGGING: number;
  1040. /**
  1041. * Minimal logging while loading
  1042. */
  1043. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1044. /**
  1045. * Summary logging while loading
  1046. */
  1047. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1048. /**
  1049. * Detailled logging while loading
  1050. */
  1051. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1052. /**
  1053. * Prepass texture index for color
  1054. */
  1055. static readonly PREPASS_COLOR_INDEX: number;
  1056. /**
  1057. * Prepass texture index for irradiance
  1058. */
  1059. static readonly PREPASS_IRRADIANCE_INDEX: number;
  1060. /**
  1061. * Prepass texture index for depth + normal
  1062. */
  1063. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  1064. /**
  1065. * Prepass texture index for albedo
  1066. */
  1067. static readonly PREPASS_ALBEDO_INDEX: number;
  1068. }
  1069. }
  1070. declare module BABYLON {
  1071. /**
  1072. * This represents the required contract to create a new type of texture loader.
  1073. */
  1074. export interface IInternalTextureLoader {
  1075. /**
  1076. * Defines wether the loader supports cascade loading the different faces.
  1077. */
  1078. supportCascades: boolean;
  1079. /**
  1080. * This returns if the loader support the current file information.
  1081. * @param extension defines the file extension of the file being loaded
  1082. * @param mimeType defines the optional mime type of the file being loaded
  1083. * @returns true if the loader can load the specified file
  1084. */
  1085. canLoad(extension: string, mimeType?: string): boolean;
  1086. /**
  1087. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1088. * @param data contains the texture data
  1089. * @param texture defines the BabylonJS internal texture
  1090. * @param createPolynomials will be true if polynomials have been requested
  1091. * @param onLoad defines the callback to trigger once the texture is ready
  1092. * @param onError defines the callback to trigger in case of error
  1093. */
  1094. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1095. /**
  1096. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1097. * @param data contains the texture data
  1098. * @param texture defines the BabylonJS internal texture
  1099. * @param callback defines the method to call once ready to upload
  1100. */
  1101. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1102. }
  1103. }
  1104. declare module BABYLON {
  1105. /**
  1106. * Class used to store and describe the pipeline context associated with an effect
  1107. */
  1108. export interface IPipelineContext {
  1109. /**
  1110. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1111. */
  1112. isAsync: boolean;
  1113. /**
  1114. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1115. */
  1116. isReady: boolean;
  1117. /** @hidden */
  1118. _getVertexShaderCode(): string | null;
  1119. /** @hidden */
  1120. _getFragmentShaderCode(): string | null;
  1121. /** @hidden */
  1122. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1123. }
  1124. }
  1125. declare module BABYLON {
  1126. /**
  1127. * Class used to store gfx data (like WebGLBuffer)
  1128. */
  1129. export class DataBuffer {
  1130. /**
  1131. * Gets or sets the number of objects referencing this buffer
  1132. */
  1133. references: number;
  1134. /** Gets or sets the size of the underlying buffer */
  1135. capacity: number;
  1136. /**
  1137. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1138. */
  1139. is32Bits: boolean;
  1140. /**
  1141. * Gets the underlying buffer
  1142. */
  1143. get underlyingResource(): any;
  1144. }
  1145. }
  1146. declare module BABYLON {
  1147. /** @hidden */
  1148. export interface IShaderProcessor {
  1149. attributeProcessor?: (attribute: string) => string;
  1150. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1151. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1152. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1153. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1154. lineProcessor?: (line: string, isFragment: boolean) => string;
  1155. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1156. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1157. }
  1158. }
  1159. declare module BABYLON {
  1160. /** @hidden */
  1161. export interface ProcessingOptions {
  1162. defines: string[];
  1163. indexParameters: any;
  1164. isFragment: boolean;
  1165. shouldUseHighPrecisionShader: boolean;
  1166. supportsUniformBuffers: boolean;
  1167. shadersRepository: string;
  1168. includesShadersStore: {
  1169. [key: string]: string;
  1170. };
  1171. processor?: IShaderProcessor;
  1172. version: string;
  1173. platformName: string;
  1174. lookForClosingBracketForUniformBuffer?: boolean;
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export class ShaderCodeNode {
  1180. line: string;
  1181. children: ShaderCodeNode[];
  1182. additionalDefineKey?: string;
  1183. additionalDefineValue?: string;
  1184. isValid(preprocessors: {
  1185. [key: string]: string;
  1186. }): boolean;
  1187. process(preprocessors: {
  1188. [key: string]: string;
  1189. }, options: ProcessingOptions): string;
  1190. }
  1191. }
  1192. declare module BABYLON {
  1193. /** @hidden */
  1194. export class ShaderCodeCursor {
  1195. private _lines;
  1196. lineIndex: number;
  1197. get currentLine(): string;
  1198. get canRead(): boolean;
  1199. set lines(value: string[]);
  1200. }
  1201. }
  1202. declare module BABYLON {
  1203. /** @hidden */
  1204. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1205. process(preprocessors: {
  1206. [key: string]: string;
  1207. }, options: ProcessingOptions): string;
  1208. }
  1209. }
  1210. declare module BABYLON {
  1211. /** @hidden */
  1212. export class ShaderDefineExpression {
  1213. isTrue(preprocessors: {
  1214. [key: string]: string;
  1215. }): boolean;
  1216. private static _OperatorPriority;
  1217. private static _Stack;
  1218. static postfixToInfix(postfix: string[]): string;
  1219. static infixToPostfix(infix: string): string[];
  1220. }
  1221. }
  1222. declare module BABYLON {
  1223. /** @hidden */
  1224. export class ShaderCodeTestNode extends ShaderCodeNode {
  1225. testExpression: ShaderDefineExpression;
  1226. isValid(preprocessors: {
  1227. [key: string]: string;
  1228. }): boolean;
  1229. }
  1230. }
  1231. declare module BABYLON {
  1232. /** @hidden */
  1233. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1234. define: string;
  1235. not: boolean;
  1236. constructor(define: string, not?: boolean);
  1237. isTrue(preprocessors: {
  1238. [key: string]: string;
  1239. }): boolean;
  1240. }
  1241. }
  1242. declare module BABYLON {
  1243. /** @hidden */
  1244. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1245. leftOperand: ShaderDefineExpression;
  1246. rightOperand: ShaderDefineExpression;
  1247. isTrue(preprocessors: {
  1248. [key: string]: string;
  1249. }): boolean;
  1250. }
  1251. }
  1252. declare module BABYLON {
  1253. /** @hidden */
  1254. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1255. leftOperand: ShaderDefineExpression;
  1256. rightOperand: ShaderDefineExpression;
  1257. isTrue(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module BABYLON {
  1263. /** @hidden */
  1264. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1265. define: string;
  1266. operand: string;
  1267. testValue: string;
  1268. constructor(define: string, operand: string, testValue: string);
  1269. isTrue(preprocessors: {
  1270. [key: string]: string;
  1271. }): boolean;
  1272. }
  1273. }
  1274. declare module BABYLON {
  1275. /**
  1276. * Class used to enable access to offline support
  1277. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1278. */
  1279. export interface IOfflineProvider {
  1280. /**
  1281. * Gets a boolean indicating if scene must be saved in the database
  1282. */
  1283. enableSceneOffline: boolean;
  1284. /**
  1285. * Gets a boolean indicating if textures must be saved in the database
  1286. */
  1287. enableTexturesOffline: boolean;
  1288. /**
  1289. * Open the offline support and make it available
  1290. * @param successCallback defines the callback to call on success
  1291. * @param errorCallback defines the callback to call on error
  1292. */
  1293. open(successCallback: () => void, errorCallback: () => void): void;
  1294. /**
  1295. * Loads an image from the offline support
  1296. * @param url defines the url to load from
  1297. * @param image defines the target DOM image
  1298. */
  1299. loadImage(url: string, image: HTMLImageElement): void;
  1300. /**
  1301. * Loads a file from offline support
  1302. * @param url defines the URL to load from
  1303. * @param sceneLoaded defines a callback to call on success
  1304. * @param progressCallBack defines a callback to call when progress changed
  1305. * @param errorCallback defines a callback to call on error
  1306. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1307. */
  1308. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1309. }
  1310. }
  1311. declare module BABYLON {
  1312. /**
  1313. * Class used to help managing file picking and drag'n'drop
  1314. * File Storage
  1315. */
  1316. export class FilesInputStore {
  1317. /**
  1318. * List of files ready to be loaded
  1319. */
  1320. static FilesToLoad: {
  1321. [key: string]: File;
  1322. };
  1323. }
  1324. }
  1325. declare module BABYLON {
  1326. /**
  1327. * Class used to define a retry strategy when error happens while loading assets
  1328. */
  1329. export class RetryStrategy {
  1330. /**
  1331. * Function used to defines an exponential back off strategy
  1332. * @param maxRetries defines the maximum number of retries (3 by default)
  1333. * @param baseInterval defines the interval between retries
  1334. * @returns the strategy function to use
  1335. */
  1336. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1337. }
  1338. }
  1339. declare module BABYLON {
  1340. /**
  1341. * @ignore
  1342. * Application error to support additional information when loading a file
  1343. */
  1344. export abstract class BaseError extends Error {
  1345. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1346. }
  1347. }
  1348. declare module BABYLON {
  1349. /** @ignore */
  1350. export class LoadFileError extends BaseError {
  1351. request?: WebRequest;
  1352. file?: File;
  1353. /**
  1354. * Creates a new LoadFileError
  1355. * @param message defines the message of the error
  1356. * @param request defines the optional web request
  1357. * @param file defines the optional file
  1358. */
  1359. constructor(message: string, object?: WebRequest | File);
  1360. }
  1361. /** @ignore */
  1362. export class RequestFileError extends BaseError {
  1363. request: WebRequest;
  1364. /**
  1365. * Creates a new LoadFileError
  1366. * @param message defines the message of the error
  1367. * @param request defines the optional web request
  1368. */
  1369. constructor(message: string, request: WebRequest);
  1370. }
  1371. /** @ignore */
  1372. export class ReadFileError extends BaseError {
  1373. file: File;
  1374. /**
  1375. * Creates a new ReadFileError
  1376. * @param message defines the message of the error
  1377. * @param file defines the optional file
  1378. */
  1379. constructor(message: string, file: File);
  1380. }
  1381. /**
  1382. * @hidden
  1383. */
  1384. export class FileTools {
  1385. /**
  1386. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1387. */
  1388. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1389. /**
  1390. * Gets or sets the base URL to use to load assets
  1391. */
  1392. static BaseUrl: string;
  1393. /**
  1394. * Default behaviour for cors in the application.
  1395. * It can be a string if the expected behavior is identical in the entire app.
  1396. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1397. */
  1398. static CorsBehavior: string | ((url: string | string[]) => string);
  1399. /**
  1400. * Gets or sets a function used to pre-process url before using them to load assets
  1401. */
  1402. static PreprocessUrl: (url: string) => string;
  1403. /**
  1404. * Removes unwanted characters from an url
  1405. * @param url defines the url to clean
  1406. * @returns the cleaned url
  1407. */
  1408. private static _CleanUrl;
  1409. /**
  1410. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1411. * @param url define the url we are trying
  1412. * @param element define the dom element where to configure the cors policy
  1413. */
  1414. static SetCorsBehavior(url: string | string[], element: {
  1415. crossOrigin: string | null;
  1416. }): void;
  1417. /**
  1418. * Loads an image as an HTMLImageElement.
  1419. * @param input url string, ArrayBuffer, or Blob to load
  1420. * @param onLoad callback called when the image successfully loads
  1421. * @param onError callback called when the image fails to load
  1422. * @param offlineProvider offline provider for caching
  1423. * @param mimeType optional mime type
  1424. * @returns the HTMLImageElement of the loaded image
  1425. */
  1426. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1427. /**
  1428. * Reads a file from a File object
  1429. * @param file defines the file to load
  1430. * @param onSuccess defines the callback to call when data is loaded
  1431. * @param onProgress defines the callback to call during loading process
  1432. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1433. * @param onError defines the callback to call when an error occurs
  1434. * @returns a file request object
  1435. */
  1436. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1437. /**
  1438. * Loads a file from a url
  1439. * @param url url to load
  1440. * @param onSuccess callback called when the file successfully loads
  1441. * @param onProgress callback called while file is loading (if the server supports this mode)
  1442. * @param offlineProvider defines the offline provider for caching
  1443. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1444. * @param onError callback called when the file fails to load
  1445. * @returns a file request object
  1446. */
  1447. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1448. /**
  1449. * Loads a file
  1450. * @param url url to load
  1451. * @param onSuccess callback called when the file successfully loads
  1452. * @param onProgress callback called while file is loading (if the server supports this mode)
  1453. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1454. * @param onError callback called when the file fails to load
  1455. * @param onOpened callback called when the web request is opened
  1456. * @returns a file request object
  1457. */
  1458. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1459. /**
  1460. * Checks if the loaded document was accessed via `file:`-Protocol.
  1461. * @returns boolean
  1462. */
  1463. static IsFileURL(): boolean;
  1464. }
  1465. }
  1466. declare module BABYLON {
  1467. /** @hidden */
  1468. export class ShaderProcessor {
  1469. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1470. private static _ProcessPrecision;
  1471. private static _ExtractOperation;
  1472. private static _BuildSubExpression;
  1473. private static _BuildExpression;
  1474. private static _MoveCursorWithinIf;
  1475. private static _MoveCursor;
  1476. private static _EvaluatePreProcessors;
  1477. private static _PreparePreProcessors;
  1478. private static _ProcessShaderConversion;
  1479. private static _ProcessIncludes;
  1480. /**
  1481. * Loads a file from a url
  1482. * @param url url to load
  1483. * @param onSuccess callback called when the file successfully loads
  1484. * @param onProgress callback called while file is loading (if the server supports this mode)
  1485. * @param offlineProvider defines the offline provider for caching
  1486. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1487. * @param onError callback called when the file fails to load
  1488. * @returns a file request object
  1489. * @hidden
  1490. */
  1491. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1492. }
  1493. }
  1494. declare module BABYLON {
  1495. /**
  1496. * @hidden
  1497. */
  1498. export interface IColor4Like {
  1499. r: float;
  1500. g: float;
  1501. b: float;
  1502. a: float;
  1503. }
  1504. /**
  1505. * @hidden
  1506. */
  1507. export interface IColor3Like {
  1508. r: float;
  1509. g: float;
  1510. b: float;
  1511. }
  1512. /**
  1513. * @hidden
  1514. */
  1515. export interface IVector4Like {
  1516. x: float;
  1517. y: float;
  1518. z: float;
  1519. w: float;
  1520. }
  1521. /**
  1522. * @hidden
  1523. */
  1524. export interface IVector3Like {
  1525. x: float;
  1526. y: float;
  1527. z: float;
  1528. }
  1529. /**
  1530. * @hidden
  1531. */
  1532. export interface IVector2Like {
  1533. x: float;
  1534. y: float;
  1535. }
  1536. /**
  1537. * @hidden
  1538. */
  1539. export interface IMatrixLike {
  1540. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1541. updateFlag: int;
  1542. }
  1543. /**
  1544. * @hidden
  1545. */
  1546. export interface IViewportLike {
  1547. x: float;
  1548. y: float;
  1549. width: float;
  1550. height: float;
  1551. }
  1552. /**
  1553. * @hidden
  1554. */
  1555. export interface IPlaneLike {
  1556. normal: IVector3Like;
  1557. d: float;
  1558. normalize(): void;
  1559. }
  1560. }
  1561. declare module BABYLON {
  1562. /**
  1563. * Interface used to define common properties for effect fallbacks
  1564. */
  1565. export interface IEffectFallbacks {
  1566. /**
  1567. * Removes the defines that should be removed when falling back.
  1568. * @param currentDefines defines the current define statements for the shader.
  1569. * @param effect defines the current effect we try to compile
  1570. * @returns The resulting defines with defines of the current rank removed.
  1571. */
  1572. reduce(currentDefines: string, effect: Effect): string;
  1573. /**
  1574. * Removes the fallback from the bound mesh.
  1575. */
  1576. unBindMesh(): void;
  1577. /**
  1578. * Checks to see if more fallbacks are still availible.
  1579. */
  1580. hasMoreFallbacks: boolean;
  1581. }
  1582. }
  1583. declare module BABYLON {
  1584. /**
  1585. * Class used to evalaute queries containing `and` and `or` operators
  1586. */
  1587. export class AndOrNotEvaluator {
  1588. /**
  1589. * Evaluate a query
  1590. * @param query defines the query to evaluate
  1591. * @param evaluateCallback defines the callback used to filter result
  1592. * @returns true if the query matches
  1593. */
  1594. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1595. private static _HandleParenthesisContent;
  1596. private static _SimplifyNegation;
  1597. }
  1598. }
  1599. declare module BABYLON {
  1600. /**
  1601. * Class used to store custom tags
  1602. */
  1603. export class Tags {
  1604. /**
  1605. * Adds support for tags on the given object
  1606. * @param obj defines the object to use
  1607. */
  1608. static EnableFor(obj: any): void;
  1609. /**
  1610. * Removes tags support
  1611. * @param obj defines the object to use
  1612. */
  1613. static DisableFor(obj: any): void;
  1614. /**
  1615. * Gets a boolean indicating if the given object has tags
  1616. * @param obj defines the object to use
  1617. * @returns a boolean
  1618. */
  1619. static HasTags(obj: any): boolean;
  1620. /**
  1621. * Gets the tags available on a given object
  1622. * @param obj defines the object to use
  1623. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1624. * @returns the tags
  1625. */
  1626. static GetTags(obj: any, asString?: boolean): any;
  1627. /**
  1628. * Adds tags to an object
  1629. * @param obj defines the object to use
  1630. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1631. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1632. */
  1633. static AddTagsTo(obj: any, tagsString: string): void;
  1634. /**
  1635. * @hidden
  1636. */
  1637. static _AddTagTo(obj: any, tag: string): void;
  1638. /**
  1639. * Removes specific tags from a specific object
  1640. * @param obj defines the object to use
  1641. * @param tagsString defines the tags to remove
  1642. */
  1643. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1644. /**
  1645. * @hidden
  1646. */
  1647. static _RemoveTagFrom(obj: any, tag: string): void;
  1648. /**
  1649. * Defines if tags hosted on an object match a given query
  1650. * @param obj defines the object to use
  1651. * @param tagsQuery defines the tag query
  1652. * @returns a boolean
  1653. */
  1654. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1655. }
  1656. }
  1657. declare module BABYLON {
  1658. /**
  1659. * Scalar computation library
  1660. */
  1661. export class Scalar {
  1662. /**
  1663. * Two pi constants convenient for computation.
  1664. */
  1665. static TwoPi: number;
  1666. /**
  1667. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1668. * @param a number
  1669. * @param b number
  1670. * @param epsilon (default = 1.401298E-45)
  1671. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1672. */
  1673. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1674. /**
  1675. * Returns a string : the upper case translation of the number i to hexadecimal.
  1676. * @param i number
  1677. * @returns the upper case translation of the number i to hexadecimal.
  1678. */
  1679. static ToHex(i: number): string;
  1680. /**
  1681. * Returns -1 if value is negative and +1 is value is positive.
  1682. * @param value the value
  1683. * @returns the value itself if it's equal to zero.
  1684. */
  1685. static Sign(value: number): number;
  1686. /**
  1687. * Returns the value itself if it's between min and max.
  1688. * Returns min if the value is lower than min.
  1689. * Returns max if the value is greater than max.
  1690. * @param value the value to clmap
  1691. * @param min the min value to clamp to (default: 0)
  1692. * @param max the max value to clamp to (default: 1)
  1693. * @returns the clamped value
  1694. */
  1695. static Clamp(value: number, min?: number, max?: number): number;
  1696. /**
  1697. * the log2 of value.
  1698. * @param value the value to compute log2 of
  1699. * @returns the log2 of value.
  1700. */
  1701. static Log2(value: number): number;
  1702. /**
  1703. * Loops the value, so that it is never larger than length and never smaller than 0.
  1704. *
  1705. * This is similar to the modulo operator but it works with floating point numbers.
  1706. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1707. * With t = 5 and length = 2.5, the result would be 0.0.
  1708. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1709. * @param value the value
  1710. * @param length the length
  1711. * @returns the looped value
  1712. */
  1713. static Repeat(value: number, length: number): number;
  1714. /**
  1715. * Normalize the value between 0.0 and 1.0 using min and max values
  1716. * @param value value to normalize
  1717. * @param min max to normalize between
  1718. * @param max min to normalize between
  1719. * @returns the normalized value
  1720. */
  1721. static Normalize(value: number, min: number, max: number): number;
  1722. /**
  1723. * Denormalize the value from 0.0 and 1.0 using min and max values
  1724. * @param normalized value to denormalize
  1725. * @param min max to denormalize between
  1726. * @param max min to denormalize between
  1727. * @returns the denormalized value
  1728. */
  1729. static Denormalize(normalized: number, min: number, max: number): number;
  1730. /**
  1731. * Calculates the shortest difference between two given angles given in degrees.
  1732. * @param current current angle in degrees
  1733. * @param target target angle in degrees
  1734. * @returns the delta
  1735. */
  1736. static DeltaAngle(current: number, target: number): number;
  1737. /**
  1738. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1739. * @param tx value
  1740. * @param length length
  1741. * @returns The returned value will move back and forth between 0 and length
  1742. */
  1743. static PingPong(tx: number, length: number): number;
  1744. /**
  1745. * Interpolates between min and max with smoothing at the limits.
  1746. *
  1747. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1748. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1749. * @param from from
  1750. * @param to to
  1751. * @param tx value
  1752. * @returns the smooth stepped value
  1753. */
  1754. static SmoothStep(from: number, to: number, tx: number): number;
  1755. /**
  1756. * Moves a value current towards target.
  1757. *
  1758. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1759. * Negative values of maxDelta pushes the value away from target.
  1760. * @param current current value
  1761. * @param target target value
  1762. * @param maxDelta max distance to move
  1763. * @returns resulting value
  1764. */
  1765. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1766. /**
  1767. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1768. *
  1769. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1770. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1771. * @param current current value
  1772. * @param target target value
  1773. * @param maxDelta max distance to move
  1774. * @returns resulting angle
  1775. */
  1776. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1777. /**
  1778. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1779. * @param start start value
  1780. * @param end target value
  1781. * @param amount amount to lerp between
  1782. * @returns the lerped value
  1783. */
  1784. static Lerp(start: number, end: number, amount: number): number;
  1785. /**
  1786. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1787. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1788. * @param start start value
  1789. * @param end target value
  1790. * @param amount amount to lerp between
  1791. * @returns the lerped value
  1792. */
  1793. static LerpAngle(start: number, end: number, amount: number): number;
  1794. /**
  1795. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1796. * @param a start value
  1797. * @param b target value
  1798. * @param value value between a and b
  1799. * @returns the inverseLerp value
  1800. */
  1801. static InverseLerp(a: number, b: number, value: number): number;
  1802. /**
  1803. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1804. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1805. * @param value1 spline value
  1806. * @param tangent1 spline value
  1807. * @param value2 spline value
  1808. * @param tangent2 spline value
  1809. * @param amount input value
  1810. * @returns hermite result
  1811. */
  1812. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1813. /**
  1814. * Returns a random float number between and min and max values
  1815. * @param min min value of random
  1816. * @param max max value of random
  1817. * @returns random value
  1818. */
  1819. static RandomRange(min: number, max: number): number;
  1820. /**
  1821. * This function returns percentage of a number in a given range.
  1822. *
  1823. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1824. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1825. * @param number to convert to percentage
  1826. * @param min min range
  1827. * @param max max range
  1828. * @returns the percentage
  1829. */
  1830. static RangeToPercent(number: number, min: number, max: number): number;
  1831. /**
  1832. * This function returns number that corresponds to the percentage in a given range.
  1833. *
  1834. * PercentToRange(0.34,0,100) will return 34.
  1835. * @param percent to convert to number
  1836. * @param min min range
  1837. * @param max max range
  1838. * @returns the number
  1839. */
  1840. static PercentToRange(percent: number, min: number, max: number): number;
  1841. /**
  1842. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1843. * @param angle The angle to normalize in radian.
  1844. * @return The converted angle.
  1845. */
  1846. static NormalizeRadians(angle: number): number;
  1847. }
  1848. }
  1849. declare module BABYLON {
  1850. /**
  1851. * Constant used to convert a value to gamma space
  1852. * @ignorenaming
  1853. */
  1854. export const ToGammaSpace: number;
  1855. /**
  1856. * Constant used to convert a value to linear space
  1857. * @ignorenaming
  1858. */
  1859. export const ToLinearSpace = 2.2;
  1860. /**
  1861. * Constant used to define the minimal number value in Babylon.js
  1862. * @ignorenaming
  1863. */
  1864. let Epsilon: number;
  1865. }
  1866. declare module BABYLON {
  1867. /**
  1868. * Class used to represent a viewport on screen
  1869. */
  1870. export class Viewport {
  1871. /** viewport left coordinate */
  1872. x: number;
  1873. /** viewport top coordinate */
  1874. y: number;
  1875. /**viewport width */
  1876. width: number;
  1877. /** viewport height */
  1878. height: number;
  1879. /**
  1880. * Creates a Viewport object located at (x, y) and sized (width, height)
  1881. * @param x defines viewport left coordinate
  1882. * @param y defines viewport top coordinate
  1883. * @param width defines the viewport width
  1884. * @param height defines the viewport height
  1885. */
  1886. constructor(
  1887. /** viewport left coordinate */
  1888. x: number,
  1889. /** viewport top coordinate */
  1890. y: number,
  1891. /**viewport width */
  1892. width: number,
  1893. /** viewport height */
  1894. height: number);
  1895. /**
  1896. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1897. * @param renderWidth defines the rendering width
  1898. * @param renderHeight defines the rendering height
  1899. * @returns a new Viewport
  1900. */
  1901. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1902. /**
  1903. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1904. * @param renderWidth defines the rendering width
  1905. * @param renderHeight defines the rendering height
  1906. * @param ref defines the target viewport
  1907. * @returns the current viewport
  1908. */
  1909. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1910. /**
  1911. * Returns a new Viewport copied from the current one
  1912. * @returns a new Viewport
  1913. */
  1914. clone(): Viewport;
  1915. }
  1916. }
  1917. declare module BABYLON {
  1918. /**
  1919. * Class containing a set of static utilities functions for arrays.
  1920. */
  1921. export class ArrayTools {
  1922. /**
  1923. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1924. * @param size the number of element to construct and put in the array
  1925. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1926. * @returns a new array filled with new objects
  1927. */
  1928. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1929. }
  1930. }
  1931. declare module BABYLON {
  1932. /**
  1933. * Represents a plane by the equation ax + by + cz + d = 0
  1934. */
  1935. export class Plane {
  1936. private static _TmpMatrix;
  1937. /**
  1938. * Normal of the plane (a,b,c)
  1939. */
  1940. normal: Vector3;
  1941. /**
  1942. * d component of the plane
  1943. */
  1944. d: number;
  1945. /**
  1946. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1947. * @param a a component of the plane
  1948. * @param b b component of the plane
  1949. * @param c c component of the plane
  1950. * @param d d component of the plane
  1951. */
  1952. constructor(a: number, b: number, c: number, d: number);
  1953. /**
  1954. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1955. */
  1956. asArray(): number[];
  1957. /**
  1958. * @returns a new plane copied from the current Plane.
  1959. */
  1960. clone(): Plane;
  1961. /**
  1962. * @returns the string "Plane".
  1963. */
  1964. getClassName(): string;
  1965. /**
  1966. * @returns the Plane hash code.
  1967. */
  1968. getHashCode(): number;
  1969. /**
  1970. * Normalize the current Plane in place.
  1971. * @returns the updated Plane.
  1972. */
  1973. normalize(): Plane;
  1974. /**
  1975. * Applies a transformation the plane and returns the result
  1976. * @param transformation the transformation matrix to be applied to the plane
  1977. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1978. */
  1979. transform(transformation: DeepImmutable<Matrix>): Plane;
  1980. /**
  1981. * Compute the dot product between the point and the plane normal
  1982. * @param point point to calculate the dot product with
  1983. * @returns the dot product (float) of the point coordinates and the plane normal.
  1984. */
  1985. dotCoordinate(point: DeepImmutable<Vector3>): number;
  1986. /**
  1987. * Updates the current Plane from the plane defined by the three given points.
  1988. * @param point1 one of the points used to contruct the plane
  1989. * @param point2 one of the points used to contruct the plane
  1990. * @param point3 one of the points used to contruct the plane
  1991. * @returns the updated Plane.
  1992. */
  1993. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  1994. /**
  1995. * Checks if the plane is facing a given direction
  1996. * @param direction the direction to check if the plane is facing
  1997. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  1998. * @returns True is the vector "direction" is the same side than the plane normal.
  1999. */
  2000. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2001. /**
  2002. * Calculates the distance to a point
  2003. * @param point point to calculate distance to
  2004. * @returns the signed distance (float) from the given point to the Plane.
  2005. */
  2006. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2007. /**
  2008. * Creates a plane from an array
  2009. * @param array the array to create a plane from
  2010. * @returns a new Plane from the given array.
  2011. */
  2012. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2013. /**
  2014. * Creates a plane from three points
  2015. * @param point1 point used to create the plane
  2016. * @param point2 point used to create the plane
  2017. * @param point3 point used to create the plane
  2018. * @returns a new Plane defined by the three given points.
  2019. */
  2020. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2021. /**
  2022. * Creates a plane from an origin point and a normal
  2023. * @param origin origin of the plane to be constructed
  2024. * @param normal normal of the plane to be constructed
  2025. * @returns a new Plane the normal vector to this plane at the given origin point.
  2026. * Note : the vector "normal" is updated because normalized.
  2027. */
  2028. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2029. /**
  2030. * Calculates the distance from a plane and a point
  2031. * @param origin origin of the plane to be constructed
  2032. * @param normal normal of the plane to be constructed
  2033. * @param point point to calculate distance to
  2034. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2035. */
  2036. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2037. }
  2038. }
  2039. declare module BABYLON {
  2040. /** @hidden */
  2041. export class PerformanceConfigurator {
  2042. /** @hidden */
  2043. static MatrixUse64Bits: boolean;
  2044. /** @hidden */
  2045. static MatrixTrackPrecisionChange: boolean;
  2046. /** @hidden */
  2047. static MatrixCurrentType: any;
  2048. /** @hidden */
  2049. static MatrixTrackedMatrices: Array<any> | null;
  2050. /** @hidden */
  2051. static SetMatrixPrecision(use64bits: boolean): void;
  2052. }
  2053. }
  2054. declare module BABYLON {
  2055. /**
  2056. * Class representing a vector containing 2 coordinates
  2057. */
  2058. export class Vector2 {
  2059. /** defines the first coordinate */
  2060. x: number;
  2061. /** defines the second coordinate */
  2062. y: number;
  2063. /**
  2064. * Creates a new Vector2 from the given x and y coordinates
  2065. * @param x defines the first coordinate
  2066. * @param y defines the second coordinate
  2067. */
  2068. constructor(
  2069. /** defines the first coordinate */
  2070. x?: number,
  2071. /** defines the second coordinate */
  2072. y?: number);
  2073. /**
  2074. * Gets a string with the Vector2 coordinates
  2075. * @returns a string with the Vector2 coordinates
  2076. */
  2077. toString(): string;
  2078. /**
  2079. * Gets class name
  2080. * @returns the string "Vector2"
  2081. */
  2082. getClassName(): string;
  2083. /**
  2084. * Gets current vector hash code
  2085. * @returns the Vector2 hash code as a number
  2086. */
  2087. getHashCode(): number;
  2088. /**
  2089. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2090. * @param array defines the source array
  2091. * @param index defines the offset in source array
  2092. * @returns the current Vector2
  2093. */
  2094. toArray(array: FloatArray, index?: number): Vector2;
  2095. /**
  2096. * Copy the current vector to an array
  2097. * @returns a new array with 2 elements: the Vector2 coordinates.
  2098. */
  2099. asArray(): number[];
  2100. /**
  2101. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2102. * @param source defines the source Vector2
  2103. * @returns the current updated Vector2
  2104. */
  2105. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2106. /**
  2107. * Sets the Vector2 coordinates with the given floats
  2108. * @param x defines the first coordinate
  2109. * @param y defines the second coordinate
  2110. * @returns the current updated Vector2
  2111. */
  2112. copyFromFloats(x: number, y: number): Vector2;
  2113. /**
  2114. * Sets the Vector2 coordinates with the given floats
  2115. * @param x defines the first coordinate
  2116. * @param y defines the second coordinate
  2117. * @returns the current updated Vector2
  2118. */
  2119. set(x: number, y: number): Vector2;
  2120. /**
  2121. * Add another vector with the current one
  2122. * @param otherVector defines the other vector
  2123. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2124. */
  2125. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2126. /**
  2127. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2128. * @param otherVector defines the other vector
  2129. * @param result defines the target vector
  2130. * @returns the unmodified current Vector2
  2131. */
  2132. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2133. /**
  2134. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2135. * @param otherVector defines the other vector
  2136. * @returns the current updated Vector2
  2137. */
  2138. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2139. /**
  2140. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2141. * @param otherVector defines the other vector
  2142. * @returns a new Vector2
  2143. */
  2144. addVector3(otherVector: Vector3): Vector2;
  2145. /**
  2146. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2147. * @param otherVector defines the other vector
  2148. * @returns a new Vector2
  2149. */
  2150. subtract(otherVector: Vector2): Vector2;
  2151. /**
  2152. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2153. * @param otherVector defines the other vector
  2154. * @param result defines the target vector
  2155. * @returns the unmodified current Vector2
  2156. */
  2157. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2158. /**
  2159. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2160. * @param otherVector defines the other vector
  2161. * @returns the current updated Vector2
  2162. */
  2163. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2164. /**
  2165. * Multiplies in place the current Vector2 coordinates by the given ones
  2166. * @param otherVector defines the other vector
  2167. * @returns the current updated Vector2
  2168. */
  2169. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2170. /**
  2171. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2172. * @param otherVector defines the other vector
  2173. * @returns a new Vector2
  2174. */
  2175. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2176. /**
  2177. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2178. * @param otherVector defines the other vector
  2179. * @param result defines the target vector
  2180. * @returns the unmodified current Vector2
  2181. */
  2182. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2183. /**
  2184. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2185. * @param x defines the first coordinate
  2186. * @param y defines the second coordinate
  2187. * @returns a new Vector2
  2188. */
  2189. multiplyByFloats(x: number, y: number): Vector2;
  2190. /**
  2191. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2192. * @param otherVector defines the other vector
  2193. * @returns a new Vector2
  2194. */
  2195. divide(otherVector: Vector2): Vector2;
  2196. /**
  2197. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2198. * @param otherVector defines the other vector
  2199. * @param result defines the target vector
  2200. * @returns the unmodified current Vector2
  2201. */
  2202. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2203. /**
  2204. * Divides the current Vector2 coordinates by the given ones
  2205. * @param otherVector defines the other vector
  2206. * @returns the current updated Vector2
  2207. */
  2208. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2209. /**
  2210. * Gets a new Vector2 with current Vector2 negated coordinates
  2211. * @returns a new Vector2
  2212. */
  2213. negate(): Vector2;
  2214. /**
  2215. * Negate this vector in place
  2216. * @returns this
  2217. */
  2218. negateInPlace(): Vector2;
  2219. /**
  2220. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2221. * @param result defines the Vector3 object where to store the result
  2222. * @returns the current Vector2
  2223. */
  2224. negateToRef(result: Vector2): Vector2;
  2225. /**
  2226. * Multiply the Vector2 coordinates by scale
  2227. * @param scale defines the scaling factor
  2228. * @returns the current updated Vector2
  2229. */
  2230. scaleInPlace(scale: number): Vector2;
  2231. /**
  2232. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2233. * @param scale defines the scaling factor
  2234. * @returns a new Vector2
  2235. */
  2236. scale(scale: number): Vector2;
  2237. /**
  2238. * Scale the current Vector2 values by a factor to a given Vector2
  2239. * @param scale defines the scale factor
  2240. * @param result defines the Vector2 object where to store the result
  2241. * @returns the unmodified current Vector2
  2242. */
  2243. scaleToRef(scale: number, result: Vector2): Vector2;
  2244. /**
  2245. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2246. * @param scale defines the scale factor
  2247. * @param result defines the Vector2 object where to store the result
  2248. * @returns the unmodified current Vector2
  2249. */
  2250. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2251. /**
  2252. * Gets a boolean if two vectors are equals
  2253. * @param otherVector defines the other vector
  2254. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2255. */
  2256. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2257. /**
  2258. * Gets a boolean if two vectors are equals (using an epsilon value)
  2259. * @param otherVector defines the other vector
  2260. * @param epsilon defines the minimal distance to consider equality
  2261. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2262. */
  2263. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2264. /**
  2265. * Gets a new Vector2 from current Vector2 floored values
  2266. * @returns a new Vector2
  2267. */
  2268. floor(): Vector2;
  2269. /**
  2270. * Gets a new Vector2 from current Vector2 floored values
  2271. * @returns a new Vector2
  2272. */
  2273. fract(): Vector2;
  2274. /**
  2275. * Gets the length of the vector
  2276. * @returns the vector length (float)
  2277. */
  2278. length(): number;
  2279. /**
  2280. * Gets the vector squared length
  2281. * @returns the vector squared length (float)
  2282. */
  2283. lengthSquared(): number;
  2284. /**
  2285. * Normalize the vector
  2286. * @returns the current updated Vector2
  2287. */
  2288. normalize(): Vector2;
  2289. /**
  2290. * Gets a new Vector2 copied from the Vector2
  2291. * @returns a new Vector2
  2292. */
  2293. clone(): Vector2;
  2294. /**
  2295. * Gets a new Vector2(0, 0)
  2296. * @returns a new Vector2
  2297. */
  2298. static Zero(): Vector2;
  2299. /**
  2300. * Gets a new Vector2(1, 1)
  2301. * @returns a new Vector2
  2302. */
  2303. static One(): Vector2;
  2304. /**
  2305. * Gets a new Vector2 set from the given index element of the given array
  2306. * @param array defines the data source
  2307. * @param offset defines the offset in the data source
  2308. * @returns a new Vector2
  2309. */
  2310. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2311. /**
  2312. * Sets "result" from the given index element of the given array
  2313. * @param array defines the data source
  2314. * @param offset defines the offset in the data source
  2315. * @param result defines the target vector
  2316. */
  2317. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2318. /**
  2319. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2320. * @param value1 defines 1st point of control
  2321. * @param value2 defines 2nd point of control
  2322. * @param value3 defines 3rd point of control
  2323. * @param value4 defines 4th point of control
  2324. * @param amount defines the interpolation factor
  2325. * @returns a new Vector2
  2326. */
  2327. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2328. /**
  2329. * 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".
  2330. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2331. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2332. * @param value defines the value to clamp
  2333. * @param min defines the lower limit
  2334. * @param max defines the upper limit
  2335. * @returns a new Vector2
  2336. */
  2337. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2338. /**
  2339. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2340. * @param value1 defines the 1st control point
  2341. * @param tangent1 defines the outgoing tangent
  2342. * @param value2 defines the 2nd control point
  2343. * @param tangent2 defines the incoming tangent
  2344. * @param amount defines the interpolation factor
  2345. * @returns a new Vector2
  2346. */
  2347. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2348. /**
  2349. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2350. * @param start defines the start vector
  2351. * @param end defines the end vector
  2352. * @param amount defines the interpolation factor
  2353. * @returns a new Vector2
  2354. */
  2355. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2356. /**
  2357. * Gets the dot product of the vector "left" and the vector "right"
  2358. * @param left defines first vector
  2359. * @param right defines second vector
  2360. * @returns the dot product (float)
  2361. */
  2362. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2363. /**
  2364. * Returns a new Vector2 equal to the normalized given vector
  2365. * @param vector defines the vector to normalize
  2366. * @returns a new Vector2
  2367. */
  2368. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2369. /**
  2370. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2371. * @param left defines 1st vector
  2372. * @param right defines 2nd vector
  2373. * @returns a new Vector2
  2374. */
  2375. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2376. /**
  2377. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2378. * @param left defines 1st vector
  2379. * @param right defines 2nd vector
  2380. * @returns a new Vector2
  2381. */
  2382. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2383. /**
  2384. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2385. * @param vector defines the vector to transform
  2386. * @param transformation defines the matrix to apply
  2387. * @returns a new Vector2
  2388. */
  2389. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2390. /**
  2391. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2392. * @param vector defines the vector to transform
  2393. * @param transformation defines the matrix to apply
  2394. * @param result defines the target vector
  2395. */
  2396. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2397. /**
  2398. * Determines if a given vector is included in a triangle
  2399. * @param p defines the vector to test
  2400. * @param p0 defines 1st triangle point
  2401. * @param p1 defines 2nd triangle point
  2402. * @param p2 defines 3rd triangle point
  2403. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2404. */
  2405. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2406. /**
  2407. * Gets the distance between the vectors "value1" and "value2"
  2408. * @param value1 defines first vector
  2409. * @param value2 defines second vector
  2410. * @returns the distance between vectors
  2411. */
  2412. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2413. /**
  2414. * Returns the squared distance between the vectors "value1" and "value2"
  2415. * @param value1 defines first vector
  2416. * @param value2 defines second vector
  2417. * @returns the squared distance between vectors
  2418. */
  2419. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2420. /**
  2421. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2422. * @param value1 defines first vector
  2423. * @param value2 defines second vector
  2424. * @returns a new Vector2
  2425. */
  2426. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2427. /**
  2428. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2429. * @param p defines the middle point
  2430. * @param segA defines one point of the segment
  2431. * @param segB defines the other point of the segment
  2432. * @returns the shortest distance
  2433. */
  2434. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2435. }
  2436. /**
  2437. * Class used to store (x,y,z) vector representation
  2438. * A Vector3 is the main object used in 3D geometry
  2439. * It can represent etiher the coordinates of a point the space, either a direction
  2440. * Reminder: js uses a left handed forward facing system
  2441. */
  2442. export class Vector3 {
  2443. private static _UpReadOnly;
  2444. private static _ZeroReadOnly;
  2445. /** @hidden */
  2446. _x: number;
  2447. /** @hidden */
  2448. _y: number;
  2449. /** @hidden */
  2450. _z: number;
  2451. /** @hidden */
  2452. _isDirty: boolean;
  2453. /** Gets or sets the x coordinate */
  2454. get x(): number;
  2455. set x(value: number);
  2456. /** Gets or sets the y coordinate */
  2457. get y(): number;
  2458. set y(value: number);
  2459. /** Gets or sets the z coordinate */
  2460. get z(): number;
  2461. set z(value: number);
  2462. /**
  2463. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2464. * @param x defines the first coordinates (on X axis)
  2465. * @param y defines the second coordinates (on Y axis)
  2466. * @param z defines the third coordinates (on Z axis)
  2467. */
  2468. constructor(x?: number, y?: number, z?: number);
  2469. /**
  2470. * Creates a string representation of the Vector3
  2471. * @returns a string with the Vector3 coordinates.
  2472. */
  2473. toString(): string;
  2474. /**
  2475. * Gets the class name
  2476. * @returns the string "Vector3"
  2477. */
  2478. getClassName(): string;
  2479. /**
  2480. * Creates the Vector3 hash code
  2481. * @returns a number which tends to be unique between Vector3 instances
  2482. */
  2483. getHashCode(): number;
  2484. /**
  2485. * Creates an array containing three elements : the coordinates of the Vector3
  2486. * @returns a new array of numbers
  2487. */
  2488. asArray(): number[];
  2489. /**
  2490. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2491. * @param array defines the destination array
  2492. * @param index defines the offset in the destination array
  2493. * @returns the current Vector3
  2494. */
  2495. toArray(array: FloatArray, index?: number): Vector3;
  2496. /**
  2497. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2498. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2499. */
  2500. toQuaternion(): Quaternion;
  2501. /**
  2502. * Adds the given vector to the current Vector3
  2503. * @param otherVector defines the second operand
  2504. * @returns the current updated Vector3
  2505. */
  2506. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2507. /**
  2508. * Adds the given coordinates to the current Vector3
  2509. * @param x defines the x coordinate of the operand
  2510. * @param y defines the y coordinate of the operand
  2511. * @param z defines the z coordinate of the operand
  2512. * @returns the current updated Vector3
  2513. */
  2514. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2515. /**
  2516. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2517. * @param otherVector defines the second operand
  2518. * @returns the resulting Vector3
  2519. */
  2520. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2521. /**
  2522. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2523. * @param otherVector defines the second operand
  2524. * @param result defines the Vector3 object where to store the result
  2525. * @returns the current Vector3
  2526. */
  2527. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2528. /**
  2529. * Subtract the given vector from the current Vector3
  2530. * @param otherVector defines the second operand
  2531. * @returns the current updated Vector3
  2532. */
  2533. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2534. /**
  2535. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2536. * @param otherVector defines the second operand
  2537. * @returns the resulting Vector3
  2538. */
  2539. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2540. /**
  2541. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2542. * @param otherVector defines the second operand
  2543. * @param result defines the Vector3 object where to store the result
  2544. * @returns the current Vector3
  2545. */
  2546. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2547. /**
  2548. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2549. * @param x defines the x coordinate of the operand
  2550. * @param y defines the y coordinate of the operand
  2551. * @param z defines the z coordinate of the operand
  2552. * @returns the resulting Vector3
  2553. */
  2554. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2555. /**
  2556. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2557. * @param x defines the x coordinate of the operand
  2558. * @param y defines the y coordinate of the operand
  2559. * @param z defines the z coordinate of the operand
  2560. * @param result defines the Vector3 object where to store the result
  2561. * @returns the current Vector3
  2562. */
  2563. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2564. /**
  2565. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2566. * @returns a new Vector3
  2567. */
  2568. negate(): Vector3;
  2569. /**
  2570. * Negate this vector in place
  2571. * @returns this
  2572. */
  2573. negateInPlace(): Vector3;
  2574. /**
  2575. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2576. * @param result defines the Vector3 object where to store the result
  2577. * @returns the current Vector3
  2578. */
  2579. negateToRef(result: Vector3): Vector3;
  2580. /**
  2581. * Multiplies the Vector3 coordinates by the float "scale"
  2582. * @param scale defines the multiplier factor
  2583. * @returns the current updated Vector3
  2584. */
  2585. scaleInPlace(scale: number): Vector3;
  2586. /**
  2587. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2588. * @param scale defines the multiplier factor
  2589. * @returns a new Vector3
  2590. */
  2591. scale(scale: number): Vector3;
  2592. /**
  2593. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2594. * @param scale defines the multiplier factor
  2595. * @param result defines the Vector3 object where to store the result
  2596. * @returns the current Vector3
  2597. */
  2598. scaleToRef(scale: number, result: Vector3): Vector3;
  2599. /**
  2600. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2601. * @param scale defines the scale factor
  2602. * @param result defines the Vector3 object where to store the result
  2603. * @returns the unmodified current Vector3
  2604. */
  2605. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2606. /**
  2607. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2608. * @param origin defines the origin of the projection ray
  2609. * @param plane defines the plane to project to
  2610. * @returns the projected vector3
  2611. */
  2612. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2613. /**
  2614. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2615. * @param origin defines the origin of the projection ray
  2616. * @param plane defines the plane to project to
  2617. * @param result defines the Vector3 where to store the result
  2618. */
  2619. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2620. /**
  2621. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2622. * @param otherVector defines the second operand
  2623. * @returns true if both vectors are equals
  2624. */
  2625. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2626. /**
  2627. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2628. * @param otherVector defines the second operand
  2629. * @param epsilon defines the minimal distance to define values as equals
  2630. * @returns true if both vectors are distant less than epsilon
  2631. */
  2632. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2633. /**
  2634. * Returns true if the current Vector3 coordinates equals the given floats
  2635. * @param x defines the x coordinate of the operand
  2636. * @param y defines the y coordinate of the operand
  2637. * @param z defines the z coordinate of the operand
  2638. * @returns true if both vectors are equals
  2639. */
  2640. equalsToFloats(x: number, y: number, z: number): boolean;
  2641. /**
  2642. * Multiplies the current Vector3 coordinates by the given ones
  2643. * @param otherVector defines the second operand
  2644. * @returns the current updated Vector3
  2645. */
  2646. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2647. /**
  2648. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2649. * @param otherVector defines the second operand
  2650. * @returns the new Vector3
  2651. */
  2652. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2653. /**
  2654. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2655. * @param otherVector defines the second operand
  2656. * @param result defines the Vector3 object where to store the result
  2657. * @returns the current Vector3
  2658. */
  2659. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2660. /**
  2661. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2662. * @param x defines the x coordinate of the operand
  2663. * @param y defines the y coordinate of the operand
  2664. * @param z defines the z coordinate of the operand
  2665. * @returns the new Vector3
  2666. */
  2667. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2668. /**
  2669. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2670. * @param otherVector defines the second operand
  2671. * @returns the new Vector3
  2672. */
  2673. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2674. /**
  2675. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2676. * @param otherVector defines the second operand
  2677. * @param result defines the Vector3 object where to store the result
  2678. * @returns the current Vector3
  2679. */
  2680. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2681. /**
  2682. * Divides the current Vector3 coordinates by the given ones.
  2683. * @param otherVector defines the second operand
  2684. * @returns the current updated Vector3
  2685. */
  2686. divideInPlace(otherVector: Vector3): Vector3;
  2687. /**
  2688. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2689. * @param other defines the second operand
  2690. * @returns the current updated Vector3
  2691. */
  2692. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2693. /**
  2694. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2695. * @param other defines the second operand
  2696. * @returns the current updated Vector3
  2697. */
  2698. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2699. /**
  2700. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2701. * @param x defines the x coordinate of the operand
  2702. * @param y defines the y coordinate of the operand
  2703. * @param z defines the z coordinate of the operand
  2704. * @returns the current updated Vector3
  2705. */
  2706. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2707. /**
  2708. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2709. * @param x defines the x coordinate of the operand
  2710. * @param y defines the y coordinate of the operand
  2711. * @param z defines the z coordinate of the operand
  2712. * @returns the current updated Vector3
  2713. */
  2714. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2715. /**
  2716. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2717. * Check if is non uniform within a certain amount of decimal places to account for this
  2718. * @param epsilon the amount the values can differ
  2719. * @returns if the the vector is non uniform to a certain number of decimal places
  2720. */
  2721. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2722. /**
  2723. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2724. */
  2725. get isNonUniform(): boolean;
  2726. /**
  2727. * Gets a new Vector3 from current Vector3 floored values
  2728. * @returns a new Vector3
  2729. */
  2730. floor(): Vector3;
  2731. /**
  2732. * Gets a new Vector3 from current Vector3 floored values
  2733. * @returns a new Vector3
  2734. */
  2735. fract(): Vector3;
  2736. /**
  2737. * Gets the length of the Vector3
  2738. * @returns the length of the Vector3
  2739. */
  2740. length(): number;
  2741. /**
  2742. * Gets the squared length of the Vector3
  2743. * @returns squared length of the Vector3
  2744. */
  2745. lengthSquared(): number;
  2746. /**
  2747. * Normalize the current Vector3.
  2748. * Please note that this is an in place operation.
  2749. * @returns the current updated Vector3
  2750. */
  2751. normalize(): Vector3;
  2752. /**
  2753. * Reorders the x y z properties of the vector in place
  2754. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2755. * @returns the current updated vector
  2756. */
  2757. reorderInPlace(order: string): this;
  2758. /**
  2759. * Rotates the vector around 0,0,0 by a quaternion
  2760. * @param quaternion the rotation quaternion
  2761. * @param result vector to store the result
  2762. * @returns the resulting vector
  2763. */
  2764. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2765. /**
  2766. * Rotates a vector around a given point
  2767. * @param quaternion the rotation quaternion
  2768. * @param point the point to rotate around
  2769. * @param result vector to store the result
  2770. * @returns the resulting vector
  2771. */
  2772. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2773. /**
  2774. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2775. * The cross product is then orthogonal to both current and "other"
  2776. * @param other defines the right operand
  2777. * @returns the cross product
  2778. */
  2779. cross(other: Vector3): Vector3;
  2780. /**
  2781. * Normalize the current Vector3 with the given input length.
  2782. * Please note that this is an in place operation.
  2783. * @param len the length of the vector
  2784. * @returns the current updated Vector3
  2785. */
  2786. normalizeFromLength(len: number): Vector3;
  2787. /**
  2788. * Normalize the current Vector3 to a new vector
  2789. * @returns the new Vector3
  2790. */
  2791. normalizeToNew(): Vector3;
  2792. /**
  2793. * Normalize the current Vector3 to the reference
  2794. * @param reference define the Vector3 to update
  2795. * @returns the updated Vector3
  2796. */
  2797. normalizeToRef(reference: Vector3): Vector3;
  2798. /**
  2799. * Creates a new Vector3 copied from the current Vector3
  2800. * @returns the new Vector3
  2801. */
  2802. clone(): Vector3;
  2803. /**
  2804. * Copies the given vector coordinates to the current Vector3 ones
  2805. * @param source defines the source Vector3
  2806. * @returns the current updated Vector3
  2807. */
  2808. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2809. /**
  2810. * Copies the given floats to the current Vector3 coordinates
  2811. * @param x defines the x coordinate of the operand
  2812. * @param y defines the y coordinate of the operand
  2813. * @param z defines the z coordinate of the operand
  2814. * @returns the current updated Vector3
  2815. */
  2816. copyFromFloats(x: number, y: number, z: number): Vector3;
  2817. /**
  2818. * Copies the given floats to the current Vector3 coordinates
  2819. * @param x defines the x coordinate of the operand
  2820. * @param y defines the y coordinate of the operand
  2821. * @param z defines the z coordinate of the operand
  2822. * @returns the current updated Vector3
  2823. */
  2824. set(x: number, y: number, z: number): Vector3;
  2825. /**
  2826. * Copies the given float to the current Vector3 coordinates
  2827. * @param v defines the x, y and z coordinates of the operand
  2828. * @returns the current updated Vector3
  2829. */
  2830. setAll(v: number): Vector3;
  2831. /**
  2832. * Get the clip factor between two vectors
  2833. * @param vector0 defines the first operand
  2834. * @param vector1 defines the second operand
  2835. * @param axis defines the axis to use
  2836. * @param size defines the size along the axis
  2837. * @returns the clip factor
  2838. */
  2839. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2840. /**
  2841. * Get angle between two vectors
  2842. * @param vector0 angle between vector0 and vector1
  2843. * @param vector1 angle between vector0 and vector1
  2844. * @param normal direction of the normal
  2845. * @return the angle between vector0 and vector1
  2846. */
  2847. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2848. /**
  2849. * Returns a new Vector3 set from the index "offset" of the given array
  2850. * @param array defines the source array
  2851. * @param offset defines the offset in the source array
  2852. * @returns the new Vector3
  2853. */
  2854. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2855. /**
  2856. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2857. * @param array defines the source array
  2858. * @param offset defines the offset in the source array
  2859. * @returns the new Vector3
  2860. * @deprecated Please use FromArray instead.
  2861. */
  2862. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2863. /**
  2864. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2865. * @param array defines the source array
  2866. * @param offset defines the offset in the source array
  2867. * @param result defines the Vector3 where to store the result
  2868. */
  2869. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2870. /**
  2871. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2872. * @param array defines the source array
  2873. * @param offset defines the offset in the source array
  2874. * @param result defines the Vector3 where to store the result
  2875. * @deprecated Please use FromArrayToRef instead.
  2876. */
  2877. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2878. /**
  2879. * Sets the given vector "result" with the given floats.
  2880. * @param x defines the x coordinate of the source
  2881. * @param y defines the y coordinate of the source
  2882. * @param z defines the z coordinate of the source
  2883. * @param result defines the Vector3 where to store the result
  2884. */
  2885. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2886. /**
  2887. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2888. * @returns a new empty Vector3
  2889. */
  2890. static Zero(): Vector3;
  2891. /**
  2892. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2893. * @returns a new unit Vector3
  2894. */
  2895. static One(): Vector3;
  2896. /**
  2897. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2898. * @returns a new up Vector3
  2899. */
  2900. static Up(): Vector3;
  2901. /**
  2902. * Gets a up Vector3 that must not be updated
  2903. */
  2904. static get UpReadOnly(): DeepImmutable<Vector3>;
  2905. /**
  2906. * Gets a zero Vector3 that must not be updated
  2907. */
  2908. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2909. /**
  2910. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2911. * @returns a new down Vector3
  2912. */
  2913. static Down(): Vector3;
  2914. /**
  2915. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2916. * @param rightHandedSystem is the scene right-handed (negative z)
  2917. * @returns a new forward Vector3
  2918. */
  2919. static Forward(rightHandedSystem?: boolean): Vector3;
  2920. /**
  2921. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2922. * @param rightHandedSystem is the scene right-handed (negative-z)
  2923. * @returns a new forward Vector3
  2924. */
  2925. static Backward(rightHandedSystem?: boolean): Vector3;
  2926. /**
  2927. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2928. * @returns a new right Vector3
  2929. */
  2930. static Right(): Vector3;
  2931. /**
  2932. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2933. * @returns a new left Vector3
  2934. */
  2935. static Left(): Vector3;
  2936. /**
  2937. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2938. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2939. * @param vector defines the Vector3 to transform
  2940. * @param transformation defines the transformation matrix
  2941. * @returns the transformed Vector3
  2942. */
  2943. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2944. /**
  2945. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2946. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2947. * @param vector defines the Vector3 to transform
  2948. * @param transformation defines the transformation matrix
  2949. * @param result defines the Vector3 where to store the result
  2950. */
  2951. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2952. /**
  2953. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2954. * This method computes tranformed coordinates only, not transformed direction vectors
  2955. * @param x define the x coordinate of the source vector
  2956. * @param y define the y coordinate of the source vector
  2957. * @param z define the z coordinate of the source vector
  2958. * @param transformation defines the transformation matrix
  2959. * @param result defines the Vector3 where to store the result
  2960. */
  2961. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2962. /**
  2963. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2964. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2965. * @param vector defines the Vector3 to transform
  2966. * @param transformation defines the transformation matrix
  2967. * @returns the new Vector3
  2968. */
  2969. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2970. /**
  2971. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2972. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2973. * @param vector defines the Vector3 to transform
  2974. * @param transformation defines the transformation matrix
  2975. * @param result defines the Vector3 where to store the result
  2976. */
  2977. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2978. /**
  2979. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2980. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2981. * @param x define the x coordinate of the source vector
  2982. * @param y define the y coordinate of the source vector
  2983. * @param z define the z coordinate of the source vector
  2984. * @param transformation defines the transformation matrix
  2985. * @param result defines the Vector3 where to store the result
  2986. */
  2987. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2988. /**
  2989. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2990. * @param value1 defines the first control point
  2991. * @param value2 defines the second control point
  2992. * @param value3 defines the third control point
  2993. * @param value4 defines the fourth control point
  2994. * @param amount defines the amount on the spline to use
  2995. * @returns the new Vector3
  2996. */
  2997. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2998. /**
  2999. * 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"
  3000. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3001. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3002. * @param value defines the current value
  3003. * @param min defines the lower range value
  3004. * @param max defines the upper range value
  3005. * @returns the new Vector3
  3006. */
  3007. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3008. /**
  3009. * 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"
  3010. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3011. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3012. * @param value defines the current value
  3013. * @param min defines the lower range value
  3014. * @param max defines the upper range value
  3015. * @param result defines the Vector3 where to store the result
  3016. */
  3017. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3018. /**
  3019. * Checks if a given vector is inside a specific range
  3020. * @param v defines the vector to test
  3021. * @param min defines the minimum range
  3022. * @param max defines the maximum range
  3023. */
  3024. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3025. /**
  3026. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3027. * @param value1 defines the first control point
  3028. * @param tangent1 defines the first tangent vector
  3029. * @param value2 defines the second control point
  3030. * @param tangent2 defines the second tangent vector
  3031. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3032. * @returns the new Vector3
  3033. */
  3034. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3035. /**
  3036. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3037. * @param start defines the start value
  3038. * @param end defines the end value
  3039. * @param amount max defines amount between both (between 0 and 1)
  3040. * @returns the new Vector3
  3041. */
  3042. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3043. /**
  3044. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3045. * @param start defines the start value
  3046. * @param end defines the end value
  3047. * @param amount max defines amount between both (between 0 and 1)
  3048. * @param result defines the Vector3 where to store the result
  3049. */
  3050. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3051. /**
  3052. * Returns the dot product (float) between the vectors "left" and "right"
  3053. * @param left defines the left operand
  3054. * @param right defines the right operand
  3055. * @returns the dot product
  3056. */
  3057. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3058. /**
  3059. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3060. * The cross product is then orthogonal to both "left" and "right"
  3061. * @param left defines the left operand
  3062. * @param right defines the right operand
  3063. * @returns the cross product
  3064. */
  3065. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3066. /**
  3067. * Sets the given vector "result" with the cross product of "left" and "right"
  3068. * The cross product is then orthogonal to both "left" and "right"
  3069. * @param left defines the left operand
  3070. * @param right defines the right operand
  3071. * @param result defines the Vector3 where to store the result
  3072. */
  3073. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3074. /**
  3075. * Returns a new Vector3 as the normalization of the given vector
  3076. * @param vector defines the Vector3 to normalize
  3077. * @returns the new Vector3
  3078. */
  3079. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3080. /**
  3081. * Sets the given vector "result" with the normalization of the given first vector
  3082. * @param vector defines the Vector3 to normalize
  3083. * @param result defines the Vector3 where to store the result
  3084. */
  3085. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3086. /**
  3087. * Project a Vector3 onto screen space
  3088. * @param vector defines the Vector3 to project
  3089. * @param world defines the world matrix to use
  3090. * @param transform defines the transform (view x projection) matrix to use
  3091. * @param viewport defines the screen viewport to use
  3092. * @returns the new Vector3
  3093. */
  3094. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3095. /** @hidden */
  3096. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3097. /**
  3098. * Unproject from screen space to object space
  3099. * @param source defines the screen space Vector3 to use
  3100. * @param viewportWidth defines the current width of the viewport
  3101. * @param viewportHeight defines the current height of the viewport
  3102. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3103. * @param transform defines the transform (view x projection) matrix to use
  3104. * @returns the new Vector3
  3105. */
  3106. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3107. /**
  3108. * Unproject from screen space to object space
  3109. * @param source defines the screen space Vector3 to use
  3110. * @param viewportWidth defines the current width of the viewport
  3111. * @param viewportHeight defines the current height of the viewport
  3112. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3113. * @param view defines the view matrix to use
  3114. * @param projection defines the projection matrix to use
  3115. * @returns the new Vector3
  3116. */
  3117. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3118. /**
  3119. * Unproject from screen space to object space
  3120. * @param source defines the screen space Vector3 to use
  3121. * @param viewportWidth defines the current width of the viewport
  3122. * @param viewportHeight defines the current height of the viewport
  3123. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3124. * @param view defines the view matrix to use
  3125. * @param projection defines the projection matrix to use
  3126. * @param result defines the Vector3 where to store the result
  3127. */
  3128. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3129. /**
  3130. * Unproject from screen space to object space
  3131. * @param sourceX defines the screen space x coordinate to use
  3132. * @param sourceY defines the screen space y coordinate to use
  3133. * @param sourceZ defines the screen space z coordinate to use
  3134. * @param viewportWidth defines the current width of the viewport
  3135. * @param viewportHeight defines the current height of the viewport
  3136. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3137. * @param view defines the view matrix to use
  3138. * @param projection defines the projection matrix to use
  3139. * @param result defines the Vector3 where to store the result
  3140. */
  3141. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3142. /**
  3143. * Gets the minimal coordinate values between two Vector3
  3144. * @param left defines the first operand
  3145. * @param right defines the second operand
  3146. * @returns the new Vector3
  3147. */
  3148. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3149. /**
  3150. * Gets the maximal coordinate values between two Vector3
  3151. * @param left defines the first operand
  3152. * @param right defines the second operand
  3153. * @returns the new Vector3
  3154. */
  3155. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3156. /**
  3157. * Returns the distance between the vectors "value1" and "value2"
  3158. * @param value1 defines the first operand
  3159. * @param value2 defines the second operand
  3160. * @returns the distance
  3161. */
  3162. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3163. /**
  3164. * Returns the squared distance between the vectors "value1" and "value2"
  3165. * @param value1 defines the first operand
  3166. * @param value2 defines the second operand
  3167. * @returns the squared distance
  3168. */
  3169. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3170. /**
  3171. * Returns a new Vector3 located at the center between "value1" and "value2"
  3172. * @param value1 defines the first operand
  3173. * @param value2 defines the second operand
  3174. * @returns the new Vector3
  3175. */
  3176. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3177. /**
  3178. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3179. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3180. * to something in order to rotate it from its local system to the given target system
  3181. * Note: axis1, axis2 and axis3 are normalized during this operation
  3182. * @param axis1 defines the first axis
  3183. * @param axis2 defines the second axis
  3184. * @param axis3 defines the third axis
  3185. * @returns a new Vector3
  3186. */
  3187. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3188. /**
  3189. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3190. * @param axis1 defines the first axis
  3191. * @param axis2 defines the second axis
  3192. * @param axis3 defines the third axis
  3193. * @param ref defines the Vector3 where to store the result
  3194. */
  3195. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3196. }
  3197. /**
  3198. * Vector4 class created for EulerAngle class conversion to Quaternion
  3199. */
  3200. export class Vector4 {
  3201. /** x value of the vector */
  3202. x: number;
  3203. /** y value of the vector */
  3204. y: number;
  3205. /** z value of the vector */
  3206. z: number;
  3207. /** w value of the vector */
  3208. w: number;
  3209. /**
  3210. * Creates a Vector4 object from the given floats.
  3211. * @param x x value of the vector
  3212. * @param y y value of the vector
  3213. * @param z z value of the vector
  3214. * @param w w value of the vector
  3215. */
  3216. constructor(
  3217. /** x value of the vector */
  3218. x: number,
  3219. /** y value of the vector */
  3220. y: number,
  3221. /** z value of the vector */
  3222. z: number,
  3223. /** w value of the vector */
  3224. w: number);
  3225. /**
  3226. * Returns the string with the Vector4 coordinates.
  3227. * @returns a string containing all the vector values
  3228. */
  3229. toString(): string;
  3230. /**
  3231. * Returns the string "Vector4".
  3232. * @returns "Vector4"
  3233. */
  3234. getClassName(): string;
  3235. /**
  3236. * Returns the Vector4 hash code.
  3237. * @returns a unique hash code
  3238. */
  3239. getHashCode(): number;
  3240. /**
  3241. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3242. * @returns the resulting array
  3243. */
  3244. asArray(): number[];
  3245. /**
  3246. * Populates the given array from the given index with the Vector4 coordinates.
  3247. * @param array array to populate
  3248. * @param index index of the array to start at (default: 0)
  3249. * @returns the Vector4.
  3250. */
  3251. toArray(array: FloatArray, index?: number): Vector4;
  3252. /**
  3253. * Adds the given vector to the current Vector4.
  3254. * @param otherVector the vector to add
  3255. * @returns the updated Vector4.
  3256. */
  3257. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3258. /**
  3259. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3260. * @param otherVector the vector to add
  3261. * @returns the resulting vector
  3262. */
  3263. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3264. /**
  3265. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3266. * @param otherVector the vector to add
  3267. * @param result the vector to store the result
  3268. * @returns the current Vector4.
  3269. */
  3270. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3271. /**
  3272. * Subtract in place the given vector from the current Vector4.
  3273. * @param otherVector the vector to subtract
  3274. * @returns the updated Vector4.
  3275. */
  3276. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3277. /**
  3278. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3279. * @param otherVector the vector to add
  3280. * @returns the new vector with the result
  3281. */
  3282. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3283. /**
  3284. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3285. * @param otherVector the vector to subtract
  3286. * @param result the vector to store the result
  3287. * @returns the current Vector4.
  3288. */
  3289. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3290. /**
  3291. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3292. */
  3293. /**
  3294. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3295. * @param x value to subtract
  3296. * @param y value to subtract
  3297. * @param z value to subtract
  3298. * @param w value to subtract
  3299. * @returns new vector containing the result
  3300. */
  3301. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3302. /**
  3303. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3304. * @param x value to subtract
  3305. * @param y value to subtract
  3306. * @param z value to subtract
  3307. * @param w value to subtract
  3308. * @param result the vector to store the result in
  3309. * @returns the current Vector4.
  3310. */
  3311. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3312. /**
  3313. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3314. * @returns a new vector with the negated values
  3315. */
  3316. negate(): Vector4;
  3317. /**
  3318. * Negate this vector in place
  3319. * @returns this
  3320. */
  3321. negateInPlace(): Vector4;
  3322. /**
  3323. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3324. * @param result defines the Vector3 object where to store the result
  3325. * @returns the current Vector4
  3326. */
  3327. negateToRef(result: Vector4): Vector4;
  3328. /**
  3329. * Multiplies the current Vector4 coordinates by scale (float).
  3330. * @param scale the number to scale with
  3331. * @returns the updated Vector4.
  3332. */
  3333. scaleInPlace(scale: number): Vector4;
  3334. /**
  3335. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3336. * @param scale the number to scale with
  3337. * @returns a new vector with the result
  3338. */
  3339. scale(scale: number): Vector4;
  3340. /**
  3341. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3342. * @param scale the number to scale with
  3343. * @param result a vector to store the result in
  3344. * @returns the current Vector4.
  3345. */
  3346. scaleToRef(scale: number, result: Vector4): Vector4;
  3347. /**
  3348. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3349. * @param scale defines the scale factor
  3350. * @param result defines the Vector4 object where to store the result
  3351. * @returns the unmodified current Vector4
  3352. */
  3353. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3354. /**
  3355. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3356. * @param otherVector the vector to compare against
  3357. * @returns true if they are equal
  3358. */
  3359. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3360. /**
  3361. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3362. * @param otherVector vector to compare against
  3363. * @param epsilon (Default: very small number)
  3364. * @returns true if they are equal
  3365. */
  3366. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3367. /**
  3368. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3369. * @param x x value to compare against
  3370. * @param y y value to compare against
  3371. * @param z z value to compare against
  3372. * @param w w value to compare against
  3373. * @returns true if equal
  3374. */
  3375. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3376. /**
  3377. * Multiplies in place the current Vector4 by the given one.
  3378. * @param otherVector vector to multiple with
  3379. * @returns the updated Vector4.
  3380. */
  3381. multiplyInPlace(otherVector: Vector4): Vector4;
  3382. /**
  3383. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3384. * @param otherVector vector to multiple with
  3385. * @returns resulting new vector
  3386. */
  3387. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3388. /**
  3389. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3390. * @param otherVector vector to multiple with
  3391. * @param result vector to store the result
  3392. * @returns the current Vector4.
  3393. */
  3394. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3395. /**
  3396. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3397. * @param x x value multiply with
  3398. * @param y y value multiply with
  3399. * @param z z value multiply with
  3400. * @param w w value multiply with
  3401. * @returns resulting new vector
  3402. */
  3403. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3404. /**
  3405. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3406. * @param otherVector vector to devide with
  3407. * @returns resulting new vector
  3408. */
  3409. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3410. /**
  3411. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3412. * @param otherVector vector to devide with
  3413. * @param result vector to store the result
  3414. * @returns the current Vector4.
  3415. */
  3416. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3417. /**
  3418. * Divides the current Vector3 coordinates by the given ones.
  3419. * @param otherVector vector to devide with
  3420. * @returns the updated Vector3.
  3421. */
  3422. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3423. /**
  3424. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3425. * @param other defines the second operand
  3426. * @returns the current updated Vector4
  3427. */
  3428. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3429. /**
  3430. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3431. * @param other defines the second operand
  3432. * @returns the current updated Vector4
  3433. */
  3434. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3435. /**
  3436. * Gets a new Vector4 from current Vector4 floored values
  3437. * @returns a new Vector4
  3438. */
  3439. floor(): Vector4;
  3440. /**
  3441. * Gets a new Vector4 from current Vector3 floored values
  3442. * @returns a new Vector4
  3443. */
  3444. fract(): Vector4;
  3445. /**
  3446. * Returns the Vector4 length (float).
  3447. * @returns the length
  3448. */
  3449. length(): number;
  3450. /**
  3451. * Returns the Vector4 squared length (float).
  3452. * @returns the length squared
  3453. */
  3454. lengthSquared(): number;
  3455. /**
  3456. * Normalizes in place the Vector4.
  3457. * @returns the updated Vector4.
  3458. */
  3459. normalize(): Vector4;
  3460. /**
  3461. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3462. * @returns this converted to a new vector3
  3463. */
  3464. toVector3(): Vector3;
  3465. /**
  3466. * Returns a new Vector4 copied from the current one.
  3467. * @returns the new cloned vector
  3468. */
  3469. clone(): Vector4;
  3470. /**
  3471. * Updates the current Vector4 with the given one coordinates.
  3472. * @param source the source vector to copy from
  3473. * @returns the updated Vector4.
  3474. */
  3475. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3476. /**
  3477. * Updates the current Vector4 coordinates with the given floats.
  3478. * @param x float to copy from
  3479. * @param y float to copy from
  3480. * @param z float to copy from
  3481. * @param w float to copy from
  3482. * @returns the updated Vector4.
  3483. */
  3484. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3485. /**
  3486. * Updates the current Vector4 coordinates with the given floats.
  3487. * @param x float to set from
  3488. * @param y float to set from
  3489. * @param z float to set from
  3490. * @param w float to set from
  3491. * @returns the updated Vector4.
  3492. */
  3493. set(x: number, y: number, z: number, w: number): Vector4;
  3494. /**
  3495. * Copies the given float to the current Vector3 coordinates
  3496. * @param v defines the x, y, z and w coordinates of the operand
  3497. * @returns the current updated Vector3
  3498. */
  3499. setAll(v: number): Vector4;
  3500. /**
  3501. * Returns a new Vector4 set from the starting index of the given array.
  3502. * @param array the array to pull values from
  3503. * @param offset the offset into the array to start at
  3504. * @returns the new vector
  3505. */
  3506. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3507. /**
  3508. * Updates the given vector "result" from the starting index of the given array.
  3509. * @param array the array to pull values from
  3510. * @param offset the offset into the array to start at
  3511. * @param result the vector to store the result in
  3512. */
  3513. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3514. /**
  3515. * Updates the given vector "result" from the starting index of the given Float32Array.
  3516. * @param array the array to pull values from
  3517. * @param offset the offset into the array to start at
  3518. * @param result the vector to store the result in
  3519. */
  3520. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3521. /**
  3522. * Updates the given vector "result" coordinates from the given floats.
  3523. * @param x float to set from
  3524. * @param y float to set from
  3525. * @param z float to set from
  3526. * @param w float to set from
  3527. * @param result the vector to the floats in
  3528. */
  3529. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3530. /**
  3531. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3532. * @returns the new vector
  3533. */
  3534. static Zero(): Vector4;
  3535. /**
  3536. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3537. * @returns the new vector
  3538. */
  3539. static One(): Vector4;
  3540. /**
  3541. * Returns a new normalized Vector4 from the given one.
  3542. * @param vector the vector to normalize
  3543. * @returns the vector
  3544. */
  3545. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3546. /**
  3547. * Updates the given vector "result" from the normalization of the given one.
  3548. * @param vector the vector to normalize
  3549. * @param result the vector to store the result in
  3550. */
  3551. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3552. /**
  3553. * Returns a vector with the minimum values from the left and right vectors
  3554. * @param left left vector to minimize
  3555. * @param right right vector to minimize
  3556. * @returns a new vector with the minimum of the left and right vector values
  3557. */
  3558. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3559. /**
  3560. * Returns a vector with the maximum values from the left and right vectors
  3561. * @param left left vector to maximize
  3562. * @param right right vector to maximize
  3563. * @returns a new vector with the maximum of the left and right vector values
  3564. */
  3565. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3566. /**
  3567. * Returns the distance (float) between the vectors "value1" and "value2".
  3568. * @param value1 value to calulate the distance between
  3569. * @param value2 value to calulate the distance between
  3570. * @return the distance between the two vectors
  3571. */
  3572. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3573. /**
  3574. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3575. * @param value1 value to calulate the distance between
  3576. * @param value2 value to calulate the distance between
  3577. * @return the distance between the two vectors squared
  3578. */
  3579. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3580. /**
  3581. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3582. * @param value1 value to calulate the center between
  3583. * @param value2 value to calulate the center between
  3584. * @return the center between the two vectors
  3585. */
  3586. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3587. /**
  3588. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3589. * This methods computes transformed normalized direction vectors only.
  3590. * @param vector the vector to transform
  3591. * @param transformation the transformation matrix to apply
  3592. * @returns the new vector
  3593. */
  3594. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3595. /**
  3596. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3597. * This methods computes transformed normalized direction vectors only.
  3598. * @param vector the vector to transform
  3599. * @param transformation the transformation matrix to apply
  3600. * @param result the vector to store the result in
  3601. */
  3602. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3603. /**
  3604. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3605. * This methods computes transformed normalized direction vectors only.
  3606. * @param x value to transform
  3607. * @param y value to transform
  3608. * @param z value to transform
  3609. * @param w value to transform
  3610. * @param transformation the transformation matrix to apply
  3611. * @param result the vector to store the results in
  3612. */
  3613. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3614. /**
  3615. * Creates a new Vector4 from a Vector3
  3616. * @param source defines the source data
  3617. * @param w defines the 4th component (default is 0)
  3618. * @returns a new Vector4
  3619. */
  3620. static FromVector3(source: Vector3, w?: number): Vector4;
  3621. }
  3622. /**
  3623. * Class used to store quaternion data
  3624. * @see https://en.wikipedia.org/wiki/Quaternion
  3625. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3626. */
  3627. export class Quaternion {
  3628. /** @hidden */
  3629. _x: number;
  3630. /** @hidden */
  3631. _y: number;
  3632. /** @hidden */
  3633. _z: number;
  3634. /** @hidden */
  3635. _w: number;
  3636. /** @hidden */
  3637. _isDirty: boolean;
  3638. /** Gets or sets the x coordinate */
  3639. get x(): number;
  3640. set x(value: number);
  3641. /** Gets or sets the y coordinate */
  3642. get y(): number;
  3643. set y(value: number);
  3644. /** Gets or sets the z coordinate */
  3645. get z(): number;
  3646. set z(value: number);
  3647. /** Gets or sets the w coordinate */
  3648. get w(): number;
  3649. set w(value: number);
  3650. /**
  3651. * Creates a new Quaternion from the given floats
  3652. * @param x defines the first component (0 by default)
  3653. * @param y defines the second component (0 by default)
  3654. * @param z defines the third component (0 by default)
  3655. * @param w defines the fourth component (1.0 by default)
  3656. */
  3657. constructor(x?: number, y?: number, z?: number, w?: number);
  3658. /**
  3659. * Gets a string representation for the current quaternion
  3660. * @returns a string with the Quaternion coordinates
  3661. */
  3662. toString(): string;
  3663. /**
  3664. * Gets the class name of the quaternion
  3665. * @returns the string "Quaternion"
  3666. */
  3667. getClassName(): string;
  3668. /**
  3669. * Gets a hash code for this quaternion
  3670. * @returns the quaternion hash code
  3671. */
  3672. getHashCode(): number;
  3673. /**
  3674. * Copy the quaternion to an array
  3675. * @returns a new array populated with 4 elements from the quaternion coordinates
  3676. */
  3677. asArray(): number[];
  3678. /**
  3679. * Check if two quaternions are equals
  3680. * @param otherQuaternion defines the second operand
  3681. * @return true if the current quaternion and the given one coordinates are strictly equals
  3682. */
  3683. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3684. /**
  3685. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3686. * @param otherQuaternion defines the other quaternion
  3687. * @param epsilon defines the minimal distance to consider equality
  3688. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3689. */
  3690. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3691. /**
  3692. * Clone the current quaternion
  3693. * @returns a new quaternion copied from the current one
  3694. */
  3695. clone(): Quaternion;
  3696. /**
  3697. * Copy a quaternion to the current one
  3698. * @param other defines the other quaternion
  3699. * @returns the updated current quaternion
  3700. */
  3701. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3702. /**
  3703. * Updates the current quaternion with the given float coordinates
  3704. * @param x defines the x coordinate
  3705. * @param y defines the y coordinate
  3706. * @param z defines the z coordinate
  3707. * @param w defines the w coordinate
  3708. * @returns the updated current quaternion
  3709. */
  3710. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3711. /**
  3712. * Updates the current quaternion from the given float coordinates
  3713. * @param x defines the x coordinate
  3714. * @param y defines the y coordinate
  3715. * @param z defines the z coordinate
  3716. * @param w defines the w coordinate
  3717. * @returns the updated current quaternion
  3718. */
  3719. set(x: number, y: number, z: number, w: number): Quaternion;
  3720. /**
  3721. * Adds two quaternions
  3722. * @param other defines the second operand
  3723. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3724. */
  3725. add(other: DeepImmutable<Quaternion>): Quaternion;
  3726. /**
  3727. * Add a quaternion to the current one
  3728. * @param other defines the quaternion to add
  3729. * @returns the current quaternion
  3730. */
  3731. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3732. /**
  3733. * Subtract two quaternions
  3734. * @param other defines the second operand
  3735. * @returns a new quaternion as the subtraction result of the given one from the current one
  3736. */
  3737. subtract(other: Quaternion): Quaternion;
  3738. /**
  3739. * Multiplies the current quaternion by a scale factor
  3740. * @param value defines the scale factor
  3741. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3742. */
  3743. scale(value: number): Quaternion;
  3744. /**
  3745. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3746. * @param scale defines the scale factor
  3747. * @param result defines the Quaternion object where to store the result
  3748. * @returns the unmodified current quaternion
  3749. */
  3750. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3751. /**
  3752. * Multiplies in place the current quaternion by a scale factor
  3753. * @param value defines the scale factor
  3754. * @returns the current modified quaternion
  3755. */
  3756. scaleInPlace(value: number): Quaternion;
  3757. /**
  3758. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3759. * @param scale defines the scale factor
  3760. * @param result defines the Quaternion object where to store the result
  3761. * @returns the unmodified current quaternion
  3762. */
  3763. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3764. /**
  3765. * Multiplies two quaternions
  3766. * @param q1 defines the second operand
  3767. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3768. */
  3769. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3770. /**
  3771. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3772. * @param q1 defines the second operand
  3773. * @param result defines the target quaternion
  3774. * @returns the current quaternion
  3775. */
  3776. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3777. /**
  3778. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3779. * @param q1 defines the second operand
  3780. * @returns the currentupdated quaternion
  3781. */
  3782. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3783. /**
  3784. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3785. * @param ref defines the target quaternion
  3786. * @returns the current quaternion
  3787. */
  3788. conjugateToRef(ref: Quaternion): Quaternion;
  3789. /**
  3790. * Conjugates in place (1-q) the current quaternion
  3791. * @returns the current updated quaternion
  3792. */
  3793. conjugateInPlace(): Quaternion;
  3794. /**
  3795. * Conjugates in place (1-q) the current quaternion
  3796. * @returns a new quaternion
  3797. */
  3798. conjugate(): Quaternion;
  3799. /**
  3800. * Gets length of current quaternion
  3801. * @returns the quaternion length (float)
  3802. */
  3803. length(): number;
  3804. /**
  3805. * Normalize in place the current quaternion
  3806. * @returns the current updated quaternion
  3807. */
  3808. normalize(): Quaternion;
  3809. /**
  3810. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3811. * @param order is a reserved parameter and is ignore for now
  3812. * @returns a new Vector3 containing the Euler angles
  3813. */
  3814. toEulerAngles(order?: string): Vector3;
  3815. /**
  3816. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3817. * @param result defines the vector which will be filled with the Euler angles
  3818. * @param order is a reserved parameter and is ignore for now
  3819. * @returns the current unchanged quaternion
  3820. */
  3821. toEulerAnglesToRef(result: Vector3): Quaternion;
  3822. /**
  3823. * Updates the given rotation matrix with the current quaternion values
  3824. * @param result defines the target matrix
  3825. * @returns the current unchanged quaternion
  3826. */
  3827. toRotationMatrix(result: Matrix): Quaternion;
  3828. /**
  3829. * Updates the current quaternion from the given rotation matrix values
  3830. * @param matrix defines the source matrix
  3831. * @returns the current updated quaternion
  3832. */
  3833. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3834. /**
  3835. * Creates a new quaternion from a rotation matrix
  3836. * @param matrix defines the source matrix
  3837. * @returns a new quaternion created from the given rotation matrix values
  3838. */
  3839. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3840. /**
  3841. * Updates the given quaternion with the given rotation matrix values
  3842. * @param matrix defines the source matrix
  3843. * @param result defines the target quaternion
  3844. */
  3845. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3846. /**
  3847. * Returns the dot product (float) between the quaternions "left" and "right"
  3848. * @param left defines the left operand
  3849. * @param right defines the right operand
  3850. * @returns the dot product
  3851. */
  3852. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3853. /**
  3854. * Checks if the two quaternions are close to each other
  3855. * @param quat0 defines the first quaternion to check
  3856. * @param quat1 defines the second quaternion to check
  3857. * @returns true if the two quaternions are close to each other
  3858. */
  3859. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3860. /**
  3861. * Creates an empty quaternion
  3862. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3863. */
  3864. static Zero(): Quaternion;
  3865. /**
  3866. * Inverse a given quaternion
  3867. * @param q defines the source quaternion
  3868. * @returns a new quaternion as the inverted current quaternion
  3869. */
  3870. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3871. /**
  3872. * Inverse a given quaternion
  3873. * @param q defines the source quaternion
  3874. * @param result the quaternion the result will be stored in
  3875. * @returns the result quaternion
  3876. */
  3877. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3878. /**
  3879. * Creates an identity quaternion
  3880. * @returns the identity quaternion
  3881. */
  3882. static Identity(): Quaternion;
  3883. /**
  3884. * Gets a boolean indicating if the given quaternion is identity
  3885. * @param quaternion defines the quaternion to check
  3886. * @returns true if the quaternion is identity
  3887. */
  3888. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3889. /**
  3890. * Creates a quaternion from a rotation around an axis
  3891. * @param axis defines the axis to use
  3892. * @param angle defines the angle to use
  3893. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3894. */
  3895. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3896. /**
  3897. * Creates a rotation around an axis and stores it into the given quaternion
  3898. * @param axis defines the axis to use
  3899. * @param angle defines the angle to use
  3900. * @param result defines the target quaternion
  3901. * @returns the target quaternion
  3902. */
  3903. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3904. /**
  3905. * Creates a new quaternion from data stored into an array
  3906. * @param array defines the data source
  3907. * @param offset defines the offset in the source array where the data starts
  3908. * @returns a new quaternion
  3909. */
  3910. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3911. /**
  3912. * Updates the given quaternion "result" from the starting index of the given array.
  3913. * @param array the array to pull values from
  3914. * @param offset the offset into the array to start at
  3915. * @param result the quaternion to store the result in
  3916. */
  3917. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3918. /**
  3919. * Create a quaternion from Euler rotation angles
  3920. * @param x Pitch
  3921. * @param y Yaw
  3922. * @param z Roll
  3923. * @returns the new Quaternion
  3924. */
  3925. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3926. /**
  3927. * Updates a quaternion from Euler rotation angles
  3928. * @param x Pitch
  3929. * @param y Yaw
  3930. * @param z Roll
  3931. * @param result the quaternion to store the result
  3932. * @returns the updated quaternion
  3933. */
  3934. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3935. /**
  3936. * Create a quaternion from Euler rotation vector
  3937. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3938. * @returns the new Quaternion
  3939. */
  3940. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3941. /**
  3942. * Updates a quaternion from Euler rotation vector
  3943. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3944. * @param result the quaternion to store the result
  3945. * @returns the updated quaternion
  3946. */
  3947. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3948. /**
  3949. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3950. * @param yaw defines the rotation around Y axis
  3951. * @param pitch defines the rotation around X axis
  3952. * @param roll defines the rotation around Z axis
  3953. * @returns the new quaternion
  3954. */
  3955. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3956. /**
  3957. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3958. * @param yaw defines the rotation around Y axis
  3959. * @param pitch defines the rotation around X axis
  3960. * @param roll defines the rotation around Z axis
  3961. * @param result defines the target quaternion
  3962. */
  3963. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3964. /**
  3965. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3966. * @param alpha defines the rotation around first axis
  3967. * @param beta defines the rotation around second axis
  3968. * @param gamma defines the rotation around third axis
  3969. * @returns the new quaternion
  3970. */
  3971. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3972. /**
  3973. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3974. * @param alpha defines the rotation around first axis
  3975. * @param beta defines the rotation around second axis
  3976. * @param gamma defines the rotation around third axis
  3977. * @param result defines the target quaternion
  3978. */
  3979. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3980. /**
  3981. * 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)
  3982. * @param axis1 defines the first axis
  3983. * @param axis2 defines the second axis
  3984. * @param axis3 defines the third axis
  3985. * @returns the new quaternion
  3986. */
  3987. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3988. /**
  3989. * 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
  3990. * @param axis1 defines the first axis
  3991. * @param axis2 defines the second axis
  3992. * @param axis3 defines the third axis
  3993. * @param ref defines the target quaternion
  3994. */
  3995. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3996. /**
  3997. * Interpolates between two quaternions
  3998. * @param left defines first quaternion
  3999. * @param right defines second quaternion
  4000. * @param amount defines the gradient to use
  4001. * @returns the new interpolated quaternion
  4002. */
  4003. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4004. /**
  4005. * Interpolates between two quaternions and stores it into a target quaternion
  4006. * @param left defines first quaternion
  4007. * @param right defines second quaternion
  4008. * @param amount defines the gradient to use
  4009. * @param result defines the target quaternion
  4010. */
  4011. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4012. /**
  4013. * Interpolate between two quaternions using Hermite interpolation
  4014. * @param value1 defines first quaternion
  4015. * @param tangent1 defines the incoming tangent
  4016. * @param value2 defines second quaternion
  4017. * @param tangent2 defines the outgoing tangent
  4018. * @param amount defines the target quaternion
  4019. * @returns the new interpolated quaternion
  4020. */
  4021. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4022. }
  4023. /**
  4024. * Class used to store matrix data (4x4)
  4025. */
  4026. export class Matrix {
  4027. /**
  4028. * Gets the precision of matrix computations
  4029. */
  4030. static get Use64Bits(): boolean;
  4031. private static _updateFlagSeed;
  4032. private static _identityReadOnly;
  4033. private _isIdentity;
  4034. private _isIdentityDirty;
  4035. private _isIdentity3x2;
  4036. private _isIdentity3x2Dirty;
  4037. /**
  4038. * Gets the update flag of the matrix which is an unique number for the matrix.
  4039. * It will be incremented every time the matrix data change.
  4040. * You can use it to speed the comparison between two versions of the same matrix.
  4041. */
  4042. updateFlag: number;
  4043. private readonly _m;
  4044. /**
  4045. * Gets the internal data of the matrix
  4046. */
  4047. get m(): DeepImmutable<Float32Array | Array<number>>;
  4048. /** @hidden */
  4049. _markAsUpdated(): void;
  4050. /** @hidden */
  4051. private _updateIdentityStatus;
  4052. /**
  4053. * Creates an empty matrix (filled with zeros)
  4054. */
  4055. constructor();
  4056. /**
  4057. * Check if the current matrix is identity
  4058. * @returns true is the matrix is the identity matrix
  4059. */
  4060. isIdentity(): boolean;
  4061. /**
  4062. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4063. * @returns true is the matrix is the identity matrix
  4064. */
  4065. isIdentityAs3x2(): boolean;
  4066. /**
  4067. * Gets the determinant of the matrix
  4068. * @returns the matrix determinant
  4069. */
  4070. determinant(): number;
  4071. /**
  4072. * Returns the matrix as a Float32Array or Array<number>
  4073. * @returns the matrix underlying array
  4074. */
  4075. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4076. /**
  4077. * Returns the matrix as a Float32Array or Array<number>
  4078. * @returns the matrix underlying array.
  4079. */
  4080. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4081. /**
  4082. * Inverts the current matrix in place
  4083. * @returns the current inverted matrix
  4084. */
  4085. invert(): Matrix;
  4086. /**
  4087. * Sets all the matrix elements to zero
  4088. * @returns the current matrix
  4089. */
  4090. reset(): Matrix;
  4091. /**
  4092. * Adds the current matrix with a second one
  4093. * @param other defines the matrix to add
  4094. * @returns a new matrix as the addition of the current matrix and the given one
  4095. */
  4096. add(other: DeepImmutable<Matrix>): Matrix;
  4097. /**
  4098. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4099. * @param other defines the matrix to add
  4100. * @param result defines the target matrix
  4101. * @returns the current matrix
  4102. */
  4103. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4104. /**
  4105. * Adds in place the given matrix to the current matrix
  4106. * @param other defines the second operand
  4107. * @returns the current updated matrix
  4108. */
  4109. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4110. /**
  4111. * Sets the given matrix to the current inverted Matrix
  4112. * @param other defines the target matrix
  4113. * @returns the unmodified current matrix
  4114. */
  4115. invertToRef(other: Matrix): Matrix;
  4116. /**
  4117. * add a value at the specified position in the current Matrix
  4118. * @param index the index of the value within the matrix. between 0 and 15.
  4119. * @param value the value to be added
  4120. * @returns the current updated matrix
  4121. */
  4122. addAtIndex(index: number, value: number): Matrix;
  4123. /**
  4124. * mutiply the specified position in the current Matrix by a value
  4125. * @param index the index of the value within the matrix. between 0 and 15.
  4126. * @param value the value to be added
  4127. * @returns the current updated matrix
  4128. */
  4129. multiplyAtIndex(index: number, value: number): Matrix;
  4130. /**
  4131. * Inserts the translation vector (using 3 floats) in the current matrix
  4132. * @param x defines the 1st component of the translation
  4133. * @param y defines the 2nd component of the translation
  4134. * @param z defines the 3rd component of the translation
  4135. * @returns the current updated matrix
  4136. */
  4137. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4138. /**
  4139. * Adds the translation vector (using 3 floats) in the current matrix
  4140. * @param x defines the 1st component of the translation
  4141. * @param y defines the 2nd component of the translation
  4142. * @param z defines the 3rd component of the translation
  4143. * @returns the current updated matrix
  4144. */
  4145. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4146. /**
  4147. * Inserts the translation vector in the current matrix
  4148. * @param vector3 defines the translation to insert
  4149. * @returns the current updated matrix
  4150. */
  4151. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4152. /**
  4153. * Gets the translation value of the current matrix
  4154. * @returns a new Vector3 as the extracted translation from the matrix
  4155. */
  4156. getTranslation(): Vector3;
  4157. /**
  4158. * Fill a Vector3 with the extracted translation from the matrix
  4159. * @param result defines the Vector3 where to store the translation
  4160. * @returns the current matrix
  4161. */
  4162. getTranslationToRef(result: Vector3): Matrix;
  4163. /**
  4164. * Remove rotation and scaling part from the matrix
  4165. * @returns the updated matrix
  4166. */
  4167. removeRotationAndScaling(): Matrix;
  4168. /**
  4169. * Multiply two matrices
  4170. * @param other defines the second operand
  4171. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4172. */
  4173. multiply(other: DeepImmutable<Matrix>): Matrix;
  4174. /**
  4175. * Copy the current matrix from the given one
  4176. * @param other defines the source matrix
  4177. * @returns the current updated matrix
  4178. */
  4179. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4180. /**
  4181. * Populates the given array from the starting index with the current matrix values
  4182. * @param array defines the target array
  4183. * @param offset defines the offset in the target array where to start storing values
  4184. * @returns the current matrix
  4185. */
  4186. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4187. /**
  4188. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4189. * @param other defines the second operand
  4190. * @param result defines the matrix where to store the multiplication
  4191. * @returns the current matrix
  4192. */
  4193. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4194. /**
  4195. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4196. * @param other defines the second operand
  4197. * @param result defines the array where to store the multiplication
  4198. * @param offset defines the offset in the target array where to start storing values
  4199. * @returns the current matrix
  4200. */
  4201. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4202. /**
  4203. * Check equality between this matrix and a second one
  4204. * @param value defines the second matrix to compare
  4205. * @returns true is the current matrix and the given one values are strictly equal
  4206. */
  4207. equals(value: DeepImmutable<Matrix>): boolean;
  4208. /**
  4209. * Clone the current matrix
  4210. * @returns a new matrix from the current matrix
  4211. */
  4212. clone(): Matrix;
  4213. /**
  4214. * Returns the name of the current matrix class
  4215. * @returns the string "Matrix"
  4216. */
  4217. getClassName(): string;
  4218. /**
  4219. * Gets the hash code of the current matrix
  4220. * @returns the hash code
  4221. */
  4222. getHashCode(): number;
  4223. /**
  4224. * Decomposes the current Matrix into a translation, rotation and scaling components
  4225. * @param scale defines the scale vector3 given as a reference to update
  4226. * @param rotation defines the rotation quaternion given as a reference to update
  4227. * @param translation defines the translation vector3 given as a reference to update
  4228. * @returns true if operation was successful
  4229. */
  4230. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4231. /**
  4232. * Gets specific row of the matrix
  4233. * @param index defines the number of the row to get
  4234. * @returns the index-th row of the current matrix as a new Vector4
  4235. */
  4236. getRow(index: number): Nullable<Vector4>;
  4237. /**
  4238. * Sets the index-th row of the current matrix to the vector4 values
  4239. * @param index defines the number of the row to set
  4240. * @param row defines the target vector4
  4241. * @returns the updated current matrix
  4242. */
  4243. setRow(index: number, row: Vector4): Matrix;
  4244. /**
  4245. * Compute the transpose of the matrix
  4246. * @returns the new transposed matrix
  4247. */
  4248. transpose(): Matrix;
  4249. /**
  4250. * Compute the transpose of the matrix and store it in a given matrix
  4251. * @param result defines the target matrix
  4252. * @returns the current matrix
  4253. */
  4254. transposeToRef(result: Matrix): Matrix;
  4255. /**
  4256. * Sets the index-th row of the current matrix with the given 4 x float values
  4257. * @param index defines the row index
  4258. * @param x defines the x component to set
  4259. * @param y defines the y component to set
  4260. * @param z defines the z component to set
  4261. * @param w defines the w component to set
  4262. * @returns the updated current matrix
  4263. */
  4264. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4265. /**
  4266. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4267. * @param scale defines the scale factor
  4268. * @returns a new matrix
  4269. */
  4270. scale(scale: number): Matrix;
  4271. /**
  4272. * Scale the current matrix values by a factor to a given result matrix
  4273. * @param scale defines the scale factor
  4274. * @param result defines the matrix to store the result
  4275. * @returns the current matrix
  4276. */
  4277. scaleToRef(scale: number, result: Matrix): Matrix;
  4278. /**
  4279. * Scale the current matrix values by a factor and add the result to a given matrix
  4280. * @param scale defines the scale factor
  4281. * @param result defines the Matrix to store the result
  4282. * @returns the current matrix
  4283. */
  4284. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4285. /**
  4286. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4287. * @param ref matrix to store the result
  4288. */
  4289. toNormalMatrix(ref: Matrix): void;
  4290. /**
  4291. * Gets only rotation part of the current matrix
  4292. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4293. */
  4294. getRotationMatrix(): Matrix;
  4295. /**
  4296. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4297. * @param result defines the target matrix to store data to
  4298. * @returns the current matrix
  4299. */
  4300. getRotationMatrixToRef(result: Matrix): Matrix;
  4301. /**
  4302. * Toggles model matrix from being right handed to left handed in place and vice versa
  4303. */
  4304. toggleModelMatrixHandInPlace(): void;
  4305. /**
  4306. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4307. */
  4308. toggleProjectionMatrixHandInPlace(): void;
  4309. /**
  4310. * Creates a matrix from an array
  4311. * @param array defines the source array
  4312. * @param offset defines an offset in the source array
  4313. * @returns a new Matrix set from the starting index of the given array
  4314. */
  4315. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4316. /**
  4317. * Copy the content of an array into a given matrix
  4318. * @param array defines the source array
  4319. * @param offset defines an offset in the source array
  4320. * @param result defines the target matrix
  4321. */
  4322. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4323. /**
  4324. * Stores an array into a matrix after having multiplied each component by a given factor
  4325. * @param array defines the source array
  4326. * @param offset defines the offset in the source array
  4327. * @param scale defines the scaling factor
  4328. * @param result defines the target matrix
  4329. */
  4330. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4331. /**
  4332. * Gets an identity matrix that must not be updated
  4333. */
  4334. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4335. /**
  4336. * Stores a list of values (16) inside a given matrix
  4337. * @param initialM11 defines 1st value of 1st row
  4338. * @param initialM12 defines 2nd value of 1st row
  4339. * @param initialM13 defines 3rd value of 1st row
  4340. * @param initialM14 defines 4th value of 1st row
  4341. * @param initialM21 defines 1st value of 2nd row
  4342. * @param initialM22 defines 2nd value of 2nd row
  4343. * @param initialM23 defines 3rd value of 2nd row
  4344. * @param initialM24 defines 4th value of 2nd row
  4345. * @param initialM31 defines 1st value of 3rd row
  4346. * @param initialM32 defines 2nd value of 3rd row
  4347. * @param initialM33 defines 3rd value of 3rd row
  4348. * @param initialM34 defines 4th value of 3rd row
  4349. * @param initialM41 defines 1st value of 4th row
  4350. * @param initialM42 defines 2nd value of 4th row
  4351. * @param initialM43 defines 3rd value of 4th row
  4352. * @param initialM44 defines 4th value of 4th row
  4353. * @param result defines the target matrix
  4354. */
  4355. 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;
  4356. /**
  4357. * Creates new matrix from a list of values (16)
  4358. * @param initialM11 defines 1st value of 1st row
  4359. * @param initialM12 defines 2nd value of 1st row
  4360. * @param initialM13 defines 3rd value of 1st row
  4361. * @param initialM14 defines 4th value of 1st row
  4362. * @param initialM21 defines 1st value of 2nd row
  4363. * @param initialM22 defines 2nd value of 2nd row
  4364. * @param initialM23 defines 3rd value of 2nd row
  4365. * @param initialM24 defines 4th value of 2nd row
  4366. * @param initialM31 defines 1st value of 3rd row
  4367. * @param initialM32 defines 2nd value of 3rd row
  4368. * @param initialM33 defines 3rd value of 3rd row
  4369. * @param initialM34 defines 4th value of 3rd row
  4370. * @param initialM41 defines 1st value of 4th row
  4371. * @param initialM42 defines 2nd value of 4th row
  4372. * @param initialM43 defines 3rd value of 4th row
  4373. * @param initialM44 defines 4th value of 4th row
  4374. * @returns the new matrix
  4375. */
  4376. 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;
  4377. /**
  4378. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4379. * @param scale defines the scale vector3
  4380. * @param rotation defines the rotation quaternion
  4381. * @param translation defines the translation vector3
  4382. * @returns a new matrix
  4383. */
  4384. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4385. /**
  4386. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4387. * @param scale defines the scale vector3
  4388. * @param rotation defines the rotation quaternion
  4389. * @param translation defines the translation vector3
  4390. * @param result defines the target matrix
  4391. */
  4392. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4393. /**
  4394. * Creates a new identity matrix
  4395. * @returns a new identity matrix
  4396. */
  4397. static Identity(): Matrix;
  4398. /**
  4399. * Creates a new identity matrix and stores the result in a given matrix
  4400. * @param result defines the target matrix
  4401. */
  4402. static IdentityToRef(result: Matrix): void;
  4403. /**
  4404. * Creates a new zero matrix
  4405. * @returns a new zero matrix
  4406. */
  4407. static Zero(): Matrix;
  4408. /**
  4409. * Creates a new rotation matrix for "angle" radians around the X axis
  4410. * @param angle defines the angle (in radians) to use
  4411. * @return the new matrix
  4412. */
  4413. static RotationX(angle: number): Matrix;
  4414. /**
  4415. * Creates a new matrix as the invert of a given matrix
  4416. * @param source defines the source matrix
  4417. * @returns the new matrix
  4418. */
  4419. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4420. /**
  4421. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4422. * @param angle defines the angle (in radians) to use
  4423. * @param result defines the target matrix
  4424. */
  4425. static RotationXToRef(angle: number, result: Matrix): void;
  4426. /**
  4427. * Creates a new rotation matrix for "angle" radians around the Y axis
  4428. * @param angle defines the angle (in radians) to use
  4429. * @return the new matrix
  4430. */
  4431. static RotationY(angle: number): Matrix;
  4432. /**
  4433. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4434. * @param angle defines the angle (in radians) to use
  4435. * @param result defines the target matrix
  4436. */
  4437. static RotationYToRef(angle: number, result: Matrix): void;
  4438. /**
  4439. * Creates a new rotation matrix for "angle" radians around the Z axis
  4440. * @param angle defines the angle (in radians) to use
  4441. * @return the new matrix
  4442. */
  4443. static RotationZ(angle: number): Matrix;
  4444. /**
  4445. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4446. * @param angle defines the angle (in radians) to use
  4447. * @param result defines the target matrix
  4448. */
  4449. static RotationZToRef(angle: number, result: Matrix): void;
  4450. /**
  4451. * Creates a new rotation matrix for "angle" radians around the given axis
  4452. * @param axis defines the axis to use
  4453. * @param angle defines the angle (in radians) to use
  4454. * @return the new matrix
  4455. */
  4456. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4457. /**
  4458. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4459. * @param axis defines the axis to use
  4460. * @param angle defines the angle (in radians) to use
  4461. * @param result defines the target matrix
  4462. */
  4463. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4464. /**
  4465. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4466. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4467. * @param from defines the vector to align
  4468. * @param to defines the vector to align to
  4469. * @param result defines the target matrix
  4470. */
  4471. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4472. /**
  4473. * Creates a rotation matrix
  4474. * @param yaw defines the yaw angle in radians (Y axis)
  4475. * @param pitch defines the pitch angle in radians (X axis)
  4476. * @param roll defines the roll angle in radians (Z axis)
  4477. * @returns the new rotation matrix
  4478. */
  4479. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4480. /**
  4481. * Creates a rotation matrix and stores it in a given matrix
  4482. * @param yaw defines the yaw angle in radians (Y axis)
  4483. * @param pitch defines the pitch angle in radians (X axis)
  4484. * @param roll defines the roll angle in radians (Z axis)
  4485. * @param result defines the target matrix
  4486. */
  4487. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4488. /**
  4489. * Creates a scaling matrix
  4490. * @param x defines the scale factor on X axis
  4491. * @param y defines the scale factor on Y axis
  4492. * @param z defines the scale factor on Z axis
  4493. * @returns the new matrix
  4494. */
  4495. static Scaling(x: number, y: number, z: number): Matrix;
  4496. /**
  4497. * Creates a scaling matrix and stores it in a given matrix
  4498. * @param x defines the scale factor on X axis
  4499. * @param y defines the scale factor on Y axis
  4500. * @param z defines the scale factor on Z axis
  4501. * @param result defines the target matrix
  4502. */
  4503. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4504. /**
  4505. * Creates a translation matrix
  4506. * @param x defines the translation on X axis
  4507. * @param y defines the translation on Y axis
  4508. * @param z defines the translationon Z axis
  4509. * @returns the new matrix
  4510. */
  4511. static Translation(x: number, y: number, z: number): Matrix;
  4512. /**
  4513. * Creates a translation matrix and stores it in a given matrix
  4514. * @param x defines the translation on X axis
  4515. * @param y defines the translation on Y axis
  4516. * @param z defines the translationon Z axis
  4517. * @param result defines the target matrix
  4518. */
  4519. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4520. /**
  4521. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4522. * @param startValue defines the start value
  4523. * @param endValue defines the end value
  4524. * @param gradient defines the gradient factor
  4525. * @returns the new matrix
  4526. */
  4527. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4528. /**
  4529. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4530. * @param startValue defines the start value
  4531. * @param endValue defines the end value
  4532. * @param gradient defines the gradient factor
  4533. * @param result defines the Matrix object where to store data
  4534. */
  4535. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4536. /**
  4537. * Builds a new matrix whose values are computed by:
  4538. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4539. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4540. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4541. * @param startValue defines the first matrix
  4542. * @param endValue defines the second matrix
  4543. * @param gradient defines the gradient between the two matrices
  4544. * @returns the new matrix
  4545. */
  4546. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4547. /**
  4548. * Update a matrix to values which are computed by:
  4549. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4550. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4551. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4552. * @param startValue defines the first matrix
  4553. * @param endValue defines the second matrix
  4554. * @param gradient defines the gradient between the two matrices
  4555. * @param result defines the target matrix
  4556. */
  4557. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4558. /**
  4559. * 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"
  4560. * This function works in left handed mode
  4561. * @param eye defines the final position of the entity
  4562. * @param target defines where the entity should look at
  4563. * @param up defines the up vector for the entity
  4564. * @returns the new matrix
  4565. */
  4566. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4567. /**
  4568. * 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".
  4569. * This function works in left handed mode
  4570. * @param eye defines the final position of the entity
  4571. * @param target defines where the entity should look at
  4572. * @param up defines the up vector for the entity
  4573. * @param result defines the target matrix
  4574. */
  4575. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4576. /**
  4577. * 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"
  4578. * This function works in right handed mode
  4579. * @param eye defines the final position of the entity
  4580. * @param target defines where the entity should look at
  4581. * @param up defines the up vector for the entity
  4582. * @returns the new matrix
  4583. */
  4584. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4585. /**
  4586. * 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".
  4587. * This function works in right handed mode
  4588. * @param eye defines the final position of the entity
  4589. * @param target defines where the entity should look at
  4590. * @param up defines the up vector for the entity
  4591. * @param result defines the target matrix
  4592. */
  4593. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4594. /**
  4595. * Create a left-handed orthographic projection matrix
  4596. * @param width defines the viewport width
  4597. * @param height defines the viewport height
  4598. * @param znear defines the near clip plane
  4599. * @param zfar defines the far clip plane
  4600. * @returns a new matrix as a left-handed orthographic projection matrix
  4601. */
  4602. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4603. /**
  4604. * Store a left-handed orthographic projection to a given matrix
  4605. * @param width defines the viewport width
  4606. * @param height defines the viewport height
  4607. * @param znear defines the near clip plane
  4608. * @param zfar defines the far clip plane
  4609. * @param result defines the target matrix
  4610. */
  4611. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4612. /**
  4613. * Create a left-handed orthographic projection matrix
  4614. * @param left defines the viewport left coordinate
  4615. * @param right defines the viewport right coordinate
  4616. * @param bottom defines the viewport bottom coordinate
  4617. * @param top defines the viewport top coordinate
  4618. * @param znear defines the near clip plane
  4619. * @param zfar defines the far clip plane
  4620. * @returns a new matrix as a left-handed orthographic projection matrix
  4621. */
  4622. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4623. /**
  4624. * Stores a left-handed orthographic projection into a given matrix
  4625. * @param left defines the viewport left coordinate
  4626. * @param right defines the viewport right coordinate
  4627. * @param bottom defines the viewport bottom coordinate
  4628. * @param top defines the viewport top coordinate
  4629. * @param znear defines the near clip plane
  4630. * @param zfar defines the far clip plane
  4631. * @param result defines the target matrix
  4632. */
  4633. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4634. /**
  4635. * Creates a right-handed orthographic projection matrix
  4636. * @param left defines the viewport left coordinate
  4637. * @param right defines the viewport right coordinate
  4638. * @param bottom defines the viewport bottom coordinate
  4639. * @param top defines the viewport top coordinate
  4640. * @param znear defines the near clip plane
  4641. * @param zfar defines the far clip plane
  4642. * @returns a new matrix as a right-handed orthographic projection matrix
  4643. */
  4644. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4645. /**
  4646. * Stores a right-handed orthographic projection into a given matrix
  4647. * @param left defines the viewport left coordinate
  4648. * @param right defines the viewport right coordinate
  4649. * @param bottom defines the viewport bottom coordinate
  4650. * @param top defines the viewport top coordinate
  4651. * @param znear defines the near clip plane
  4652. * @param zfar defines the far clip plane
  4653. * @param result defines the target matrix
  4654. */
  4655. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4656. /**
  4657. * Creates a left-handed perspective projection matrix
  4658. * @param width defines the viewport width
  4659. * @param height defines the viewport height
  4660. * @param znear defines the near clip plane
  4661. * @param zfar defines the far clip plane
  4662. * @returns a new matrix as a left-handed perspective projection matrix
  4663. */
  4664. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4665. /**
  4666. * Creates a left-handed perspective projection matrix
  4667. * @param fov defines the horizontal field of view
  4668. * @param aspect defines the aspect ratio
  4669. * @param znear defines the near clip plane
  4670. * @param zfar defines the far clip plane
  4671. * @returns a new matrix as a left-handed perspective projection matrix
  4672. */
  4673. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4674. /**
  4675. * Stores a left-handed perspective projection into a given matrix
  4676. * @param fov defines the horizontal field of view
  4677. * @param aspect defines the aspect ratio
  4678. * @param znear defines the near clip plane
  4679. * @param zfar defines the far clip plane
  4680. * @param result defines the target matrix
  4681. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4682. */
  4683. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4684. /**
  4685. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4686. * @param fov defines the horizontal field of view
  4687. * @param aspect defines the aspect ratio
  4688. * @param znear defines the near clip plane
  4689. * @param zfar not used as infinity is used as far clip
  4690. * @param result defines the target matrix
  4691. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4692. */
  4693. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4694. /**
  4695. * Creates a right-handed perspective projection matrix
  4696. * @param fov defines the horizontal field of view
  4697. * @param aspect defines the aspect ratio
  4698. * @param znear defines the near clip plane
  4699. * @param zfar defines the far clip plane
  4700. * @returns a new matrix as a right-handed perspective projection matrix
  4701. */
  4702. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4703. /**
  4704. * Stores a right-handed perspective projection into a given matrix
  4705. * @param fov defines the horizontal field of view
  4706. * @param aspect defines the aspect ratio
  4707. * @param znear defines the near clip plane
  4708. * @param zfar defines the far clip plane
  4709. * @param result defines the target matrix
  4710. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4711. */
  4712. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4713. /**
  4714. * Stores a right-handed perspective projection into a given matrix
  4715. * @param fov defines the horizontal field of view
  4716. * @param aspect defines the aspect ratio
  4717. * @param znear defines the near clip plane
  4718. * @param zfar not used as infinity is used as far clip
  4719. * @param result defines the target matrix
  4720. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4721. */
  4722. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4723. /**
  4724. * Stores a perspective projection for WebVR info a given matrix
  4725. * @param fov defines the field of view
  4726. * @param znear defines the near clip plane
  4727. * @param zfar defines the far clip plane
  4728. * @param result defines the target matrix
  4729. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4730. */
  4731. static PerspectiveFovWebVRToRef(fov: {
  4732. upDegrees: number;
  4733. downDegrees: number;
  4734. leftDegrees: number;
  4735. rightDegrees: number;
  4736. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4737. /**
  4738. * Computes a complete transformation matrix
  4739. * @param viewport defines the viewport to use
  4740. * @param world defines the world matrix
  4741. * @param view defines the view matrix
  4742. * @param projection defines the projection matrix
  4743. * @param zmin defines the near clip plane
  4744. * @param zmax defines the far clip plane
  4745. * @returns the transformation matrix
  4746. */
  4747. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4748. /**
  4749. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4750. * @param matrix defines the matrix to use
  4751. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4752. */
  4753. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4754. /**
  4755. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4756. * @param matrix defines the matrix to use
  4757. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4758. */
  4759. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4760. /**
  4761. * Compute the transpose of a given matrix
  4762. * @param matrix defines the matrix to transpose
  4763. * @returns the new matrix
  4764. */
  4765. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4766. /**
  4767. * Compute the transpose of a matrix and store it in a target matrix
  4768. * @param matrix defines the matrix to transpose
  4769. * @param result defines the target matrix
  4770. */
  4771. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4772. /**
  4773. * Computes a reflection matrix from a plane
  4774. * @param plane defines the reflection plane
  4775. * @returns a new matrix
  4776. */
  4777. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4778. /**
  4779. * Computes a reflection matrix from a plane
  4780. * @param plane defines the reflection plane
  4781. * @param result defines the target matrix
  4782. */
  4783. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4784. /**
  4785. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4786. * @param xaxis defines the value of the 1st axis
  4787. * @param yaxis defines the value of the 2nd axis
  4788. * @param zaxis defines the value of the 3rd axis
  4789. * @param result defines the target matrix
  4790. */
  4791. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4792. /**
  4793. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4794. * @param quat defines the quaternion to use
  4795. * @param result defines the target matrix
  4796. */
  4797. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4798. }
  4799. /**
  4800. * @hidden
  4801. */
  4802. export class TmpVectors {
  4803. static Vector2: Vector2[];
  4804. static Vector3: Vector3[];
  4805. static Vector4: Vector4[];
  4806. static Quaternion: Quaternion[];
  4807. static Matrix: Matrix[];
  4808. }
  4809. }
  4810. declare module BABYLON {
  4811. /**
  4812. * Defines potential orientation for back face culling
  4813. */
  4814. export enum Orientation {
  4815. /**
  4816. * Clockwise
  4817. */
  4818. CW = 0,
  4819. /** Counter clockwise */
  4820. CCW = 1
  4821. }
  4822. /** Class used to represent a Bezier curve */
  4823. export class BezierCurve {
  4824. /**
  4825. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4826. * @param t defines the time
  4827. * @param x1 defines the left coordinate on X axis
  4828. * @param y1 defines the left coordinate on Y axis
  4829. * @param x2 defines the right coordinate on X axis
  4830. * @param y2 defines the right coordinate on Y axis
  4831. * @returns the interpolated value
  4832. */
  4833. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4834. }
  4835. /**
  4836. * Defines angle representation
  4837. */
  4838. export class Angle {
  4839. private _radians;
  4840. /**
  4841. * Creates an Angle object of "radians" radians (float).
  4842. * @param radians the angle in radians
  4843. */
  4844. constructor(radians: number);
  4845. /**
  4846. * Get value in degrees
  4847. * @returns the Angle value in degrees (float)
  4848. */
  4849. degrees(): number;
  4850. /**
  4851. * Get value in radians
  4852. * @returns the Angle value in radians (float)
  4853. */
  4854. radians(): number;
  4855. /**
  4856. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4857. * @param a defines first point as the origin
  4858. * @param b defines point
  4859. * @returns a new Angle
  4860. */
  4861. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4862. /**
  4863. * Gets a new Angle object from the given float in radians
  4864. * @param radians defines the angle value in radians
  4865. * @returns a new Angle
  4866. */
  4867. static FromRadians(radians: number): Angle;
  4868. /**
  4869. * Gets a new Angle object from the given float in degrees
  4870. * @param degrees defines the angle value in degrees
  4871. * @returns a new Angle
  4872. */
  4873. static FromDegrees(degrees: number): Angle;
  4874. }
  4875. /**
  4876. * This represents an arc in a 2d space.
  4877. */
  4878. export class Arc2 {
  4879. /** Defines the start point of the arc */
  4880. startPoint: Vector2;
  4881. /** Defines the mid point of the arc */
  4882. midPoint: Vector2;
  4883. /** Defines the end point of the arc */
  4884. endPoint: Vector2;
  4885. /**
  4886. * Defines the center point of the arc.
  4887. */
  4888. centerPoint: Vector2;
  4889. /**
  4890. * Defines the radius of the arc.
  4891. */
  4892. radius: number;
  4893. /**
  4894. * Defines the angle of the arc (from mid point to end point).
  4895. */
  4896. angle: Angle;
  4897. /**
  4898. * Defines the start angle of the arc (from start point to middle point).
  4899. */
  4900. startAngle: Angle;
  4901. /**
  4902. * Defines the orientation of the arc (clock wise/counter clock wise).
  4903. */
  4904. orientation: Orientation;
  4905. /**
  4906. * Creates an Arc object from the three given points : start, middle and end.
  4907. * @param startPoint Defines the start point of the arc
  4908. * @param midPoint Defines the midlle point of the arc
  4909. * @param endPoint Defines the end point of the arc
  4910. */
  4911. constructor(
  4912. /** Defines the start point of the arc */
  4913. startPoint: Vector2,
  4914. /** Defines the mid point of the arc */
  4915. midPoint: Vector2,
  4916. /** Defines the end point of the arc */
  4917. endPoint: Vector2);
  4918. }
  4919. /**
  4920. * Represents a 2D path made up of multiple 2D points
  4921. */
  4922. export class Path2 {
  4923. private _points;
  4924. private _length;
  4925. /**
  4926. * If the path start and end point are the same
  4927. */
  4928. closed: boolean;
  4929. /**
  4930. * Creates a Path2 object from the starting 2D coordinates x and y.
  4931. * @param x the starting points x value
  4932. * @param y the starting points y value
  4933. */
  4934. constructor(x: number, y: number);
  4935. /**
  4936. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4937. * @param x the added points x value
  4938. * @param y the added points y value
  4939. * @returns the updated Path2.
  4940. */
  4941. addLineTo(x: number, y: number): Path2;
  4942. /**
  4943. * 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.
  4944. * @param midX middle point x value
  4945. * @param midY middle point y value
  4946. * @param endX end point x value
  4947. * @param endY end point y value
  4948. * @param numberOfSegments (default: 36)
  4949. * @returns the updated Path2.
  4950. */
  4951. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4952. /**
  4953. * Closes the Path2.
  4954. * @returns the Path2.
  4955. */
  4956. close(): Path2;
  4957. /**
  4958. * Gets the sum of the distance between each sequential point in the path
  4959. * @returns the Path2 total length (float).
  4960. */
  4961. length(): number;
  4962. /**
  4963. * Gets the points which construct the path
  4964. * @returns the Path2 internal array of points.
  4965. */
  4966. getPoints(): Vector2[];
  4967. /**
  4968. * Retreives the point at the distance aways from the starting point
  4969. * @param normalizedLengthPosition the length along the path to retreive the point from
  4970. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4971. */
  4972. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4973. /**
  4974. * Creates a new path starting from an x and y position
  4975. * @param x starting x value
  4976. * @param y starting y value
  4977. * @returns a new Path2 starting at the coordinates (x, y).
  4978. */
  4979. static StartingAt(x: number, y: number): Path2;
  4980. }
  4981. /**
  4982. * Represents a 3D path made up of multiple 3D points
  4983. */
  4984. export class Path3D {
  4985. /**
  4986. * an array of Vector3, the curve axis of the Path3D
  4987. */
  4988. path: Vector3[];
  4989. private _curve;
  4990. private _distances;
  4991. private _tangents;
  4992. private _normals;
  4993. private _binormals;
  4994. private _raw;
  4995. private _alignTangentsWithPath;
  4996. private readonly _pointAtData;
  4997. /**
  4998. * new Path3D(path, normal, raw)
  4999. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5000. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5001. * @param path an array of Vector3, the curve axis of the Path3D
  5002. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5003. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5004. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5005. */
  5006. constructor(
  5007. /**
  5008. * an array of Vector3, the curve axis of the Path3D
  5009. */
  5010. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5011. /**
  5012. * Returns the Path3D array of successive Vector3 designing its curve.
  5013. * @returns the Path3D array of successive Vector3 designing its curve.
  5014. */
  5015. getCurve(): Vector3[];
  5016. /**
  5017. * Returns the Path3D array of successive Vector3 designing its curve.
  5018. * @returns the Path3D array of successive Vector3 designing its curve.
  5019. */
  5020. getPoints(): Vector3[];
  5021. /**
  5022. * @returns the computed length (float) of the path.
  5023. */
  5024. length(): number;
  5025. /**
  5026. * Returns an array populated with tangent vectors on each Path3D curve point.
  5027. * @returns an array populated with tangent vectors on each Path3D curve point.
  5028. */
  5029. getTangents(): Vector3[];
  5030. /**
  5031. * Returns an array populated with normal vectors on each Path3D curve point.
  5032. * @returns an array populated with normal vectors on each Path3D curve point.
  5033. */
  5034. getNormals(): Vector3[];
  5035. /**
  5036. * Returns an array populated with binormal vectors on each Path3D curve point.
  5037. * @returns an array populated with binormal vectors on each Path3D curve point.
  5038. */
  5039. getBinormals(): Vector3[];
  5040. /**
  5041. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5042. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5043. */
  5044. getDistances(): number[];
  5045. /**
  5046. * Returns an interpolated point along this path
  5047. * @param position the position of the point along this path, from 0.0 to 1.0
  5048. * @returns a new Vector3 as the point
  5049. */
  5050. getPointAt(position: number): Vector3;
  5051. /**
  5052. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5053. * @param position the position of the point along this path, from 0.0 to 1.0
  5054. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5055. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5056. */
  5057. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5058. /**
  5059. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5060. * @param position the position of the point along this path, from 0.0 to 1.0
  5061. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5062. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5063. */
  5064. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5065. /**
  5066. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5067. * @param position the position of the point along this path, from 0.0 to 1.0
  5068. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5069. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5070. */
  5071. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5072. /**
  5073. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5074. * @param position the position of the point along this path, from 0.0 to 1.0
  5075. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5076. */
  5077. getDistanceAt(position: number): number;
  5078. /**
  5079. * Returns the array index of the previous point of an interpolated point along this path
  5080. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5081. * @returns the array index
  5082. */
  5083. getPreviousPointIndexAt(position: number): number;
  5084. /**
  5085. * 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)
  5086. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5087. * @returns the sub position
  5088. */
  5089. getSubPositionAt(position: number): number;
  5090. /**
  5091. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5092. * @param target the vector of which to get the closest position to
  5093. * @returns the position of the closest virtual point on this path to the target vector
  5094. */
  5095. getClosestPositionTo(target: Vector3): number;
  5096. /**
  5097. * Returns a sub path (slice) of this path
  5098. * @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
  5099. * @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
  5100. * @returns a sub path (slice) of this path
  5101. */
  5102. slice(start?: number, end?: number): Path3D;
  5103. /**
  5104. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5105. * @param path path which all values are copied into the curves points
  5106. * @param firstNormal which should be projected onto the curve
  5107. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5108. * @returns the same object updated.
  5109. */
  5110. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5111. private _compute;
  5112. private _getFirstNonNullVector;
  5113. private _getLastNonNullVector;
  5114. private _normalVector;
  5115. /**
  5116. * Updates the point at data for an interpolated point along this curve
  5117. * @param position the position of the point along this curve, from 0.0 to 1.0
  5118. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5119. * @returns the (updated) point at data
  5120. */
  5121. private _updatePointAtData;
  5122. /**
  5123. * Updates the point at data from the specified parameters
  5124. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5125. * @param point the interpolated point
  5126. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5127. */
  5128. private _setPointAtData;
  5129. /**
  5130. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5131. */
  5132. private _updateInterpolationMatrix;
  5133. }
  5134. /**
  5135. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5136. * A Curve3 is designed from a series of successive Vector3.
  5137. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5138. */
  5139. export class Curve3 {
  5140. private _points;
  5141. private _length;
  5142. /**
  5143. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5144. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5145. * @param v1 (Vector3) the control point
  5146. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5147. * @param nbPoints (integer) the wanted number of points in the curve
  5148. * @returns the created Curve3
  5149. */
  5150. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5151. /**
  5152. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5153. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5154. * @param v1 (Vector3) the first control point
  5155. * @param v2 (Vector3) the second control point
  5156. * @param v3 (Vector3) the end point of the Cubic Bezier
  5157. * @param nbPoints (integer) the wanted number of points in the curve
  5158. * @returns the created Curve3
  5159. */
  5160. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5161. /**
  5162. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5163. * @param p1 (Vector3) the origin point of the Hermite Spline
  5164. * @param t1 (Vector3) the tangent vector at the origin point
  5165. * @param p2 (Vector3) the end point of the Hermite Spline
  5166. * @param t2 (Vector3) the tangent vector at the end point
  5167. * @param nbPoints (integer) the wanted number of points in the curve
  5168. * @returns the created Curve3
  5169. */
  5170. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5171. /**
  5172. * Returns a Curve3 object along a CatmullRom Spline curve :
  5173. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5174. * @param nbPoints (integer) the wanted number of points between each curve control points
  5175. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5176. * @returns the created Curve3
  5177. */
  5178. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5179. /**
  5180. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5181. * A Curve3 is designed from a series of successive Vector3.
  5182. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5183. * @param points points which make up the curve
  5184. */
  5185. constructor(points: Vector3[]);
  5186. /**
  5187. * @returns the Curve3 stored array of successive Vector3
  5188. */
  5189. getPoints(): Vector3[];
  5190. /**
  5191. * @returns the computed length (float) of the curve.
  5192. */
  5193. length(): number;
  5194. /**
  5195. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5196. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5197. * curveA and curveB keep unchanged.
  5198. * @param curve the curve to continue from this curve
  5199. * @returns the newly constructed curve
  5200. */
  5201. continue(curve: DeepImmutable<Curve3>): Curve3;
  5202. private _computeLength;
  5203. }
  5204. }
  5205. declare module BABYLON {
  5206. /**
  5207. * This represents the main contract an easing function should follow.
  5208. * Easing functions are used throughout the animation system.
  5209. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5210. */
  5211. export interface IEasingFunction {
  5212. /**
  5213. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5214. * of the easing function.
  5215. * The link below provides some of the most common examples of easing functions.
  5216. * @see https://easings.net/
  5217. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5218. * @returns the corresponding value on the curve defined by the easing function
  5219. */
  5220. ease(gradient: number): number;
  5221. }
  5222. /**
  5223. * Base class used for every default easing function.
  5224. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5225. */
  5226. export class EasingFunction implements IEasingFunction {
  5227. /**
  5228. * Interpolation follows the mathematical formula associated with the easing function.
  5229. */
  5230. static readonly EASINGMODE_EASEIN: number;
  5231. /**
  5232. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5233. */
  5234. static readonly EASINGMODE_EASEOUT: number;
  5235. /**
  5236. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5237. */
  5238. static readonly EASINGMODE_EASEINOUT: number;
  5239. private _easingMode;
  5240. /**
  5241. * Sets the easing mode of the current function.
  5242. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5243. */
  5244. setEasingMode(easingMode: number): void;
  5245. /**
  5246. * Gets the current easing mode.
  5247. * @returns the easing mode
  5248. */
  5249. getEasingMode(): number;
  5250. /**
  5251. * @hidden
  5252. */
  5253. easeInCore(gradient: number): number;
  5254. /**
  5255. * Given an input gradient between 0 and 1, this returns the corresponding value
  5256. * of the easing function.
  5257. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5258. * @returns the corresponding value on the curve defined by the easing function
  5259. */
  5260. ease(gradient: number): number;
  5261. }
  5262. /**
  5263. * Easing function with a circle shape (see link below).
  5264. * @see https://easings.net/#easeInCirc
  5265. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5266. */
  5267. export class CircleEase extends EasingFunction implements IEasingFunction {
  5268. /** @hidden */
  5269. easeInCore(gradient: number): number;
  5270. }
  5271. /**
  5272. * Easing function with a ease back shape (see link below).
  5273. * @see https://easings.net/#easeInBack
  5274. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5275. */
  5276. export class BackEase extends EasingFunction implements IEasingFunction {
  5277. /** Defines the amplitude of the function */
  5278. amplitude: number;
  5279. /**
  5280. * Instantiates a back ease easing
  5281. * @see https://easings.net/#easeInBack
  5282. * @param amplitude Defines the amplitude of the function
  5283. */
  5284. constructor(
  5285. /** Defines the amplitude of the function */
  5286. amplitude?: number);
  5287. /** @hidden */
  5288. easeInCore(gradient: number): number;
  5289. }
  5290. /**
  5291. * Easing function with a bouncing shape (see link below).
  5292. * @see https://easings.net/#easeInBounce
  5293. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5294. */
  5295. export class BounceEase extends EasingFunction implements IEasingFunction {
  5296. /** Defines the number of bounces */
  5297. bounces: number;
  5298. /** Defines the amplitude of the bounce */
  5299. bounciness: number;
  5300. /**
  5301. * Instantiates a bounce easing
  5302. * @see https://easings.net/#easeInBounce
  5303. * @param bounces Defines the number of bounces
  5304. * @param bounciness Defines the amplitude of the bounce
  5305. */
  5306. constructor(
  5307. /** Defines the number of bounces */
  5308. bounces?: number,
  5309. /** Defines the amplitude of the bounce */
  5310. bounciness?: number);
  5311. /** @hidden */
  5312. easeInCore(gradient: number): number;
  5313. }
  5314. /**
  5315. * Easing function with a power of 3 shape (see link below).
  5316. * @see https://easings.net/#easeInCubic
  5317. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5318. */
  5319. export class CubicEase extends EasingFunction implements IEasingFunction {
  5320. /** @hidden */
  5321. easeInCore(gradient: number): number;
  5322. }
  5323. /**
  5324. * Easing function with an elastic shape (see link below).
  5325. * @see https://easings.net/#easeInElastic
  5326. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5327. */
  5328. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5329. /** Defines the number of oscillations*/
  5330. oscillations: number;
  5331. /** Defines the amplitude of the oscillations*/
  5332. springiness: number;
  5333. /**
  5334. * Instantiates an elastic easing function
  5335. * @see https://easings.net/#easeInElastic
  5336. * @param oscillations Defines the number of oscillations
  5337. * @param springiness Defines the amplitude of the oscillations
  5338. */
  5339. constructor(
  5340. /** Defines the number of oscillations*/
  5341. oscillations?: number,
  5342. /** Defines the amplitude of the oscillations*/
  5343. springiness?: number);
  5344. /** @hidden */
  5345. easeInCore(gradient: number): number;
  5346. }
  5347. /**
  5348. * Easing function with an exponential shape (see link below).
  5349. * @see https://easings.net/#easeInExpo
  5350. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5351. */
  5352. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5353. /** Defines the exponent of the function */
  5354. exponent: number;
  5355. /**
  5356. * Instantiates an exponential easing function
  5357. * @see https://easings.net/#easeInExpo
  5358. * @param exponent Defines the exponent of the function
  5359. */
  5360. constructor(
  5361. /** Defines the exponent of the function */
  5362. exponent?: number);
  5363. /** @hidden */
  5364. easeInCore(gradient: number): number;
  5365. }
  5366. /**
  5367. * Easing function with a power shape (see link below).
  5368. * @see https://easings.net/#easeInQuad
  5369. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5370. */
  5371. export class PowerEase extends EasingFunction implements IEasingFunction {
  5372. /** Defines the power of the function */
  5373. power: number;
  5374. /**
  5375. * Instantiates an power base easing function
  5376. * @see https://easings.net/#easeInQuad
  5377. * @param power Defines the power of the function
  5378. */
  5379. constructor(
  5380. /** Defines the power of the function */
  5381. power?: number);
  5382. /** @hidden */
  5383. easeInCore(gradient: number): number;
  5384. }
  5385. /**
  5386. * Easing function with a power of 2 shape (see link below).
  5387. * @see https://easings.net/#easeInQuad
  5388. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5389. */
  5390. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5391. /** @hidden */
  5392. easeInCore(gradient: number): number;
  5393. }
  5394. /**
  5395. * Easing function with a power of 4 shape (see link below).
  5396. * @see https://easings.net/#easeInQuart
  5397. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5398. */
  5399. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5400. /** @hidden */
  5401. easeInCore(gradient: number): number;
  5402. }
  5403. /**
  5404. * Easing function with a power of 5 shape (see link below).
  5405. * @see https://easings.net/#easeInQuint
  5406. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5407. */
  5408. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5409. /** @hidden */
  5410. easeInCore(gradient: number): number;
  5411. }
  5412. /**
  5413. * Easing function with a sin shape (see link below).
  5414. * @see https://easings.net/#easeInSine
  5415. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5416. */
  5417. export class SineEase extends EasingFunction implements IEasingFunction {
  5418. /** @hidden */
  5419. easeInCore(gradient: number): number;
  5420. }
  5421. /**
  5422. * Easing function with a bezier shape (see link below).
  5423. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5424. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5425. */
  5426. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5427. /** Defines the x component of the start tangent in the bezier curve */
  5428. x1: number;
  5429. /** Defines the y component of the start tangent in the bezier curve */
  5430. y1: number;
  5431. /** Defines the x component of the end tangent in the bezier curve */
  5432. x2: number;
  5433. /** Defines the y component of the end tangent in the bezier curve */
  5434. y2: number;
  5435. /**
  5436. * Instantiates a bezier function
  5437. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5438. * @param x1 Defines the x component of the start tangent in the bezier curve
  5439. * @param y1 Defines the y component of the start tangent in the bezier curve
  5440. * @param x2 Defines the x component of the end tangent in the bezier curve
  5441. * @param y2 Defines the y component of the end tangent in the bezier curve
  5442. */
  5443. constructor(
  5444. /** Defines the x component of the start tangent in the bezier curve */
  5445. x1?: number,
  5446. /** Defines the y component of the start tangent in the bezier curve */
  5447. y1?: number,
  5448. /** Defines the x component of the end tangent in the bezier curve */
  5449. x2?: number,
  5450. /** Defines the y component of the end tangent in the bezier curve */
  5451. y2?: number);
  5452. /** @hidden */
  5453. easeInCore(gradient: number): number;
  5454. }
  5455. }
  5456. declare module BABYLON {
  5457. /**
  5458. * Class used to hold a RBG color
  5459. */
  5460. export class Color3 {
  5461. /**
  5462. * Defines the red component (between 0 and 1, default is 0)
  5463. */
  5464. r: number;
  5465. /**
  5466. * Defines the green component (between 0 and 1, default is 0)
  5467. */
  5468. g: number;
  5469. /**
  5470. * Defines the blue component (between 0 and 1, default is 0)
  5471. */
  5472. b: number;
  5473. /**
  5474. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5475. * @param r defines the red component (between 0 and 1, default is 0)
  5476. * @param g defines the green component (between 0 and 1, default is 0)
  5477. * @param b defines the blue component (between 0 and 1, default is 0)
  5478. */
  5479. constructor(
  5480. /**
  5481. * Defines the red component (between 0 and 1, default is 0)
  5482. */
  5483. r?: number,
  5484. /**
  5485. * Defines the green component (between 0 and 1, default is 0)
  5486. */
  5487. g?: number,
  5488. /**
  5489. * Defines the blue component (between 0 and 1, default is 0)
  5490. */
  5491. b?: number);
  5492. /**
  5493. * Creates a string with the Color3 current values
  5494. * @returns the string representation of the Color3 object
  5495. */
  5496. toString(): string;
  5497. /**
  5498. * Returns the string "Color3"
  5499. * @returns "Color3"
  5500. */
  5501. getClassName(): string;
  5502. /**
  5503. * Compute the Color3 hash code
  5504. * @returns an unique number that can be used to hash Color3 objects
  5505. */
  5506. getHashCode(): number;
  5507. /**
  5508. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5509. * @param array defines the array where to store the r,g,b components
  5510. * @param index defines an optional index in the target array to define where to start storing values
  5511. * @returns the current Color3 object
  5512. */
  5513. toArray(array: FloatArray, index?: number): Color3;
  5514. /**
  5515. * Returns a new Color4 object from the current Color3 and the given alpha
  5516. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5517. * @returns a new Color4 object
  5518. */
  5519. toColor4(alpha?: number): Color4;
  5520. /**
  5521. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5522. * @returns the new array
  5523. */
  5524. asArray(): number[];
  5525. /**
  5526. * Returns the luminance value
  5527. * @returns a float value
  5528. */
  5529. toLuminance(): number;
  5530. /**
  5531. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5532. * @param otherColor defines the second operand
  5533. * @returns the new Color3 object
  5534. */
  5535. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5536. /**
  5537. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5538. * @param otherColor defines the second operand
  5539. * @param result defines the Color3 object where to store the result
  5540. * @returns the current Color3
  5541. */
  5542. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5543. /**
  5544. * Determines equality between Color3 objects
  5545. * @param otherColor defines the second operand
  5546. * @returns true if the rgb values are equal to the given ones
  5547. */
  5548. equals(otherColor: DeepImmutable<Color3>): boolean;
  5549. /**
  5550. * Determines equality between the current Color3 object and a set of r,b,g values
  5551. * @param r defines the red component to check
  5552. * @param g defines the green component to check
  5553. * @param b defines the blue component to check
  5554. * @returns true if the rgb values are equal to the given ones
  5555. */
  5556. equalsFloats(r: number, g: number, b: number): boolean;
  5557. /**
  5558. * Multiplies in place each rgb value by scale
  5559. * @param scale defines the scaling factor
  5560. * @returns the updated Color3
  5561. */
  5562. scale(scale: number): Color3;
  5563. /**
  5564. * Multiplies the rgb values by scale and stores the result into "result"
  5565. * @param scale defines the scaling factor
  5566. * @param result defines the Color3 object where to store the result
  5567. * @returns the unmodified current Color3
  5568. */
  5569. scaleToRef(scale: number, result: Color3): Color3;
  5570. /**
  5571. * Scale the current Color3 values by a factor and add the result to a given Color3
  5572. * @param scale defines the scale factor
  5573. * @param result defines color to store the result into
  5574. * @returns the unmodified current Color3
  5575. */
  5576. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5577. /**
  5578. * Clamps the rgb values by the min and max values and stores the result into "result"
  5579. * @param min defines minimum clamping value (default is 0)
  5580. * @param max defines maximum clamping value (default is 1)
  5581. * @param result defines color to store the result into
  5582. * @returns the original Color3
  5583. */
  5584. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5585. /**
  5586. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5587. * @param otherColor defines the second operand
  5588. * @returns the new Color3
  5589. */
  5590. add(otherColor: DeepImmutable<Color3>): Color3;
  5591. /**
  5592. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5593. * @param otherColor defines the second operand
  5594. * @param result defines Color3 object to store the result into
  5595. * @returns the unmodified current Color3
  5596. */
  5597. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5598. /**
  5599. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5600. * @param otherColor defines the second operand
  5601. * @returns the new Color3
  5602. */
  5603. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5604. /**
  5605. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5606. * @param otherColor defines the second operand
  5607. * @param result defines Color3 object to store the result into
  5608. * @returns the unmodified current Color3
  5609. */
  5610. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5611. /**
  5612. * Copy the current object
  5613. * @returns a new Color3 copied the current one
  5614. */
  5615. clone(): Color3;
  5616. /**
  5617. * Copies the rgb values from the source in the current Color3
  5618. * @param source defines the source Color3 object
  5619. * @returns the updated Color3 object
  5620. */
  5621. copyFrom(source: DeepImmutable<Color3>): Color3;
  5622. /**
  5623. * Updates the Color3 rgb values from the given floats
  5624. * @param r defines the red component to read from
  5625. * @param g defines the green component to read from
  5626. * @param b defines the blue component to read from
  5627. * @returns the current Color3 object
  5628. */
  5629. copyFromFloats(r: number, g: number, b: number): Color3;
  5630. /**
  5631. * Updates the Color3 rgb values from the given floats
  5632. * @param r defines the red component to read from
  5633. * @param g defines the green component to read from
  5634. * @param b defines the blue component to read from
  5635. * @returns the current Color3 object
  5636. */
  5637. set(r: number, g: number, b: number): Color3;
  5638. /**
  5639. * Compute the Color3 hexadecimal code as a string
  5640. * @returns a string containing the hexadecimal representation of the Color3 object
  5641. */
  5642. toHexString(): string;
  5643. /**
  5644. * Computes a new Color3 converted from the current one to linear space
  5645. * @returns a new Color3 object
  5646. */
  5647. toLinearSpace(): Color3;
  5648. /**
  5649. * Converts current color in rgb space to HSV values
  5650. * @returns a new color3 representing the HSV values
  5651. */
  5652. toHSV(): Color3;
  5653. /**
  5654. * Converts current color in rgb space to HSV values
  5655. * @param result defines the Color3 where to store the HSV values
  5656. */
  5657. toHSVToRef(result: Color3): void;
  5658. /**
  5659. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5660. * @param convertedColor defines the Color3 object where to store the linear space version
  5661. * @returns the unmodified Color3
  5662. */
  5663. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5664. /**
  5665. * Computes a new Color3 converted from the current one to gamma space
  5666. * @returns a new Color3 object
  5667. */
  5668. toGammaSpace(): Color3;
  5669. /**
  5670. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5671. * @param convertedColor defines the Color3 object where to store the gamma space version
  5672. * @returns the unmodified Color3
  5673. */
  5674. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5675. private static _BlackReadOnly;
  5676. /**
  5677. * Convert Hue, saturation and value to a Color3 (RGB)
  5678. * @param hue defines the hue
  5679. * @param saturation defines the saturation
  5680. * @param value defines the value
  5681. * @param result defines the Color3 where to store the RGB values
  5682. */
  5683. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5684. /**
  5685. * Creates a new Color3 from the string containing valid hexadecimal values
  5686. * @param hex defines a string containing valid hexadecimal values
  5687. * @returns a new Color3 object
  5688. */
  5689. static FromHexString(hex: string): Color3;
  5690. /**
  5691. * Creates a new Color3 from the starting index of the given array
  5692. * @param array defines the source array
  5693. * @param offset defines an offset in the source array
  5694. * @returns a new Color3 object
  5695. */
  5696. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5697. /**
  5698. * Creates a new Color3 from integer values (< 256)
  5699. * @param r defines the red component to read from (value between 0 and 255)
  5700. * @param g defines the green component to read from (value between 0 and 255)
  5701. * @param b defines the blue component to read from (value between 0 and 255)
  5702. * @returns a new Color3 object
  5703. */
  5704. static FromInts(r: number, g: number, b: number): Color3;
  5705. /**
  5706. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5707. * @param start defines the start Color3 value
  5708. * @param end defines the end Color3 value
  5709. * @param amount defines the gradient value between start and end
  5710. * @returns a new Color3 object
  5711. */
  5712. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5713. /**
  5714. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5715. * @param left defines the start value
  5716. * @param right defines the end value
  5717. * @param amount defines the gradient factor
  5718. * @param result defines the Color3 object where to store the result
  5719. */
  5720. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5721. /**
  5722. * Returns a Color3 value containing a red color
  5723. * @returns a new Color3 object
  5724. */
  5725. static Red(): Color3;
  5726. /**
  5727. * Returns a Color3 value containing a green color
  5728. * @returns a new Color3 object
  5729. */
  5730. static Green(): Color3;
  5731. /**
  5732. * Returns a Color3 value containing a blue color
  5733. * @returns a new Color3 object
  5734. */
  5735. static Blue(): Color3;
  5736. /**
  5737. * Returns a Color3 value containing a black color
  5738. * @returns a new Color3 object
  5739. */
  5740. static Black(): Color3;
  5741. /**
  5742. * Gets a Color3 value containing a black color that must not be updated
  5743. */
  5744. static get BlackReadOnly(): DeepImmutable<Color3>;
  5745. /**
  5746. * Returns a Color3 value containing a white color
  5747. * @returns a new Color3 object
  5748. */
  5749. static White(): Color3;
  5750. /**
  5751. * Returns a Color3 value containing a purple color
  5752. * @returns a new Color3 object
  5753. */
  5754. static Purple(): Color3;
  5755. /**
  5756. * Returns a Color3 value containing a magenta color
  5757. * @returns a new Color3 object
  5758. */
  5759. static Magenta(): Color3;
  5760. /**
  5761. * Returns a Color3 value containing a yellow color
  5762. * @returns a new Color3 object
  5763. */
  5764. static Yellow(): Color3;
  5765. /**
  5766. * Returns a Color3 value containing a gray color
  5767. * @returns a new Color3 object
  5768. */
  5769. static Gray(): Color3;
  5770. /**
  5771. * Returns a Color3 value containing a teal color
  5772. * @returns a new Color3 object
  5773. */
  5774. static Teal(): Color3;
  5775. /**
  5776. * Returns a Color3 value containing a random color
  5777. * @returns a new Color3 object
  5778. */
  5779. static Random(): Color3;
  5780. }
  5781. /**
  5782. * Class used to hold a RBGA color
  5783. */
  5784. export class Color4 {
  5785. /**
  5786. * Defines the red component (between 0 and 1, default is 0)
  5787. */
  5788. r: number;
  5789. /**
  5790. * Defines the green component (between 0 and 1, default is 0)
  5791. */
  5792. g: number;
  5793. /**
  5794. * Defines the blue component (between 0 and 1, default is 0)
  5795. */
  5796. b: number;
  5797. /**
  5798. * Defines the alpha component (between 0 and 1, default is 1)
  5799. */
  5800. a: number;
  5801. /**
  5802. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5803. * @param r defines the red component (between 0 and 1, default is 0)
  5804. * @param g defines the green component (between 0 and 1, default is 0)
  5805. * @param b defines the blue component (between 0 and 1, default is 0)
  5806. * @param a defines the alpha component (between 0 and 1, default is 1)
  5807. */
  5808. constructor(
  5809. /**
  5810. * Defines the red component (between 0 and 1, default is 0)
  5811. */
  5812. r?: number,
  5813. /**
  5814. * Defines the green component (between 0 and 1, default is 0)
  5815. */
  5816. g?: number,
  5817. /**
  5818. * Defines the blue component (between 0 and 1, default is 0)
  5819. */
  5820. b?: number,
  5821. /**
  5822. * Defines the alpha component (between 0 and 1, default is 1)
  5823. */
  5824. a?: number);
  5825. /**
  5826. * Adds in place the given Color4 values to the current Color4 object
  5827. * @param right defines the second operand
  5828. * @returns the current updated Color4 object
  5829. */
  5830. addInPlace(right: DeepImmutable<Color4>): Color4;
  5831. /**
  5832. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5833. * @returns the new array
  5834. */
  5835. asArray(): number[];
  5836. /**
  5837. * Stores from the starting index in the given array the Color4 successive values
  5838. * @param array defines the array where to store the r,g,b components
  5839. * @param index defines an optional index in the target array to define where to start storing values
  5840. * @returns the current Color4 object
  5841. */
  5842. toArray(array: number[], index?: number): Color4;
  5843. /**
  5844. * Determines equality between Color4 objects
  5845. * @param otherColor defines the second operand
  5846. * @returns true if the rgba values are equal to the given ones
  5847. */
  5848. equals(otherColor: DeepImmutable<Color4>): boolean;
  5849. /**
  5850. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5851. * @param right defines the second operand
  5852. * @returns a new Color4 object
  5853. */
  5854. add(right: DeepImmutable<Color4>): Color4;
  5855. /**
  5856. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5857. * @param right defines the second operand
  5858. * @returns a new Color4 object
  5859. */
  5860. subtract(right: DeepImmutable<Color4>): Color4;
  5861. /**
  5862. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5863. * @param right defines the second operand
  5864. * @param result defines the Color4 object where to store the result
  5865. * @returns the current Color4 object
  5866. */
  5867. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5868. /**
  5869. * Creates a new Color4 with the current Color4 values multiplied by scale
  5870. * @param scale defines the scaling factor to apply
  5871. * @returns a new Color4 object
  5872. */
  5873. scale(scale: number): Color4;
  5874. /**
  5875. * Multiplies the current Color4 values by scale and stores the result in "result"
  5876. * @param scale defines the scaling factor to apply
  5877. * @param result defines the Color4 object where to store the result
  5878. * @returns the current unmodified Color4
  5879. */
  5880. scaleToRef(scale: number, result: Color4): Color4;
  5881. /**
  5882. * Scale the current Color4 values by a factor and add the result to a given Color4
  5883. * @param scale defines the scale factor
  5884. * @param result defines the Color4 object where to store the result
  5885. * @returns the unmodified current Color4
  5886. */
  5887. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5888. /**
  5889. * Clamps the rgb values by the min and max values and stores the result into "result"
  5890. * @param min defines minimum clamping value (default is 0)
  5891. * @param max defines maximum clamping value (default is 1)
  5892. * @param result defines color to store the result into.
  5893. * @returns the cuurent Color4
  5894. */
  5895. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5896. /**
  5897. * Multipy an Color4 value by another and return a new Color4 object
  5898. * @param color defines the Color4 value to multiply by
  5899. * @returns a new Color4 object
  5900. */
  5901. multiply(color: Color4): Color4;
  5902. /**
  5903. * Multipy a Color4 value by another and push the result in a reference value
  5904. * @param color defines the Color4 value to multiply by
  5905. * @param result defines the Color4 to fill the result in
  5906. * @returns the result Color4
  5907. */
  5908. multiplyToRef(color: Color4, result: Color4): Color4;
  5909. /**
  5910. * Creates a string with the Color4 current values
  5911. * @returns the string representation of the Color4 object
  5912. */
  5913. toString(): string;
  5914. /**
  5915. * Returns the string "Color4"
  5916. * @returns "Color4"
  5917. */
  5918. getClassName(): string;
  5919. /**
  5920. * Compute the Color4 hash code
  5921. * @returns an unique number that can be used to hash Color4 objects
  5922. */
  5923. getHashCode(): number;
  5924. /**
  5925. * Creates a new Color4 copied from the current one
  5926. * @returns a new Color4 object
  5927. */
  5928. clone(): Color4;
  5929. /**
  5930. * Copies the given Color4 values into the current one
  5931. * @param source defines the source Color4 object
  5932. * @returns the current updated Color4 object
  5933. */
  5934. copyFrom(source: Color4): Color4;
  5935. /**
  5936. * Copies the given float values into the current one
  5937. * @param r defines the red component to read from
  5938. * @param g defines the green component to read from
  5939. * @param b defines the blue component to read from
  5940. * @param a defines the alpha component to read from
  5941. * @returns the current updated Color4 object
  5942. */
  5943. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5944. /**
  5945. * Copies the given float values into the current one
  5946. * @param r defines the red component to read from
  5947. * @param g defines the green component to read from
  5948. * @param b defines the blue component to read from
  5949. * @param a defines the alpha component to read from
  5950. * @returns the current updated Color4 object
  5951. */
  5952. set(r: number, g: number, b: number, a: number): Color4;
  5953. /**
  5954. * Compute the Color4 hexadecimal code as a string
  5955. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5956. * @returns a string containing the hexadecimal representation of the Color4 object
  5957. */
  5958. toHexString(returnAsColor3?: boolean): string;
  5959. /**
  5960. * Computes a new Color4 converted from the current one to linear space
  5961. * @returns a new Color4 object
  5962. */
  5963. toLinearSpace(): Color4;
  5964. /**
  5965. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5966. * @param convertedColor defines the Color4 object where to store the linear space version
  5967. * @returns the unmodified Color4
  5968. */
  5969. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5970. /**
  5971. * Computes a new Color4 converted from the current one to gamma space
  5972. * @returns a new Color4 object
  5973. */
  5974. toGammaSpace(): Color4;
  5975. /**
  5976. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5977. * @param convertedColor defines the Color4 object where to store the gamma space version
  5978. * @returns the unmodified Color4
  5979. */
  5980. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5981. /**
  5982. * Creates a new Color4 from the string containing valid hexadecimal values
  5983. * @param hex defines a string containing valid hexadecimal values
  5984. * @returns a new Color4 object
  5985. */
  5986. static FromHexString(hex: string): Color4;
  5987. /**
  5988. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5989. * @param left defines the start value
  5990. * @param right defines the end value
  5991. * @param amount defines the gradient factor
  5992. * @returns a new Color4 object
  5993. */
  5994. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5995. /**
  5996. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5997. * @param left defines the start value
  5998. * @param right defines the end value
  5999. * @param amount defines the gradient factor
  6000. * @param result defines the Color4 object where to store data
  6001. */
  6002. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6003. /**
  6004. * Creates a new Color4 from a Color3 and an alpha value
  6005. * @param color3 defines the source Color3 to read from
  6006. * @param alpha defines the alpha component (1.0 by default)
  6007. * @returns a new Color4 object
  6008. */
  6009. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6010. /**
  6011. * Creates a new Color4 from the starting index element of the given array
  6012. * @param array defines the source array to read from
  6013. * @param offset defines the offset in the source array
  6014. * @returns a new Color4 object
  6015. */
  6016. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6017. /**
  6018. * Creates a new Color3 from integer values (< 256)
  6019. * @param r defines the red component to read from (value between 0 and 255)
  6020. * @param g defines the green component to read from (value between 0 and 255)
  6021. * @param b defines the blue component to read from (value between 0 and 255)
  6022. * @param a defines the alpha component to read from (value between 0 and 255)
  6023. * @returns a new Color3 object
  6024. */
  6025. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6026. /**
  6027. * Check the content of a given array and convert it to an array containing RGBA data
  6028. * If the original array was already containing count * 4 values then it is returned directly
  6029. * @param colors defines the array to check
  6030. * @param count defines the number of RGBA data to expect
  6031. * @returns an array containing count * 4 values (RGBA)
  6032. */
  6033. static CheckColors4(colors: number[], count: number): number[];
  6034. }
  6035. /**
  6036. * @hidden
  6037. */
  6038. export class TmpColors {
  6039. static Color3: Color3[];
  6040. static Color4: Color4[];
  6041. }
  6042. }
  6043. declare module BABYLON {
  6044. /**
  6045. * Defines an interface which represents an animation key frame
  6046. */
  6047. export interface IAnimationKey {
  6048. /**
  6049. * Frame of the key frame
  6050. */
  6051. frame: number;
  6052. /**
  6053. * Value at the specifies key frame
  6054. */
  6055. value: any;
  6056. /**
  6057. * The input tangent for the cubic hermite spline
  6058. */
  6059. inTangent?: any;
  6060. /**
  6061. * The output tangent for the cubic hermite spline
  6062. */
  6063. outTangent?: any;
  6064. /**
  6065. * The animation interpolation type
  6066. */
  6067. interpolation?: AnimationKeyInterpolation;
  6068. }
  6069. /**
  6070. * Enum for the animation key frame interpolation type
  6071. */
  6072. export enum AnimationKeyInterpolation {
  6073. /**
  6074. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6075. */
  6076. STEP = 1
  6077. }
  6078. }
  6079. declare module BABYLON {
  6080. /**
  6081. * Represents the range of an animation
  6082. */
  6083. export class AnimationRange {
  6084. /**The name of the animation range**/
  6085. name: string;
  6086. /**The starting frame of the animation */
  6087. from: number;
  6088. /**The ending frame of the animation*/
  6089. to: number;
  6090. /**
  6091. * Initializes the range of an animation
  6092. * @param name The name of the animation range
  6093. * @param from The starting frame of the animation
  6094. * @param to The ending frame of the animation
  6095. */
  6096. constructor(
  6097. /**The name of the animation range**/
  6098. name: string,
  6099. /**The starting frame of the animation */
  6100. from: number,
  6101. /**The ending frame of the animation*/
  6102. to: number);
  6103. /**
  6104. * Makes a copy of the animation range
  6105. * @returns A copy of the animation range
  6106. */
  6107. clone(): AnimationRange;
  6108. }
  6109. }
  6110. declare module BABYLON {
  6111. /**
  6112. * Composed of a frame, and an action function
  6113. */
  6114. export class AnimationEvent {
  6115. /** The frame for which the event is triggered **/
  6116. frame: number;
  6117. /** The event to perform when triggered **/
  6118. action: (currentFrame: number) => void;
  6119. /** Specifies if the event should be triggered only once**/
  6120. onlyOnce?: boolean | undefined;
  6121. /**
  6122. * Specifies if the animation event is done
  6123. */
  6124. isDone: boolean;
  6125. /**
  6126. * Initializes the animation event
  6127. * @param frame The frame for which the event is triggered
  6128. * @param action The event to perform when triggered
  6129. * @param onlyOnce Specifies if the event should be triggered only once
  6130. */
  6131. constructor(
  6132. /** The frame for which the event is triggered **/
  6133. frame: number,
  6134. /** The event to perform when triggered **/
  6135. action: (currentFrame: number) => void,
  6136. /** Specifies if the event should be triggered only once**/
  6137. onlyOnce?: boolean | undefined);
  6138. /** @hidden */
  6139. _clone(): AnimationEvent;
  6140. }
  6141. }
  6142. declare module BABYLON {
  6143. /**
  6144. * Interface used to define a behavior
  6145. */
  6146. export interface Behavior<T> {
  6147. /** gets or sets behavior's name */
  6148. name: string;
  6149. /**
  6150. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6151. */
  6152. init(): void;
  6153. /**
  6154. * Called when the behavior is attached to a target
  6155. * @param target defines the target where the behavior is attached to
  6156. */
  6157. attach(target: T): void;
  6158. /**
  6159. * Called when the behavior is detached from its target
  6160. */
  6161. detach(): void;
  6162. }
  6163. /**
  6164. * Interface implemented by classes supporting behaviors
  6165. */
  6166. export interface IBehaviorAware<T> {
  6167. /**
  6168. * Attach a behavior
  6169. * @param behavior defines the behavior to attach
  6170. * @returns the current host
  6171. */
  6172. addBehavior(behavior: Behavior<T>): T;
  6173. /**
  6174. * Remove a behavior from the current object
  6175. * @param behavior defines the behavior to detach
  6176. * @returns the current host
  6177. */
  6178. removeBehavior(behavior: Behavior<T>): T;
  6179. /**
  6180. * Gets a behavior using its name to search
  6181. * @param name defines the name to search
  6182. * @returns the behavior or null if not found
  6183. */
  6184. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6185. }
  6186. }
  6187. declare module BABYLON {
  6188. /**
  6189. * Defines an array and its length.
  6190. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6191. */
  6192. export interface ISmartArrayLike<T> {
  6193. /**
  6194. * The data of the array.
  6195. */
  6196. data: Array<T>;
  6197. /**
  6198. * The active length of the array.
  6199. */
  6200. length: number;
  6201. }
  6202. /**
  6203. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6204. */
  6205. export class SmartArray<T> implements ISmartArrayLike<T> {
  6206. /**
  6207. * The full set of data from the array.
  6208. */
  6209. data: Array<T>;
  6210. /**
  6211. * The active length of the array.
  6212. */
  6213. length: number;
  6214. protected _id: number;
  6215. /**
  6216. * Instantiates a Smart Array.
  6217. * @param capacity defines the default capacity of the array.
  6218. */
  6219. constructor(capacity: number);
  6220. /**
  6221. * Pushes a value at the end of the active data.
  6222. * @param value defines the object to push in the array.
  6223. */
  6224. push(value: T): void;
  6225. /**
  6226. * Iterates over the active data and apply the lambda to them.
  6227. * @param func defines the action to apply on each value.
  6228. */
  6229. forEach(func: (content: T) => void): void;
  6230. /**
  6231. * Sorts the full sets of data.
  6232. * @param compareFn defines the comparison function to apply.
  6233. */
  6234. sort(compareFn: (a: T, b: T) => number): void;
  6235. /**
  6236. * Resets the active data to an empty array.
  6237. */
  6238. reset(): void;
  6239. /**
  6240. * Releases all the data from the array as well as the array.
  6241. */
  6242. dispose(): void;
  6243. /**
  6244. * Concats the active data with a given array.
  6245. * @param array defines the data to concatenate with.
  6246. */
  6247. concat(array: any): void;
  6248. /**
  6249. * Returns the position of a value in the active data.
  6250. * @param value defines the value to find the index for
  6251. * @returns the index if found in the active data otherwise -1
  6252. */
  6253. indexOf(value: T): number;
  6254. /**
  6255. * Returns whether an element is part of the active data.
  6256. * @param value defines the value to look for
  6257. * @returns true if found in the active data otherwise false
  6258. */
  6259. contains(value: T): boolean;
  6260. private static _GlobalId;
  6261. }
  6262. /**
  6263. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6264. * The data in this array can only be present once
  6265. */
  6266. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6267. private _duplicateId;
  6268. /**
  6269. * Pushes a value at the end of the active data.
  6270. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6271. * @param value defines the object to push in the array.
  6272. */
  6273. push(value: T): void;
  6274. /**
  6275. * Pushes a value at the end of the active data.
  6276. * If the data is already present, it won t be added again
  6277. * @param value defines the object to push in the array.
  6278. * @returns true if added false if it was already present
  6279. */
  6280. pushNoDuplicate(value: T): boolean;
  6281. /**
  6282. * Resets the active data to an empty array.
  6283. */
  6284. reset(): void;
  6285. /**
  6286. * Concats the active data with a given array.
  6287. * This ensures no dupplicate will be present in the result.
  6288. * @param array defines the data to concatenate with.
  6289. */
  6290. concatWithNoDuplicate(array: any): void;
  6291. }
  6292. }
  6293. declare module BABYLON {
  6294. /**
  6295. * @ignore
  6296. * This is a list of all the different input types that are available in the application.
  6297. * Fo instance: ArcRotateCameraGamepadInput...
  6298. */
  6299. export var CameraInputTypes: {};
  6300. /**
  6301. * This is the contract to implement in order to create a new input class.
  6302. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6303. */
  6304. export interface ICameraInput<TCamera extends Camera> {
  6305. /**
  6306. * Defines the camera the input is attached to.
  6307. */
  6308. camera: Nullable<TCamera>;
  6309. /**
  6310. * Gets the class name of the current intput.
  6311. * @returns the class name
  6312. */
  6313. getClassName(): string;
  6314. /**
  6315. * Get the friendly name associated with the input class.
  6316. * @returns the input friendly name
  6317. */
  6318. getSimpleName(): string;
  6319. /**
  6320. * Attach the input controls to a specific dom element to get the input from.
  6321. * @param element Defines the element the controls should be listened from
  6322. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6323. */
  6324. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6325. /**
  6326. * Detach the current controls from the specified dom element.
  6327. * @param element Defines the element to stop listening the inputs from
  6328. */
  6329. detachControl(element: Nullable<HTMLElement>): void;
  6330. /**
  6331. * Update the current camera state depending on the inputs that have been used this frame.
  6332. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6333. */
  6334. checkInputs?: () => void;
  6335. }
  6336. /**
  6337. * Represents a map of input types to input instance or input index to input instance.
  6338. */
  6339. export interface CameraInputsMap<TCamera extends Camera> {
  6340. /**
  6341. * Accessor to the input by input type.
  6342. */
  6343. [name: string]: ICameraInput<TCamera>;
  6344. /**
  6345. * Accessor to the input by input index.
  6346. */
  6347. [idx: number]: ICameraInput<TCamera>;
  6348. }
  6349. /**
  6350. * This represents the input manager used within a camera.
  6351. * It helps dealing with all the different kind of input attached to a camera.
  6352. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6353. */
  6354. export class CameraInputsManager<TCamera extends Camera> {
  6355. /**
  6356. * Defines the list of inputs attahed to the camera.
  6357. */
  6358. attached: CameraInputsMap<TCamera>;
  6359. /**
  6360. * Defines the dom element the camera is collecting inputs from.
  6361. * This is null if the controls have not been attached.
  6362. */
  6363. attachedElement: Nullable<HTMLElement>;
  6364. /**
  6365. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6366. */
  6367. noPreventDefault: boolean;
  6368. /**
  6369. * Defined the camera the input manager belongs to.
  6370. */
  6371. camera: TCamera;
  6372. /**
  6373. * Update the current camera state depending on the inputs that have been used this frame.
  6374. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6375. */
  6376. checkInputs: () => void;
  6377. /**
  6378. * Instantiate a new Camera Input Manager.
  6379. * @param camera Defines the camera the input manager blongs to
  6380. */
  6381. constructor(camera: TCamera);
  6382. /**
  6383. * Add an input method to a camera
  6384. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6385. * @param input camera input method
  6386. */
  6387. add(input: ICameraInput<TCamera>): void;
  6388. /**
  6389. * Remove a specific input method from a camera
  6390. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6391. * @param inputToRemove camera input method
  6392. */
  6393. remove(inputToRemove: ICameraInput<TCamera>): void;
  6394. /**
  6395. * Remove a specific input type from a camera
  6396. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6397. * @param inputType the type of the input to remove
  6398. */
  6399. removeByType(inputType: string): void;
  6400. private _addCheckInputs;
  6401. /**
  6402. * Attach the input controls to the currently attached dom element to listen the events from.
  6403. * @param input Defines the input to attach
  6404. */
  6405. attachInput(input: ICameraInput<TCamera>): void;
  6406. /**
  6407. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6408. * @param element Defines the dom element to collect the events from
  6409. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6410. */
  6411. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6412. /**
  6413. * Detach the current manager inputs controls from a specific dom element.
  6414. * @param element Defines the dom element to collect the events from
  6415. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6416. */
  6417. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6418. /**
  6419. * Rebuild the dynamic inputCheck function from the current list of
  6420. * defined inputs in the manager.
  6421. */
  6422. rebuildInputCheck(): void;
  6423. /**
  6424. * Remove all attached input methods from a camera
  6425. */
  6426. clear(): void;
  6427. /**
  6428. * Serialize the current input manager attached to a camera.
  6429. * This ensures than once parsed,
  6430. * the input associated to the camera will be identical to the current ones
  6431. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6432. */
  6433. serialize(serializedCamera: any): void;
  6434. /**
  6435. * Parses an input manager serialized JSON to restore the previous list of inputs
  6436. * and states associated to a camera.
  6437. * @param parsedCamera Defines the JSON to parse
  6438. */
  6439. parse(parsedCamera: any): void;
  6440. }
  6441. }
  6442. declare module BABYLON {
  6443. /**
  6444. * Class used to store data that will be store in GPU memory
  6445. */
  6446. export class Buffer {
  6447. private _engine;
  6448. private _buffer;
  6449. /** @hidden */
  6450. _data: Nullable<DataArray>;
  6451. private _updatable;
  6452. private _instanced;
  6453. private _divisor;
  6454. /**
  6455. * Gets the byte stride.
  6456. */
  6457. readonly byteStride: number;
  6458. /**
  6459. * Constructor
  6460. * @param engine the engine
  6461. * @param data the data to use for this buffer
  6462. * @param updatable whether the data is updatable
  6463. * @param stride the stride (optional)
  6464. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6465. * @param instanced whether the buffer is instanced (optional)
  6466. * @param useBytes set to true if the stride in in bytes (optional)
  6467. * @param divisor sets an optional divisor for instances (1 by default)
  6468. */
  6469. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6470. /**
  6471. * Create a new VertexBuffer based on the current buffer
  6472. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6473. * @param offset defines offset in the buffer (0 by default)
  6474. * @param size defines the size in floats of attributes (position is 3 for instance)
  6475. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6476. * @param instanced defines if the vertex buffer contains indexed data
  6477. * @param useBytes defines if the offset and stride are in bytes *
  6478. * @param divisor sets an optional divisor for instances (1 by default)
  6479. * @returns the new vertex buffer
  6480. */
  6481. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6482. /**
  6483. * Gets a boolean indicating if the Buffer is updatable?
  6484. * @returns true if the buffer is updatable
  6485. */
  6486. isUpdatable(): boolean;
  6487. /**
  6488. * Gets current buffer's data
  6489. * @returns a DataArray or null
  6490. */
  6491. getData(): Nullable<DataArray>;
  6492. /**
  6493. * Gets underlying native buffer
  6494. * @returns underlying native buffer
  6495. */
  6496. getBuffer(): Nullable<DataBuffer>;
  6497. /**
  6498. * Gets the stride in float32 units (i.e. byte stride / 4).
  6499. * May not be an integer if the byte stride is not divisible by 4.
  6500. * @returns the stride in float32 units
  6501. * @deprecated Please use byteStride instead.
  6502. */
  6503. getStrideSize(): number;
  6504. /**
  6505. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6506. * @param data defines the data to store
  6507. */
  6508. create(data?: Nullable<DataArray>): void;
  6509. /** @hidden */
  6510. _rebuild(): void;
  6511. /**
  6512. * Update current buffer data
  6513. * @param data defines the data to store
  6514. */
  6515. update(data: DataArray): void;
  6516. /**
  6517. * Updates the data directly.
  6518. * @param data the new data
  6519. * @param offset the new offset
  6520. * @param vertexCount the vertex count (optional)
  6521. * @param useBytes set to true if the offset is in bytes
  6522. */
  6523. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6524. /**
  6525. * Release all resources
  6526. */
  6527. dispose(): void;
  6528. }
  6529. /**
  6530. * Specialized buffer used to store vertex data
  6531. */
  6532. export class VertexBuffer {
  6533. /** @hidden */
  6534. _buffer: Buffer;
  6535. private _kind;
  6536. private _size;
  6537. private _ownsBuffer;
  6538. private _instanced;
  6539. private _instanceDivisor;
  6540. /**
  6541. * The byte type.
  6542. */
  6543. static readonly BYTE: number;
  6544. /**
  6545. * The unsigned byte type.
  6546. */
  6547. static readonly UNSIGNED_BYTE: number;
  6548. /**
  6549. * The short type.
  6550. */
  6551. static readonly SHORT: number;
  6552. /**
  6553. * The unsigned short type.
  6554. */
  6555. static readonly UNSIGNED_SHORT: number;
  6556. /**
  6557. * The integer type.
  6558. */
  6559. static readonly INT: number;
  6560. /**
  6561. * The unsigned integer type.
  6562. */
  6563. static readonly UNSIGNED_INT: number;
  6564. /**
  6565. * The float type.
  6566. */
  6567. static readonly FLOAT: number;
  6568. /**
  6569. * Gets or sets the instance divisor when in instanced mode
  6570. */
  6571. get instanceDivisor(): number;
  6572. set instanceDivisor(value: number);
  6573. /**
  6574. * Gets the byte stride.
  6575. */
  6576. readonly byteStride: number;
  6577. /**
  6578. * Gets the byte offset.
  6579. */
  6580. readonly byteOffset: number;
  6581. /**
  6582. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6583. */
  6584. readonly normalized: boolean;
  6585. /**
  6586. * Gets the data type of each component in the array.
  6587. */
  6588. readonly type: number;
  6589. /**
  6590. * Constructor
  6591. * @param engine the engine
  6592. * @param data the data to use for this vertex buffer
  6593. * @param kind the vertex buffer kind
  6594. * @param updatable whether the data is updatable
  6595. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6596. * @param stride the stride (optional)
  6597. * @param instanced whether the buffer is instanced (optional)
  6598. * @param offset the offset of the data (optional)
  6599. * @param size the number of components (optional)
  6600. * @param type the type of the component (optional)
  6601. * @param normalized whether the data contains normalized data (optional)
  6602. * @param useBytes set to true if stride and offset are in bytes (optional)
  6603. * @param divisor defines the instance divisor to use (1 by default)
  6604. */
  6605. 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);
  6606. /** @hidden */
  6607. _rebuild(): void;
  6608. /**
  6609. * Returns the kind of the VertexBuffer (string)
  6610. * @returns a string
  6611. */
  6612. getKind(): string;
  6613. /**
  6614. * Gets a boolean indicating if the VertexBuffer is updatable?
  6615. * @returns true if the buffer is updatable
  6616. */
  6617. isUpdatable(): boolean;
  6618. /**
  6619. * Gets current buffer's data
  6620. * @returns a DataArray or null
  6621. */
  6622. getData(): Nullable<DataArray>;
  6623. /**
  6624. * Gets underlying native buffer
  6625. * @returns underlying native buffer
  6626. */
  6627. getBuffer(): Nullable<DataBuffer>;
  6628. /**
  6629. * Gets the stride in float32 units (i.e. byte stride / 4).
  6630. * May not be an integer if the byte stride is not divisible by 4.
  6631. * @returns the stride in float32 units
  6632. * @deprecated Please use byteStride instead.
  6633. */
  6634. getStrideSize(): number;
  6635. /**
  6636. * Returns the offset as a multiple of the type byte length.
  6637. * @returns the offset in bytes
  6638. * @deprecated Please use byteOffset instead.
  6639. */
  6640. getOffset(): number;
  6641. /**
  6642. * Returns the number of components per vertex attribute (integer)
  6643. * @returns the size in float
  6644. */
  6645. getSize(): number;
  6646. /**
  6647. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6648. * @returns true if this buffer is instanced
  6649. */
  6650. getIsInstanced(): boolean;
  6651. /**
  6652. * Returns the instancing divisor, zero for non-instanced (integer).
  6653. * @returns a number
  6654. */
  6655. getInstanceDivisor(): number;
  6656. /**
  6657. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6658. * @param data defines the data to store
  6659. */
  6660. create(data?: DataArray): void;
  6661. /**
  6662. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6663. * This function will create a new buffer if the current one is not updatable
  6664. * @param data defines the data to store
  6665. */
  6666. update(data: DataArray): void;
  6667. /**
  6668. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6669. * Returns the directly updated WebGLBuffer.
  6670. * @param data the new data
  6671. * @param offset the new offset
  6672. * @param useBytes set to true if the offset is in bytes
  6673. */
  6674. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6675. /**
  6676. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6677. */
  6678. dispose(): void;
  6679. /**
  6680. * Enumerates each value of this vertex buffer as numbers.
  6681. * @param count the number of values to enumerate
  6682. * @param callback the callback function called for each value
  6683. */
  6684. forEach(count: number, callback: (value: number, index: number) => void): void;
  6685. /**
  6686. * Positions
  6687. */
  6688. static readonly PositionKind: string;
  6689. /**
  6690. * Normals
  6691. */
  6692. static readonly NormalKind: string;
  6693. /**
  6694. * Tangents
  6695. */
  6696. static readonly TangentKind: string;
  6697. /**
  6698. * Texture coordinates
  6699. */
  6700. static readonly UVKind: string;
  6701. /**
  6702. * Texture coordinates 2
  6703. */
  6704. static readonly UV2Kind: string;
  6705. /**
  6706. * Texture coordinates 3
  6707. */
  6708. static readonly UV3Kind: string;
  6709. /**
  6710. * Texture coordinates 4
  6711. */
  6712. static readonly UV4Kind: string;
  6713. /**
  6714. * Texture coordinates 5
  6715. */
  6716. static readonly UV5Kind: string;
  6717. /**
  6718. * Texture coordinates 6
  6719. */
  6720. static readonly UV6Kind: string;
  6721. /**
  6722. * Colors
  6723. */
  6724. static readonly ColorKind: string;
  6725. /**
  6726. * Matrix indices (for bones)
  6727. */
  6728. static readonly MatricesIndicesKind: string;
  6729. /**
  6730. * Matrix weights (for bones)
  6731. */
  6732. static readonly MatricesWeightsKind: string;
  6733. /**
  6734. * Additional matrix indices (for bones)
  6735. */
  6736. static readonly MatricesIndicesExtraKind: string;
  6737. /**
  6738. * Additional matrix weights (for bones)
  6739. */
  6740. static readonly MatricesWeightsExtraKind: string;
  6741. /**
  6742. * Deduces the stride given a kind.
  6743. * @param kind The kind string to deduce
  6744. * @returns The deduced stride
  6745. */
  6746. static DeduceStride(kind: string): number;
  6747. /**
  6748. * Gets the byte length of the given type.
  6749. * @param type the type
  6750. * @returns the number of bytes
  6751. */
  6752. static GetTypeByteLength(type: number): number;
  6753. /**
  6754. * Enumerates each value of the given parameters as numbers.
  6755. * @param data the data to enumerate
  6756. * @param byteOffset the byte offset of the data
  6757. * @param byteStride the byte stride of the data
  6758. * @param componentCount the number of components per element
  6759. * @param componentType the type of the component
  6760. * @param count the number of values to enumerate
  6761. * @param normalized whether the data is normalized
  6762. * @param callback the callback function called for each value
  6763. */
  6764. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6765. private static _GetFloatValue;
  6766. }
  6767. }
  6768. declare module BABYLON {
  6769. /**
  6770. * @hidden
  6771. */
  6772. export class IntersectionInfo {
  6773. bu: Nullable<number>;
  6774. bv: Nullable<number>;
  6775. distance: number;
  6776. faceId: number;
  6777. subMeshId: number;
  6778. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6779. }
  6780. }
  6781. declare module BABYLON {
  6782. /**
  6783. * Class used to store bounding sphere information
  6784. */
  6785. export class BoundingSphere {
  6786. /**
  6787. * Gets the center of the bounding sphere in local space
  6788. */
  6789. readonly center: Vector3;
  6790. /**
  6791. * Radius of the bounding sphere in local space
  6792. */
  6793. radius: number;
  6794. /**
  6795. * Gets the center of the bounding sphere in world space
  6796. */
  6797. readonly centerWorld: Vector3;
  6798. /**
  6799. * Radius of the bounding sphere in world space
  6800. */
  6801. radiusWorld: number;
  6802. /**
  6803. * Gets the minimum vector in local space
  6804. */
  6805. readonly minimum: Vector3;
  6806. /**
  6807. * Gets the maximum vector in local space
  6808. */
  6809. readonly maximum: Vector3;
  6810. private _worldMatrix;
  6811. private static readonly TmpVector3;
  6812. /**
  6813. * Creates a new bounding sphere
  6814. * @param min defines the minimum vector (in local space)
  6815. * @param max defines the maximum vector (in local space)
  6816. * @param worldMatrix defines the new world matrix
  6817. */
  6818. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6819. /**
  6820. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6821. * @param min defines the new minimum vector (in local space)
  6822. * @param max defines the new maximum vector (in local space)
  6823. * @param worldMatrix defines the new world matrix
  6824. */
  6825. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6826. /**
  6827. * Scale the current bounding sphere by applying a scale factor
  6828. * @param factor defines the scale factor to apply
  6829. * @returns the current bounding box
  6830. */
  6831. scale(factor: number): BoundingSphere;
  6832. /**
  6833. * Gets the world matrix of the bounding box
  6834. * @returns a matrix
  6835. */
  6836. getWorldMatrix(): DeepImmutable<Matrix>;
  6837. /** @hidden */
  6838. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6839. /**
  6840. * Tests if the bounding sphere is intersecting the frustum planes
  6841. * @param frustumPlanes defines the frustum planes to test
  6842. * @returns true if there is an intersection
  6843. */
  6844. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6845. /**
  6846. * Tests if the bounding sphere center is in between the frustum planes.
  6847. * Used for optimistic fast inclusion.
  6848. * @param frustumPlanes defines the frustum planes to test
  6849. * @returns true if the sphere center is in between the frustum planes
  6850. */
  6851. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6852. /**
  6853. * Tests if a point is inside the bounding sphere
  6854. * @param point defines the point to test
  6855. * @returns true if the point is inside the bounding sphere
  6856. */
  6857. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6858. /**
  6859. * Checks if two sphere intersct
  6860. * @param sphere0 sphere 0
  6861. * @param sphere1 sphere 1
  6862. * @returns true if the speres intersect
  6863. */
  6864. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6865. }
  6866. }
  6867. declare module BABYLON {
  6868. /**
  6869. * Class used to store bounding box information
  6870. */
  6871. export class BoundingBox implements ICullable {
  6872. /**
  6873. * Gets the 8 vectors representing the bounding box in local space
  6874. */
  6875. readonly vectors: Vector3[];
  6876. /**
  6877. * Gets the center of the bounding box in local space
  6878. */
  6879. readonly center: Vector3;
  6880. /**
  6881. * Gets the center of the bounding box in world space
  6882. */
  6883. readonly centerWorld: Vector3;
  6884. /**
  6885. * Gets the extend size in local space
  6886. */
  6887. readonly extendSize: Vector3;
  6888. /**
  6889. * Gets the extend size in world space
  6890. */
  6891. readonly extendSizeWorld: Vector3;
  6892. /**
  6893. * Gets the OBB (object bounding box) directions
  6894. */
  6895. readonly directions: Vector3[];
  6896. /**
  6897. * Gets the 8 vectors representing the bounding box in world space
  6898. */
  6899. readonly vectorsWorld: Vector3[];
  6900. /**
  6901. * Gets the minimum vector in world space
  6902. */
  6903. readonly minimumWorld: Vector3;
  6904. /**
  6905. * Gets the maximum vector in world space
  6906. */
  6907. readonly maximumWorld: Vector3;
  6908. /**
  6909. * Gets the minimum vector in local space
  6910. */
  6911. readonly minimum: Vector3;
  6912. /**
  6913. * Gets the maximum vector in local space
  6914. */
  6915. readonly maximum: Vector3;
  6916. private _worldMatrix;
  6917. private static readonly TmpVector3;
  6918. /**
  6919. * @hidden
  6920. */
  6921. _tag: number;
  6922. /**
  6923. * Creates a new bounding box
  6924. * @param min defines the minimum vector (in local space)
  6925. * @param max defines the maximum vector (in local space)
  6926. * @param worldMatrix defines the new world matrix
  6927. */
  6928. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6929. /**
  6930. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6931. * @param min defines the new minimum vector (in local space)
  6932. * @param max defines the new maximum vector (in local space)
  6933. * @param worldMatrix defines the new world matrix
  6934. */
  6935. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6936. /**
  6937. * Scale the current bounding box by applying a scale factor
  6938. * @param factor defines the scale factor to apply
  6939. * @returns the current bounding box
  6940. */
  6941. scale(factor: number): BoundingBox;
  6942. /**
  6943. * Gets the world matrix of the bounding box
  6944. * @returns a matrix
  6945. */
  6946. getWorldMatrix(): DeepImmutable<Matrix>;
  6947. /** @hidden */
  6948. _update(world: DeepImmutable<Matrix>): void;
  6949. /**
  6950. * Tests if the bounding box is intersecting the frustum planes
  6951. * @param frustumPlanes defines the frustum planes to test
  6952. * @returns true if there is an intersection
  6953. */
  6954. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6955. /**
  6956. * Tests if the bounding box is entirely inside the frustum planes
  6957. * @param frustumPlanes defines the frustum planes to test
  6958. * @returns true if there is an inclusion
  6959. */
  6960. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6961. /**
  6962. * Tests if a point is inside the bounding box
  6963. * @param point defines the point to test
  6964. * @returns true if the point is inside the bounding box
  6965. */
  6966. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6967. /**
  6968. * Tests if the bounding box intersects with a bounding sphere
  6969. * @param sphere defines the sphere to test
  6970. * @returns true if there is an intersection
  6971. */
  6972. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6973. /**
  6974. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6975. * @param min defines the min vector to use
  6976. * @param max defines the max vector to use
  6977. * @returns true if there is an intersection
  6978. */
  6979. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6980. /**
  6981. * Tests if two bounding boxes are intersections
  6982. * @param box0 defines the first box to test
  6983. * @param box1 defines the second box to test
  6984. * @returns true if there is an intersection
  6985. */
  6986. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6987. /**
  6988. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6989. * @param minPoint defines the minimum vector of the bounding box
  6990. * @param maxPoint defines the maximum vector of the bounding box
  6991. * @param sphereCenter defines the sphere center
  6992. * @param sphereRadius defines the sphere radius
  6993. * @returns true if there is an intersection
  6994. */
  6995. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6996. /**
  6997. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6998. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6999. * @param frustumPlanes defines the frustum planes to test
  7000. * @return true if there is an inclusion
  7001. */
  7002. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7003. /**
  7004. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7005. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7006. * @param frustumPlanes defines the frustum planes to test
  7007. * @return true if there is an intersection
  7008. */
  7009. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7010. }
  7011. }
  7012. declare module BABYLON {
  7013. /** @hidden */
  7014. export class Collider {
  7015. /** Define if a collision was found */
  7016. collisionFound: boolean;
  7017. /**
  7018. * Define last intersection point in local space
  7019. */
  7020. intersectionPoint: Vector3;
  7021. /**
  7022. * Define last collided mesh
  7023. */
  7024. collidedMesh: Nullable<AbstractMesh>;
  7025. private _collisionPoint;
  7026. private _planeIntersectionPoint;
  7027. private _tempVector;
  7028. private _tempVector2;
  7029. private _tempVector3;
  7030. private _tempVector4;
  7031. private _edge;
  7032. private _baseToVertex;
  7033. private _destinationPoint;
  7034. private _slidePlaneNormal;
  7035. private _displacementVector;
  7036. /** @hidden */
  7037. _radius: Vector3;
  7038. /** @hidden */
  7039. _retry: number;
  7040. private _velocity;
  7041. private _basePoint;
  7042. private _epsilon;
  7043. /** @hidden */
  7044. _velocityWorldLength: number;
  7045. /** @hidden */
  7046. _basePointWorld: Vector3;
  7047. private _velocityWorld;
  7048. private _normalizedVelocity;
  7049. /** @hidden */
  7050. _initialVelocity: Vector3;
  7051. /** @hidden */
  7052. _initialPosition: Vector3;
  7053. private _nearestDistance;
  7054. private _collisionMask;
  7055. get collisionMask(): number;
  7056. set collisionMask(mask: number);
  7057. /**
  7058. * Gets the plane normal used to compute the sliding response (in local space)
  7059. */
  7060. get slidePlaneNormal(): Vector3;
  7061. /** @hidden */
  7062. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7063. /** @hidden */
  7064. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7065. /** @hidden */
  7066. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7067. /** @hidden */
  7068. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7069. /** @hidden */
  7070. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7071. /** @hidden */
  7072. _getResponse(pos: Vector3, vel: Vector3): void;
  7073. }
  7074. }
  7075. declare module BABYLON {
  7076. /**
  7077. * Interface for cullable objects
  7078. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7079. */
  7080. export interface ICullable {
  7081. /**
  7082. * Checks if the object or part of the object is in the frustum
  7083. * @param frustumPlanes Camera near/planes
  7084. * @returns true if the object is in frustum otherwise false
  7085. */
  7086. isInFrustum(frustumPlanes: Plane[]): boolean;
  7087. /**
  7088. * Checks if a cullable object (mesh...) is in the camera frustum
  7089. * Unlike isInFrustum this cheks the full bounding box
  7090. * @param frustumPlanes Camera near/planes
  7091. * @returns true if the object is in frustum otherwise false
  7092. */
  7093. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7094. }
  7095. /**
  7096. * Info for a bounding data of a mesh
  7097. */
  7098. export class BoundingInfo implements ICullable {
  7099. /**
  7100. * Bounding box for the mesh
  7101. */
  7102. readonly boundingBox: BoundingBox;
  7103. /**
  7104. * Bounding sphere for the mesh
  7105. */
  7106. readonly boundingSphere: BoundingSphere;
  7107. private _isLocked;
  7108. private static readonly TmpVector3;
  7109. /**
  7110. * Constructs bounding info
  7111. * @param minimum min vector of the bounding box/sphere
  7112. * @param maximum max vector of the bounding box/sphere
  7113. * @param worldMatrix defines the new world matrix
  7114. */
  7115. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7116. /**
  7117. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7118. * @param min defines the new minimum vector (in local space)
  7119. * @param max defines the new maximum vector (in local space)
  7120. * @param worldMatrix defines the new world matrix
  7121. */
  7122. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7123. /**
  7124. * min vector of the bounding box/sphere
  7125. */
  7126. get minimum(): Vector3;
  7127. /**
  7128. * max vector of the bounding box/sphere
  7129. */
  7130. get maximum(): Vector3;
  7131. /**
  7132. * If the info is locked and won't be updated to avoid perf overhead
  7133. */
  7134. get isLocked(): boolean;
  7135. set isLocked(value: boolean);
  7136. /**
  7137. * Updates the bounding sphere and box
  7138. * @param world world matrix to be used to update
  7139. */
  7140. update(world: DeepImmutable<Matrix>): void;
  7141. /**
  7142. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7143. * @param center New center of the bounding info
  7144. * @param extend New extend of the bounding info
  7145. * @returns the current bounding info
  7146. */
  7147. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7148. /**
  7149. * Scale the current bounding info by applying a scale factor
  7150. * @param factor defines the scale factor to apply
  7151. * @returns the current bounding info
  7152. */
  7153. scale(factor: number): BoundingInfo;
  7154. /**
  7155. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7156. * @param frustumPlanes defines the frustum to test
  7157. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7158. * @returns true if the bounding info is in the frustum planes
  7159. */
  7160. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7161. /**
  7162. * Gets the world distance between the min and max points of the bounding box
  7163. */
  7164. get diagonalLength(): number;
  7165. /**
  7166. * Checks if a cullable object (mesh...) is in the camera frustum
  7167. * Unlike isInFrustum this cheks the full bounding box
  7168. * @param frustumPlanes Camera near/planes
  7169. * @returns true if the object is in frustum otherwise false
  7170. */
  7171. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7172. /** @hidden */
  7173. _checkCollision(collider: Collider): boolean;
  7174. /**
  7175. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7176. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7177. * @param point the point to check intersection with
  7178. * @returns if the point intersects
  7179. */
  7180. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7181. /**
  7182. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7183. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7184. * @param boundingInfo the bounding info to check intersection with
  7185. * @param precise if the intersection should be done using OBB
  7186. * @returns if the bounding info intersects
  7187. */
  7188. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7189. }
  7190. }
  7191. declare module BABYLON {
  7192. /**
  7193. * Extracts minimum and maximum values from a list of indexed positions
  7194. * @param positions defines the positions to use
  7195. * @param indices defines the indices to the positions
  7196. * @param indexStart defines the start index
  7197. * @param indexCount defines the end index
  7198. * @param bias defines bias value to add to the result
  7199. * @return minimum and maximum values
  7200. */
  7201. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7202. minimum: Vector3;
  7203. maximum: Vector3;
  7204. };
  7205. /**
  7206. * Extracts minimum and maximum values from a list of positions
  7207. * @param positions defines the positions to use
  7208. * @param start defines the start index in the positions array
  7209. * @param count defines the number of positions to handle
  7210. * @param bias defines bias value to add to the result
  7211. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7212. * @return minimum and maximum values
  7213. */
  7214. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7215. minimum: Vector3;
  7216. maximum: Vector3;
  7217. };
  7218. }
  7219. declare module BABYLON {
  7220. /** @hidden */
  7221. export class WebGLDataBuffer extends DataBuffer {
  7222. private _buffer;
  7223. constructor(resource: WebGLBuffer);
  7224. get underlyingResource(): any;
  7225. }
  7226. }
  7227. declare module BABYLON {
  7228. /** @hidden */
  7229. export class WebGLPipelineContext implements IPipelineContext {
  7230. engine: ThinEngine;
  7231. program: Nullable<WebGLProgram>;
  7232. context?: WebGLRenderingContext;
  7233. vertexShader?: WebGLShader;
  7234. fragmentShader?: WebGLShader;
  7235. isParallelCompiled: boolean;
  7236. onCompiled?: () => void;
  7237. transformFeedback?: WebGLTransformFeedback | null;
  7238. vertexCompilationError: Nullable<string>;
  7239. fragmentCompilationError: Nullable<string>;
  7240. programLinkError: Nullable<string>;
  7241. programValidationError: Nullable<string>;
  7242. get isAsync(): boolean;
  7243. get isReady(): boolean;
  7244. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7245. _getVertexShaderCode(): string | null;
  7246. _getFragmentShaderCode(): string | null;
  7247. }
  7248. }
  7249. declare module BABYLON {
  7250. interface ThinEngine {
  7251. /**
  7252. * Create an uniform buffer
  7253. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7254. * @param elements defines the content of the uniform buffer
  7255. * @returns the webGL uniform buffer
  7256. */
  7257. createUniformBuffer(elements: FloatArray): DataBuffer;
  7258. /**
  7259. * Create a dynamic uniform buffer
  7260. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7261. * @param elements defines the content of the uniform buffer
  7262. * @returns the webGL uniform buffer
  7263. */
  7264. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7265. /**
  7266. * Update an existing uniform buffer
  7267. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7268. * @param uniformBuffer defines the target uniform buffer
  7269. * @param elements defines the content to update
  7270. * @param offset defines the offset in the uniform buffer where update should start
  7271. * @param count defines the size of the data to update
  7272. */
  7273. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7274. /**
  7275. * Bind an uniform buffer to the current webGL context
  7276. * @param buffer defines the buffer to bind
  7277. */
  7278. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7279. /**
  7280. * Bind a buffer to the current webGL context at a given location
  7281. * @param buffer defines the buffer to bind
  7282. * @param location defines the index where to bind the buffer
  7283. */
  7284. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7285. /**
  7286. * Bind a specific block at a given index in a specific shader program
  7287. * @param pipelineContext defines the pipeline context to use
  7288. * @param blockName defines the block name
  7289. * @param index defines the index where to bind the block
  7290. */
  7291. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7292. }
  7293. }
  7294. declare module BABYLON {
  7295. /**
  7296. * Uniform buffer objects.
  7297. *
  7298. * Handles blocks of uniform on the GPU.
  7299. *
  7300. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7301. *
  7302. * For more information, please refer to :
  7303. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7304. */
  7305. export class UniformBuffer {
  7306. private _engine;
  7307. private _buffer;
  7308. private _data;
  7309. private _bufferData;
  7310. private _dynamic?;
  7311. private _uniformLocations;
  7312. private _uniformSizes;
  7313. private _uniformLocationPointer;
  7314. private _needSync;
  7315. private _noUBO;
  7316. private _currentEffect;
  7317. /** @hidden */
  7318. _alreadyBound: boolean;
  7319. private static _MAX_UNIFORM_SIZE;
  7320. private static _tempBuffer;
  7321. /**
  7322. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7323. * This is dynamic to allow compat with webgl 1 and 2.
  7324. * You will need to pass the name of the uniform as well as the value.
  7325. */
  7326. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7327. /**
  7328. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7329. * This is dynamic to allow compat with webgl 1 and 2.
  7330. * You will need to pass the name of the uniform as well as the value.
  7331. */
  7332. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7333. /**
  7334. * Lambda to Update a single float in a uniform buffer.
  7335. * This is dynamic to allow compat with webgl 1 and 2.
  7336. * You will need to pass the name of the uniform as well as the value.
  7337. */
  7338. updateFloat: (name: string, x: number) => void;
  7339. /**
  7340. * Lambda to Update a vec2 of float in a uniform buffer.
  7341. * This is dynamic to allow compat with webgl 1 and 2.
  7342. * You will need to pass the name of the uniform as well as the value.
  7343. */
  7344. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7345. /**
  7346. * Lambda to Update a vec3 of float in a uniform buffer.
  7347. * This is dynamic to allow compat with webgl 1 and 2.
  7348. * You will need to pass the name of the uniform as well as the value.
  7349. */
  7350. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7351. /**
  7352. * Lambda to Update a vec4 of float in a uniform buffer.
  7353. * This is dynamic to allow compat with webgl 1 and 2.
  7354. * You will need to pass the name of the uniform as well as the value.
  7355. */
  7356. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7357. /**
  7358. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7359. * This is dynamic to allow compat with webgl 1 and 2.
  7360. * You will need to pass the name of the uniform as well as the value.
  7361. */
  7362. updateMatrix: (name: string, mat: Matrix) => void;
  7363. /**
  7364. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7365. * This is dynamic to allow compat with webgl 1 and 2.
  7366. * You will need to pass the name of the uniform as well as the value.
  7367. */
  7368. updateVector3: (name: string, vector: Vector3) => void;
  7369. /**
  7370. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7371. * This is dynamic to allow compat with webgl 1 and 2.
  7372. * You will need to pass the name of the uniform as well as the value.
  7373. */
  7374. updateVector4: (name: string, vector: Vector4) => void;
  7375. /**
  7376. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7377. * This is dynamic to allow compat with webgl 1 and 2.
  7378. * You will need to pass the name of the uniform as well as the value.
  7379. */
  7380. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7381. /**
  7382. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7383. * This is dynamic to allow compat with webgl 1 and 2.
  7384. * You will need to pass the name of the uniform as well as the value.
  7385. */
  7386. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7387. /**
  7388. * Instantiates a new Uniform buffer objects.
  7389. *
  7390. * Handles blocks of uniform on the GPU.
  7391. *
  7392. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7393. *
  7394. * For more information, please refer to :
  7395. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7396. * @param engine Define the engine the buffer is associated with
  7397. * @param data Define the data contained in the buffer
  7398. * @param dynamic Define if the buffer is updatable
  7399. */
  7400. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7401. /**
  7402. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7403. * or just falling back on setUniformXXX calls.
  7404. */
  7405. get useUbo(): boolean;
  7406. /**
  7407. * Indicates if the WebGL underlying uniform buffer is in sync
  7408. * with the javascript cache data.
  7409. */
  7410. get isSync(): boolean;
  7411. /**
  7412. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7413. * Also, a dynamic UniformBuffer will disable cache verification and always
  7414. * update the underlying WebGL uniform buffer to the GPU.
  7415. * @returns if Dynamic, otherwise false
  7416. */
  7417. isDynamic(): boolean;
  7418. /**
  7419. * The data cache on JS side.
  7420. * @returns the underlying data as a float array
  7421. */
  7422. getData(): Float32Array;
  7423. /**
  7424. * The underlying WebGL Uniform buffer.
  7425. * @returns the webgl buffer
  7426. */
  7427. getBuffer(): Nullable<DataBuffer>;
  7428. /**
  7429. * std140 layout specifies how to align data within an UBO structure.
  7430. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7431. * for specs.
  7432. */
  7433. private _fillAlignment;
  7434. /**
  7435. * Adds an uniform in the buffer.
  7436. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7437. * for the layout to be correct !
  7438. * @param name Name of the uniform, as used in the uniform block in the shader.
  7439. * @param size Data size, or data directly.
  7440. */
  7441. addUniform(name: string, size: number | number[]): void;
  7442. /**
  7443. * Adds a Matrix 4x4 to the uniform buffer.
  7444. * @param name Name of the uniform, as used in the uniform block in the shader.
  7445. * @param mat A 4x4 matrix.
  7446. */
  7447. addMatrix(name: string, mat: Matrix): void;
  7448. /**
  7449. * Adds a vec2 to the uniform buffer.
  7450. * @param name Name of the uniform, as used in the uniform block in the shader.
  7451. * @param x Define the x component value of the vec2
  7452. * @param y Define the y component value of the vec2
  7453. */
  7454. addFloat2(name: string, x: number, y: number): void;
  7455. /**
  7456. * Adds a vec3 to the uniform buffer.
  7457. * @param name Name of the uniform, as used in the uniform block in the shader.
  7458. * @param x Define the x component value of the vec3
  7459. * @param y Define the y component value of the vec3
  7460. * @param z Define the z component value of the vec3
  7461. */
  7462. addFloat3(name: string, x: number, y: number, z: number): void;
  7463. /**
  7464. * Adds a vec3 to the uniform buffer.
  7465. * @param name Name of the uniform, as used in the uniform block in the shader.
  7466. * @param color Define the vec3 from a Color
  7467. */
  7468. addColor3(name: string, color: Color3): void;
  7469. /**
  7470. * Adds a vec4 to the uniform buffer.
  7471. * @param name Name of the uniform, as used in the uniform block in the shader.
  7472. * @param color Define the rgb components from a Color
  7473. * @param alpha Define the a component of the vec4
  7474. */
  7475. addColor4(name: string, color: Color3, alpha: number): void;
  7476. /**
  7477. * Adds a vec3 to the uniform buffer.
  7478. * @param name Name of the uniform, as used in the uniform block in the shader.
  7479. * @param vector Define the vec3 components from a Vector
  7480. */
  7481. addVector3(name: string, vector: Vector3): void;
  7482. /**
  7483. * Adds a Matrix 3x3 to the uniform buffer.
  7484. * @param name Name of the uniform, as used in the uniform block in the shader.
  7485. */
  7486. addMatrix3x3(name: string): void;
  7487. /**
  7488. * Adds a Matrix 2x2 to the uniform buffer.
  7489. * @param name Name of the uniform, as used in the uniform block in the shader.
  7490. */
  7491. addMatrix2x2(name: string): void;
  7492. /**
  7493. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7494. */
  7495. create(): void;
  7496. /** @hidden */
  7497. _rebuild(): void;
  7498. /**
  7499. * Updates the WebGL Uniform Buffer on the GPU.
  7500. * If the `dynamic` flag is set to true, no cache comparison is done.
  7501. * Otherwise, the buffer will be updated only if the cache differs.
  7502. */
  7503. update(): void;
  7504. /**
  7505. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7506. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7507. * @param data Define the flattened data
  7508. * @param size Define the size of the data.
  7509. */
  7510. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7511. private _valueCache;
  7512. private _cacheMatrix;
  7513. private _updateMatrix3x3ForUniform;
  7514. private _updateMatrix3x3ForEffect;
  7515. private _updateMatrix2x2ForEffect;
  7516. private _updateMatrix2x2ForUniform;
  7517. private _updateFloatForEffect;
  7518. private _updateFloatForUniform;
  7519. private _updateFloat2ForEffect;
  7520. private _updateFloat2ForUniform;
  7521. private _updateFloat3ForEffect;
  7522. private _updateFloat3ForUniform;
  7523. private _updateFloat4ForEffect;
  7524. private _updateFloat4ForUniform;
  7525. private _updateMatrixForEffect;
  7526. private _updateMatrixForUniform;
  7527. private _updateVector3ForEffect;
  7528. private _updateVector3ForUniform;
  7529. private _updateVector4ForEffect;
  7530. private _updateVector4ForUniform;
  7531. private _updateColor3ForEffect;
  7532. private _updateColor3ForUniform;
  7533. private _updateColor4ForEffect;
  7534. private _updateColor4ForUniform;
  7535. /**
  7536. * Sets a sampler uniform on the effect.
  7537. * @param name Define the name of the sampler.
  7538. * @param texture Define the texture to set in the sampler
  7539. */
  7540. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7541. /**
  7542. * Directly updates the value of the uniform in the cache AND on the GPU.
  7543. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7544. * @param data Define the flattened data
  7545. */
  7546. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7547. /**
  7548. * Binds this uniform buffer to an effect.
  7549. * @param effect Define the effect to bind the buffer to
  7550. * @param name Name of the uniform block in the shader.
  7551. */
  7552. bindToEffect(effect: Effect, name: string): void;
  7553. /**
  7554. * Disposes the uniform buffer.
  7555. */
  7556. dispose(): void;
  7557. }
  7558. }
  7559. declare module BABYLON {
  7560. /**
  7561. * Enum that determines the text-wrapping mode to use.
  7562. */
  7563. export enum InspectableType {
  7564. /**
  7565. * Checkbox for booleans
  7566. */
  7567. Checkbox = 0,
  7568. /**
  7569. * Sliders for numbers
  7570. */
  7571. Slider = 1,
  7572. /**
  7573. * Vector3
  7574. */
  7575. Vector3 = 2,
  7576. /**
  7577. * Quaternions
  7578. */
  7579. Quaternion = 3,
  7580. /**
  7581. * Color3
  7582. */
  7583. Color3 = 4,
  7584. /**
  7585. * String
  7586. */
  7587. String = 5
  7588. }
  7589. /**
  7590. * Interface used to define custom inspectable properties.
  7591. * This interface is used by the inspector to display custom property grids
  7592. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7593. */
  7594. export interface IInspectable {
  7595. /**
  7596. * Gets the label to display
  7597. */
  7598. label: string;
  7599. /**
  7600. * Gets the name of the property to edit
  7601. */
  7602. propertyName: string;
  7603. /**
  7604. * Gets the type of the editor to use
  7605. */
  7606. type: InspectableType;
  7607. /**
  7608. * Gets the minimum value of the property when using in "slider" mode
  7609. */
  7610. min?: number;
  7611. /**
  7612. * Gets the maximum value of the property when using in "slider" mode
  7613. */
  7614. max?: number;
  7615. /**
  7616. * Gets the setp to use when using in "slider" mode
  7617. */
  7618. step?: number;
  7619. }
  7620. }
  7621. declare module BABYLON {
  7622. /**
  7623. * Class used to provide helper for timing
  7624. */
  7625. export class TimingTools {
  7626. /**
  7627. * Polyfill for setImmediate
  7628. * @param action defines the action to execute after the current execution block
  7629. */
  7630. static SetImmediate(action: () => void): void;
  7631. }
  7632. }
  7633. declare module BABYLON {
  7634. /**
  7635. * Class used to enable instatition of objects by class name
  7636. */
  7637. export class InstantiationTools {
  7638. /**
  7639. * Use this object to register external classes like custom textures or material
  7640. * to allow the laoders to instantiate them
  7641. */
  7642. static RegisteredExternalClasses: {
  7643. [key: string]: Object;
  7644. };
  7645. /**
  7646. * Tries to instantiate a new object from a given class name
  7647. * @param className defines the class name to instantiate
  7648. * @returns the new object or null if the system was not able to do the instantiation
  7649. */
  7650. static Instantiate(className: string): any;
  7651. }
  7652. }
  7653. declare module BABYLON {
  7654. /**
  7655. * Define options used to create a depth texture
  7656. */
  7657. export class DepthTextureCreationOptions {
  7658. /** Specifies whether or not a stencil should be allocated in the texture */
  7659. generateStencil?: boolean;
  7660. /** Specifies whether or not bilinear filtering is enable on the texture */
  7661. bilinearFiltering?: boolean;
  7662. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7663. comparisonFunction?: number;
  7664. /** Specifies if the created texture is a cube texture */
  7665. isCube?: boolean;
  7666. }
  7667. }
  7668. declare module BABYLON {
  7669. interface ThinEngine {
  7670. /**
  7671. * Creates a depth stencil cube texture.
  7672. * This is only available in WebGL 2.
  7673. * @param size The size of face edge in the cube texture.
  7674. * @param options The options defining the cube texture.
  7675. * @returns The cube texture
  7676. */
  7677. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7678. /**
  7679. * Creates a cube texture
  7680. * @param rootUrl defines the url where the files to load is located
  7681. * @param scene defines the current scene
  7682. * @param files defines the list of files to load (1 per face)
  7683. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7684. * @param onLoad defines an optional callback raised when the texture is loaded
  7685. * @param onError defines an optional callback raised if there is an issue to load the texture
  7686. * @param format defines the format of the data
  7687. * @param forcedExtension defines the extension to use to pick the right loader
  7688. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7689. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7690. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7691. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7692. * @returns the cube texture as an InternalTexture
  7693. */
  7694. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7695. /**
  7696. * Creates a cube texture
  7697. * @param rootUrl defines the url where the files to load is located
  7698. * @param scene defines the current scene
  7699. * @param files defines the list of files to load (1 per face)
  7700. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7701. * @param onLoad defines an optional callback raised when the texture is loaded
  7702. * @param onError defines an optional callback raised if there is an issue to load the texture
  7703. * @param format defines the format of the data
  7704. * @param forcedExtension defines the extension to use to pick the right loader
  7705. * @returns the cube texture as an InternalTexture
  7706. */
  7707. 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;
  7708. /**
  7709. * Creates a cube texture
  7710. * @param rootUrl defines the url where the files to load is located
  7711. * @param scene defines the current scene
  7712. * @param files defines the list of files to load (1 per face)
  7713. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7714. * @param onLoad defines an optional callback raised when the texture is loaded
  7715. * @param onError defines an optional callback raised if there is an issue to load the texture
  7716. * @param format defines the format of the data
  7717. * @param forcedExtension defines the extension to use to pick the right loader
  7718. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7719. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7720. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7721. * @returns the cube texture as an InternalTexture
  7722. */
  7723. 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;
  7724. /** @hidden */
  7725. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7726. /** @hidden */
  7727. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7728. /** @hidden */
  7729. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7730. /** @hidden */
  7731. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7732. /**
  7733. * @hidden
  7734. */
  7735. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7736. }
  7737. }
  7738. declare module BABYLON {
  7739. /**
  7740. * Class for creating a cube texture
  7741. */
  7742. export class CubeTexture extends BaseTexture {
  7743. private _delayedOnLoad;
  7744. /**
  7745. * Observable triggered once the texture has been loaded.
  7746. */
  7747. onLoadObservable: Observable<CubeTexture>;
  7748. /**
  7749. * The url of the texture
  7750. */
  7751. url: string;
  7752. /**
  7753. * Gets or sets the center of the bounding box associated with the cube texture.
  7754. * It must define where the camera used to render the texture was set
  7755. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7756. */
  7757. boundingBoxPosition: Vector3;
  7758. private _boundingBoxSize;
  7759. /**
  7760. * Gets or sets the size of the bounding box associated with the cube texture
  7761. * When defined, the cubemap will switch to local mode
  7762. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7763. * @example https://www.babylonjs-playground.com/#RNASML
  7764. */
  7765. set boundingBoxSize(value: Vector3);
  7766. /**
  7767. * Returns the bounding box size
  7768. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7769. */
  7770. get boundingBoxSize(): Vector3;
  7771. protected _rotationY: number;
  7772. /**
  7773. * Sets texture matrix rotation angle around Y axis in radians.
  7774. */
  7775. set rotationY(value: number);
  7776. /**
  7777. * Gets texture matrix rotation angle around Y axis radians.
  7778. */
  7779. get rotationY(): number;
  7780. /**
  7781. * Are mip maps generated for this texture or not.
  7782. */
  7783. get noMipmap(): boolean;
  7784. private _noMipmap;
  7785. private _files;
  7786. protected _forcedExtension: Nullable<string>;
  7787. private _extensions;
  7788. private _textureMatrix;
  7789. private _format;
  7790. private _createPolynomials;
  7791. /**
  7792. * Creates a cube texture from an array of image urls
  7793. * @param files defines an array of image urls
  7794. * @param scene defines the hosting scene
  7795. * @param noMipmap specifies if mip maps are not used
  7796. * @returns a cube texture
  7797. */
  7798. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7799. /**
  7800. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7801. * @param url defines the url of the prefiltered texture
  7802. * @param scene defines the scene the texture is attached to
  7803. * @param forcedExtension defines the extension of the file if different from the url
  7804. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7805. * @return the prefiltered texture
  7806. */
  7807. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7808. /**
  7809. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7810. * as prefiltered data.
  7811. * @param rootUrl defines the url of the texture or the root name of the six images
  7812. * @param null defines the scene or engine the texture is attached to
  7813. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7814. * @param noMipmap defines if mipmaps should be created or not
  7815. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7816. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7817. * @param onError defines a callback triggered in case of error during load
  7818. * @param format defines the internal format to use for the texture once loaded
  7819. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7820. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7821. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7822. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7823. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7824. * @return the cube texture
  7825. */
  7826. 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);
  7827. /**
  7828. * Get the current class name of the texture useful for serialization or dynamic coding.
  7829. * @returns "CubeTexture"
  7830. */
  7831. getClassName(): string;
  7832. /**
  7833. * Update the url (and optional buffer) of this texture if url was null during construction.
  7834. * @param url the url of the texture
  7835. * @param forcedExtension defines the extension to use
  7836. * @param onLoad callback called when the texture is loaded (defaults to null)
  7837. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7838. */
  7839. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7840. /**
  7841. * Delays loading of the cube texture
  7842. * @param forcedExtension defines the extension to use
  7843. */
  7844. delayLoad(forcedExtension?: string): void;
  7845. /**
  7846. * Returns the reflection texture matrix
  7847. * @returns the reflection texture matrix
  7848. */
  7849. getReflectionTextureMatrix(): Matrix;
  7850. /**
  7851. * Sets the reflection texture matrix
  7852. * @param value Reflection texture matrix
  7853. */
  7854. setReflectionTextureMatrix(value: Matrix): void;
  7855. /**
  7856. * Parses text to create a cube texture
  7857. * @param parsedTexture define the serialized text to read from
  7858. * @param scene defines the hosting scene
  7859. * @param rootUrl defines the root url of the cube texture
  7860. * @returns a cube texture
  7861. */
  7862. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7863. /**
  7864. * Makes a clone, or deep copy, of the cube texture
  7865. * @returns a new cube texture
  7866. */
  7867. clone(): CubeTexture;
  7868. }
  7869. }
  7870. declare module BABYLON {
  7871. /**
  7872. * Manages the defines for the Material
  7873. */
  7874. export class MaterialDefines {
  7875. /** @hidden */
  7876. protected _keys: string[];
  7877. private _isDirty;
  7878. /** @hidden */
  7879. _renderId: number;
  7880. /** @hidden */
  7881. _areLightsDirty: boolean;
  7882. /** @hidden */
  7883. _areLightsDisposed: boolean;
  7884. /** @hidden */
  7885. _areAttributesDirty: boolean;
  7886. /** @hidden */
  7887. _areTexturesDirty: boolean;
  7888. /** @hidden */
  7889. _areFresnelDirty: boolean;
  7890. /** @hidden */
  7891. _areMiscDirty: boolean;
  7892. /** @hidden */
  7893. _areImageProcessingDirty: boolean;
  7894. /** @hidden */
  7895. _normals: boolean;
  7896. /** @hidden */
  7897. _uvs: boolean;
  7898. /** @hidden */
  7899. _needNormals: boolean;
  7900. /** @hidden */
  7901. _needUVs: boolean;
  7902. [id: string]: any;
  7903. /**
  7904. * Specifies if the material needs to be re-calculated
  7905. */
  7906. get isDirty(): boolean;
  7907. /**
  7908. * Marks the material to indicate that it has been re-calculated
  7909. */
  7910. markAsProcessed(): void;
  7911. /**
  7912. * Marks the material to indicate that it needs to be re-calculated
  7913. */
  7914. markAsUnprocessed(): void;
  7915. /**
  7916. * Marks the material to indicate all of its defines need to be re-calculated
  7917. */
  7918. markAllAsDirty(): void;
  7919. /**
  7920. * Marks the material to indicate that image processing needs to be re-calculated
  7921. */
  7922. markAsImageProcessingDirty(): void;
  7923. /**
  7924. * Marks the material to indicate the lights need to be re-calculated
  7925. * @param disposed Defines whether the light is dirty due to dispose or not
  7926. */
  7927. markAsLightDirty(disposed?: boolean): void;
  7928. /**
  7929. * Marks the attribute state as changed
  7930. */
  7931. markAsAttributesDirty(): void;
  7932. /**
  7933. * Marks the texture state as changed
  7934. */
  7935. markAsTexturesDirty(): void;
  7936. /**
  7937. * Marks the fresnel state as changed
  7938. */
  7939. markAsFresnelDirty(): void;
  7940. /**
  7941. * Marks the misc state as changed
  7942. */
  7943. markAsMiscDirty(): void;
  7944. /**
  7945. * Rebuilds the material defines
  7946. */
  7947. rebuild(): void;
  7948. /**
  7949. * Specifies if two material defines are equal
  7950. * @param other - A material define instance to compare to
  7951. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7952. */
  7953. isEqual(other: MaterialDefines): boolean;
  7954. /**
  7955. * Clones this instance's defines to another instance
  7956. * @param other - material defines to clone values to
  7957. */
  7958. cloneTo(other: MaterialDefines): void;
  7959. /**
  7960. * Resets the material define values
  7961. */
  7962. reset(): void;
  7963. /**
  7964. * Converts the material define values to a string
  7965. * @returns - String of material define information
  7966. */
  7967. toString(): string;
  7968. }
  7969. }
  7970. declare module BABYLON {
  7971. /**
  7972. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7973. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7974. * 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;
  7975. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7976. */
  7977. export class ColorCurves {
  7978. private _dirty;
  7979. private _tempColor;
  7980. private _globalCurve;
  7981. private _highlightsCurve;
  7982. private _midtonesCurve;
  7983. private _shadowsCurve;
  7984. private _positiveCurve;
  7985. private _negativeCurve;
  7986. private _globalHue;
  7987. private _globalDensity;
  7988. private _globalSaturation;
  7989. private _globalExposure;
  7990. /**
  7991. * Gets the global Hue value.
  7992. * 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).
  7993. */
  7994. get globalHue(): number;
  7995. /**
  7996. * Sets the global Hue value.
  7997. * 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).
  7998. */
  7999. set globalHue(value: number);
  8000. /**
  8001. * Gets the global Density value.
  8002. * 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.
  8003. * Values less than zero provide a filter of opposite hue.
  8004. */
  8005. get globalDensity(): number;
  8006. /**
  8007. * Sets the global Density value.
  8008. * 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.
  8009. * Values less than zero provide a filter of opposite hue.
  8010. */
  8011. set globalDensity(value: number);
  8012. /**
  8013. * Gets the global Saturation value.
  8014. * 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.
  8015. */
  8016. get globalSaturation(): number;
  8017. /**
  8018. * Sets the global Saturation value.
  8019. * 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.
  8020. */
  8021. set globalSaturation(value: number);
  8022. /**
  8023. * Gets the global Exposure value.
  8024. * 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.
  8025. */
  8026. get globalExposure(): number;
  8027. /**
  8028. * Sets the global Exposure value.
  8029. * 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.
  8030. */
  8031. set globalExposure(value: number);
  8032. private _highlightsHue;
  8033. private _highlightsDensity;
  8034. private _highlightsSaturation;
  8035. private _highlightsExposure;
  8036. /**
  8037. * Gets the highlights Hue value.
  8038. * 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).
  8039. */
  8040. get highlightsHue(): number;
  8041. /**
  8042. * Sets the highlights Hue value.
  8043. * 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).
  8044. */
  8045. set highlightsHue(value: number);
  8046. /**
  8047. * Gets the highlights Density value.
  8048. * 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.
  8049. * Values less than zero provide a filter of opposite hue.
  8050. */
  8051. get highlightsDensity(): number;
  8052. /**
  8053. * Sets the highlights Density value.
  8054. * 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.
  8055. * Values less than zero provide a filter of opposite hue.
  8056. */
  8057. set highlightsDensity(value: number);
  8058. /**
  8059. * Gets the highlights Saturation value.
  8060. * 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.
  8061. */
  8062. get highlightsSaturation(): number;
  8063. /**
  8064. * Sets the highlights Saturation value.
  8065. * 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.
  8066. */
  8067. set highlightsSaturation(value: number);
  8068. /**
  8069. * Gets the highlights Exposure value.
  8070. * 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.
  8071. */
  8072. get highlightsExposure(): number;
  8073. /**
  8074. * Sets the highlights Exposure value.
  8075. * 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.
  8076. */
  8077. set highlightsExposure(value: number);
  8078. private _midtonesHue;
  8079. private _midtonesDensity;
  8080. private _midtonesSaturation;
  8081. private _midtonesExposure;
  8082. /**
  8083. * Gets the midtones Hue value.
  8084. * 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).
  8085. */
  8086. get midtonesHue(): number;
  8087. /**
  8088. * Sets the midtones Hue value.
  8089. * 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).
  8090. */
  8091. set midtonesHue(value: number);
  8092. /**
  8093. * Gets the midtones Density value.
  8094. * 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.
  8095. * Values less than zero provide a filter of opposite hue.
  8096. */
  8097. get midtonesDensity(): number;
  8098. /**
  8099. * Sets the midtones Density value.
  8100. * 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.
  8101. * Values less than zero provide a filter of opposite hue.
  8102. */
  8103. set midtonesDensity(value: number);
  8104. /**
  8105. * Gets the midtones Saturation value.
  8106. * 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.
  8107. */
  8108. get midtonesSaturation(): number;
  8109. /**
  8110. * Sets the midtones Saturation value.
  8111. * 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.
  8112. */
  8113. set midtonesSaturation(value: number);
  8114. /**
  8115. * Gets the midtones Exposure value.
  8116. * 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.
  8117. */
  8118. get midtonesExposure(): number;
  8119. /**
  8120. * Sets the midtones Exposure value.
  8121. * 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.
  8122. */
  8123. set midtonesExposure(value: number);
  8124. private _shadowsHue;
  8125. private _shadowsDensity;
  8126. private _shadowsSaturation;
  8127. private _shadowsExposure;
  8128. /**
  8129. * Gets the shadows Hue value.
  8130. * 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).
  8131. */
  8132. get shadowsHue(): number;
  8133. /**
  8134. * Sets the shadows Hue value.
  8135. * 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).
  8136. */
  8137. set shadowsHue(value: number);
  8138. /**
  8139. * Gets the shadows Density value.
  8140. * 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.
  8141. * Values less than zero provide a filter of opposite hue.
  8142. */
  8143. get shadowsDensity(): number;
  8144. /**
  8145. * Sets the shadows Density value.
  8146. * 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.
  8147. * Values less than zero provide a filter of opposite hue.
  8148. */
  8149. set shadowsDensity(value: number);
  8150. /**
  8151. * Gets the shadows Saturation value.
  8152. * 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.
  8153. */
  8154. get shadowsSaturation(): number;
  8155. /**
  8156. * Sets the shadows Saturation value.
  8157. * 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.
  8158. */
  8159. set shadowsSaturation(value: number);
  8160. /**
  8161. * Gets the shadows Exposure value.
  8162. * 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.
  8163. */
  8164. get shadowsExposure(): number;
  8165. /**
  8166. * Sets the shadows Exposure value.
  8167. * 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.
  8168. */
  8169. set shadowsExposure(value: number);
  8170. /**
  8171. * Returns the class name
  8172. * @returns The class name
  8173. */
  8174. getClassName(): string;
  8175. /**
  8176. * Binds the color curves to the shader.
  8177. * @param colorCurves The color curve to bind
  8178. * @param effect The effect to bind to
  8179. * @param positiveUniform The positive uniform shader parameter
  8180. * @param neutralUniform The neutral uniform shader parameter
  8181. * @param negativeUniform The negative uniform shader parameter
  8182. */
  8183. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8184. /**
  8185. * Prepare the list of uniforms associated with the ColorCurves effects.
  8186. * @param uniformsList The list of uniforms used in the effect
  8187. */
  8188. static PrepareUniforms(uniformsList: string[]): void;
  8189. /**
  8190. * Returns color grading data based on a hue, density, saturation and exposure value.
  8191. * @param filterHue The hue of the color filter.
  8192. * @param filterDensity The density of the color filter.
  8193. * @param saturation The saturation.
  8194. * @param exposure The exposure.
  8195. * @param result The result data container.
  8196. */
  8197. private getColorGradingDataToRef;
  8198. /**
  8199. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8200. * @param value The input slider value in range [-100,100].
  8201. * @returns Adjusted value.
  8202. */
  8203. private static applyColorGradingSliderNonlinear;
  8204. /**
  8205. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8206. * @param hue The hue (H) input.
  8207. * @param saturation The saturation (S) input.
  8208. * @param brightness The brightness (B) input.
  8209. * @result An RGBA color represented as Vector4.
  8210. */
  8211. private static fromHSBToRef;
  8212. /**
  8213. * Returns a value clamped between min and max
  8214. * @param value The value to clamp
  8215. * @param min The minimum of value
  8216. * @param max The maximum of value
  8217. * @returns The clamped value.
  8218. */
  8219. private static clamp;
  8220. /**
  8221. * Clones the current color curve instance.
  8222. * @return The cloned curves
  8223. */
  8224. clone(): ColorCurves;
  8225. /**
  8226. * Serializes the current color curve instance to a json representation.
  8227. * @return a JSON representation
  8228. */
  8229. serialize(): any;
  8230. /**
  8231. * Parses the color curve from a json representation.
  8232. * @param source the JSON source to parse
  8233. * @return The parsed curves
  8234. */
  8235. static Parse(source: any): ColorCurves;
  8236. }
  8237. }
  8238. declare module BABYLON {
  8239. /**
  8240. * Interface to follow in your material defines to integrate easily the
  8241. * Image proccessing functions.
  8242. * @hidden
  8243. */
  8244. export interface IImageProcessingConfigurationDefines {
  8245. IMAGEPROCESSING: boolean;
  8246. VIGNETTE: boolean;
  8247. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8248. VIGNETTEBLENDMODEOPAQUE: boolean;
  8249. TONEMAPPING: boolean;
  8250. TONEMAPPING_ACES: boolean;
  8251. CONTRAST: boolean;
  8252. EXPOSURE: boolean;
  8253. COLORCURVES: boolean;
  8254. COLORGRADING: boolean;
  8255. COLORGRADING3D: boolean;
  8256. SAMPLER3DGREENDEPTH: boolean;
  8257. SAMPLER3DBGRMAP: boolean;
  8258. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8259. }
  8260. /**
  8261. * @hidden
  8262. */
  8263. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8264. IMAGEPROCESSING: boolean;
  8265. VIGNETTE: boolean;
  8266. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8267. VIGNETTEBLENDMODEOPAQUE: boolean;
  8268. TONEMAPPING: boolean;
  8269. TONEMAPPING_ACES: boolean;
  8270. CONTRAST: boolean;
  8271. COLORCURVES: boolean;
  8272. COLORGRADING: boolean;
  8273. COLORGRADING3D: boolean;
  8274. SAMPLER3DGREENDEPTH: boolean;
  8275. SAMPLER3DBGRMAP: boolean;
  8276. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8277. EXPOSURE: boolean;
  8278. constructor();
  8279. }
  8280. /**
  8281. * This groups together the common properties used for image processing either in direct forward pass
  8282. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8283. * or not.
  8284. */
  8285. export class ImageProcessingConfiguration {
  8286. /**
  8287. * Default tone mapping applied in BabylonJS.
  8288. */
  8289. static readonly TONEMAPPING_STANDARD: number;
  8290. /**
  8291. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8292. * to other engines rendering to increase portability.
  8293. */
  8294. static readonly TONEMAPPING_ACES: number;
  8295. /**
  8296. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8297. */
  8298. colorCurves: Nullable<ColorCurves>;
  8299. private _colorCurvesEnabled;
  8300. /**
  8301. * Gets wether the color curves effect is enabled.
  8302. */
  8303. get colorCurvesEnabled(): boolean;
  8304. /**
  8305. * Sets wether the color curves effect is enabled.
  8306. */
  8307. set colorCurvesEnabled(value: boolean);
  8308. private _colorGradingTexture;
  8309. /**
  8310. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8311. */
  8312. get colorGradingTexture(): Nullable<BaseTexture>;
  8313. /**
  8314. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8315. */
  8316. set colorGradingTexture(value: Nullable<BaseTexture>);
  8317. private _colorGradingEnabled;
  8318. /**
  8319. * Gets wether the color grading effect is enabled.
  8320. */
  8321. get colorGradingEnabled(): boolean;
  8322. /**
  8323. * Sets wether the color grading effect is enabled.
  8324. */
  8325. set colorGradingEnabled(value: boolean);
  8326. private _colorGradingWithGreenDepth;
  8327. /**
  8328. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8329. */
  8330. get colorGradingWithGreenDepth(): boolean;
  8331. /**
  8332. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8333. */
  8334. set colorGradingWithGreenDepth(value: boolean);
  8335. private _colorGradingBGR;
  8336. /**
  8337. * Gets wether the color grading texture contains BGR values.
  8338. */
  8339. get colorGradingBGR(): boolean;
  8340. /**
  8341. * Sets wether the color grading texture contains BGR values.
  8342. */
  8343. set colorGradingBGR(value: boolean);
  8344. /** @hidden */
  8345. _exposure: number;
  8346. /**
  8347. * Gets the Exposure used in the effect.
  8348. */
  8349. get exposure(): number;
  8350. /**
  8351. * Sets the Exposure used in the effect.
  8352. */
  8353. set exposure(value: number);
  8354. private _toneMappingEnabled;
  8355. /**
  8356. * Gets wether the tone mapping effect is enabled.
  8357. */
  8358. get toneMappingEnabled(): boolean;
  8359. /**
  8360. * Sets wether the tone mapping effect is enabled.
  8361. */
  8362. set toneMappingEnabled(value: boolean);
  8363. private _toneMappingType;
  8364. /**
  8365. * Gets the type of tone mapping effect.
  8366. */
  8367. get toneMappingType(): number;
  8368. /**
  8369. * Sets the type of tone mapping effect used in BabylonJS.
  8370. */
  8371. set toneMappingType(value: number);
  8372. protected _contrast: number;
  8373. /**
  8374. * Gets the contrast used in the effect.
  8375. */
  8376. get contrast(): number;
  8377. /**
  8378. * Sets the contrast used in the effect.
  8379. */
  8380. set contrast(value: number);
  8381. /**
  8382. * Vignette stretch size.
  8383. */
  8384. vignetteStretch: number;
  8385. /**
  8386. * Vignette centre X Offset.
  8387. */
  8388. vignetteCentreX: number;
  8389. /**
  8390. * Vignette centre Y Offset.
  8391. */
  8392. vignetteCentreY: number;
  8393. /**
  8394. * Vignette weight or intensity of the vignette effect.
  8395. */
  8396. vignetteWeight: number;
  8397. /**
  8398. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8399. * if vignetteEnabled is set to true.
  8400. */
  8401. vignetteColor: Color4;
  8402. /**
  8403. * Camera field of view used by the Vignette effect.
  8404. */
  8405. vignetteCameraFov: number;
  8406. private _vignetteBlendMode;
  8407. /**
  8408. * Gets the vignette blend mode allowing different kind of effect.
  8409. */
  8410. get vignetteBlendMode(): number;
  8411. /**
  8412. * Sets the vignette blend mode allowing different kind of effect.
  8413. */
  8414. set vignetteBlendMode(value: number);
  8415. private _vignetteEnabled;
  8416. /**
  8417. * Gets wether the vignette effect is enabled.
  8418. */
  8419. get vignetteEnabled(): boolean;
  8420. /**
  8421. * Sets wether the vignette effect is enabled.
  8422. */
  8423. set vignetteEnabled(value: boolean);
  8424. private _applyByPostProcess;
  8425. /**
  8426. * Gets wether the image processing is applied through a post process or not.
  8427. */
  8428. get applyByPostProcess(): boolean;
  8429. /**
  8430. * Sets wether the image processing is applied through a post process or not.
  8431. */
  8432. set applyByPostProcess(value: boolean);
  8433. private _isEnabled;
  8434. /**
  8435. * Gets wether the image processing is enabled or not.
  8436. */
  8437. get isEnabled(): boolean;
  8438. /**
  8439. * Sets wether the image processing is enabled or not.
  8440. */
  8441. set isEnabled(value: boolean);
  8442. /**
  8443. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8444. */
  8445. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8446. /**
  8447. * Method called each time the image processing information changes requires to recompile the effect.
  8448. */
  8449. protected _updateParameters(): void;
  8450. /**
  8451. * Gets the current class name.
  8452. * @return "ImageProcessingConfiguration"
  8453. */
  8454. getClassName(): string;
  8455. /**
  8456. * Prepare the list of uniforms associated with the Image Processing effects.
  8457. * @param uniforms The list of uniforms used in the effect
  8458. * @param defines the list of defines currently in use
  8459. */
  8460. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8461. /**
  8462. * Prepare the list of samplers associated with the Image Processing effects.
  8463. * @param samplersList The list of uniforms used in the effect
  8464. * @param defines the list of defines currently in use
  8465. */
  8466. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8467. /**
  8468. * Prepare the list of defines associated to the shader.
  8469. * @param defines the list of defines to complete
  8470. * @param forPostProcess Define if we are currently in post process mode or not
  8471. */
  8472. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8473. /**
  8474. * Returns true if all the image processing information are ready.
  8475. * @returns True if ready, otherwise, false
  8476. */
  8477. isReady(): boolean;
  8478. /**
  8479. * Binds the image processing to the shader.
  8480. * @param effect The effect to bind to
  8481. * @param overrideAspectRatio Override the aspect ratio of the effect
  8482. */
  8483. bind(effect: Effect, overrideAspectRatio?: number): void;
  8484. /**
  8485. * Clones the current image processing instance.
  8486. * @return The cloned image processing
  8487. */
  8488. clone(): ImageProcessingConfiguration;
  8489. /**
  8490. * Serializes the current image processing instance to a json representation.
  8491. * @return a JSON representation
  8492. */
  8493. serialize(): any;
  8494. /**
  8495. * Parses the image processing from a json representation.
  8496. * @param source the JSON source to parse
  8497. * @return The parsed image processing
  8498. */
  8499. static Parse(source: any): ImageProcessingConfiguration;
  8500. private static _VIGNETTEMODE_MULTIPLY;
  8501. private static _VIGNETTEMODE_OPAQUE;
  8502. /**
  8503. * Used to apply the vignette as a mix with the pixel color.
  8504. */
  8505. static get VIGNETTEMODE_MULTIPLY(): number;
  8506. /**
  8507. * Used to apply the vignette as a replacement of the pixel color.
  8508. */
  8509. static get VIGNETTEMODE_OPAQUE(): number;
  8510. }
  8511. }
  8512. declare module BABYLON {
  8513. /** @hidden */
  8514. export var postprocessVertexShader: {
  8515. name: string;
  8516. shader: string;
  8517. };
  8518. }
  8519. declare module BABYLON {
  8520. interface ThinEngine {
  8521. /**
  8522. * Creates a new render target texture
  8523. * @param size defines the size of the texture
  8524. * @param options defines the options used to create the texture
  8525. * @returns a new render target texture stored in an InternalTexture
  8526. */
  8527. createRenderTargetTexture(size: number | {
  8528. width: number;
  8529. height: number;
  8530. layers?: number;
  8531. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8532. /**
  8533. * Creates a depth stencil texture.
  8534. * This is only available in WebGL 2 or with the depth texture extension available.
  8535. * @param size The size of face edge in the texture.
  8536. * @param options The options defining the texture.
  8537. * @returns The texture
  8538. */
  8539. createDepthStencilTexture(size: number | {
  8540. width: number;
  8541. height: number;
  8542. layers?: number;
  8543. }, options: DepthTextureCreationOptions): InternalTexture;
  8544. /** @hidden */
  8545. _createDepthStencilTexture(size: number | {
  8546. width: number;
  8547. height: number;
  8548. layers?: number;
  8549. }, options: DepthTextureCreationOptions): InternalTexture;
  8550. }
  8551. }
  8552. declare module BABYLON {
  8553. /**
  8554. * Defines the kind of connection point for node based material
  8555. */
  8556. export enum NodeMaterialBlockConnectionPointTypes {
  8557. /** Float */
  8558. Float = 1,
  8559. /** Int */
  8560. Int = 2,
  8561. /** Vector2 */
  8562. Vector2 = 4,
  8563. /** Vector3 */
  8564. Vector3 = 8,
  8565. /** Vector4 */
  8566. Vector4 = 16,
  8567. /** Color3 */
  8568. Color3 = 32,
  8569. /** Color4 */
  8570. Color4 = 64,
  8571. /** Matrix */
  8572. Matrix = 128,
  8573. /** Custom object */
  8574. Object = 256,
  8575. /** Detect type based on connection */
  8576. AutoDetect = 1024,
  8577. /** Output type that will be defined by input type */
  8578. BasedOnInput = 2048
  8579. }
  8580. }
  8581. declare module BABYLON {
  8582. /**
  8583. * Enum used to define the target of a block
  8584. */
  8585. export enum NodeMaterialBlockTargets {
  8586. /** Vertex shader */
  8587. Vertex = 1,
  8588. /** Fragment shader */
  8589. Fragment = 2,
  8590. /** Neutral */
  8591. Neutral = 4,
  8592. /** Vertex and Fragment */
  8593. VertexAndFragment = 3
  8594. }
  8595. }
  8596. declare module BABYLON {
  8597. /**
  8598. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8599. */
  8600. export enum NodeMaterialBlockConnectionPointMode {
  8601. /** Value is an uniform */
  8602. Uniform = 0,
  8603. /** Value is a mesh attribute */
  8604. Attribute = 1,
  8605. /** Value is a varying between vertex and fragment shaders */
  8606. Varying = 2,
  8607. /** Mode is undefined */
  8608. Undefined = 3
  8609. }
  8610. }
  8611. declare module BABYLON {
  8612. /**
  8613. * Enum used to define system values e.g. values automatically provided by the system
  8614. */
  8615. export enum NodeMaterialSystemValues {
  8616. /** World */
  8617. World = 1,
  8618. /** View */
  8619. View = 2,
  8620. /** Projection */
  8621. Projection = 3,
  8622. /** ViewProjection */
  8623. ViewProjection = 4,
  8624. /** WorldView */
  8625. WorldView = 5,
  8626. /** WorldViewProjection */
  8627. WorldViewProjection = 6,
  8628. /** CameraPosition */
  8629. CameraPosition = 7,
  8630. /** Fog Color */
  8631. FogColor = 8,
  8632. /** Delta time */
  8633. DeltaTime = 9
  8634. }
  8635. }
  8636. declare module BABYLON {
  8637. /** Defines supported spaces */
  8638. export enum Space {
  8639. /** Local (object) space */
  8640. LOCAL = 0,
  8641. /** World space */
  8642. WORLD = 1,
  8643. /** Bone space */
  8644. BONE = 2
  8645. }
  8646. /** Defines the 3 main axes */
  8647. export class Axis {
  8648. /** X axis */
  8649. static X: Vector3;
  8650. /** Y axis */
  8651. static Y: Vector3;
  8652. /** Z axis */
  8653. static Z: Vector3;
  8654. }
  8655. }
  8656. declare module BABYLON {
  8657. /**
  8658. * Represents a camera frustum
  8659. */
  8660. export class Frustum {
  8661. /**
  8662. * Gets the planes representing the frustum
  8663. * @param transform matrix to be applied to the returned planes
  8664. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8665. */
  8666. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8667. /**
  8668. * Gets the near frustum plane transformed by the transform matrix
  8669. * @param transform transformation matrix to be applied to the resulting frustum plane
  8670. * @param frustumPlane the resuling frustum plane
  8671. */
  8672. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8673. /**
  8674. * Gets the far frustum plane transformed by the transform matrix
  8675. * @param transform transformation matrix to be applied to the resulting frustum plane
  8676. * @param frustumPlane the resuling frustum plane
  8677. */
  8678. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8679. /**
  8680. * Gets the left frustum plane transformed by the transform matrix
  8681. * @param transform transformation matrix to be applied to the resulting frustum plane
  8682. * @param frustumPlane the resuling frustum plane
  8683. */
  8684. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8685. /**
  8686. * Gets the right frustum plane transformed by the transform matrix
  8687. * @param transform transformation matrix to be applied to the resulting frustum plane
  8688. * @param frustumPlane the resuling frustum plane
  8689. */
  8690. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8691. /**
  8692. * Gets the top frustum plane transformed by the transform matrix
  8693. * @param transform transformation matrix to be applied to the resulting frustum plane
  8694. * @param frustumPlane the resuling frustum plane
  8695. */
  8696. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8697. /**
  8698. * Gets the bottom frustum plane transformed by the transform matrix
  8699. * @param transform transformation matrix to be applied to the resulting frustum plane
  8700. * @param frustumPlane the resuling frustum plane
  8701. */
  8702. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8703. /**
  8704. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8705. * @param transform transformation matrix to be applied to the resulting frustum planes
  8706. * @param frustumPlanes the resuling frustum planes
  8707. */
  8708. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8709. }
  8710. }
  8711. declare module BABYLON {
  8712. /**
  8713. * Interface for the size containing width and height
  8714. */
  8715. export interface ISize {
  8716. /**
  8717. * Width
  8718. */
  8719. width: number;
  8720. /**
  8721. * Heighht
  8722. */
  8723. height: number;
  8724. }
  8725. /**
  8726. * Size containing widht and height
  8727. */
  8728. export class Size implements ISize {
  8729. /**
  8730. * Width
  8731. */
  8732. width: number;
  8733. /**
  8734. * Height
  8735. */
  8736. height: number;
  8737. /**
  8738. * Creates a Size object from the given width and height (floats).
  8739. * @param width width of the new size
  8740. * @param height height of the new size
  8741. */
  8742. constructor(width: number, height: number);
  8743. /**
  8744. * Returns a string with the Size width and height
  8745. * @returns a string with the Size width and height
  8746. */
  8747. toString(): string;
  8748. /**
  8749. * "Size"
  8750. * @returns the string "Size"
  8751. */
  8752. getClassName(): string;
  8753. /**
  8754. * Returns the Size hash code.
  8755. * @returns a hash code for a unique width and height
  8756. */
  8757. getHashCode(): number;
  8758. /**
  8759. * Updates the current size from the given one.
  8760. * @param src the given size
  8761. */
  8762. copyFrom(src: Size): void;
  8763. /**
  8764. * Updates in place the current Size from the given floats.
  8765. * @param width width of the new size
  8766. * @param height height of the new size
  8767. * @returns the updated Size.
  8768. */
  8769. copyFromFloats(width: number, height: number): Size;
  8770. /**
  8771. * Updates in place the current Size from the given floats.
  8772. * @param width width to set
  8773. * @param height height to set
  8774. * @returns the updated Size.
  8775. */
  8776. set(width: number, height: number): Size;
  8777. /**
  8778. * Multiplies the width and height by numbers
  8779. * @param w factor to multiple the width by
  8780. * @param h factor to multiple the height by
  8781. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8782. */
  8783. multiplyByFloats(w: number, h: number): Size;
  8784. /**
  8785. * Clones the size
  8786. * @returns a new Size copied from the given one.
  8787. */
  8788. clone(): Size;
  8789. /**
  8790. * True if the current Size and the given one width and height are strictly equal.
  8791. * @param other the other size to compare against
  8792. * @returns True if the current Size and the given one width and height are strictly equal.
  8793. */
  8794. equals(other: Size): boolean;
  8795. /**
  8796. * The surface of the Size : width * height (float).
  8797. */
  8798. get surface(): number;
  8799. /**
  8800. * Create a new size of zero
  8801. * @returns a new Size set to (0.0, 0.0)
  8802. */
  8803. static Zero(): Size;
  8804. /**
  8805. * Sums the width and height of two sizes
  8806. * @param otherSize size to add to this size
  8807. * @returns a new Size set as the addition result of the current Size and the given one.
  8808. */
  8809. add(otherSize: Size): Size;
  8810. /**
  8811. * Subtracts the width and height of two
  8812. * @param otherSize size to subtract to this size
  8813. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8814. */
  8815. subtract(otherSize: Size): Size;
  8816. /**
  8817. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8818. * @param start starting size to lerp between
  8819. * @param end end size to lerp between
  8820. * @param amount amount to lerp between the start and end values
  8821. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8822. */
  8823. static Lerp(start: Size, end: Size, amount: number): Size;
  8824. }
  8825. }
  8826. declare module BABYLON {
  8827. /**
  8828. * Contains position and normal vectors for a vertex
  8829. */
  8830. export class PositionNormalVertex {
  8831. /** the position of the vertex (defaut: 0,0,0) */
  8832. position: Vector3;
  8833. /** the normal of the vertex (defaut: 0,1,0) */
  8834. normal: Vector3;
  8835. /**
  8836. * Creates a PositionNormalVertex
  8837. * @param position the position of the vertex (defaut: 0,0,0)
  8838. * @param normal the normal of the vertex (defaut: 0,1,0)
  8839. */
  8840. constructor(
  8841. /** the position of the vertex (defaut: 0,0,0) */
  8842. position?: Vector3,
  8843. /** the normal of the vertex (defaut: 0,1,0) */
  8844. normal?: Vector3);
  8845. /**
  8846. * Clones the PositionNormalVertex
  8847. * @returns the cloned PositionNormalVertex
  8848. */
  8849. clone(): PositionNormalVertex;
  8850. }
  8851. /**
  8852. * Contains position, normal and uv vectors for a vertex
  8853. */
  8854. export class PositionNormalTextureVertex {
  8855. /** the position of the vertex (defaut: 0,0,0) */
  8856. position: Vector3;
  8857. /** the normal of the vertex (defaut: 0,1,0) */
  8858. normal: Vector3;
  8859. /** the uv of the vertex (default: 0,0) */
  8860. uv: Vector2;
  8861. /**
  8862. * Creates a PositionNormalTextureVertex
  8863. * @param position the position of the vertex (defaut: 0,0,0)
  8864. * @param normal the normal of the vertex (defaut: 0,1,0)
  8865. * @param uv the uv of the vertex (default: 0,0)
  8866. */
  8867. constructor(
  8868. /** the position of the vertex (defaut: 0,0,0) */
  8869. position?: Vector3,
  8870. /** the normal of the vertex (defaut: 0,1,0) */
  8871. normal?: Vector3,
  8872. /** the uv of the vertex (default: 0,0) */
  8873. uv?: Vector2);
  8874. /**
  8875. * Clones the PositionNormalTextureVertex
  8876. * @returns the cloned PositionNormalTextureVertex
  8877. */
  8878. clone(): PositionNormalTextureVertex;
  8879. }
  8880. }
  8881. declare module BABYLON {
  8882. /**
  8883. * Enum defining the type of animations supported by InputBlock
  8884. */
  8885. export enum AnimatedInputBlockTypes {
  8886. /** No animation */
  8887. None = 0,
  8888. /** Time based animation. Will only work for floats */
  8889. Time = 1
  8890. }
  8891. }
  8892. declare module BABYLON {
  8893. /**
  8894. * Interface describing all the common properties and methods a shadow light needs to implement.
  8895. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8896. * as well as binding the different shadow properties to the effects.
  8897. */
  8898. export interface IShadowLight extends Light {
  8899. /**
  8900. * The light id in the scene (used in scene.findLighById for instance)
  8901. */
  8902. id: string;
  8903. /**
  8904. * The position the shdow will be casted from.
  8905. */
  8906. position: Vector3;
  8907. /**
  8908. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8909. */
  8910. direction: Vector3;
  8911. /**
  8912. * The transformed position. Position of the light in world space taking parenting in account.
  8913. */
  8914. transformedPosition: Vector3;
  8915. /**
  8916. * The transformed direction. Direction of the light in world space taking parenting in account.
  8917. */
  8918. transformedDirection: Vector3;
  8919. /**
  8920. * The friendly name of the light in the scene.
  8921. */
  8922. name: string;
  8923. /**
  8924. * Defines the shadow projection clipping minimum z value.
  8925. */
  8926. shadowMinZ: number;
  8927. /**
  8928. * Defines the shadow projection clipping maximum z value.
  8929. */
  8930. shadowMaxZ: number;
  8931. /**
  8932. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8933. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8934. */
  8935. computeTransformedInformation(): boolean;
  8936. /**
  8937. * Gets the scene the light belongs to.
  8938. * @returns The scene
  8939. */
  8940. getScene(): Scene;
  8941. /**
  8942. * Callback defining a custom Projection Matrix Builder.
  8943. * This can be used to override the default projection matrix computation.
  8944. */
  8945. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8946. /**
  8947. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8948. * @param matrix The materix to updated with the projection information
  8949. * @param viewMatrix The transform matrix of the light
  8950. * @param renderList The list of mesh to render in the map
  8951. * @returns The current light
  8952. */
  8953. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8954. /**
  8955. * Gets the current depth scale used in ESM.
  8956. * @returns The scale
  8957. */
  8958. getDepthScale(): number;
  8959. /**
  8960. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8961. * @returns true if a cube texture needs to be use
  8962. */
  8963. needCube(): boolean;
  8964. /**
  8965. * Detects if the projection matrix requires to be recomputed this frame.
  8966. * @returns true if it requires to be recomputed otherwise, false.
  8967. */
  8968. needProjectionMatrixCompute(): boolean;
  8969. /**
  8970. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8971. */
  8972. forceProjectionMatrixCompute(): void;
  8973. /**
  8974. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8975. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8976. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8977. */
  8978. getShadowDirection(faceIndex?: number): Vector3;
  8979. /**
  8980. * Gets the minZ used for shadow according to both the scene and the light.
  8981. * @param activeCamera The camera we are returning the min for
  8982. * @returns the depth min z
  8983. */
  8984. getDepthMinZ(activeCamera: Camera): number;
  8985. /**
  8986. * Gets the maxZ used for shadow according to both the scene and the light.
  8987. * @param activeCamera The camera we are returning the max for
  8988. * @returns the depth max z
  8989. */
  8990. getDepthMaxZ(activeCamera: Camera): number;
  8991. }
  8992. /**
  8993. * Base implementation IShadowLight
  8994. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8995. */
  8996. export abstract class ShadowLight extends Light implements IShadowLight {
  8997. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8998. protected _position: Vector3;
  8999. protected _setPosition(value: Vector3): void;
  9000. /**
  9001. * Sets the position the shadow will be casted from. Also use as the light position for both
  9002. * point and spot lights.
  9003. */
  9004. get position(): Vector3;
  9005. /**
  9006. * Sets the position the shadow will be casted from. Also use as the light position for both
  9007. * point and spot lights.
  9008. */
  9009. set position(value: Vector3);
  9010. protected _direction: Vector3;
  9011. protected _setDirection(value: Vector3): void;
  9012. /**
  9013. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9014. * Also use as the light direction on spot and directional lights.
  9015. */
  9016. get direction(): Vector3;
  9017. /**
  9018. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9019. * Also use as the light direction on spot and directional lights.
  9020. */
  9021. set direction(value: Vector3);
  9022. protected _shadowMinZ: number;
  9023. /**
  9024. * Gets the shadow projection clipping minimum z value.
  9025. */
  9026. get shadowMinZ(): number;
  9027. /**
  9028. * Sets the shadow projection clipping minimum z value.
  9029. */
  9030. set shadowMinZ(value: number);
  9031. protected _shadowMaxZ: number;
  9032. /**
  9033. * Sets the shadow projection clipping maximum z value.
  9034. */
  9035. get shadowMaxZ(): number;
  9036. /**
  9037. * Gets the shadow projection clipping maximum z value.
  9038. */
  9039. set shadowMaxZ(value: number);
  9040. /**
  9041. * Callback defining a custom Projection Matrix Builder.
  9042. * This can be used to override the default projection matrix computation.
  9043. */
  9044. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9045. /**
  9046. * The transformed position. Position of the light in world space taking parenting in account.
  9047. */
  9048. transformedPosition: Vector3;
  9049. /**
  9050. * The transformed direction. Direction of the light in world space taking parenting in account.
  9051. */
  9052. transformedDirection: Vector3;
  9053. private _needProjectionMatrixCompute;
  9054. /**
  9055. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9056. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9057. */
  9058. computeTransformedInformation(): boolean;
  9059. /**
  9060. * Return the depth scale used for the shadow map.
  9061. * @returns the depth scale.
  9062. */
  9063. getDepthScale(): number;
  9064. /**
  9065. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9066. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9067. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9068. */
  9069. getShadowDirection(faceIndex?: number): Vector3;
  9070. /**
  9071. * Returns the ShadowLight absolute position in the World.
  9072. * @returns the position vector in world space
  9073. */
  9074. getAbsolutePosition(): Vector3;
  9075. /**
  9076. * Sets the ShadowLight direction toward the passed target.
  9077. * @param target The point to target in local space
  9078. * @returns the updated ShadowLight direction
  9079. */
  9080. setDirectionToTarget(target: Vector3): Vector3;
  9081. /**
  9082. * Returns the light rotation in euler definition.
  9083. * @returns the x y z rotation in local space.
  9084. */
  9085. getRotation(): Vector3;
  9086. /**
  9087. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9088. * @returns true if a cube texture needs to be use
  9089. */
  9090. needCube(): boolean;
  9091. /**
  9092. * Detects if the projection matrix requires to be recomputed this frame.
  9093. * @returns true if it requires to be recomputed otherwise, false.
  9094. */
  9095. needProjectionMatrixCompute(): boolean;
  9096. /**
  9097. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9098. */
  9099. forceProjectionMatrixCompute(): void;
  9100. /** @hidden */
  9101. _initCache(): void;
  9102. /** @hidden */
  9103. _isSynchronized(): boolean;
  9104. /**
  9105. * Computes the world matrix of the node
  9106. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9107. * @returns the world matrix
  9108. */
  9109. computeWorldMatrix(force?: boolean): Matrix;
  9110. /**
  9111. * Gets the minZ used for shadow according to both the scene and the light.
  9112. * @param activeCamera The camera we are returning the min for
  9113. * @returns the depth min z
  9114. */
  9115. getDepthMinZ(activeCamera: Camera): number;
  9116. /**
  9117. * Gets the maxZ used for shadow according to both the scene and the light.
  9118. * @param activeCamera The camera we are returning the max for
  9119. * @returns the depth max z
  9120. */
  9121. getDepthMaxZ(activeCamera: Camera): number;
  9122. /**
  9123. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9124. * @param matrix The materix to updated with the projection information
  9125. * @param viewMatrix The transform matrix of the light
  9126. * @param renderList The list of mesh to render in the map
  9127. * @returns The current light
  9128. */
  9129. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9130. }
  9131. }
  9132. declare module BABYLON {
  9133. /** @hidden */
  9134. export var packingFunctions: {
  9135. name: string;
  9136. shader: string;
  9137. };
  9138. }
  9139. declare module BABYLON {
  9140. /** @hidden */
  9141. export var bayerDitherFunctions: {
  9142. name: string;
  9143. shader: string;
  9144. };
  9145. }
  9146. declare module BABYLON {
  9147. /** @hidden */
  9148. export var shadowMapFragmentDeclaration: {
  9149. name: string;
  9150. shader: string;
  9151. };
  9152. }
  9153. declare module BABYLON {
  9154. /** @hidden */
  9155. export var clipPlaneFragmentDeclaration: {
  9156. name: string;
  9157. shader: string;
  9158. };
  9159. }
  9160. declare module BABYLON {
  9161. /** @hidden */
  9162. export var clipPlaneFragment: {
  9163. name: string;
  9164. shader: string;
  9165. };
  9166. }
  9167. declare module BABYLON {
  9168. /** @hidden */
  9169. export var shadowMapFragment: {
  9170. name: string;
  9171. shader: string;
  9172. };
  9173. }
  9174. declare module BABYLON {
  9175. /** @hidden */
  9176. export var shadowMapPixelShader: {
  9177. name: string;
  9178. shader: string;
  9179. };
  9180. }
  9181. declare module BABYLON {
  9182. /** @hidden */
  9183. export var bonesDeclaration: {
  9184. name: string;
  9185. shader: string;
  9186. };
  9187. }
  9188. declare module BABYLON {
  9189. /** @hidden */
  9190. export var morphTargetsVertexGlobalDeclaration: {
  9191. name: string;
  9192. shader: string;
  9193. };
  9194. }
  9195. declare module BABYLON {
  9196. /** @hidden */
  9197. export var morphTargetsVertexDeclaration: {
  9198. name: string;
  9199. shader: string;
  9200. };
  9201. }
  9202. declare module BABYLON {
  9203. /** @hidden */
  9204. export var instancesDeclaration: {
  9205. name: string;
  9206. shader: string;
  9207. };
  9208. }
  9209. declare module BABYLON {
  9210. /** @hidden */
  9211. export var helperFunctions: {
  9212. name: string;
  9213. shader: string;
  9214. };
  9215. }
  9216. declare module BABYLON {
  9217. /** @hidden */
  9218. export var shadowMapVertexDeclaration: {
  9219. name: string;
  9220. shader: string;
  9221. };
  9222. }
  9223. declare module BABYLON {
  9224. /** @hidden */
  9225. export var clipPlaneVertexDeclaration: {
  9226. name: string;
  9227. shader: string;
  9228. };
  9229. }
  9230. declare module BABYLON {
  9231. /** @hidden */
  9232. export var morphTargetsVertex: {
  9233. name: string;
  9234. shader: string;
  9235. };
  9236. }
  9237. declare module BABYLON {
  9238. /** @hidden */
  9239. export var instancesVertex: {
  9240. name: string;
  9241. shader: string;
  9242. };
  9243. }
  9244. declare module BABYLON {
  9245. /** @hidden */
  9246. export var bonesVertex: {
  9247. name: string;
  9248. shader: string;
  9249. };
  9250. }
  9251. declare module BABYLON {
  9252. /** @hidden */
  9253. export var shadowMapVertexNormalBias: {
  9254. name: string;
  9255. shader: string;
  9256. };
  9257. }
  9258. declare module BABYLON {
  9259. /** @hidden */
  9260. export var shadowMapVertexMetric: {
  9261. name: string;
  9262. shader: string;
  9263. };
  9264. }
  9265. declare module BABYLON {
  9266. /** @hidden */
  9267. export var clipPlaneVertex: {
  9268. name: string;
  9269. shader: string;
  9270. };
  9271. }
  9272. declare module BABYLON {
  9273. /** @hidden */
  9274. export var shadowMapVertexShader: {
  9275. name: string;
  9276. shader: string;
  9277. };
  9278. }
  9279. declare module BABYLON {
  9280. /** @hidden */
  9281. export var depthBoxBlurPixelShader: {
  9282. name: string;
  9283. shader: string;
  9284. };
  9285. }
  9286. declare module BABYLON {
  9287. /** @hidden */
  9288. export var shadowMapFragmentSoftTransparentShadow: {
  9289. name: string;
  9290. shader: string;
  9291. };
  9292. }
  9293. declare module BABYLON {
  9294. /**
  9295. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9296. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9297. */
  9298. export class EffectFallbacks implements IEffectFallbacks {
  9299. private _defines;
  9300. private _currentRank;
  9301. private _maxRank;
  9302. private _mesh;
  9303. /**
  9304. * Removes the fallback from the bound mesh.
  9305. */
  9306. unBindMesh(): void;
  9307. /**
  9308. * Adds a fallback on the specified property.
  9309. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9310. * @param define The name of the define in the shader
  9311. */
  9312. addFallback(rank: number, define: string): void;
  9313. /**
  9314. * Sets the mesh to use CPU skinning when needing to fallback.
  9315. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9316. * @param mesh The mesh to use the fallbacks.
  9317. */
  9318. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9319. /**
  9320. * Checks to see if more fallbacks are still availible.
  9321. */
  9322. get hasMoreFallbacks(): boolean;
  9323. /**
  9324. * Removes the defines that should be removed when falling back.
  9325. * @param currentDefines defines the current define statements for the shader.
  9326. * @param effect defines the current effect we try to compile
  9327. * @returns The resulting defines with defines of the current rank removed.
  9328. */
  9329. reduce(currentDefines: string, effect: Effect): string;
  9330. }
  9331. }
  9332. declare module BABYLON {
  9333. /**
  9334. * Interface used to define Action
  9335. */
  9336. export interface IAction {
  9337. /**
  9338. * Trigger for the action
  9339. */
  9340. trigger: number;
  9341. /** Options of the trigger */
  9342. triggerOptions: any;
  9343. /**
  9344. * Gets the trigger parameters
  9345. * @returns the trigger parameters
  9346. */
  9347. getTriggerParameter(): any;
  9348. /**
  9349. * Internal only - executes current action event
  9350. * @hidden
  9351. */
  9352. _executeCurrent(evt?: ActionEvent): void;
  9353. /**
  9354. * Serialize placeholder for child classes
  9355. * @param parent of child
  9356. * @returns the serialized object
  9357. */
  9358. serialize(parent: any): any;
  9359. /**
  9360. * Internal only
  9361. * @hidden
  9362. */
  9363. _prepare(): void;
  9364. /**
  9365. * Internal only - manager for action
  9366. * @hidden
  9367. */
  9368. _actionManager: AbstractActionManager;
  9369. /**
  9370. * Adds action to chain of actions, may be a DoNothingAction
  9371. * @param action defines the next action to execute
  9372. * @returns The action passed in
  9373. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9374. */
  9375. then(action: IAction): IAction;
  9376. }
  9377. /**
  9378. * The action to be carried out following a trigger
  9379. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9380. */
  9381. export class Action implements IAction {
  9382. /** the trigger, with or without parameters, for the action */
  9383. triggerOptions: any;
  9384. /**
  9385. * Trigger for the action
  9386. */
  9387. trigger: number;
  9388. /**
  9389. * Internal only - manager for action
  9390. * @hidden
  9391. */
  9392. _actionManager: ActionManager;
  9393. private _nextActiveAction;
  9394. private _child;
  9395. private _condition?;
  9396. private _triggerParameter;
  9397. /**
  9398. * An event triggered prior to action being executed.
  9399. */
  9400. onBeforeExecuteObservable: Observable<Action>;
  9401. /**
  9402. * Creates a new Action
  9403. * @param triggerOptions the trigger, with or without parameters, for the action
  9404. * @param condition an optional determinant of action
  9405. */
  9406. constructor(
  9407. /** the trigger, with or without parameters, for the action */
  9408. triggerOptions: any, condition?: Condition);
  9409. /**
  9410. * Internal only
  9411. * @hidden
  9412. */
  9413. _prepare(): void;
  9414. /**
  9415. * Gets the trigger parameters
  9416. * @returns the trigger parameters
  9417. */
  9418. getTriggerParameter(): any;
  9419. /**
  9420. * Internal only - executes current action event
  9421. * @hidden
  9422. */
  9423. _executeCurrent(evt?: ActionEvent): void;
  9424. /**
  9425. * Execute placeholder for child classes
  9426. * @param evt optional action event
  9427. */
  9428. execute(evt?: ActionEvent): void;
  9429. /**
  9430. * Skips to next active action
  9431. */
  9432. skipToNextActiveAction(): void;
  9433. /**
  9434. * Adds action to chain of actions, may be a DoNothingAction
  9435. * @param action defines the next action to execute
  9436. * @returns The action passed in
  9437. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9438. */
  9439. then(action: Action): Action;
  9440. /**
  9441. * Internal only
  9442. * @hidden
  9443. */
  9444. _getProperty(propertyPath: string): string;
  9445. /**
  9446. * Internal only
  9447. * @hidden
  9448. */
  9449. _getEffectiveTarget(target: any, propertyPath: string): any;
  9450. /**
  9451. * Serialize placeholder for child classes
  9452. * @param parent of child
  9453. * @returns the serialized object
  9454. */
  9455. serialize(parent: any): any;
  9456. /**
  9457. * Internal only called by serialize
  9458. * @hidden
  9459. */
  9460. protected _serialize(serializedAction: any, parent?: any): any;
  9461. /**
  9462. * Internal only
  9463. * @hidden
  9464. */
  9465. static _SerializeValueAsString: (value: any) => string;
  9466. /**
  9467. * Internal only
  9468. * @hidden
  9469. */
  9470. static _GetTargetProperty: (target: Scene | Node) => {
  9471. name: string;
  9472. targetType: string;
  9473. value: string;
  9474. };
  9475. }
  9476. }
  9477. declare module BABYLON {
  9478. /**
  9479. * A Condition applied to an Action
  9480. */
  9481. export class Condition {
  9482. /**
  9483. * Internal only - manager for action
  9484. * @hidden
  9485. */
  9486. _actionManager: ActionManager;
  9487. /**
  9488. * Internal only
  9489. * @hidden
  9490. */
  9491. _evaluationId: number;
  9492. /**
  9493. * Internal only
  9494. * @hidden
  9495. */
  9496. _currentResult: boolean;
  9497. /**
  9498. * Creates a new Condition
  9499. * @param actionManager the manager of the action the condition is applied to
  9500. */
  9501. constructor(actionManager: ActionManager);
  9502. /**
  9503. * Check if the current condition is valid
  9504. * @returns a boolean
  9505. */
  9506. isValid(): boolean;
  9507. /**
  9508. * Internal only
  9509. * @hidden
  9510. */
  9511. _getProperty(propertyPath: string): string;
  9512. /**
  9513. * Internal only
  9514. * @hidden
  9515. */
  9516. _getEffectiveTarget(target: any, propertyPath: string): any;
  9517. /**
  9518. * Serialize placeholder for child classes
  9519. * @returns the serialized object
  9520. */
  9521. serialize(): any;
  9522. /**
  9523. * Internal only
  9524. * @hidden
  9525. */
  9526. protected _serialize(serializedCondition: any): any;
  9527. }
  9528. /**
  9529. * Defines specific conditional operators as extensions of Condition
  9530. */
  9531. export class ValueCondition extends Condition {
  9532. /** path to specify the property of the target the conditional operator uses */
  9533. propertyPath: string;
  9534. /** the value compared by the conditional operator against the current value of the property */
  9535. value: any;
  9536. /** the conditional operator, default ValueCondition.IsEqual */
  9537. operator: number;
  9538. /**
  9539. * Internal only
  9540. * @hidden
  9541. */
  9542. private static _IsEqual;
  9543. /**
  9544. * Internal only
  9545. * @hidden
  9546. */
  9547. private static _IsDifferent;
  9548. /**
  9549. * Internal only
  9550. * @hidden
  9551. */
  9552. private static _IsGreater;
  9553. /**
  9554. * Internal only
  9555. * @hidden
  9556. */
  9557. private static _IsLesser;
  9558. /**
  9559. * returns the number for IsEqual
  9560. */
  9561. static get IsEqual(): number;
  9562. /**
  9563. * Returns the number for IsDifferent
  9564. */
  9565. static get IsDifferent(): number;
  9566. /**
  9567. * Returns the number for IsGreater
  9568. */
  9569. static get IsGreater(): number;
  9570. /**
  9571. * Returns the number for IsLesser
  9572. */
  9573. static get IsLesser(): number;
  9574. /**
  9575. * Internal only The action manager for the condition
  9576. * @hidden
  9577. */
  9578. _actionManager: ActionManager;
  9579. /**
  9580. * Internal only
  9581. * @hidden
  9582. */
  9583. private _target;
  9584. /**
  9585. * Internal only
  9586. * @hidden
  9587. */
  9588. private _effectiveTarget;
  9589. /**
  9590. * Internal only
  9591. * @hidden
  9592. */
  9593. private _property;
  9594. /**
  9595. * Creates a new ValueCondition
  9596. * @param actionManager manager for the action the condition applies to
  9597. * @param target for the action
  9598. * @param propertyPath path to specify the property of the target the conditional operator uses
  9599. * @param value the value compared by the conditional operator against the current value of the property
  9600. * @param operator the conditional operator, default ValueCondition.IsEqual
  9601. */
  9602. constructor(actionManager: ActionManager, target: any,
  9603. /** path to specify the property of the target the conditional operator uses */
  9604. propertyPath: string,
  9605. /** the value compared by the conditional operator against the current value of the property */
  9606. value: any,
  9607. /** the conditional operator, default ValueCondition.IsEqual */
  9608. operator?: number);
  9609. /**
  9610. * Compares the given value with the property value for the specified conditional operator
  9611. * @returns the result of the comparison
  9612. */
  9613. isValid(): boolean;
  9614. /**
  9615. * Serialize the ValueCondition into a JSON compatible object
  9616. * @returns serialization object
  9617. */
  9618. serialize(): any;
  9619. /**
  9620. * Gets the name of the conditional operator for the ValueCondition
  9621. * @param operator the conditional operator
  9622. * @returns the name
  9623. */
  9624. static GetOperatorName(operator: number): string;
  9625. }
  9626. /**
  9627. * Defines a predicate condition as an extension of Condition
  9628. */
  9629. export class PredicateCondition extends Condition {
  9630. /** defines the predicate function used to validate the condition */
  9631. predicate: () => boolean;
  9632. /**
  9633. * Internal only - manager for action
  9634. * @hidden
  9635. */
  9636. _actionManager: ActionManager;
  9637. /**
  9638. * Creates a new PredicateCondition
  9639. * @param actionManager manager for the action the condition applies to
  9640. * @param predicate defines the predicate function used to validate the condition
  9641. */
  9642. constructor(actionManager: ActionManager,
  9643. /** defines the predicate function used to validate the condition */
  9644. predicate: () => boolean);
  9645. /**
  9646. * @returns the validity of the predicate condition
  9647. */
  9648. isValid(): boolean;
  9649. }
  9650. /**
  9651. * Defines a state condition as an extension of Condition
  9652. */
  9653. export class StateCondition extends Condition {
  9654. /** Value to compare with target state */
  9655. value: string;
  9656. /**
  9657. * Internal only - manager for action
  9658. * @hidden
  9659. */
  9660. _actionManager: ActionManager;
  9661. /**
  9662. * Internal only
  9663. * @hidden
  9664. */
  9665. private _target;
  9666. /**
  9667. * Creates a new StateCondition
  9668. * @param actionManager manager for the action the condition applies to
  9669. * @param target of the condition
  9670. * @param value to compare with target state
  9671. */
  9672. constructor(actionManager: ActionManager, target: any,
  9673. /** Value to compare with target state */
  9674. value: string);
  9675. /**
  9676. * Gets a boolean indicating if the current condition is met
  9677. * @returns the validity of the state
  9678. */
  9679. isValid(): boolean;
  9680. /**
  9681. * Serialize the StateCondition into a JSON compatible object
  9682. * @returns serialization object
  9683. */
  9684. serialize(): any;
  9685. }
  9686. }
  9687. declare module BABYLON {
  9688. /**
  9689. * This defines an action responsible to toggle a boolean once triggered.
  9690. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9691. */
  9692. export class SwitchBooleanAction extends Action {
  9693. /**
  9694. * The path to the boolean property in the target object
  9695. */
  9696. propertyPath: string;
  9697. private _target;
  9698. private _effectiveTarget;
  9699. private _property;
  9700. /**
  9701. * Instantiate the action
  9702. * @param triggerOptions defines the trigger options
  9703. * @param target defines the object containing the boolean
  9704. * @param propertyPath defines the path to the boolean property in the target object
  9705. * @param condition defines the trigger related conditions
  9706. */
  9707. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9708. /** @hidden */
  9709. _prepare(): void;
  9710. /**
  9711. * Execute the action toggle the boolean value.
  9712. */
  9713. execute(): void;
  9714. /**
  9715. * Serializes the actions and its related information.
  9716. * @param parent defines the object to serialize in
  9717. * @returns the serialized object
  9718. */
  9719. serialize(parent: any): any;
  9720. }
  9721. /**
  9722. * This defines an action responsible to set a the state field of the target
  9723. * to a desired value once triggered.
  9724. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9725. */
  9726. export class SetStateAction extends Action {
  9727. /**
  9728. * The value to store in the state field.
  9729. */
  9730. value: string;
  9731. private _target;
  9732. /**
  9733. * Instantiate the action
  9734. * @param triggerOptions defines the trigger options
  9735. * @param target defines the object containing the state property
  9736. * @param value defines the value to store in the state field
  9737. * @param condition defines the trigger related conditions
  9738. */
  9739. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9740. /**
  9741. * Execute the action and store the value on the target state property.
  9742. */
  9743. execute(): void;
  9744. /**
  9745. * Serializes the actions and its related information.
  9746. * @param parent defines the object to serialize in
  9747. * @returns the serialized object
  9748. */
  9749. serialize(parent: any): any;
  9750. }
  9751. /**
  9752. * This defines an action responsible to set a property of the target
  9753. * to a desired value once triggered.
  9754. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9755. */
  9756. export class SetValueAction extends Action {
  9757. /**
  9758. * The path of the property to set in the target.
  9759. */
  9760. propertyPath: string;
  9761. /**
  9762. * The value to set in the property
  9763. */
  9764. value: any;
  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 property
  9772. * @param propertyPath defines the path of the property to set in the target
  9773. * @param value defines the value to set in the property
  9774. * @param condition defines the trigger related conditions
  9775. */
  9776. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9777. /** @hidden */
  9778. _prepare(): void;
  9779. /**
  9780. * Execute the action and set the targetted property to the desired value.
  9781. */
  9782. execute(): void;
  9783. /**
  9784. * Serializes the actions and its related information.
  9785. * @param parent defines the object to serialize in
  9786. * @returns the serialized object
  9787. */
  9788. serialize(parent: any): any;
  9789. }
  9790. /**
  9791. * This defines an action responsible to increment the target value
  9792. * to a desired value once triggered.
  9793. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9794. */
  9795. export class IncrementValueAction extends Action {
  9796. /**
  9797. * The path of the property to increment in the target.
  9798. */
  9799. propertyPath: string;
  9800. /**
  9801. * The value we should increment the property by.
  9802. */
  9803. value: any;
  9804. private _target;
  9805. private _effectiveTarget;
  9806. private _property;
  9807. /**
  9808. * Instantiate the action
  9809. * @param triggerOptions defines the trigger options
  9810. * @param target defines the object containing the property
  9811. * @param propertyPath defines the path of the property to increment in the target
  9812. * @param value defines the value value we should increment the property by
  9813. * @param condition defines the trigger related conditions
  9814. */
  9815. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9816. /** @hidden */
  9817. _prepare(): void;
  9818. /**
  9819. * Execute the action and increment the target of the value amount.
  9820. */
  9821. execute(): void;
  9822. /**
  9823. * Serializes the actions and its related information.
  9824. * @param parent defines the object to serialize in
  9825. * @returns the serialized object
  9826. */
  9827. serialize(parent: any): any;
  9828. }
  9829. /**
  9830. * This defines an action responsible to start an animation once triggered.
  9831. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9832. */
  9833. export class PlayAnimationAction extends Action {
  9834. /**
  9835. * Where the animation should start (animation frame)
  9836. */
  9837. from: number;
  9838. /**
  9839. * Where the animation should stop (animation frame)
  9840. */
  9841. to: number;
  9842. /**
  9843. * Define if the animation should loop or stop after the first play.
  9844. */
  9845. loop?: boolean;
  9846. private _target;
  9847. /**
  9848. * Instantiate the action
  9849. * @param triggerOptions defines the trigger options
  9850. * @param target defines the target animation or animation name
  9851. * @param from defines from where the animation should start (animation frame)
  9852. * @param end defines where the animation should stop (animation frame)
  9853. * @param loop defines if the animation should loop or stop after the first play
  9854. * @param condition defines the trigger related conditions
  9855. */
  9856. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9857. /** @hidden */
  9858. _prepare(): void;
  9859. /**
  9860. * Execute the action and play the animation.
  9861. */
  9862. execute(): void;
  9863. /**
  9864. * Serializes the actions and its related information.
  9865. * @param parent defines the object to serialize in
  9866. * @returns the serialized object
  9867. */
  9868. serialize(parent: any): any;
  9869. }
  9870. /**
  9871. * This defines an action responsible to stop an animation once triggered.
  9872. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9873. */
  9874. export class StopAnimationAction extends Action {
  9875. private _target;
  9876. /**
  9877. * Instantiate the action
  9878. * @param triggerOptions defines the trigger options
  9879. * @param target defines the target animation or animation name
  9880. * @param condition defines the trigger related conditions
  9881. */
  9882. constructor(triggerOptions: any, target: any, condition?: Condition);
  9883. /** @hidden */
  9884. _prepare(): void;
  9885. /**
  9886. * Execute the action and stop the animation.
  9887. */
  9888. execute(): void;
  9889. /**
  9890. * Serializes the actions and its related information.
  9891. * @param parent defines the object to serialize in
  9892. * @returns the serialized object
  9893. */
  9894. serialize(parent: any): any;
  9895. }
  9896. /**
  9897. * This defines an action responsible that does nothing once triggered.
  9898. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9899. */
  9900. export class DoNothingAction extends Action {
  9901. /**
  9902. * Instantiate the action
  9903. * @param triggerOptions defines the trigger options
  9904. * @param condition defines the trigger related conditions
  9905. */
  9906. constructor(triggerOptions?: any, condition?: Condition);
  9907. /**
  9908. * Execute the action and do nothing.
  9909. */
  9910. execute(): void;
  9911. /**
  9912. * Serializes the actions and its related information.
  9913. * @param parent defines the object to serialize in
  9914. * @returns the serialized object
  9915. */
  9916. serialize(parent: any): any;
  9917. }
  9918. /**
  9919. * This defines an action responsible to trigger several actions once triggered.
  9920. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9921. */
  9922. export class CombineAction extends Action {
  9923. /**
  9924. * The list of aggregated animations to run.
  9925. */
  9926. children: Action[];
  9927. /**
  9928. * Instantiate the action
  9929. * @param triggerOptions defines the trigger options
  9930. * @param children defines the list of aggregated animations to run
  9931. * @param condition defines the trigger related conditions
  9932. */
  9933. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  9934. /** @hidden */
  9935. _prepare(): void;
  9936. /**
  9937. * Execute the action and executes all the aggregated actions.
  9938. */
  9939. execute(evt: ActionEvent): void;
  9940. /**
  9941. * Serializes the actions and its related information.
  9942. * @param parent defines the object to serialize in
  9943. * @returns the serialized object
  9944. */
  9945. serialize(parent: any): any;
  9946. }
  9947. /**
  9948. * This defines an action responsible to run code (external event) once triggered.
  9949. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9950. */
  9951. export class ExecuteCodeAction extends Action {
  9952. /**
  9953. * The callback function to run.
  9954. */
  9955. func: (evt: ActionEvent) => void;
  9956. /**
  9957. * Instantiate the action
  9958. * @param triggerOptions defines the trigger options
  9959. * @param func defines the callback function to run
  9960. * @param condition defines the trigger related conditions
  9961. */
  9962. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  9963. /**
  9964. * Execute the action and run the attached code.
  9965. */
  9966. execute(evt: ActionEvent): void;
  9967. }
  9968. /**
  9969. * This defines an action responsible to set the parent property of the target once triggered.
  9970. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9971. */
  9972. export class SetParentAction extends Action {
  9973. private _parent;
  9974. private _target;
  9975. /**
  9976. * Instantiate the action
  9977. * @param triggerOptions defines the trigger options
  9978. * @param target defines the target containing the parent property
  9979. * @param parent defines from where the animation should start (animation frame)
  9980. * @param condition defines the trigger related conditions
  9981. */
  9982. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  9983. /** @hidden */
  9984. _prepare(): void;
  9985. /**
  9986. * Execute the action and set the parent property.
  9987. */
  9988. execute(): void;
  9989. /**
  9990. * Serializes the actions and its related information.
  9991. * @param parent defines the object to serialize in
  9992. * @returns the serialized object
  9993. */
  9994. serialize(parent: any): any;
  9995. }
  9996. }
  9997. declare module BABYLON {
  9998. /**
  9999. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10000. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10001. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10002. */
  10003. export class ActionManager extends AbstractActionManager {
  10004. /**
  10005. * Nothing
  10006. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10007. */
  10008. static readonly NothingTrigger: number;
  10009. /**
  10010. * On pick
  10011. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10012. */
  10013. static readonly OnPickTrigger: number;
  10014. /**
  10015. * On left pick
  10016. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10017. */
  10018. static readonly OnLeftPickTrigger: number;
  10019. /**
  10020. * On right pick
  10021. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10022. */
  10023. static readonly OnRightPickTrigger: number;
  10024. /**
  10025. * On center pick
  10026. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10027. */
  10028. static readonly OnCenterPickTrigger: number;
  10029. /**
  10030. * On pick down
  10031. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10032. */
  10033. static readonly OnPickDownTrigger: number;
  10034. /**
  10035. * On double pick
  10036. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10037. */
  10038. static readonly OnDoublePickTrigger: number;
  10039. /**
  10040. * On pick up
  10041. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10042. */
  10043. static readonly OnPickUpTrigger: number;
  10044. /**
  10045. * On pick out.
  10046. * This trigger will only be raised if you also declared a OnPickDown
  10047. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10048. */
  10049. static readonly OnPickOutTrigger: number;
  10050. /**
  10051. * On long press
  10052. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10053. */
  10054. static readonly OnLongPressTrigger: number;
  10055. /**
  10056. * On pointer over
  10057. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10058. */
  10059. static readonly OnPointerOverTrigger: number;
  10060. /**
  10061. * On pointer out
  10062. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10063. */
  10064. static readonly OnPointerOutTrigger: number;
  10065. /**
  10066. * On every frame
  10067. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10068. */
  10069. static readonly OnEveryFrameTrigger: number;
  10070. /**
  10071. * On intersection enter
  10072. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10073. */
  10074. static readonly OnIntersectionEnterTrigger: number;
  10075. /**
  10076. * On intersection exit
  10077. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10078. */
  10079. static readonly OnIntersectionExitTrigger: number;
  10080. /**
  10081. * On key down
  10082. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10083. */
  10084. static readonly OnKeyDownTrigger: number;
  10085. /**
  10086. * On key up
  10087. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10088. */
  10089. static readonly OnKeyUpTrigger: number;
  10090. private _scene;
  10091. /**
  10092. * Creates a new action manager
  10093. * @param scene defines the hosting scene
  10094. */
  10095. constructor(scene: Scene);
  10096. /**
  10097. * Releases all associated resources
  10098. */
  10099. dispose(): void;
  10100. /**
  10101. * Gets hosting scene
  10102. * @returns the hosting scene
  10103. */
  10104. getScene(): Scene;
  10105. /**
  10106. * Does this action manager handles actions of any of the given triggers
  10107. * @param triggers defines the triggers to be tested
  10108. * @return a boolean indicating whether one (or more) of the triggers is handled
  10109. */
  10110. hasSpecificTriggers(triggers: number[]): boolean;
  10111. /**
  10112. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10113. * speed.
  10114. * @param triggerA defines the trigger to be tested
  10115. * @param triggerB defines the trigger to be tested
  10116. * @return a boolean indicating whether one (or more) of the triggers is handled
  10117. */
  10118. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10119. /**
  10120. * Does this action manager handles actions of a given trigger
  10121. * @param trigger defines the trigger to be tested
  10122. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10123. * @return whether the trigger is handled
  10124. */
  10125. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10126. /**
  10127. * Does this action manager has pointer triggers
  10128. */
  10129. get hasPointerTriggers(): boolean;
  10130. /**
  10131. * Does this action manager has pick triggers
  10132. */
  10133. get hasPickTriggers(): boolean;
  10134. /**
  10135. * Registers an action to this action manager
  10136. * @param action defines the action to be registered
  10137. * @return the action amended (prepared) after registration
  10138. */
  10139. registerAction(action: IAction): Nullable<IAction>;
  10140. /**
  10141. * Unregisters an action to this action manager
  10142. * @param action defines the action to be unregistered
  10143. * @return a boolean indicating whether the action has been unregistered
  10144. */
  10145. unregisterAction(action: IAction): Boolean;
  10146. /**
  10147. * Process a specific trigger
  10148. * @param trigger defines the trigger to process
  10149. * @param evt defines the event details to be processed
  10150. */
  10151. processTrigger(trigger: number, evt?: IActionEvent): void;
  10152. /** @hidden */
  10153. _getEffectiveTarget(target: any, propertyPath: string): any;
  10154. /** @hidden */
  10155. _getProperty(propertyPath: string): string;
  10156. /**
  10157. * Serialize this manager to a JSON object
  10158. * @param name defines the property name to store this manager
  10159. * @returns a JSON representation of this manager
  10160. */
  10161. serialize(name: string): any;
  10162. /**
  10163. * Creates a new ActionManager from a JSON data
  10164. * @param parsedActions defines the JSON data to read from
  10165. * @param object defines the hosting mesh
  10166. * @param scene defines the hosting scene
  10167. */
  10168. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10169. /**
  10170. * Get a trigger name by index
  10171. * @param trigger defines the trigger index
  10172. * @returns a trigger name
  10173. */
  10174. static GetTriggerName(trigger: number): string;
  10175. }
  10176. }
  10177. declare module BABYLON {
  10178. /**
  10179. * Class used to represent a sprite
  10180. * @see https://doc.babylonjs.com/babylon101/sprites
  10181. */
  10182. export class Sprite implements IAnimatable {
  10183. /** defines the name */
  10184. name: string;
  10185. /** Gets or sets the current world position */
  10186. position: Vector3;
  10187. /** Gets or sets the main color */
  10188. color: Color4;
  10189. /** Gets or sets the width */
  10190. width: number;
  10191. /** Gets or sets the height */
  10192. height: number;
  10193. /** Gets or sets rotation angle */
  10194. angle: number;
  10195. /** Gets or sets the cell index in the sprite sheet */
  10196. cellIndex: number;
  10197. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10198. cellRef: string;
  10199. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10200. invertU: boolean;
  10201. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10202. invertV: boolean;
  10203. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10204. disposeWhenFinishedAnimating: boolean;
  10205. /** Gets the list of attached animations */
  10206. animations: Nullable<Array<Animation>>;
  10207. /** Gets or sets a boolean indicating if the sprite can be picked */
  10208. isPickable: boolean;
  10209. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10210. useAlphaForPicking: boolean;
  10211. /** @hidden */
  10212. _xOffset: number;
  10213. /** @hidden */
  10214. _yOffset: number;
  10215. /** @hidden */
  10216. _xSize: number;
  10217. /** @hidden */
  10218. _ySize: number;
  10219. /**
  10220. * Gets or sets the associated action manager
  10221. */
  10222. actionManager: Nullable<ActionManager>;
  10223. /**
  10224. * An event triggered when the control has been disposed
  10225. */
  10226. onDisposeObservable: Observable<Sprite>;
  10227. private _animationStarted;
  10228. private _loopAnimation;
  10229. private _fromIndex;
  10230. private _toIndex;
  10231. private _delay;
  10232. private _direction;
  10233. private _manager;
  10234. private _time;
  10235. private _onAnimationEnd;
  10236. /**
  10237. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10238. */
  10239. isVisible: boolean;
  10240. /**
  10241. * Gets or sets the sprite size
  10242. */
  10243. get size(): number;
  10244. set size(value: number);
  10245. /**
  10246. * Returns a boolean indicating if the animation is started
  10247. */
  10248. get animationStarted(): boolean;
  10249. /**
  10250. * Gets or sets the unique id of the sprite
  10251. */
  10252. uniqueId: number;
  10253. /**
  10254. * Gets the manager of this sprite
  10255. */
  10256. get manager(): ISpriteManager;
  10257. /**
  10258. * Creates a new Sprite
  10259. * @param name defines the name
  10260. * @param manager defines the manager
  10261. */
  10262. constructor(
  10263. /** defines the name */
  10264. name: string, manager: ISpriteManager);
  10265. /**
  10266. * Returns the string "Sprite"
  10267. * @returns "Sprite"
  10268. */
  10269. getClassName(): string;
  10270. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10271. get fromIndex(): number;
  10272. set fromIndex(value: number);
  10273. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10274. get toIndex(): number;
  10275. set toIndex(value: number);
  10276. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10277. get loopAnimation(): boolean;
  10278. set loopAnimation(value: boolean);
  10279. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10280. get delay(): number;
  10281. set delay(value: number);
  10282. /**
  10283. * Starts an animation
  10284. * @param from defines the initial key
  10285. * @param to defines the end key
  10286. * @param loop defines if the animation must loop
  10287. * @param delay defines the start delay (in ms)
  10288. * @param onAnimationEnd defines a callback to call when animation ends
  10289. */
  10290. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10291. /** Stops current animation (if any) */
  10292. stopAnimation(): void;
  10293. /** @hidden */
  10294. _animate(deltaTime: number): void;
  10295. /** Release associated resources */
  10296. dispose(): void;
  10297. /**
  10298. * Serializes the sprite to a JSON object
  10299. * @returns the JSON object
  10300. */
  10301. serialize(): any;
  10302. /**
  10303. * Parses a JSON object to create a new sprite
  10304. * @param parsedSprite The JSON object to parse
  10305. * @param manager defines the hosting manager
  10306. * @returns the new sprite
  10307. */
  10308. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10309. }
  10310. }
  10311. declare module BABYLON {
  10312. /**
  10313. * Information about the result of picking within a scene
  10314. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10315. */
  10316. export class PickingInfo {
  10317. /** @hidden */
  10318. _pickingUnavailable: boolean;
  10319. /**
  10320. * If the pick collided with an object
  10321. */
  10322. hit: boolean;
  10323. /**
  10324. * Distance away where the pick collided
  10325. */
  10326. distance: number;
  10327. /**
  10328. * The location of pick collision
  10329. */
  10330. pickedPoint: Nullable<Vector3>;
  10331. /**
  10332. * The mesh corresponding the the pick collision
  10333. */
  10334. pickedMesh: Nullable<AbstractMesh>;
  10335. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10336. bu: number;
  10337. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10338. bv: number;
  10339. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10340. faceId: number;
  10341. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10342. subMeshFaceId: number;
  10343. /** Id of the the submesh that was picked */
  10344. subMeshId: number;
  10345. /** If a sprite was picked, this will be the sprite the pick collided with */
  10346. pickedSprite: Nullable<Sprite>;
  10347. /**
  10348. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10349. */
  10350. originMesh: Nullable<AbstractMesh>;
  10351. /**
  10352. * The ray that was used to perform the picking.
  10353. */
  10354. ray: Nullable<Ray>;
  10355. /**
  10356. * Gets the normal correspodning to the face the pick collided with
  10357. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10358. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10359. * @returns The normal correspodning to the face the pick collided with
  10360. */
  10361. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10362. /**
  10363. * Gets the texture coordinates of where the pick occured
  10364. * @returns the vector containing the coordnates of the texture
  10365. */
  10366. getTextureCoordinates(): Nullable<Vector2>;
  10367. }
  10368. }
  10369. declare module BABYLON {
  10370. /**
  10371. * Class representing a ray with position and direction
  10372. */
  10373. export class Ray {
  10374. /** origin point */
  10375. origin: Vector3;
  10376. /** direction */
  10377. direction: Vector3;
  10378. /** length of the ray */
  10379. length: number;
  10380. private static readonly TmpVector3;
  10381. private _tmpRay;
  10382. /**
  10383. * Creates a new ray
  10384. * @param origin origin point
  10385. * @param direction direction
  10386. * @param length length of the ray
  10387. */
  10388. constructor(
  10389. /** origin point */
  10390. origin: Vector3,
  10391. /** direction */
  10392. direction: Vector3,
  10393. /** length of the ray */
  10394. length?: number);
  10395. /**
  10396. * Checks if the ray intersects a box
  10397. * This does not account for the ray lenght by design to improve perfs.
  10398. * @param minimum bound of the box
  10399. * @param maximum bound of the box
  10400. * @param intersectionTreshold extra extend to be added to the box in all direction
  10401. * @returns if the box was hit
  10402. */
  10403. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10404. /**
  10405. * Checks if the ray intersects a box
  10406. * This does not account for the ray lenght by design to improve perfs.
  10407. * @param box the bounding box to check
  10408. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10409. * @returns if the box was hit
  10410. */
  10411. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10412. /**
  10413. * If the ray hits a sphere
  10414. * @param sphere the bounding sphere to check
  10415. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10416. * @returns true if it hits the sphere
  10417. */
  10418. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10419. /**
  10420. * If the ray hits a triange
  10421. * @param vertex0 triangle vertex
  10422. * @param vertex1 triangle vertex
  10423. * @param vertex2 triangle vertex
  10424. * @returns intersection information if hit
  10425. */
  10426. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10427. /**
  10428. * Checks if ray intersects a plane
  10429. * @param plane the plane to check
  10430. * @returns the distance away it was hit
  10431. */
  10432. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10433. /**
  10434. * Calculate the intercept of a ray on a given axis
  10435. * @param axis to check 'x' | 'y' | 'z'
  10436. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10437. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10438. */
  10439. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10440. /**
  10441. * Checks if ray intersects a mesh
  10442. * @param mesh the mesh to check
  10443. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10444. * @returns picking info of the intersecton
  10445. */
  10446. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10447. /**
  10448. * Checks if ray intersects a mesh
  10449. * @param meshes the meshes to check
  10450. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10451. * @param results array to store result in
  10452. * @returns Array of picking infos
  10453. */
  10454. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10455. private _comparePickingInfo;
  10456. private static smallnum;
  10457. private static rayl;
  10458. /**
  10459. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10460. * @param sega the first point of the segment to test the intersection against
  10461. * @param segb the second point of the segment to test the intersection against
  10462. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10463. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10464. */
  10465. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10466. /**
  10467. * Update the ray from viewport position
  10468. * @param x position
  10469. * @param y y position
  10470. * @param viewportWidth viewport width
  10471. * @param viewportHeight viewport height
  10472. * @param world world matrix
  10473. * @param view view matrix
  10474. * @param projection projection matrix
  10475. * @returns this ray updated
  10476. */
  10477. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10478. /**
  10479. * Creates a ray with origin and direction of 0,0,0
  10480. * @returns the new ray
  10481. */
  10482. static Zero(): Ray;
  10483. /**
  10484. * Creates a new ray from screen space and viewport
  10485. * @param x position
  10486. * @param y y position
  10487. * @param viewportWidth viewport width
  10488. * @param viewportHeight viewport height
  10489. * @param world world matrix
  10490. * @param view view matrix
  10491. * @param projection projection matrix
  10492. * @returns new ray
  10493. */
  10494. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10495. /**
  10496. * 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
  10497. * transformed to the given world matrix.
  10498. * @param origin The origin point
  10499. * @param end The end point
  10500. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10501. * @returns the new ray
  10502. */
  10503. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10504. /**
  10505. * Transforms a ray by a matrix
  10506. * @param ray ray to transform
  10507. * @param matrix matrix to apply
  10508. * @returns the resulting new ray
  10509. */
  10510. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10511. /**
  10512. * Transforms a ray by a matrix
  10513. * @param ray ray to transform
  10514. * @param matrix matrix to apply
  10515. * @param result ray to store result in
  10516. */
  10517. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10518. /**
  10519. * Unproject a ray from screen space to object space
  10520. * @param sourceX defines the screen space x coordinate to use
  10521. * @param sourceY defines the screen space y coordinate to use
  10522. * @param viewportWidth defines the current width of the viewport
  10523. * @param viewportHeight defines the current height of the viewport
  10524. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10525. * @param view defines the view matrix to use
  10526. * @param projection defines the projection matrix to use
  10527. */
  10528. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10529. }
  10530. /**
  10531. * Type used to define predicate used to select faces when a mesh intersection is detected
  10532. */
  10533. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10534. interface Scene {
  10535. /** @hidden */
  10536. _tempPickingRay: Nullable<Ray>;
  10537. /** @hidden */
  10538. _cachedRayForTransform: Ray;
  10539. /** @hidden */
  10540. _pickWithRayInverseMatrix: Matrix;
  10541. /** @hidden */
  10542. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10543. /** @hidden */
  10544. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10545. }
  10546. }
  10547. declare module BABYLON {
  10548. /**
  10549. * Groups all the scene component constants in one place to ease maintenance.
  10550. * @hidden
  10551. */
  10552. export class SceneComponentConstants {
  10553. static readonly NAME_EFFECTLAYER: string;
  10554. static readonly NAME_LAYER: string;
  10555. static readonly NAME_LENSFLARESYSTEM: string;
  10556. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10557. static readonly NAME_PARTICLESYSTEM: string;
  10558. static readonly NAME_GAMEPAD: string;
  10559. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10560. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10561. static readonly NAME_PREPASSRENDERER: string;
  10562. static readonly NAME_DEPTHRENDERER: string;
  10563. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10564. static readonly NAME_SPRITE: string;
  10565. static readonly NAME_OUTLINERENDERER: string;
  10566. static readonly NAME_PROCEDURALTEXTURE: string;
  10567. static readonly NAME_SHADOWGENERATOR: string;
  10568. static readonly NAME_OCTREE: string;
  10569. static readonly NAME_PHYSICSENGINE: string;
  10570. static readonly NAME_AUDIO: string;
  10571. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10572. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10573. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10574. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10575. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10576. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10577. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10578. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10579. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10580. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10581. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10582. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10583. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10584. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10585. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10586. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10587. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10588. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10589. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10590. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10591. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10592. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10593. static readonly STEP_AFTERRENDER_AUDIO: number;
  10594. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10595. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10596. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10597. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10598. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10599. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10600. static readonly STEP_POINTERMOVE_SPRITE: number;
  10601. static readonly STEP_POINTERDOWN_SPRITE: number;
  10602. static readonly STEP_POINTERUP_SPRITE: number;
  10603. }
  10604. /**
  10605. * This represents a scene component.
  10606. *
  10607. * This is used to decouple the dependency the scene is having on the different workloads like
  10608. * layers, post processes...
  10609. */
  10610. export interface ISceneComponent {
  10611. /**
  10612. * The name of the component. Each component must have a unique name.
  10613. */
  10614. name: string;
  10615. /**
  10616. * The scene the component belongs to.
  10617. */
  10618. scene: Scene;
  10619. /**
  10620. * Register the component to one instance of a scene.
  10621. */
  10622. register(): void;
  10623. /**
  10624. * Rebuilds the elements related to this component in case of
  10625. * context lost for instance.
  10626. */
  10627. rebuild(): void;
  10628. /**
  10629. * Disposes the component and the associated ressources.
  10630. */
  10631. dispose(): void;
  10632. }
  10633. /**
  10634. * This represents a SERIALIZABLE scene component.
  10635. *
  10636. * This extends Scene Component to add Serialization methods on top.
  10637. */
  10638. export interface ISceneSerializableComponent extends ISceneComponent {
  10639. /**
  10640. * Adds all the elements from the container to the scene
  10641. * @param container the container holding the elements
  10642. */
  10643. addFromContainer(container: AbstractScene): void;
  10644. /**
  10645. * Removes all the elements in the container from the scene
  10646. * @param container contains the elements to remove
  10647. * @param dispose if the removed element should be disposed (default: false)
  10648. */
  10649. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10650. /**
  10651. * Serializes the component data to the specified json object
  10652. * @param serializationObject The object to serialize to
  10653. */
  10654. serialize(serializationObject: any): void;
  10655. }
  10656. /**
  10657. * Strong typing of a Mesh related stage step action
  10658. */
  10659. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10660. /**
  10661. * Strong typing of a Evaluate Sub Mesh related stage step action
  10662. */
  10663. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10664. /**
  10665. * Strong typing of a Active Mesh related stage step action
  10666. */
  10667. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10668. /**
  10669. * Strong typing of a Camera related stage step action
  10670. */
  10671. export type CameraStageAction = (camera: Camera) => void;
  10672. /**
  10673. * Strong typing of a Camera Frame buffer related stage step action
  10674. */
  10675. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10676. /**
  10677. * Strong typing of a Render Target related stage step action
  10678. */
  10679. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10680. /**
  10681. * Strong typing of a RenderingGroup related stage step action
  10682. */
  10683. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10684. /**
  10685. * Strong typing of a Mesh Render related stage step action
  10686. */
  10687. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10688. /**
  10689. * Strong typing of a simple stage step action
  10690. */
  10691. export type SimpleStageAction = () => void;
  10692. /**
  10693. * Strong typing of a render target action.
  10694. */
  10695. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10696. /**
  10697. * Strong typing of a pointer move action.
  10698. */
  10699. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10700. /**
  10701. * Strong typing of a pointer up/down action.
  10702. */
  10703. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10704. /**
  10705. * Representation of a stage in the scene (Basically a list of ordered steps)
  10706. * @hidden
  10707. */
  10708. export class Stage<T extends Function> extends Array<{
  10709. index: number;
  10710. component: ISceneComponent;
  10711. action: T;
  10712. }> {
  10713. /**
  10714. * Hide ctor from the rest of the world.
  10715. * @param items The items to add.
  10716. */
  10717. private constructor();
  10718. /**
  10719. * Creates a new Stage.
  10720. * @returns A new instance of a Stage
  10721. */
  10722. static Create<T extends Function>(): Stage<T>;
  10723. /**
  10724. * Registers a step in an ordered way in the targeted stage.
  10725. * @param index Defines the position to register the step in
  10726. * @param component Defines the component attached to the step
  10727. * @param action Defines the action to launch during the step
  10728. */
  10729. registerStep(index: number, component: ISceneComponent, action: T): void;
  10730. /**
  10731. * Clears all the steps from the stage.
  10732. */
  10733. clear(): void;
  10734. }
  10735. }
  10736. declare module BABYLON {
  10737. interface Scene {
  10738. /** @hidden */
  10739. _pointerOverSprite: Nullable<Sprite>;
  10740. /** @hidden */
  10741. _pickedDownSprite: Nullable<Sprite>;
  10742. /** @hidden */
  10743. _tempSpritePickingRay: Nullable<Ray>;
  10744. /**
  10745. * All of the sprite managers added to this scene
  10746. * @see https://doc.babylonjs.com/babylon101/sprites
  10747. */
  10748. spriteManagers: Array<ISpriteManager>;
  10749. /**
  10750. * An event triggered when sprites rendering is about to start
  10751. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10752. */
  10753. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10754. /**
  10755. * An event triggered when sprites rendering is done
  10756. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10757. */
  10758. onAfterSpritesRenderingObservable: Observable<Scene>;
  10759. /** @hidden */
  10760. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10761. /** Launch a ray to try to pick a sprite in the scene
  10762. * @param x position on screen
  10763. * @param y position on screen
  10764. * @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
  10765. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10766. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10767. * @returns a PickingInfo
  10768. */
  10769. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10770. /** Use the given ray to pick a sprite in the scene
  10771. * @param ray The ray (in world space) to use to pick meshes
  10772. * @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
  10773. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10774. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10775. * @returns a PickingInfo
  10776. */
  10777. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10778. /** @hidden */
  10779. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10780. /** Launch a ray to try to pick sprites in the scene
  10781. * @param x position on screen
  10782. * @param y position on screen
  10783. * @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
  10784. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10785. * @returns a PickingInfo array
  10786. */
  10787. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10788. /** Use the given ray to pick sprites in the scene
  10789. * @param ray The ray (in world space) to use to pick meshes
  10790. * @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
  10791. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10792. * @returns a PickingInfo array
  10793. */
  10794. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10795. /**
  10796. * Force the sprite under the pointer
  10797. * @param sprite defines the sprite to use
  10798. */
  10799. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10800. /**
  10801. * Gets the sprite under the pointer
  10802. * @returns a Sprite or null if no sprite is under the pointer
  10803. */
  10804. getPointerOverSprite(): Nullable<Sprite>;
  10805. }
  10806. /**
  10807. * Defines the sprite scene component responsible to manage sprites
  10808. * in a given scene.
  10809. */
  10810. export class SpriteSceneComponent implements ISceneComponent {
  10811. /**
  10812. * The component name helpfull to identify the component in the list of scene components.
  10813. */
  10814. readonly name: string;
  10815. /**
  10816. * The scene the component belongs to.
  10817. */
  10818. scene: Scene;
  10819. /** @hidden */
  10820. private _spritePredicate;
  10821. /**
  10822. * Creates a new instance of the component for the given scene
  10823. * @param scene Defines the scene to register the component in
  10824. */
  10825. constructor(scene: Scene);
  10826. /**
  10827. * Registers the component in a given scene
  10828. */
  10829. register(): void;
  10830. /**
  10831. * Rebuilds the elements related to this component in case of
  10832. * context lost for instance.
  10833. */
  10834. rebuild(): void;
  10835. /**
  10836. * Disposes the component and the associated ressources.
  10837. */
  10838. dispose(): void;
  10839. private _pickSpriteButKeepRay;
  10840. private _pointerMove;
  10841. private _pointerDown;
  10842. private _pointerUp;
  10843. }
  10844. }
  10845. declare module BABYLON {
  10846. /** @hidden */
  10847. export var fogFragmentDeclaration: {
  10848. name: string;
  10849. shader: string;
  10850. };
  10851. }
  10852. declare module BABYLON {
  10853. /** @hidden */
  10854. export var fogFragment: {
  10855. name: string;
  10856. shader: string;
  10857. };
  10858. }
  10859. declare module BABYLON {
  10860. /** @hidden */
  10861. export var spritesPixelShader: {
  10862. name: string;
  10863. shader: string;
  10864. };
  10865. }
  10866. declare module BABYLON {
  10867. /** @hidden */
  10868. export var fogVertexDeclaration: {
  10869. name: string;
  10870. shader: string;
  10871. };
  10872. }
  10873. declare module BABYLON {
  10874. /** @hidden */
  10875. export var spritesVertexShader: {
  10876. name: string;
  10877. shader: string;
  10878. };
  10879. }
  10880. declare module BABYLON {
  10881. /**
  10882. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10883. */
  10884. export interface ISpriteManager extends IDisposable {
  10885. /**
  10886. * Gets manager's name
  10887. */
  10888. name: string;
  10889. /**
  10890. * Restricts the camera to viewing objects with the same layerMask.
  10891. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10892. */
  10893. layerMask: number;
  10894. /**
  10895. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10896. */
  10897. isPickable: boolean;
  10898. /**
  10899. * Gets the hosting scene
  10900. */
  10901. scene: Scene;
  10902. /**
  10903. * Specifies the rendering group id for this mesh (0 by default)
  10904. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10905. */
  10906. renderingGroupId: number;
  10907. /**
  10908. * Defines the list of sprites managed by the manager.
  10909. */
  10910. sprites: Array<Sprite>;
  10911. /**
  10912. * Gets or sets the spritesheet texture
  10913. */
  10914. texture: Texture;
  10915. /** Defines the default width of a cell in the spritesheet */
  10916. cellWidth: number;
  10917. /** Defines the default height of a cell in the spritesheet */
  10918. cellHeight: number;
  10919. /**
  10920. * Tests the intersection of a sprite with a specific ray.
  10921. * @param ray The ray we are sending to test the collision
  10922. * @param camera The camera space we are sending rays in
  10923. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10924. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10925. * @returns picking info or null.
  10926. */
  10927. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10928. /**
  10929. * Intersects the sprites with a ray
  10930. * @param ray defines the ray to intersect with
  10931. * @param camera defines the current active camera
  10932. * @param predicate defines a predicate used to select candidate sprites
  10933. * @returns null if no hit or a PickingInfo array
  10934. */
  10935. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10936. /**
  10937. * Renders the list of sprites on screen.
  10938. */
  10939. render(): void;
  10940. }
  10941. /**
  10942. * Class used to manage multiple sprites on the same spritesheet
  10943. * @see https://doc.babylonjs.com/babylon101/sprites
  10944. */
  10945. export class SpriteManager implements ISpriteManager {
  10946. /** defines the manager's name */
  10947. name: string;
  10948. /** Define the Url to load snippets */
  10949. static SnippetUrl: string;
  10950. /** Snippet ID if the manager was created from the snippet server */
  10951. snippetId: string;
  10952. /** Gets the list of sprites */
  10953. sprites: Sprite[];
  10954. /** Gets or sets the rendering group id (0 by default) */
  10955. renderingGroupId: number;
  10956. /** Gets or sets camera layer mask */
  10957. layerMask: number;
  10958. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10959. fogEnabled: boolean;
  10960. /** Gets or sets a boolean indicating if the sprites are pickable */
  10961. isPickable: boolean;
  10962. /** Defines the default width of a cell in the spritesheet */
  10963. cellWidth: number;
  10964. /** Defines the default height of a cell in the spritesheet */
  10965. cellHeight: number;
  10966. /** Associative array from JSON sprite data file */
  10967. private _cellData;
  10968. /** Array of sprite names from JSON sprite data file */
  10969. private _spriteMap;
  10970. /** True when packed cell data from JSON file is ready*/
  10971. private _packedAndReady;
  10972. private _textureContent;
  10973. /**
  10974. * An event triggered when the manager is disposed.
  10975. */
  10976. onDisposeObservable: Observable<SpriteManager>;
  10977. private _onDisposeObserver;
  10978. /**
  10979. * Callback called when the manager is disposed
  10980. */
  10981. set onDispose(callback: () => void);
  10982. private _capacity;
  10983. private _fromPacked;
  10984. private _spriteTexture;
  10985. private _epsilon;
  10986. private _scene;
  10987. private _vertexData;
  10988. private _buffer;
  10989. private _vertexBuffers;
  10990. private _indexBuffer;
  10991. private _effectBase;
  10992. private _effectFog;
  10993. /**
  10994. * Gets or sets the unique id of the sprite
  10995. */
  10996. uniqueId: number;
  10997. /**
  10998. * Gets the array of sprites
  10999. */
  11000. get children(): Sprite[];
  11001. /**
  11002. * Gets the hosting scene
  11003. */
  11004. get scene(): Scene;
  11005. /**
  11006. * Gets the capacity of the manager
  11007. */
  11008. get capacity(): number;
  11009. /**
  11010. * Gets or sets the spritesheet texture
  11011. */
  11012. get texture(): Texture;
  11013. set texture(value: Texture);
  11014. private _blendMode;
  11015. /**
  11016. * Blend mode use to render the particle, it can be any of
  11017. * the static Constants.ALPHA_x properties provided in this class.
  11018. * Default value is Constants.ALPHA_COMBINE
  11019. */
  11020. get blendMode(): number;
  11021. set blendMode(blendMode: number);
  11022. /** Disables writing to the depth buffer when rendering the sprites.
  11023. * It can be handy to disable depth writing when using textures without alpha channel
  11024. * and setting some specific blend modes.
  11025. */
  11026. disableDepthWrite: boolean;
  11027. /**
  11028. * Creates a new sprite manager
  11029. * @param name defines the manager's name
  11030. * @param imgUrl defines the sprite sheet url
  11031. * @param capacity defines the maximum allowed number of sprites
  11032. * @param cellSize defines the size of a sprite cell
  11033. * @param scene defines the hosting scene
  11034. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11035. * @param samplingMode defines the smapling mode to use with spritesheet
  11036. * @param fromPacked set to false; do not alter
  11037. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11038. */
  11039. constructor(
  11040. /** defines the manager's name */
  11041. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11042. /**
  11043. * Returns the string "SpriteManager"
  11044. * @returns "SpriteManager"
  11045. */
  11046. getClassName(): string;
  11047. private _makePacked;
  11048. private _appendSpriteVertex;
  11049. private _checkTextureAlpha;
  11050. /**
  11051. * Intersects the sprites with a ray
  11052. * @param ray defines the ray to intersect with
  11053. * @param camera defines the current active camera
  11054. * @param predicate defines a predicate used to select candidate sprites
  11055. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11056. * @returns null if no hit or a PickingInfo
  11057. */
  11058. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11059. /**
  11060. * Intersects the sprites with a ray
  11061. * @param ray defines the ray to intersect with
  11062. * @param camera defines the current active camera
  11063. * @param predicate defines a predicate used to select candidate sprites
  11064. * @returns null if no hit or a PickingInfo array
  11065. */
  11066. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11067. /**
  11068. * Render all child sprites
  11069. */
  11070. render(): void;
  11071. /**
  11072. * Release associated resources
  11073. */
  11074. dispose(): void;
  11075. /**
  11076. * Serializes the sprite manager to a JSON object
  11077. * @param serializeTexture defines if the texture must be serialized as well
  11078. * @returns the JSON object
  11079. */
  11080. serialize(serializeTexture?: boolean): any;
  11081. /**
  11082. * Parses a JSON object to create a new sprite manager.
  11083. * @param parsedManager The JSON object to parse
  11084. * @param scene The scene to create the sprite managerin
  11085. * @param rootUrl The root url to use to load external dependencies like texture
  11086. * @returns the new sprite manager
  11087. */
  11088. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11089. /**
  11090. * Creates a sprite manager from a snippet saved in a remote file
  11091. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11092. * @param url defines the url to load from
  11093. * @param scene defines the hosting scene
  11094. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11095. * @returns a promise that will resolve to the new sprite manager
  11096. */
  11097. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11098. /**
  11099. * Creates a sprite manager from a snippet saved by the sprite editor
  11100. * @param snippetId defines the snippet to load
  11101. * @param scene defines the hosting scene
  11102. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11103. * @returns a promise that will resolve to the new sprite manager
  11104. */
  11105. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11106. }
  11107. }
  11108. declare module BABYLON {
  11109. /** Interface used by value gradients (color, factor, ...) */
  11110. export interface IValueGradient {
  11111. /**
  11112. * Gets or sets the gradient value (between 0 and 1)
  11113. */
  11114. gradient: number;
  11115. }
  11116. /** Class used to store color4 gradient */
  11117. export class ColorGradient implements IValueGradient {
  11118. /**
  11119. * Gets or sets the gradient value (between 0 and 1)
  11120. */
  11121. gradient: number;
  11122. /**
  11123. * Gets or sets first associated color
  11124. */
  11125. color1: Color4;
  11126. /**
  11127. * Gets or sets second associated color
  11128. */
  11129. color2?: Color4 | undefined;
  11130. /**
  11131. * Creates a new color4 gradient
  11132. * @param gradient gets or sets the gradient value (between 0 and 1)
  11133. * @param color1 gets or sets first associated color
  11134. * @param color2 gets or sets first second color
  11135. */
  11136. constructor(
  11137. /**
  11138. * Gets or sets the gradient value (between 0 and 1)
  11139. */
  11140. gradient: number,
  11141. /**
  11142. * Gets or sets first associated color
  11143. */
  11144. color1: Color4,
  11145. /**
  11146. * Gets or sets second associated color
  11147. */
  11148. color2?: Color4 | undefined);
  11149. /**
  11150. * Will get a color picked randomly between color1 and color2.
  11151. * If color2 is undefined then color1 will be used
  11152. * @param result defines the target Color4 to store the result in
  11153. */
  11154. getColorToRef(result: Color4): void;
  11155. }
  11156. /** Class used to store color 3 gradient */
  11157. export class Color3Gradient implements IValueGradient {
  11158. /**
  11159. * Gets or sets the gradient value (between 0 and 1)
  11160. */
  11161. gradient: number;
  11162. /**
  11163. * Gets or sets the associated color
  11164. */
  11165. color: Color3;
  11166. /**
  11167. * Creates a new color3 gradient
  11168. * @param gradient gets or sets the gradient value (between 0 and 1)
  11169. * @param color gets or sets associated color
  11170. */
  11171. constructor(
  11172. /**
  11173. * Gets or sets the gradient value (between 0 and 1)
  11174. */
  11175. gradient: number,
  11176. /**
  11177. * Gets or sets the associated color
  11178. */
  11179. color: Color3);
  11180. }
  11181. /** Class used to store factor gradient */
  11182. export class FactorGradient implements IValueGradient {
  11183. /**
  11184. * Gets or sets the gradient value (between 0 and 1)
  11185. */
  11186. gradient: number;
  11187. /**
  11188. * Gets or sets first associated factor
  11189. */
  11190. factor1: number;
  11191. /**
  11192. * Gets or sets second associated factor
  11193. */
  11194. factor2?: number | undefined;
  11195. /**
  11196. * Creates a new factor gradient
  11197. * @param gradient gets or sets the gradient value (between 0 and 1)
  11198. * @param factor1 gets or sets first associated factor
  11199. * @param factor2 gets or sets second associated factor
  11200. */
  11201. constructor(
  11202. /**
  11203. * Gets or sets the gradient value (between 0 and 1)
  11204. */
  11205. gradient: number,
  11206. /**
  11207. * Gets or sets first associated factor
  11208. */
  11209. factor1: number,
  11210. /**
  11211. * Gets or sets second associated factor
  11212. */
  11213. factor2?: number | undefined);
  11214. /**
  11215. * Will get a number picked randomly between factor1 and factor2.
  11216. * If factor2 is undefined then factor1 will be used
  11217. * @returns the picked number
  11218. */
  11219. getFactor(): number;
  11220. }
  11221. /**
  11222. * Helper used to simplify some generic gradient tasks
  11223. */
  11224. export class GradientHelper {
  11225. /**
  11226. * Gets the current gradient from an array of IValueGradient
  11227. * @param ratio defines the current ratio to get
  11228. * @param gradients defines the array of IValueGradient
  11229. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11230. */
  11231. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11232. }
  11233. }
  11234. declare module BABYLON {
  11235. interface ThinEngine {
  11236. /**
  11237. * Creates a raw texture
  11238. * @param data defines the data to store in the texture
  11239. * @param width defines the width of the texture
  11240. * @param height defines the height of the texture
  11241. * @param format defines the format of the data
  11242. * @param generateMipMaps defines if the engine should generate the mip levels
  11243. * @param invertY defines if data must be stored with Y axis inverted
  11244. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11245. * @param compression defines the compression used (null by default)
  11246. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11247. * @returns the raw texture inside an InternalTexture
  11248. */
  11249. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11250. /**
  11251. * Update a raw texture
  11252. * @param texture defines the texture to update
  11253. * @param data defines the data to store in the texture
  11254. * @param format defines the format of the data
  11255. * @param invertY defines if data must be stored with Y axis inverted
  11256. */
  11257. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11258. /**
  11259. * Update a raw texture
  11260. * @param texture defines the texture to update
  11261. * @param data defines the data to store in the texture
  11262. * @param format defines the format of the data
  11263. * @param invertY defines if data must be stored with Y axis inverted
  11264. * @param compression defines the compression used (null by default)
  11265. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11266. */
  11267. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11268. /**
  11269. * Creates a new raw cube texture
  11270. * @param data defines the array of data to use to create each face
  11271. * @param size defines the size of the textures
  11272. * @param format defines the format of the data
  11273. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11274. * @param generateMipMaps defines if the engine should generate the mip levels
  11275. * @param invertY defines if data must be stored with Y axis inverted
  11276. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11277. * @param compression defines the compression used (null by default)
  11278. * @returns the cube texture as an InternalTexture
  11279. */
  11280. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11281. /**
  11282. * Update a raw cube texture
  11283. * @param texture defines the texture to udpdate
  11284. * @param data defines the data to store
  11285. * @param format defines the data format
  11286. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11287. * @param invertY defines if data must be stored with Y axis inverted
  11288. */
  11289. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11290. /**
  11291. * Update a raw cube texture
  11292. * @param texture defines the texture to udpdate
  11293. * @param data defines the data to store
  11294. * @param format defines the data format
  11295. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11296. * @param invertY defines if data must be stored with Y axis inverted
  11297. * @param compression defines the compression used (null by default)
  11298. */
  11299. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11300. /**
  11301. * Update a raw cube texture
  11302. * @param texture defines the texture to udpdate
  11303. * @param data defines the data to store
  11304. * @param format defines the data format
  11305. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11306. * @param invertY defines if data must be stored with Y axis inverted
  11307. * @param compression defines the compression used (null by default)
  11308. * @param level defines which level of the texture to update
  11309. */
  11310. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11311. /**
  11312. * Creates a new raw cube texture from a specified url
  11313. * @param url defines the url where the data is located
  11314. * @param scene defines the current scene
  11315. * @param size defines the size of the textures
  11316. * @param format defines the format of the data
  11317. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11318. * @param noMipmap defines if the engine should avoid generating the mip levels
  11319. * @param callback defines a callback used to extract texture data from loaded data
  11320. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11321. * @param onLoad defines a callback called when texture is loaded
  11322. * @param onError defines a callback called if there is an error
  11323. * @returns the cube texture as an InternalTexture
  11324. */
  11325. 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;
  11326. /**
  11327. * Creates a new raw cube texture from a specified url
  11328. * @param url defines the url where the data is located
  11329. * @param scene defines the current scene
  11330. * @param size defines the size of the textures
  11331. * @param format defines the format of the data
  11332. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11333. * @param noMipmap defines if the engine should avoid generating the mip levels
  11334. * @param callback defines a callback used to extract texture data from loaded data
  11335. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11336. * @param onLoad defines a callback called when texture is loaded
  11337. * @param onError defines a callback called if there is an error
  11338. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11339. * @param invertY defines if data must be stored with Y axis inverted
  11340. * @returns the cube texture as an InternalTexture
  11341. */
  11342. 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;
  11343. /**
  11344. * Creates a new raw 3D texture
  11345. * @param data defines the data used to create the texture
  11346. * @param width defines the width of the texture
  11347. * @param height defines the height of the texture
  11348. * @param depth defines the depth of the texture
  11349. * @param format defines the format of the texture
  11350. * @param generateMipMaps defines if the engine must generate mip levels
  11351. * @param invertY defines if data must be stored with Y axis inverted
  11352. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11353. * @param compression defines the compressed used (can be null)
  11354. * @param textureType defines the compressed used (can be null)
  11355. * @returns a new raw 3D texture (stored in an InternalTexture)
  11356. */
  11357. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11358. /**
  11359. * Update a raw 3D texture
  11360. * @param texture defines the texture to update
  11361. * @param data defines the data to store
  11362. * @param format defines the data format
  11363. * @param invertY defines if data must be stored with Y axis inverted
  11364. */
  11365. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11366. /**
  11367. * Update a raw 3D texture
  11368. * @param texture defines the texture to update
  11369. * @param data defines the data to store
  11370. * @param format defines the data format
  11371. * @param invertY defines if data must be stored with Y axis inverted
  11372. * @param compression defines the used compression (can be null)
  11373. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11374. */
  11375. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11376. /**
  11377. * Creates a new raw 2D array texture
  11378. * @param data defines the data used to create the texture
  11379. * @param width defines the width of the texture
  11380. * @param height defines the height of the texture
  11381. * @param depth defines the number of layers of the texture
  11382. * @param format defines the format of the texture
  11383. * @param generateMipMaps defines if the engine must generate mip levels
  11384. * @param invertY defines if data must be stored with Y axis inverted
  11385. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11386. * @param compression defines the compressed used (can be null)
  11387. * @param textureType defines the compressed used (can be null)
  11388. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11389. */
  11390. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11391. /**
  11392. * Update a raw 2D array texture
  11393. * @param texture defines the texture to update
  11394. * @param data defines the data to store
  11395. * @param format defines the data format
  11396. * @param invertY defines if data must be stored with Y axis inverted
  11397. */
  11398. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11399. /**
  11400. * Update a raw 2D array texture
  11401. * @param texture defines the texture to update
  11402. * @param data defines the data to store
  11403. * @param format defines the data format
  11404. * @param invertY defines if data must be stored with Y axis inverted
  11405. * @param compression defines the used compression (can be null)
  11406. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11407. */
  11408. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11409. }
  11410. }
  11411. declare module BABYLON {
  11412. /**
  11413. * Raw texture can help creating a texture directly from an array of data.
  11414. * This can be super useful if you either get the data from an uncompressed source or
  11415. * if you wish to create your texture pixel by pixel.
  11416. */
  11417. export class RawTexture extends Texture {
  11418. /**
  11419. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11420. */
  11421. format: number;
  11422. /**
  11423. * Instantiates a new RawTexture.
  11424. * Raw texture can help creating a texture directly from an array of data.
  11425. * This can be super useful if you either get the data from an uncompressed source or
  11426. * if you wish to create your texture pixel by pixel.
  11427. * @param data define the array of data to use to create the texture
  11428. * @param width define the width of the texture
  11429. * @param height define the height of the texture
  11430. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11431. * @param scene define the scene the texture belongs to
  11432. * @param generateMipMaps define whether mip maps should be generated or not
  11433. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11434. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11435. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11436. */
  11437. constructor(data: ArrayBufferView, width: number, height: number,
  11438. /**
  11439. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11440. */
  11441. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11442. /**
  11443. * Updates the texture underlying data.
  11444. * @param data Define the new data of the texture
  11445. */
  11446. update(data: ArrayBufferView): void;
  11447. /**
  11448. * Creates a luminance texture from some data.
  11449. * @param data Define the texture data
  11450. * @param width Define the width of the texture
  11451. * @param height Define the height of the texture
  11452. * @param scene Define the scene the texture belongs to
  11453. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11454. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11455. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11456. * @returns the luminance texture
  11457. */
  11458. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11459. /**
  11460. * Creates a luminance alpha texture from some data.
  11461. * @param data Define the texture data
  11462. * @param width Define the width of the texture
  11463. * @param height Define the height of the texture
  11464. * @param scene Define the scene the texture belongs to
  11465. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11466. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11467. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11468. * @returns the luminance alpha texture
  11469. */
  11470. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11471. /**
  11472. * Creates an alpha texture from some data.
  11473. * @param data Define the texture data
  11474. * @param width Define the width of the texture
  11475. * @param height Define the height of the texture
  11476. * @param scene Define the scene the texture belongs to
  11477. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11478. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11479. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11480. * @returns the alpha texture
  11481. */
  11482. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11483. /**
  11484. * Creates a RGB texture from some data.
  11485. * @param data Define the texture data
  11486. * @param width Define the width of the texture
  11487. * @param height Define the height of the texture
  11488. * @param scene Define the scene the texture belongs to
  11489. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11490. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11491. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11492. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11493. * @returns the RGB alpha texture
  11494. */
  11495. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11496. /**
  11497. * Creates a RGBA texture from some data.
  11498. * @param data Define the texture data
  11499. * @param width Define the width of the texture
  11500. * @param height Define the height of the texture
  11501. * @param scene Define the scene the texture belongs to
  11502. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11503. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11504. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11505. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11506. * @returns the RGBA texture
  11507. */
  11508. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11509. /**
  11510. * Creates a R texture from some data.
  11511. * @param data Define the texture data
  11512. * @param width Define the width of the texture
  11513. * @param height Define the height of the texture
  11514. * @param scene Define the scene the texture belongs to
  11515. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11516. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11517. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11518. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11519. * @returns the R texture
  11520. */
  11521. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11522. }
  11523. }
  11524. declare module BABYLON {
  11525. interface AbstractScene {
  11526. /**
  11527. * The list of procedural textures added to the scene
  11528. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11529. */
  11530. proceduralTextures: Array<ProceduralTexture>;
  11531. }
  11532. /**
  11533. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11534. * in a given scene.
  11535. */
  11536. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11537. /**
  11538. * The component name helpfull to identify the component in the list of scene components.
  11539. */
  11540. readonly name: string;
  11541. /**
  11542. * The scene the component belongs to.
  11543. */
  11544. scene: Scene;
  11545. /**
  11546. * Creates a new instance of the component for the given scene
  11547. * @param scene Defines the scene to register the component in
  11548. */
  11549. constructor(scene: Scene);
  11550. /**
  11551. * Registers the component in a given scene
  11552. */
  11553. register(): void;
  11554. /**
  11555. * Rebuilds the elements related to this component in case of
  11556. * context lost for instance.
  11557. */
  11558. rebuild(): void;
  11559. /**
  11560. * Disposes the component and the associated ressources.
  11561. */
  11562. dispose(): void;
  11563. private _beforeClear;
  11564. }
  11565. }
  11566. declare module BABYLON {
  11567. interface ThinEngine {
  11568. /**
  11569. * Creates a new render target cube texture
  11570. * @param size defines the size of the texture
  11571. * @param options defines the options used to create the texture
  11572. * @returns a new render target cube texture stored in an InternalTexture
  11573. */
  11574. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11575. }
  11576. }
  11577. declare module BABYLON {
  11578. /** @hidden */
  11579. export var proceduralVertexShader: {
  11580. name: string;
  11581. shader: string;
  11582. };
  11583. }
  11584. declare module BABYLON {
  11585. /**
  11586. * 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.
  11587. * This is the base class of any Procedural texture and contains most of the shareable code.
  11588. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11589. */
  11590. export class ProceduralTexture extends Texture {
  11591. isCube: boolean;
  11592. /**
  11593. * Define if the texture is enabled or not (disabled texture will not render)
  11594. */
  11595. isEnabled: boolean;
  11596. /**
  11597. * Define if the texture must be cleared before rendering (default is true)
  11598. */
  11599. autoClear: boolean;
  11600. /**
  11601. * Callback called when the texture is generated
  11602. */
  11603. onGenerated: () => void;
  11604. /**
  11605. * Event raised when the texture is generated
  11606. */
  11607. onGeneratedObservable: Observable<ProceduralTexture>;
  11608. /** @hidden */
  11609. _generateMipMaps: boolean;
  11610. /** @hidden **/
  11611. _effect: Effect;
  11612. /** @hidden */
  11613. _textures: {
  11614. [key: string]: Texture;
  11615. };
  11616. /** @hidden */
  11617. protected _fallbackTexture: Nullable<Texture>;
  11618. private _size;
  11619. private _currentRefreshId;
  11620. private _frameId;
  11621. private _refreshRate;
  11622. private _vertexBuffers;
  11623. private _indexBuffer;
  11624. private _uniforms;
  11625. private _samplers;
  11626. private _fragment;
  11627. private _floats;
  11628. private _ints;
  11629. private _floatsArrays;
  11630. private _colors3;
  11631. private _colors4;
  11632. private _vectors2;
  11633. private _vectors3;
  11634. private _matrices;
  11635. private _fallbackTextureUsed;
  11636. private _fullEngine;
  11637. private _cachedDefines;
  11638. private _contentUpdateId;
  11639. private _contentData;
  11640. /**
  11641. * Instantiates a new procedural texture.
  11642. * 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.
  11643. * This is the base class of any Procedural texture and contains most of the shareable code.
  11644. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11645. * @param name Define the name of the texture
  11646. * @param size Define the size of the texture to create
  11647. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11648. * @param scene Define the scene the texture belongs to
  11649. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11650. * @param generateMipMaps Define if the texture should creates mip maps or not
  11651. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11652. */
  11653. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11654. /**
  11655. * The effect that is created when initializing the post process.
  11656. * @returns The created effect corresponding the the postprocess.
  11657. */
  11658. getEffect(): Effect;
  11659. /**
  11660. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11661. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11662. */
  11663. getContent(): Nullable<ArrayBufferView>;
  11664. private _createIndexBuffer;
  11665. /** @hidden */
  11666. _rebuild(): void;
  11667. /**
  11668. * Resets the texture in order to recreate its associated resources.
  11669. * This can be called in case of context loss
  11670. */
  11671. reset(): void;
  11672. protected _getDefines(): string;
  11673. /**
  11674. * Is the texture ready to be used ? (rendered at least once)
  11675. * @returns true if ready, otherwise, false.
  11676. */
  11677. isReady(): boolean;
  11678. /**
  11679. * Resets the refresh counter of the texture and start bak from scratch.
  11680. * Could be useful to regenerate the texture if it is setup to render only once.
  11681. */
  11682. resetRefreshCounter(): void;
  11683. /**
  11684. * Set the fragment shader to use in order to render the texture.
  11685. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11686. */
  11687. setFragment(fragment: any): void;
  11688. /**
  11689. * Define the refresh rate of the texture or the rendering frequency.
  11690. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11691. */
  11692. get refreshRate(): number;
  11693. set refreshRate(value: number);
  11694. /** @hidden */
  11695. _shouldRender(): boolean;
  11696. /**
  11697. * Get the size the texture is rendering at.
  11698. * @returns the size (texture is always squared)
  11699. */
  11700. getRenderSize(): number;
  11701. /**
  11702. * Resize the texture to new value.
  11703. * @param size Define the new size the texture should have
  11704. * @param generateMipMaps Define whether the new texture should create mip maps
  11705. */
  11706. resize(size: number, generateMipMaps: boolean): void;
  11707. private _checkUniform;
  11708. /**
  11709. * Set a texture in the shader program used to render.
  11710. * @param name Define the name of the uniform samplers as defined in the shader
  11711. * @param texture Define the texture to bind to this sampler
  11712. * @return the texture itself allowing "fluent" like uniform updates
  11713. */
  11714. setTexture(name: string, texture: Texture): ProceduralTexture;
  11715. /**
  11716. * Set a float in the shader.
  11717. * @param name Define the name of the uniform as defined in the shader
  11718. * @param value Define the value to give to the uniform
  11719. * @return the texture itself allowing "fluent" like uniform updates
  11720. */
  11721. setFloat(name: string, value: number): ProceduralTexture;
  11722. /**
  11723. * Set a int in the shader.
  11724. * @param name Define the name of the uniform as defined in the shader
  11725. * @param value Define the value to give to the uniform
  11726. * @return the texture itself allowing "fluent" like uniform updates
  11727. */
  11728. setInt(name: string, value: number): ProceduralTexture;
  11729. /**
  11730. * Set an array of floats in the shader.
  11731. * @param name Define the name of the uniform as defined in the shader
  11732. * @param value Define the value to give to the uniform
  11733. * @return the texture itself allowing "fluent" like uniform updates
  11734. */
  11735. setFloats(name: string, value: number[]): ProceduralTexture;
  11736. /**
  11737. * Set a vec3 in the shader from a Color3.
  11738. * @param name Define the name of the uniform as defined in the shader
  11739. * @param value Define the value to give to the uniform
  11740. * @return the texture itself allowing "fluent" like uniform updates
  11741. */
  11742. setColor3(name: string, value: Color3): ProceduralTexture;
  11743. /**
  11744. * Set a vec4 in the shader from a Color4.
  11745. * @param name Define the name of the uniform as defined in the shader
  11746. * @param value Define the value to give to the uniform
  11747. * @return the texture itself allowing "fluent" like uniform updates
  11748. */
  11749. setColor4(name: string, value: Color4): ProceduralTexture;
  11750. /**
  11751. * Set a vec2 in the shader from a Vector2.
  11752. * @param name Define the name of the uniform as defined in the shader
  11753. * @param value Define the value to give to the uniform
  11754. * @return the texture itself allowing "fluent" like uniform updates
  11755. */
  11756. setVector2(name: string, value: Vector2): ProceduralTexture;
  11757. /**
  11758. * Set a vec3 in the shader from a Vector3.
  11759. * @param name Define the name of the uniform as defined in the shader
  11760. * @param value Define the value to give to the uniform
  11761. * @return the texture itself allowing "fluent" like uniform updates
  11762. */
  11763. setVector3(name: string, value: Vector3): ProceduralTexture;
  11764. /**
  11765. * Set a mat4 in the shader from a MAtrix.
  11766. * @param name Define the name of the uniform as defined in the shader
  11767. * @param value Define the value to give to the uniform
  11768. * @return the texture itself allowing "fluent" like uniform updates
  11769. */
  11770. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11771. /**
  11772. * Render the texture to its associated render target.
  11773. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11774. */
  11775. render(useCameraPostProcess?: boolean): void;
  11776. /**
  11777. * Clone the texture.
  11778. * @returns the cloned texture
  11779. */
  11780. clone(): ProceduralTexture;
  11781. /**
  11782. * Dispose the texture and release its asoociated resources.
  11783. */
  11784. dispose(): void;
  11785. }
  11786. }
  11787. declare module BABYLON {
  11788. /**
  11789. * This represents the base class for particle system in Babylon.
  11790. * 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.
  11791. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11792. * @example https://doc.babylonjs.com/babylon101/particles
  11793. */
  11794. export class BaseParticleSystem {
  11795. /**
  11796. * Source color is added to the destination color without alpha affecting the result
  11797. */
  11798. static BLENDMODE_ONEONE: number;
  11799. /**
  11800. * Blend current color and particle color using particle’s alpha
  11801. */
  11802. static BLENDMODE_STANDARD: number;
  11803. /**
  11804. * Add current color and particle color multiplied by particle’s alpha
  11805. */
  11806. static BLENDMODE_ADD: number;
  11807. /**
  11808. * Multiply current color with particle color
  11809. */
  11810. static BLENDMODE_MULTIPLY: number;
  11811. /**
  11812. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11813. */
  11814. static BLENDMODE_MULTIPLYADD: number;
  11815. /**
  11816. * List of animations used by the particle system.
  11817. */
  11818. animations: Animation[];
  11819. /**
  11820. * Gets or sets the unique id of the particle system
  11821. */
  11822. uniqueId: number;
  11823. /**
  11824. * The id of the Particle system.
  11825. */
  11826. id: string;
  11827. /**
  11828. * The friendly name of the Particle system.
  11829. */
  11830. name: string;
  11831. /**
  11832. * Snippet ID if the particle system was created from the snippet server
  11833. */
  11834. snippetId: string;
  11835. /**
  11836. * The rendering group used by the Particle system to chose when to render.
  11837. */
  11838. renderingGroupId: number;
  11839. /**
  11840. * The emitter represents the Mesh or position we are attaching the particle system to.
  11841. */
  11842. emitter: Nullable<AbstractMesh | Vector3>;
  11843. /**
  11844. * The maximum number of particles to emit per frame
  11845. */
  11846. emitRate: number;
  11847. /**
  11848. * If you want to launch only a few particles at once, that can be done, as well.
  11849. */
  11850. manualEmitCount: number;
  11851. /**
  11852. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11853. */
  11854. updateSpeed: number;
  11855. /**
  11856. * The amount of time the particle system is running (depends of the overall update speed).
  11857. */
  11858. targetStopDuration: number;
  11859. /**
  11860. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11861. */
  11862. disposeOnStop: boolean;
  11863. /**
  11864. * Minimum power of emitting particles.
  11865. */
  11866. minEmitPower: number;
  11867. /**
  11868. * Maximum power of emitting particles.
  11869. */
  11870. maxEmitPower: number;
  11871. /**
  11872. * Minimum life time of emitting particles.
  11873. */
  11874. minLifeTime: number;
  11875. /**
  11876. * Maximum life time of emitting particles.
  11877. */
  11878. maxLifeTime: number;
  11879. /**
  11880. * Minimum Size of emitting particles.
  11881. */
  11882. minSize: number;
  11883. /**
  11884. * Maximum Size of emitting particles.
  11885. */
  11886. maxSize: number;
  11887. /**
  11888. * Minimum scale of emitting particles on X axis.
  11889. */
  11890. minScaleX: number;
  11891. /**
  11892. * Maximum scale of emitting particles on X axis.
  11893. */
  11894. maxScaleX: number;
  11895. /**
  11896. * Minimum scale of emitting particles on Y axis.
  11897. */
  11898. minScaleY: number;
  11899. /**
  11900. * Maximum scale of emitting particles on Y axis.
  11901. */
  11902. maxScaleY: number;
  11903. /**
  11904. * Gets or sets the minimal initial rotation in radians.
  11905. */
  11906. minInitialRotation: number;
  11907. /**
  11908. * Gets or sets the maximal initial rotation in radians.
  11909. */
  11910. maxInitialRotation: number;
  11911. /**
  11912. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11913. */
  11914. minAngularSpeed: number;
  11915. /**
  11916. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11917. */
  11918. maxAngularSpeed: number;
  11919. /**
  11920. * The texture used to render each particle. (this can be a spritesheet)
  11921. */
  11922. particleTexture: Nullable<Texture>;
  11923. /**
  11924. * The layer mask we are rendering the particles through.
  11925. */
  11926. layerMask: number;
  11927. /**
  11928. * This can help using your own shader to render the particle system.
  11929. * The according effect will be created
  11930. */
  11931. customShader: any;
  11932. /**
  11933. * By default particle system starts as soon as they are created. This prevents the
  11934. * automatic start to happen and let you decide when to start emitting particles.
  11935. */
  11936. preventAutoStart: boolean;
  11937. private _noiseTexture;
  11938. /**
  11939. * Gets or sets a texture used to add random noise to particle positions
  11940. */
  11941. get noiseTexture(): Nullable<ProceduralTexture>;
  11942. set noiseTexture(value: Nullable<ProceduralTexture>);
  11943. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11944. noiseStrength: Vector3;
  11945. /**
  11946. * Callback triggered when the particle animation is ending.
  11947. */
  11948. onAnimationEnd: Nullable<() => void>;
  11949. /**
  11950. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11951. */
  11952. blendMode: number;
  11953. /**
  11954. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11955. * to override the particles.
  11956. */
  11957. forceDepthWrite: boolean;
  11958. /** 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 */
  11959. preWarmCycles: number;
  11960. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11961. preWarmStepOffset: number;
  11962. /**
  11963. * 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)
  11964. */
  11965. spriteCellChangeSpeed: number;
  11966. /**
  11967. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11968. */
  11969. startSpriteCellID: number;
  11970. /**
  11971. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11972. */
  11973. endSpriteCellID: number;
  11974. /**
  11975. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11976. */
  11977. spriteCellWidth: number;
  11978. /**
  11979. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11980. */
  11981. spriteCellHeight: number;
  11982. /**
  11983. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11984. */
  11985. spriteRandomStartCell: boolean;
  11986. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11987. translationPivot: Vector2;
  11988. /** @hidden */
  11989. protected _isAnimationSheetEnabled: boolean;
  11990. /**
  11991. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11992. */
  11993. beginAnimationOnStart: boolean;
  11994. /**
  11995. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11996. */
  11997. beginAnimationFrom: number;
  11998. /**
  11999. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12000. */
  12001. beginAnimationTo: number;
  12002. /**
  12003. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12004. */
  12005. beginAnimationLoop: boolean;
  12006. /**
  12007. * Gets or sets a world offset applied to all particles
  12008. */
  12009. worldOffset: Vector3;
  12010. /**
  12011. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12012. */
  12013. get isAnimationSheetEnabled(): boolean;
  12014. set isAnimationSheetEnabled(value: boolean);
  12015. /**
  12016. * Get hosting scene
  12017. * @returns the scene
  12018. */
  12019. getScene(): Scene;
  12020. /**
  12021. * You can use gravity if you want to give an orientation to your particles.
  12022. */
  12023. gravity: Vector3;
  12024. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12025. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12026. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12027. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12028. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12029. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12030. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12031. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12032. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12033. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12034. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12035. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12036. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12037. /**
  12038. * Defines the delay in milliseconds before starting the system (0 by default)
  12039. */
  12040. startDelay: number;
  12041. /**
  12042. * Gets the current list of drag gradients.
  12043. * You must use addDragGradient and removeDragGradient to udpate this list
  12044. * @returns the list of drag gradients
  12045. */
  12046. getDragGradients(): Nullable<Array<FactorGradient>>;
  12047. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12048. limitVelocityDamping: number;
  12049. /**
  12050. * Gets the current list of limit velocity gradients.
  12051. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12052. * @returns the list of limit velocity gradients
  12053. */
  12054. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12055. /**
  12056. * Gets the current list of color gradients.
  12057. * You must use addColorGradient and removeColorGradient to udpate this list
  12058. * @returns the list of color gradients
  12059. */
  12060. getColorGradients(): Nullable<Array<ColorGradient>>;
  12061. /**
  12062. * Gets the current list of size gradients.
  12063. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12064. * @returns the list of size gradients
  12065. */
  12066. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12067. /**
  12068. * Gets the current list of color remap gradients.
  12069. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12070. * @returns the list of color remap gradients
  12071. */
  12072. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12073. /**
  12074. * Gets the current list of alpha remap gradients.
  12075. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12076. * @returns the list of alpha remap gradients
  12077. */
  12078. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12079. /**
  12080. * Gets the current list of life time gradients.
  12081. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12082. * @returns the list of life time gradients
  12083. */
  12084. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12085. /**
  12086. * Gets the current list of angular speed gradients.
  12087. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12088. * @returns the list of angular speed gradients
  12089. */
  12090. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12091. /**
  12092. * Gets the current list of velocity gradients.
  12093. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12094. * @returns the list of velocity gradients
  12095. */
  12096. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12097. /**
  12098. * Gets the current list of start size gradients.
  12099. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12100. * @returns the list of start size gradients
  12101. */
  12102. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12103. /**
  12104. * Gets the current list of emit rate gradients.
  12105. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12106. * @returns the list of emit rate gradients
  12107. */
  12108. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12109. /**
  12110. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12111. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12112. */
  12113. get direction1(): Vector3;
  12114. set direction1(value: Vector3);
  12115. /**
  12116. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12117. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12118. */
  12119. get direction2(): Vector3;
  12120. set direction2(value: Vector3);
  12121. /**
  12122. * 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.
  12123. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12124. */
  12125. get minEmitBox(): Vector3;
  12126. set minEmitBox(value: Vector3);
  12127. /**
  12128. * 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.
  12129. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12130. */
  12131. get maxEmitBox(): Vector3;
  12132. set maxEmitBox(value: Vector3);
  12133. /**
  12134. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12135. */
  12136. color1: Color4;
  12137. /**
  12138. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12139. */
  12140. color2: Color4;
  12141. /**
  12142. * Color the particle will have at the end of its lifetime
  12143. */
  12144. colorDead: Color4;
  12145. /**
  12146. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12147. */
  12148. textureMask: Color4;
  12149. /**
  12150. * The particle emitter type defines the emitter used by the particle system.
  12151. * It can be for example box, sphere, or cone...
  12152. */
  12153. particleEmitterType: IParticleEmitterType;
  12154. /** @hidden */
  12155. _isSubEmitter: boolean;
  12156. /**
  12157. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12158. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12159. */
  12160. billboardMode: number;
  12161. protected _isBillboardBased: boolean;
  12162. /**
  12163. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12164. */
  12165. get isBillboardBased(): boolean;
  12166. set isBillboardBased(value: boolean);
  12167. /**
  12168. * The scene the particle system belongs to.
  12169. */
  12170. protected _scene: Scene;
  12171. /**
  12172. * Local cache of defines for image processing.
  12173. */
  12174. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12175. /**
  12176. * Default configuration related to image processing available in the standard Material.
  12177. */
  12178. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12179. /**
  12180. * Gets the image processing configuration used either in this material.
  12181. */
  12182. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12183. /**
  12184. * Sets the Default image processing configuration used either in the this material.
  12185. *
  12186. * If sets to null, the scene one is in use.
  12187. */
  12188. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12189. /**
  12190. * Attaches a new image processing configuration to the Standard Material.
  12191. * @param configuration
  12192. */
  12193. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12194. /** @hidden */
  12195. protected _reset(): void;
  12196. /** @hidden */
  12197. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12198. /**
  12199. * Instantiates a particle system.
  12200. * 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.
  12201. * @param name The name of the particle system
  12202. */
  12203. constructor(name: string);
  12204. /**
  12205. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12206. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12207. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12208. * @returns the emitter
  12209. */
  12210. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12211. /**
  12212. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12213. * @param radius The radius of the hemisphere to emit from
  12214. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12215. * @returns the emitter
  12216. */
  12217. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12218. /**
  12219. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12220. * @param radius The radius of the sphere to emit from
  12221. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12222. * @returns the emitter
  12223. */
  12224. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12225. /**
  12226. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12227. * @param radius The radius of the sphere to emit from
  12228. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12229. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12230. * @returns the emitter
  12231. */
  12232. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12233. /**
  12234. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12235. * @param radius The radius of the emission cylinder
  12236. * @param height The height of the emission cylinder
  12237. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12238. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12239. * @returns the emitter
  12240. */
  12241. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12242. /**
  12243. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12244. * @param radius The radius of the cylinder to emit from
  12245. * @param height The height of the emission cylinder
  12246. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12247. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12248. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12249. * @returns the emitter
  12250. */
  12251. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12252. /**
  12253. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12254. * @param radius The radius of the cone to emit from
  12255. * @param angle The base angle of the cone
  12256. * @returns the emitter
  12257. */
  12258. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12259. /**
  12260. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12261. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12262. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12263. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12264. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12265. * @returns the emitter
  12266. */
  12267. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12268. }
  12269. }
  12270. declare module BABYLON {
  12271. /**
  12272. * Type of sub emitter
  12273. */
  12274. export enum SubEmitterType {
  12275. /**
  12276. * Attached to the particle over it's lifetime
  12277. */
  12278. ATTACHED = 0,
  12279. /**
  12280. * Created when the particle dies
  12281. */
  12282. END = 1
  12283. }
  12284. /**
  12285. * Sub emitter class used to emit particles from an existing particle
  12286. */
  12287. export class SubEmitter {
  12288. /**
  12289. * the particle system to be used by the sub emitter
  12290. */
  12291. particleSystem: ParticleSystem;
  12292. /**
  12293. * Type of the submitter (Default: END)
  12294. */
  12295. type: SubEmitterType;
  12296. /**
  12297. * 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)
  12298. * Note: This only is supported when using an emitter of type Mesh
  12299. */
  12300. inheritDirection: boolean;
  12301. /**
  12302. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12303. */
  12304. inheritedVelocityAmount: number;
  12305. /**
  12306. * Creates a sub emitter
  12307. * @param particleSystem the particle system to be used by the sub emitter
  12308. */
  12309. constructor(
  12310. /**
  12311. * the particle system to be used by the sub emitter
  12312. */
  12313. particleSystem: ParticleSystem);
  12314. /**
  12315. * Clones the sub emitter
  12316. * @returns the cloned sub emitter
  12317. */
  12318. clone(): SubEmitter;
  12319. /**
  12320. * Serialize current object to a JSON object
  12321. * @returns the serialized object
  12322. */
  12323. serialize(): any;
  12324. /** @hidden */
  12325. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12326. /**
  12327. * Creates a new SubEmitter from a serialized JSON version
  12328. * @param serializationObject defines the JSON object to read from
  12329. * @param scene defines the hosting scene
  12330. * @param rootUrl defines the rootUrl for data loading
  12331. * @returns a new SubEmitter
  12332. */
  12333. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12334. /** Release associated resources */
  12335. dispose(): void;
  12336. }
  12337. }
  12338. declare module BABYLON {
  12339. /** @hidden */
  12340. export var imageProcessingDeclaration: {
  12341. name: string;
  12342. shader: string;
  12343. };
  12344. }
  12345. declare module BABYLON {
  12346. /** @hidden */
  12347. export var imageProcessingFunctions: {
  12348. name: string;
  12349. shader: string;
  12350. };
  12351. }
  12352. declare module BABYLON {
  12353. /** @hidden */
  12354. export var particlesPixelShader: {
  12355. name: string;
  12356. shader: string;
  12357. };
  12358. }
  12359. declare module BABYLON {
  12360. /** @hidden */
  12361. export var particlesVertexShader: {
  12362. name: string;
  12363. shader: string;
  12364. };
  12365. }
  12366. declare module BABYLON {
  12367. /**
  12368. * This represents a particle system in Babylon.
  12369. * 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.
  12370. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12371. * @example https://doc.babylonjs.com/babylon101/particles
  12372. */
  12373. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12374. /**
  12375. * Billboard mode will only apply to Y axis
  12376. */
  12377. static readonly BILLBOARDMODE_Y: number;
  12378. /**
  12379. * Billboard mode will apply to all axes
  12380. */
  12381. static readonly BILLBOARDMODE_ALL: number;
  12382. /**
  12383. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12384. */
  12385. static readonly BILLBOARDMODE_STRETCHED: number;
  12386. /**
  12387. * This function can be defined to provide custom update for active particles.
  12388. * This function will be called instead of regular update (age, position, color, etc.).
  12389. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12390. */
  12391. updateFunction: (particles: Particle[]) => void;
  12392. private _emitterWorldMatrix;
  12393. /**
  12394. * This function can be defined to specify initial direction for every new particle.
  12395. * It by default use the emitterType defined function
  12396. */
  12397. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12398. /**
  12399. * This function can be defined to specify initial position for every new particle.
  12400. * It by default use the emitterType defined function
  12401. */
  12402. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12403. /**
  12404. * @hidden
  12405. */
  12406. _inheritedVelocityOffset: Vector3;
  12407. /**
  12408. * An event triggered when the system is disposed
  12409. */
  12410. onDisposeObservable: Observable<IParticleSystem>;
  12411. private _onDisposeObserver;
  12412. /**
  12413. * Sets a callback that will be triggered when the system is disposed
  12414. */
  12415. set onDispose(callback: () => void);
  12416. private _particles;
  12417. private _epsilon;
  12418. private _capacity;
  12419. private _stockParticles;
  12420. private _newPartsExcess;
  12421. private _vertexData;
  12422. private _vertexBuffer;
  12423. private _vertexBuffers;
  12424. private _spriteBuffer;
  12425. private _indexBuffer;
  12426. private _effect;
  12427. private _customEffect;
  12428. private _cachedDefines;
  12429. private _scaledColorStep;
  12430. private _colorDiff;
  12431. private _scaledDirection;
  12432. private _scaledGravity;
  12433. private _currentRenderId;
  12434. private _alive;
  12435. private _useInstancing;
  12436. private _started;
  12437. private _stopped;
  12438. private _actualFrame;
  12439. private _scaledUpdateSpeed;
  12440. private _vertexBufferSize;
  12441. /** @hidden */
  12442. _currentEmitRateGradient: Nullable<FactorGradient>;
  12443. /** @hidden */
  12444. _currentEmitRate1: number;
  12445. /** @hidden */
  12446. _currentEmitRate2: number;
  12447. /** @hidden */
  12448. _currentStartSizeGradient: Nullable<FactorGradient>;
  12449. /** @hidden */
  12450. _currentStartSize1: number;
  12451. /** @hidden */
  12452. _currentStartSize2: number;
  12453. private readonly _rawTextureWidth;
  12454. private _rampGradientsTexture;
  12455. private _useRampGradients;
  12456. /** Gets or sets a boolean indicating that ramp gradients must be used
  12457. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12458. */
  12459. get useRampGradients(): boolean;
  12460. set useRampGradients(value: boolean);
  12461. /**
  12462. * 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.
  12463. * 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: [])
  12464. */
  12465. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12466. private _subEmitters;
  12467. /**
  12468. * @hidden
  12469. * If the particle systems emitter should be disposed when the particle system is disposed
  12470. */
  12471. _disposeEmitterOnDispose: boolean;
  12472. /**
  12473. * The current active Sub-systems, this property is used by the root particle system only.
  12474. */
  12475. activeSubSystems: Array<ParticleSystem>;
  12476. /**
  12477. * Specifies if the particles are updated in emitter local space or world space
  12478. */
  12479. isLocal: boolean;
  12480. private _rootParticleSystem;
  12481. /**
  12482. * Gets the current list of active particles
  12483. */
  12484. get particles(): Particle[];
  12485. /**
  12486. * Gets the number of particles active at the same time.
  12487. * @returns The number of active particles.
  12488. */
  12489. getActiveCount(): number;
  12490. /**
  12491. * Returns the string "ParticleSystem"
  12492. * @returns a string containing the class name
  12493. */
  12494. getClassName(): string;
  12495. /**
  12496. * Gets a boolean indicating that the system is stopping
  12497. * @returns true if the system is currently stopping
  12498. */
  12499. isStopping(): boolean;
  12500. /**
  12501. * Gets the custom effect used to render the particles
  12502. * @param blendMode Blend mode for which the effect should be retrieved
  12503. * @returns The effect
  12504. */
  12505. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12506. /**
  12507. * Sets the custom effect used to render the particles
  12508. * @param effect The effect to set
  12509. * @param blendMode Blend mode for which the effect should be set
  12510. */
  12511. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12512. /** @hidden */
  12513. private _onBeforeDrawParticlesObservable;
  12514. /**
  12515. * Observable that will be called just before the particles are drawn
  12516. */
  12517. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12518. /**
  12519. * Gets the name of the particle vertex shader
  12520. */
  12521. get vertexShaderName(): string;
  12522. /**
  12523. * Instantiates a particle system.
  12524. * 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.
  12525. * @param name The name of the particle system
  12526. * @param capacity The max number of particles alive at the same time
  12527. * @param scene The scene the particle system belongs to
  12528. * @param customEffect a custom effect used to change the way particles are rendered by default
  12529. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12530. * @param epsilon Offset used to render the particles
  12531. */
  12532. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12533. private _addFactorGradient;
  12534. private _removeFactorGradient;
  12535. /**
  12536. * Adds a new life time gradient
  12537. * @param gradient defines the gradient to use (between 0 and 1)
  12538. * @param factor defines the life time factor to affect to the specified gradient
  12539. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12540. * @returns the current particle system
  12541. */
  12542. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12543. /**
  12544. * Remove a specific life time gradient
  12545. * @param gradient defines the gradient to remove
  12546. * @returns the current particle system
  12547. */
  12548. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12549. /**
  12550. * Adds a new size gradient
  12551. * @param gradient defines the gradient to use (between 0 and 1)
  12552. * @param factor defines the size factor to affect to the specified gradient
  12553. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12554. * @returns the current particle system
  12555. */
  12556. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12557. /**
  12558. * Remove a specific size gradient
  12559. * @param gradient defines the gradient to remove
  12560. * @returns the current particle system
  12561. */
  12562. removeSizeGradient(gradient: number): IParticleSystem;
  12563. /**
  12564. * Adds a new color remap gradient
  12565. * @param gradient defines the gradient to use (between 0 and 1)
  12566. * @param min defines the color remap minimal range
  12567. * @param max defines the color remap maximal range
  12568. * @returns the current particle system
  12569. */
  12570. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12571. /**
  12572. * Remove a specific color remap gradient
  12573. * @param gradient defines the gradient to remove
  12574. * @returns the current particle system
  12575. */
  12576. removeColorRemapGradient(gradient: number): IParticleSystem;
  12577. /**
  12578. * Adds a new alpha remap gradient
  12579. * @param gradient defines the gradient to use (between 0 and 1)
  12580. * @param min defines the alpha remap minimal range
  12581. * @param max defines the alpha remap maximal range
  12582. * @returns the current particle system
  12583. */
  12584. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12585. /**
  12586. * Remove a specific alpha remap gradient
  12587. * @param gradient defines the gradient to remove
  12588. * @returns the current particle system
  12589. */
  12590. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12591. /**
  12592. * Adds a new angular speed gradient
  12593. * @param gradient defines the gradient to use (between 0 and 1)
  12594. * @param factor defines the angular speed to affect to the specified gradient
  12595. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12596. * @returns the current particle system
  12597. */
  12598. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12599. /**
  12600. * Remove a specific angular speed gradient
  12601. * @param gradient defines the gradient to remove
  12602. * @returns the current particle system
  12603. */
  12604. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12605. /**
  12606. * Adds a new velocity gradient
  12607. * @param gradient defines the gradient to use (between 0 and 1)
  12608. * @param factor defines the velocity to affect to the specified gradient
  12609. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12610. * @returns the current particle system
  12611. */
  12612. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12613. /**
  12614. * Remove a specific velocity gradient
  12615. * @param gradient defines the gradient to remove
  12616. * @returns the current particle system
  12617. */
  12618. removeVelocityGradient(gradient: number): IParticleSystem;
  12619. /**
  12620. * Adds a new limit velocity gradient
  12621. * @param gradient defines the gradient to use (between 0 and 1)
  12622. * @param factor defines the limit velocity value to affect to the specified gradient
  12623. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12624. * @returns the current particle system
  12625. */
  12626. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12627. /**
  12628. * Remove a specific limit velocity gradient
  12629. * @param gradient defines the gradient to remove
  12630. * @returns the current particle system
  12631. */
  12632. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12633. /**
  12634. * Adds a new drag gradient
  12635. * @param gradient defines the gradient to use (between 0 and 1)
  12636. * @param factor defines the drag value to affect to the specified gradient
  12637. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12638. * @returns the current particle system
  12639. */
  12640. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12641. /**
  12642. * Remove a specific drag gradient
  12643. * @param gradient defines the gradient to remove
  12644. * @returns the current particle system
  12645. */
  12646. removeDragGradient(gradient: number): IParticleSystem;
  12647. /**
  12648. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12649. * @param gradient defines the gradient to use (between 0 and 1)
  12650. * @param factor defines the emit rate value to affect to the specified gradient
  12651. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12652. * @returns the current particle system
  12653. */
  12654. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12655. /**
  12656. * Remove a specific emit rate gradient
  12657. * @param gradient defines the gradient to remove
  12658. * @returns the current particle system
  12659. */
  12660. removeEmitRateGradient(gradient: number): IParticleSystem;
  12661. /**
  12662. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12663. * @param gradient defines the gradient to use (between 0 and 1)
  12664. * @param factor defines the start size value to affect to the specified gradient
  12665. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12666. * @returns the current particle system
  12667. */
  12668. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12669. /**
  12670. * Remove a specific start size gradient
  12671. * @param gradient defines the gradient to remove
  12672. * @returns the current particle system
  12673. */
  12674. removeStartSizeGradient(gradient: number): IParticleSystem;
  12675. private _createRampGradientTexture;
  12676. /**
  12677. * Gets the current list of ramp gradients.
  12678. * You must use addRampGradient and removeRampGradient to udpate this list
  12679. * @returns the list of ramp gradients
  12680. */
  12681. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12682. /** Force the system to rebuild all gradients that need to be resync */
  12683. forceRefreshGradients(): void;
  12684. private _syncRampGradientTexture;
  12685. /**
  12686. * Adds a new ramp gradient used to remap particle colors
  12687. * @param gradient defines the gradient to use (between 0 and 1)
  12688. * @param color defines the color to affect to the specified gradient
  12689. * @returns the current particle system
  12690. */
  12691. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12692. /**
  12693. * Remove a specific ramp gradient
  12694. * @param gradient defines the gradient to remove
  12695. * @returns the current particle system
  12696. */
  12697. removeRampGradient(gradient: number): ParticleSystem;
  12698. /**
  12699. * Adds a new color gradient
  12700. * @param gradient defines the gradient to use (between 0 and 1)
  12701. * @param color1 defines the color to affect to the specified gradient
  12702. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12703. * @returns this particle system
  12704. */
  12705. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12706. /**
  12707. * Remove a specific color gradient
  12708. * @param gradient defines the gradient to remove
  12709. * @returns this particle system
  12710. */
  12711. removeColorGradient(gradient: number): IParticleSystem;
  12712. private _fetchR;
  12713. protected _reset(): void;
  12714. private _resetEffect;
  12715. private _createVertexBuffers;
  12716. private _createIndexBuffer;
  12717. /**
  12718. * Gets the maximum number of particles active at the same time.
  12719. * @returns The max number of active particles.
  12720. */
  12721. getCapacity(): number;
  12722. /**
  12723. * Gets whether there are still active particles in the system.
  12724. * @returns True if it is alive, otherwise false.
  12725. */
  12726. isAlive(): boolean;
  12727. /**
  12728. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12729. * @returns True if it has been started, otherwise false.
  12730. */
  12731. isStarted(): boolean;
  12732. private _prepareSubEmitterInternalArray;
  12733. /**
  12734. * Starts the particle system and begins to emit
  12735. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12736. */
  12737. start(delay?: number): void;
  12738. /**
  12739. * Stops the particle system.
  12740. * @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.
  12741. */
  12742. stop(stopSubEmitters?: boolean): void;
  12743. /**
  12744. * Remove all active particles
  12745. */
  12746. reset(): void;
  12747. /**
  12748. * @hidden (for internal use only)
  12749. */
  12750. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12751. /**
  12752. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12753. * Its lifetime will start back at 0.
  12754. */
  12755. recycleParticle: (particle: Particle) => void;
  12756. private _stopSubEmitters;
  12757. private _createParticle;
  12758. private _removeFromRoot;
  12759. private _emitFromParticle;
  12760. private _update;
  12761. /** @hidden */
  12762. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12763. /** @hidden */
  12764. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12765. /**
  12766. * Fill the defines array according to the current settings of the particle system
  12767. * @param defines Array to be updated
  12768. * @param blendMode blend mode to take into account when updating the array
  12769. */
  12770. fillDefines(defines: Array<string>, blendMode: number): void;
  12771. /**
  12772. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  12773. * @param uniforms Uniforms array to fill
  12774. * @param attributes Attributes array to fill
  12775. * @param samplers Samplers array to fill
  12776. */
  12777. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  12778. /** @hidden */
  12779. private _getEffect;
  12780. /**
  12781. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12782. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12783. */
  12784. animate(preWarmOnly?: boolean): void;
  12785. private _appendParticleVertices;
  12786. /**
  12787. * Rebuilds the particle system.
  12788. */
  12789. rebuild(): void;
  12790. /**
  12791. * Is this system ready to be used/rendered
  12792. * @return true if the system is ready
  12793. */
  12794. isReady(): boolean;
  12795. private _render;
  12796. /**
  12797. * Renders the particle system in its current state.
  12798. * @returns the current number of particles
  12799. */
  12800. render(): number;
  12801. /**
  12802. * Disposes the particle system and free the associated resources
  12803. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12804. */
  12805. dispose(disposeTexture?: boolean): void;
  12806. /**
  12807. * Clones the particle system.
  12808. * @param name The name of the cloned object
  12809. * @param newEmitter The new emitter to use
  12810. * @returns the cloned particle system
  12811. */
  12812. clone(name: string, newEmitter: any): ParticleSystem;
  12813. /**
  12814. * Serializes the particle system to a JSON object
  12815. * @param serializeTexture defines if the texture must be serialized as well
  12816. * @returns the JSON object
  12817. */
  12818. serialize(serializeTexture?: boolean): any;
  12819. /** @hidden */
  12820. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12821. /** @hidden */
  12822. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12823. /**
  12824. * Parses a JSON object to create a particle system.
  12825. * @param parsedParticleSystem The JSON object to parse
  12826. * @param scene The scene to create the particle system in
  12827. * @param rootUrl The root url to use to load external dependencies like texture
  12828. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12829. * @returns the Parsed particle system
  12830. */
  12831. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12832. }
  12833. }
  12834. declare module BABYLON {
  12835. /**
  12836. * A particle represents one of the element emitted by a particle system.
  12837. * This is mainly define by its coordinates, direction, velocity and age.
  12838. */
  12839. export class Particle {
  12840. /**
  12841. * The particle system the particle belongs to.
  12842. */
  12843. particleSystem: ParticleSystem;
  12844. private static _Count;
  12845. /**
  12846. * Unique ID of the particle
  12847. */
  12848. id: number;
  12849. /**
  12850. * The world position of the particle in the scene.
  12851. */
  12852. position: Vector3;
  12853. /**
  12854. * The world direction of the particle in the scene.
  12855. */
  12856. direction: Vector3;
  12857. /**
  12858. * The color of the particle.
  12859. */
  12860. color: Color4;
  12861. /**
  12862. * The color change of the particle per step.
  12863. */
  12864. colorStep: Color4;
  12865. /**
  12866. * Defines how long will the life of the particle be.
  12867. */
  12868. lifeTime: number;
  12869. /**
  12870. * The current age of the particle.
  12871. */
  12872. age: number;
  12873. /**
  12874. * The current size of the particle.
  12875. */
  12876. size: number;
  12877. /**
  12878. * The current scale of the particle.
  12879. */
  12880. scale: Vector2;
  12881. /**
  12882. * The current angle of the particle.
  12883. */
  12884. angle: number;
  12885. /**
  12886. * Defines how fast is the angle changing.
  12887. */
  12888. angularSpeed: number;
  12889. /**
  12890. * Defines the cell index used by the particle to be rendered from a sprite.
  12891. */
  12892. cellIndex: number;
  12893. /**
  12894. * The information required to support color remapping
  12895. */
  12896. remapData: Vector4;
  12897. /** @hidden */
  12898. _randomCellOffset?: number;
  12899. /** @hidden */
  12900. _initialDirection: Nullable<Vector3>;
  12901. /** @hidden */
  12902. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12903. /** @hidden */
  12904. _initialStartSpriteCellID: number;
  12905. /** @hidden */
  12906. _initialEndSpriteCellID: number;
  12907. /** @hidden */
  12908. _currentColorGradient: Nullable<ColorGradient>;
  12909. /** @hidden */
  12910. _currentColor1: Color4;
  12911. /** @hidden */
  12912. _currentColor2: Color4;
  12913. /** @hidden */
  12914. _currentSizeGradient: Nullable<FactorGradient>;
  12915. /** @hidden */
  12916. _currentSize1: number;
  12917. /** @hidden */
  12918. _currentSize2: number;
  12919. /** @hidden */
  12920. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12921. /** @hidden */
  12922. _currentAngularSpeed1: number;
  12923. /** @hidden */
  12924. _currentAngularSpeed2: number;
  12925. /** @hidden */
  12926. _currentVelocityGradient: Nullable<FactorGradient>;
  12927. /** @hidden */
  12928. _currentVelocity1: number;
  12929. /** @hidden */
  12930. _currentVelocity2: number;
  12931. /** @hidden */
  12932. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12933. /** @hidden */
  12934. _currentLimitVelocity1: number;
  12935. /** @hidden */
  12936. _currentLimitVelocity2: number;
  12937. /** @hidden */
  12938. _currentDragGradient: Nullable<FactorGradient>;
  12939. /** @hidden */
  12940. _currentDrag1: number;
  12941. /** @hidden */
  12942. _currentDrag2: number;
  12943. /** @hidden */
  12944. _randomNoiseCoordinates1: Vector3;
  12945. /** @hidden */
  12946. _randomNoiseCoordinates2: Vector3;
  12947. /** @hidden */
  12948. _localPosition?: Vector3;
  12949. /**
  12950. * Creates a new instance Particle
  12951. * @param particleSystem the particle system the particle belongs to
  12952. */
  12953. constructor(
  12954. /**
  12955. * The particle system the particle belongs to.
  12956. */
  12957. particleSystem: ParticleSystem);
  12958. private updateCellInfoFromSystem;
  12959. /**
  12960. * Defines how the sprite cell index is updated for the particle
  12961. */
  12962. updateCellIndex(): void;
  12963. /** @hidden */
  12964. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12965. /** @hidden */
  12966. _inheritParticleInfoToSubEmitters(): void;
  12967. /** @hidden */
  12968. _reset(): void;
  12969. /**
  12970. * Copy the properties of particle to another one.
  12971. * @param other the particle to copy the information to.
  12972. */
  12973. copyTo(other: Particle): void;
  12974. }
  12975. }
  12976. declare module BABYLON {
  12977. /**
  12978. * Particle emitter represents a volume emitting particles.
  12979. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12980. */
  12981. export interface IParticleEmitterType {
  12982. /**
  12983. * Called by the particle System when the direction is computed for the created particle.
  12984. * @param worldMatrix is the world matrix of the particle system
  12985. * @param directionToUpdate is the direction vector to update with the result
  12986. * @param particle is the particle we are computed the direction for
  12987. * @param isLocal defines if the direction should be set in local space
  12988. */
  12989. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12990. /**
  12991. * Called by the particle System when the position is computed for the created particle.
  12992. * @param worldMatrix is the world matrix of the particle system
  12993. * @param positionToUpdate is the position vector to update with the result
  12994. * @param particle is the particle we are computed the position for
  12995. * @param isLocal defines if the position should be set in local space
  12996. */
  12997. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12998. /**
  12999. * Clones the current emitter and returns a copy of it
  13000. * @returns the new emitter
  13001. */
  13002. clone(): IParticleEmitterType;
  13003. /**
  13004. * Called by the GPUParticleSystem to setup the update shader
  13005. * @param effect defines the update shader
  13006. */
  13007. applyToShader(effect: Effect): void;
  13008. /**
  13009. * Returns a string to use to update the GPU particles update shader
  13010. * @returns the effect defines string
  13011. */
  13012. getEffectDefines(): string;
  13013. /**
  13014. * Returns a string representing the class name
  13015. * @returns a string containing the class name
  13016. */
  13017. getClassName(): string;
  13018. /**
  13019. * Serializes the particle system to a JSON object.
  13020. * @returns the JSON object
  13021. */
  13022. serialize(): any;
  13023. /**
  13024. * Parse properties from a JSON object
  13025. * @param serializationObject defines the JSON object
  13026. * @param scene defines the hosting scene
  13027. */
  13028. parse(serializationObject: any, scene: Scene): void;
  13029. }
  13030. }
  13031. declare module BABYLON {
  13032. /**
  13033. * Particle emitter emitting particles from the inside of a box.
  13034. * It emits the particles randomly between 2 given directions.
  13035. */
  13036. export class BoxParticleEmitter implements IParticleEmitterType {
  13037. /**
  13038. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13039. */
  13040. direction1: Vector3;
  13041. /**
  13042. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13043. */
  13044. direction2: Vector3;
  13045. /**
  13046. * 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.
  13047. */
  13048. minEmitBox: Vector3;
  13049. /**
  13050. * 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.
  13051. */
  13052. maxEmitBox: Vector3;
  13053. /**
  13054. * Creates a new instance BoxParticleEmitter
  13055. */
  13056. constructor();
  13057. /**
  13058. * Called by the particle System when the direction is computed for the created particle.
  13059. * @param worldMatrix is the world matrix of the particle system
  13060. * @param directionToUpdate is the direction vector to update with the result
  13061. * @param particle is the particle we are computed the direction for
  13062. * @param isLocal defines if the direction should be set in local space
  13063. */
  13064. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13065. /**
  13066. * Called by the particle System when the position is computed for the created particle.
  13067. * @param worldMatrix is the world matrix of the particle system
  13068. * @param positionToUpdate is the position vector to update with the result
  13069. * @param particle is the particle we are computed the position for
  13070. * @param isLocal defines if the position should be set in local space
  13071. */
  13072. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13073. /**
  13074. * Clones the current emitter and returns a copy of it
  13075. * @returns the new emitter
  13076. */
  13077. clone(): BoxParticleEmitter;
  13078. /**
  13079. * Called by the GPUParticleSystem to setup the update shader
  13080. * @param effect defines the update shader
  13081. */
  13082. applyToShader(effect: Effect): void;
  13083. /**
  13084. * Returns a string to use to update the GPU particles update shader
  13085. * @returns a string containng the defines string
  13086. */
  13087. getEffectDefines(): string;
  13088. /**
  13089. * Returns the string "BoxParticleEmitter"
  13090. * @returns a string containing the class name
  13091. */
  13092. getClassName(): string;
  13093. /**
  13094. * Serializes the particle system to a JSON object.
  13095. * @returns the JSON object
  13096. */
  13097. serialize(): any;
  13098. /**
  13099. * Parse properties from a JSON object
  13100. * @param serializationObject defines the JSON object
  13101. */
  13102. parse(serializationObject: any): void;
  13103. }
  13104. }
  13105. declare module BABYLON {
  13106. /**
  13107. * Particle emitter emitting particles from the inside of a cone.
  13108. * It emits the particles alongside the cone volume from the base to the particle.
  13109. * The emission direction might be randomized.
  13110. */
  13111. export class ConeParticleEmitter implements IParticleEmitterType {
  13112. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13113. directionRandomizer: number;
  13114. private _radius;
  13115. private _angle;
  13116. private _height;
  13117. /**
  13118. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13119. */
  13120. radiusRange: number;
  13121. /**
  13122. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13123. */
  13124. heightRange: number;
  13125. /**
  13126. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13127. */
  13128. emitFromSpawnPointOnly: boolean;
  13129. /**
  13130. * Gets or sets the radius of the emission cone
  13131. */
  13132. get radius(): number;
  13133. set radius(value: number);
  13134. /**
  13135. * Gets or sets the angle of the emission cone
  13136. */
  13137. get angle(): number;
  13138. set angle(value: number);
  13139. private _buildHeight;
  13140. /**
  13141. * Creates a new instance ConeParticleEmitter
  13142. * @param radius the radius of the emission cone (1 by default)
  13143. * @param angle the cone base angle (PI by default)
  13144. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13145. */
  13146. constructor(radius?: number, angle?: number,
  13147. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13148. directionRandomizer?: number);
  13149. /**
  13150. * Called by the particle System when the direction is computed for the created particle.
  13151. * @param worldMatrix is the world matrix of the particle system
  13152. * @param directionToUpdate is the direction vector to update with the result
  13153. * @param particle is the particle we are computed the direction for
  13154. * @param isLocal defines if the direction should be set in local space
  13155. */
  13156. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13157. /**
  13158. * Called by the particle System when the position is computed for the created particle.
  13159. * @param worldMatrix is the world matrix of the particle system
  13160. * @param positionToUpdate is the position vector to update with the result
  13161. * @param particle is the particle we are computed the position for
  13162. * @param isLocal defines if the position should be set in local space
  13163. */
  13164. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13165. /**
  13166. * Clones the current emitter and returns a copy of it
  13167. * @returns the new emitter
  13168. */
  13169. clone(): ConeParticleEmitter;
  13170. /**
  13171. * Called by the GPUParticleSystem to setup the update shader
  13172. * @param effect defines the update shader
  13173. */
  13174. applyToShader(effect: Effect): void;
  13175. /**
  13176. * Returns a string to use to update the GPU particles update shader
  13177. * @returns a string containng the defines string
  13178. */
  13179. getEffectDefines(): string;
  13180. /**
  13181. * Returns the string "ConeParticleEmitter"
  13182. * @returns a string containing the class name
  13183. */
  13184. getClassName(): string;
  13185. /**
  13186. * Serializes the particle system to a JSON object.
  13187. * @returns the JSON object
  13188. */
  13189. serialize(): any;
  13190. /**
  13191. * Parse properties from a JSON object
  13192. * @param serializationObject defines the JSON object
  13193. */
  13194. parse(serializationObject: any): void;
  13195. }
  13196. }
  13197. declare module BABYLON {
  13198. /**
  13199. * Particle emitter emitting particles from the inside of a cylinder.
  13200. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13201. */
  13202. export class CylinderParticleEmitter implements IParticleEmitterType {
  13203. /**
  13204. * The radius of the emission cylinder.
  13205. */
  13206. radius: number;
  13207. /**
  13208. * The height of the emission cylinder.
  13209. */
  13210. height: number;
  13211. /**
  13212. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13213. */
  13214. radiusRange: number;
  13215. /**
  13216. * How much to randomize the particle direction [0-1].
  13217. */
  13218. directionRandomizer: number;
  13219. /**
  13220. * Creates a new instance CylinderParticleEmitter
  13221. * @param radius the radius of the emission cylinder (1 by default)
  13222. * @param height the height of the emission cylinder (1 by default)
  13223. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13224. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13225. */
  13226. constructor(
  13227. /**
  13228. * The radius of the emission cylinder.
  13229. */
  13230. radius?: number,
  13231. /**
  13232. * The height of the emission cylinder.
  13233. */
  13234. height?: number,
  13235. /**
  13236. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13237. */
  13238. radiusRange?: number,
  13239. /**
  13240. * How much to randomize the particle direction [0-1].
  13241. */
  13242. directionRandomizer?: number);
  13243. /**
  13244. * Called by the particle System when the direction is computed for the created particle.
  13245. * @param worldMatrix is the world matrix of the particle system
  13246. * @param directionToUpdate is the direction vector to update with the result
  13247. * @param particle is the particle we are computed the direction for
  13248. * @param isLocal defines if the direction should be set in local space
  13249. */
  13250. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13251. /**
  13252. * Called by the particle System when the position is computed for the created particle.
  13253. * @param worldMatrix is the world matrix of the particle system
  13254. * @param positionToUpdate is the position vector to update with the result
  13255. * @param particle is the particle we are computed the position for
  13256. * @param isLocal defines if the position should be set in local space
  13257. */
  13258. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13259. /**
  13260. * Clones the current emitter and returns a copy of it
  13261. * @returns the new emitter
  13262. */
  13263. clone(): CylinderParticleEmitter;
  13264. /**
  13265. * Called by the GPUParticleSystem to setup the update shader
  13266. * @param effect defines the update shader
  13267. */
  13268. applyToShader(effect: Effect): void;
  13269. /**
  13270. * Returns a string to use to update the GPU particles update shader
  13271. * @returns a string containng the defines string
  13272. */
  13273. getEffectDefines(): string;
  13274. /**
  13275. * Returns the string "CylinderParticleEmitter"
  13276. * @returns a string containing the class name
  13277. */
  13278. getClassName(): string;
  13279. /**
  13280. * Serializes the particle system to a JSON object.
  13281. * @returns the JSON object
  13282. */
  13283. serialize(): any;
  13284. /**
  13285. * Parse properties from a JSON object
  13286. * @param serializationObject defines the JSON object
  13287. */
  13288. parse(serializationObject: any): void;
  13289. }
  13290. /**
  13291. * Particle emitter emitting particles from the inside of a cylinder.
  13292. * It emits the particles randomly between two vectors.
  13293. */
  13294. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13295. /**
  13296. * The min limit of the emission direction.
  13297. */
  13298. direction1: Vector3;
  13299. /**
  13300. * The max limit of the emission direction.
  13301. */
  13302. direction2: Vector3;
  13303. /**
  13304. * Creates a new instance CylinderDirectedParticleEmitter
  13305. * @param radius the radius of the emission cylinder (1 by default)
  13306. * @param height the height of the emission cylinder (1 by default)
  13307. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13308. * @param direction1 the min limit of the emission direction (up vector by default)
  13309. * @param direction2 the max limit of the emission direction (up vector by default)
  13310. */
  13311. constructor(radius?: number, height?: number, radiusRange?: number,
  13312. /**
  13313. * The min limit of the emission direction.
  13314. */
  13315. direction1?: Vector3,
  13316. /**
  13317. * The max limit of the emission direction.
  13318. */
  13319. direction2?: Vector3);
  13320. /**
  13321. * Called by the particle System when the direction is computed for the created particle.
  13322. * @param worldMatrix is the world matrix of the particle system
  13323. * @param directionToUpdate is the direction vector to update with the result
  13324. * @param particle is the particle we are computed the direction for
  13325. */
  13326. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13327. /**
  13328. * Clones the current emitter and returns a copy of it
  13329. * @returns the new emitter
  13330. */
  13331. clone(): CylinderDirectedParticleEmitter;
  13332. /**
  13333. * Called by the GPUParticleSystem to setup the update shader
  13334. * @param effect defines the update shader
  13335. */
  13336. applyToShader(effect: Effect): void;
  13337. /**
  13338. * Returns a string to use to update the GPU particles update shader
  13339. * @returns a string containng the defines string
  13340. */
  13341. getEffectDefines(): string;
  13342. /**
  13343. * Returns the string "CylinderDirectedParticleEmitter"
  13344. * @returns a string containing the class name
  13345. */
  13346. getClassName(): string;
  13347. /**
  13348. * Serializes the particle system to a JSON object.
  13349. * @returns the JSON object
  13350. */
  13351. serialize(): any;
  13352. /**
  13353. * Parse properties from a JSON object
  13354. * @param serializationObject defines the JSON object
  13355. */
  13356. parse(serializationObject: any): void;
  13357. }
  13358. }
  13359. declare module BABYLON {
  13360. /**
  13361. * Particle emitter emitting particles from the inside of a hemisphere.
  13362. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13363. */
  13364. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13365. /**
  13366. * The radius of the emission hemisphere.
  13367. */
  13368. radius: number;
  13369. /**
  13370. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13371. */
  13372. radiusRange: number;
  13373. /**
  13374. * How much to randomize the particle direction [0-1].
  13375. */
  13376. directionRandomizer: number;
  13377. /**
  13378. * Creates a new instance HemisphericParticleEmitter
  13379. * @param radius the radius of the emission hemisphere (1 by default)
  13380. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13381. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13382. */
  13383. constructor(
  13384. /**
  13385. * The radius of the emission hemisphere.
  13386. */
  13387. radius?: number,
  13388. /**
  13389. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13390. */
  13391. radiusRange?: number,
  13392. /**
  13393. * How much to randomize the particle direction [0-1].
  13394. */
  13395. directionRandomizer?: number);
  13396. /**
  13397. * Called by the particle System when the direction is computed for the created particle.
  13398. * @param worldMatrix is the world matrix of the particle system
  13399. * @param directionToUpdate is the direction vector to update with the result
  13400. * @param particle is the particle we are computed the direction for
  13401. * @param isLocal defines if the direction should be set in local space
  13402. */
  13403. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13404. /**
  13405. * Called by the particle System when the position is computed for the created particle.
  13406. * @param worldMatrix is the world matrix of the particle system
  13407. * @param positionToUpdate is the position vector to update with the result
  13408. * @param particle is the particle we are computed the position for
  13409. * @param isLocal defines if the position should be set in local space
  13410. */
  13411. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13412. /**
  13413. * Clones the current emitter and returns a copy of it
  13414. * @returns the new emitter
  13415. */
  13416. clone(): HemisphericParticleEmitter;
  13417. /**
  13418. * Called by the GPUParticleSystem to setup the update shader
  13419. * @param effect defines the update shader
  13420. */
  13421. applyToShader(effect: Effect): void;
  13422. /**
  13423. * Returns a string to use to update the GPU particles update shader
  13424. * @returns a string containng the defines string
  13425. */
  13426. getEffectDefines(): string;
  13427. /**
  13428. * Returns the string "HemisphericParticleEmitter"
  13429. * @returns a string containing the class name
  13430. */
  13431. getClassName(): string;
  13432. /**
  13433. * Serializes the particle system to a JSON object.
  13434. * @returns the JSON object
  13435. */
  13436. serialize(): any;
  13437. /**
  13438. * Parse properties from a JSON object
  13439. * @param serializationObject defines the JSON object
  13440. */
  13441. parse(serializationObject: any): void;
  13442. }
  13443. }
  13444. declare module BABYLON {
  13445. /**
  13446. * Particle emitter emitting particles from a point.
  13447. * It emits the particles randomly between 2 given directions.
  13448. */
  13449. export class PointParticleEmitter implements IParticleEmitterType {
  13450. /**
  13451. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13452. */
  13453. direction1: Vector3;
  13454. /**
  13455. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13456. */
  13457. direction2: Vector3;
  13458. /**
  13459. * Creates a new instance PointParticleEmitter
  13460. */
  13461. constructor();
  13462. /**
  13463. * Called by the particle System when the direction is computed for the created particle.
  13464. * @param worldMatrix is the world matrix of the particle system
  13465. * @param directionToUpdate is the direction vector to update with the result
  13466. * @param particle is the particle we are computed the direction for
  13467. * @param isLocal defines if the direction should be set in local space
  13468. */
  13469. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13470. /**
  13471. * Called by the particle System when the position is computed for the created particle.
  13472. * @param worldMatrix is the world matrix of the particle system
  13473. * @param positionToUpdate is the position vector to update with the result
  13474. * @param particle is the particle we are computed the position for
  13475. * @param isLocal defines if the position should be set in local space
  13476. */
  13477. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13478. /**
  13479. * Clones the current emitter and returns a copy of it
  13480. * @returns the new emitter
  13481. */
  13482. clone(): PointParticleEmitter;
  13483. /**
  13484. * Called by the GPUParticleSystem to setup the update shader
  13485. * @param effect defines the update shader
  13486. */
  13487. applyToShader(effect: Effect): void;
  13488. /**
  13489. * Returns a string to use to update the GPU particles update shader
  13490. * @returns a string containng the defines string
  13491. */
  13492. getEffectDefines(): string;
  13493. /**
  13494. * Returns the string "PointParticleEmitter"
  13495. * @returns a string containing the class name
  13496. */
  13497. getClassName(): string;
  13498. /**
  13499. * Serializes the particle system to a JSON object.
  13500. * @returns the JSON object
  13501. */
  13502. serialize(): any;
  13503. /**
  13504. * Parse properties from a JSON object
  13505. * @param serializationObject defines the JSON object
  13506. */
  13507. parse(serializationObject: any): void;
  13508. }
  13509. }
  13510. declare module BABYLON {
  13511. /**
  13512. * Particle emitter emitting particles from the inside of a sphere.
  13513. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13514. */
  13515. export class SphereParticleEmitter implements IParticleEmitterType {
  13516. /**
  13517. * The radius of the emission sphere.
  13518. */
  13519. radius: number;
  13520. /**
  13521. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13522. */
  13523. radiusRange: number;
  13524. /**
  13525. * How much to randomize the particle direction [0-1].
  13526. */
  13527. directionRandomizer: number;
  13528. /**
  13529. * Creates a new instance SphereParticleEmitter
  13530. * @param radius the radius of the emission sphere (1 by default)
  13531. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13532. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13533. */
  13534. constructor(
  13535. /**
  13536. * The radius of the emission sphere.
  13537. */
  13538. radius?: number,
  13539. /**
  13540. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13541. */
  13542. radiusRange?: number,
  13543. /**
  13544. * How much to randomize the particle direction [0-1].
  13545. */
  13546. directionRandomizer?: number);
  13547. /**
  13548. * Called by the particle System when the direction is computed for the created particle.
  13549. * @param worldMatrix is the world matrix of the particle system
  13550. * @param directionToUpdate is the direction vector to update with the result
  13551. * @param particle is the particle we are computed the direction for
  13552. * @param isLocal defines if the direction should be set in local space
  13553. */
  13554. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13555. /**
  13556. * Called by the particle System when the position is computed for the created particle.
  13557. * @param worldMatrix is the world matrix of the particle system
  13558. * @param positionToUpdate is the position vector to update with the result
  13559. * @param particle is the particle we are computed the position for
  13560. * @param isLocal defines if the position should be set in local space
  13561. */
  13562. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13563. /**
  13564. * Clones the current emitter and returns a copy of it
  13565. * @returns the new emitter
  13566. */
  13567. clone(): SphereParticleEmitter;
  13568. /**
  13569. * Called by the GPUParticleSystem to setup the update shader
  13570. * @param effect defines the update shader
  13571. */
  13572. applyToShader(effect: Effect): void;
  13573. /**
  13574. * Returns a string to use to update the GPU particles update shader
  13575. * @returns a string containng the defines string
  13576. */
  13577. getEffectDefines(): string;
  13578. /**
  13579. * Returns the string "SphereParticleEmitter"
  13580. * @returns a string containing the class name
  13581. */
  13582. getClassName(): string;
  13583. /**
  13584. * Serializes the particle system to a JSON object.
  13585. * @returns the JSON object
  13586. */
  13587. serialize(): any;
  13588. /**
  13589. * Parse properties from a JSON object
  13590. * @param serializationObject defines the JSON object
  13591. */
  13592. parse(serializationObject: any): void;
  13593. }
  13594. /**
  13595. * Particle emitter emitting particles from the inside of a sphere.
  13596. * It emits the particles randomly between two vectors.
  13597. */
  13598. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13599. /**
  13600. * The min limit of the emission direction.
  13601. */
  13602. direction1: Vector3;
  13603. /**
  13604. * The max limit of the emission direction.
  13605. */
  13606. direction2: Vector3;
  13607. /**
  13608. * Creates a new instance SphereDirectedParticleEmitter
  13609. * @param radius the radius of the emission sphere (1 by default)
  13610. * @param direction1 the min limit of the emission direction (up vector by default)
  13611. * @param direction2 the max limit of the emission direction (up vector by default)
  13612. */
  13613. constructor(radius?: number,
  13614. /**
  13615. * The min limit of the emission direction.
  13616. */
  13617. direction1?: Vector3,
  13618. /**
  13619. * The max limit of the emission direction.
  13620. */
  13621. direction2?: Vector3);
  13622. /**
  13623. * Called by the particle System when the direction is computed for the created particle.
  13624. * @param worldMatrix is the world matrix of the particle system
  13625. * @param directionToUpdate is the direction vector to update with the result
  13626. * @param particle is the particle we are computed the direction for
  13627. */
  13628. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13629. /**
  13630. * Clones the current emitter and returns a copy of it
  13631. * @returns the new emitter
  13632. */
  13633. clone(): SphereDirectedParticleEmitter;
  13634. /**
  13635. * Called by the GPUParticleSystem to setup the update shader
  13636. * @param effect defines the update shader
  13637. */
  13638. applyToShader(effect: Effect): void;
  13639. /**
  13640. * Returns a string to use to update the GPU particles update shader
  13641. * @returns a string containng the defines string
  13642. */
  13643. getEffectDefines(): string;
  13644. /**
  13645. * Returns the string "SphereDirectedParticleEmitter"
  13646. * @returns a string containing the class name
  13647. */
  13648. getClassName(): string;
  13649. /**
  13650. * Serializes the particle system to a JSON object.
  13651. * @returns the JSON object
  13652. */
  13653. serialize(): any;
  13654. /**
  13655. * Parse properties from a JSON object
  13656. * @param serializationObject defines the JSON object
  13657. */
  13658. parse(serializationObject: any): void;
  13659. }
  13660. }
  13661. declare module BABYLON {
  13662. /**
  13663. * Particle emitter emitting particles from a custom list of positions.
  13664. */
  13665. export class CustomParticleEmitter implements IParticleEmitterType {
  13666. /**
  13667. * Gets or sets the position generator that will create the inital position of each particle.
  13668. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13669. */
  13670. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13671. /**
  13672. * Gets or sets the destination generator that will create the final destination of each particle.
  13673. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13674. */
  13675. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13676. /**
  13677. * Creates a new instance CustomParticleEmitter
  13678. */
  13679. constructor();
  13680. /**
  13681. * Called by the particle System when the direction is computed for the created particle.
  13682. * @param worldMatrix is the world matrix of the particle system
  13683. * @param directionToUpdate is the direction vector to update with the result
  13684. * @param particle is the particle we are computed the direction for
  13685. * @param isLocal defines if the direction should be set in local space
  13686. */
  13687. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13688. /**
  13689. * Called by the particle System when the position is computed for the created particle.
  13690. * @param worldMatrix is the world matrix of the particle system
  13691. * @param positionToUpdate is the position vector to update with the result
  13692. * @param particle is the particle we are computed the position for
  13693. * @param isLocal defines if the position should be set in local space
  13694. */
  13695. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13696. /**
  13697. * Clones the current emitter and returns a copy of it
  13698. * @returns the new emitter
  13699. */
  13700. clone(): CustomParticleEmitter;
  13701. /**
  13702. * Called by the GPUParticleSystem to setup the update shader
  13703. * @param effect defines the update shader
  13704. */
  13705. applyToShader(effect: Effect): void;
  13706. /**
  13707. * Returns a string to use to update the GPU particles update shader
  13708. * @returns a string containng the defines string
  13709. */
  13710. getEffectDefines(): string;
  13711. /**
  13712. * Returns the string "PointParticleEmitter"
  13713. * @returns a string containing the class name
  13714. */
  13715. getClassName(): string;
  13716. /**
  13717. * Serializes the particle system to a JSON object.
  13718. * @returns the JSON object
  13719. */
  13720. serialize(): any;
  13721. /**
  13722. * Parse properties from a JSON object
  13723. * @param serializationObject defines the JSON object
  13724. */
  13725. parse(serializationObject: any): void;
  13726. }
  13727. }
  13728. declare module BABYLON {
  13729. /**
  13730. * Particle emitter emitting particles from the inside of a box.
  13731. * It emits the particles randomly between 2 given directions.
  13732. */
  13733. export class MeshParticleEmitter implements IParticleEmitterType {
  13734. private _indices;
  13735. private _positions;
  13736. private _normals;
  13737. private _storedNormal;
  13738. private _mesh;
  13739. /**
  13740. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13741. */
  13742. direction1: Vector3;
  13743. /**
  13744. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13745. */
  13746. direction2: Vector3;
  13747. /**
  13748. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13749. */
  13750. useMeshNormalsForDirection: boolean;
  13751. /** Defines the mesh to use as source */
  13752. get mesh(): Nullable<AbstractMesh>;
  13753. set mesh(value: Nullable<AbstractMesh>);
  13754. /**
  13755. * Creates a new instance MeshParticleEmitter
  13756. * @param mesh defines the mesh to use as source
  13757. */
  13758. constructor(mesh?: Nullable<AbstractMesh>);
  13759. /**
  13760. * Called by the particle System when the direction is computed for the created particle.
  13761. * @param worldMatrix is the world matrix of the particle system
  13762. * @param directionToUpdate is the direction vector to update with the result
  13763. * @param particle is the particle we are computed the direction for
  13764. * @param isLocal defines if the direction should be set in local space
  13765. */
  13766. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13767. /**
  13768. * Called by the particle System when the position is computed for the created particle.
  13769. * @param worldMatrix is the world matrix of the particle system
  13770. * @param positionToUpdate is the position vector to update with the result
  13771. * @param particle is the particle we are computed the position for
  13772. * @param isLocal defines if the position should be set in local space
  13773. */
  13774. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13775. /**
  13776. * Clones the current emitter and returns a copy of it
  13777. * @returns the new emitter
  13778. */
  13779. clone(): MeshParticleEmitter;
  13780. /**
  13781. * Called by the GPUParticleSystem to setup the update shader
  13782. * @param effect defines the update shader
  13783. */
  13784. applyToShader(effect: Effect): void;
  13785. /**
  13786. * Returns a string to use to update the GPU particles update shader
  13787. * @returns a string containng the defines string
  13788. */
  13789. getEffectDefines(): string;
  13790. /**
  13791. * Returns the string "BoxParticleEmitter"
  13792. * @returns a string containing the class name
  13793. */
  13794. getClassName(): string;
  13795. /**
  13796. * Serializes the particle system to a JSON object.
  13797. * @returns the JSON object
  13798. */
  13799. serialize(): any;
  13800. /**
  13801. * Parse properties from a JSON object
  13802. * @param serializationObject defines the JSON object
  13803. * @param scene defines the hosting scene
  13804. */
  13805. parse(serializationObject: any, scene: Scene): void;
  13806. }
  13807. }
  13808. declare module BABYLON {
  13809. /**
  13810. * Interface representing a particle system in Babylon.js.
  13811. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13812. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13813. */
  13814. export interface IParticleSystem {
  13815. /**
  13816. * List of animations used by the particle system.
  13817. */
  13818. animations: Animation[];
  13819. /**
  13820. * The id of the Particle system.
  13821. */
  13822. id: string;
  13823. /**
  13824. * The name of the Particle system.
  13825. */
  13826. name: string;
  13827. /**
  13828. * The emitter represents the Mesh or position we are attaching the particle system to.
  13829. */
  13830. emitter: Nullable<AbstractMesh | Vector3>;
  13831. /**
  13832. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13833. */
  13834. isBillboardBased: boolean;
  13835. /**
  13836. * The rendering group used by the Particle system to chose when to render.
  13837. */
  13838. renderingGroupId: number;
  13839. /**
  13840. * The layer mask we are rendering the particles through.
  13841. */
  13842. layerMask: number;
  13843. /**
  13844. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13845. */
  13846. updateSpeed: number;
  13847. /**
  13848. * The amount of time the particle system is running (depends of the overall update speed).
  13849. */
  13850. targetStopDuration: number;
  13851. /**
  13852. * The texture used to render each particle. (this can be a spritesheet)
  13853. */
  13854. particleTexture: Nullable<Texture>;
  13855. /**
  13856. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13857. */
  13858. blendMode: number;
  13859. /**
  13860. * Minimum life time of emitting particles.
  13861. */
  13862. minLifeTime: number;
  13863. /**
  13864. * Maximum life time of emitting particles.
  13865. */
  13866. maxLifeTime: number;
  13867. /**
  13868. * Minimum Size of emitting particles.
  13869. */
  13870. minSize: number;
  13871. /**
  13872. * Maximum Size of emitting particles.
  13873. */
  13874. maxSize: number;
  13875. /**
  13876. * Minimum scale of emitting particles on X axis.
  13877. */
  13878. minScaleX: number;
  13879. /**
  13880. * Maximum scale of emitting particles on X axis.
  13881. */
  13882. maxScaleX: number;
  13883. /**
  13884. * Minimum scale of emitting particles on Y axis.
  13885. */
  13886. minScaleY: number;
  13887. /**
  13888. * Maximum scale of emitting particles on Y axis.
  13889. */
  13890. maxScaleY: number;
  13891. /**
  13892. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13893. */
  13894. color1: Color4;
  13895. /**
  13896. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13897. */
  13898. color2: Color4;
  13899. /**
  13900. * Color the particle will have at the end of its lifetime.
  13901. */
  13902. colorDead: Color4;
  13903. /**
  13904. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13905. */
  13906. emitRate: number;
  13907. /**
  13908. * You can use gravity if you want to give an orientation to your particles.
  13909. */
  13910. gravity: Vector3;
  13911. /**
  13912. * Minimum power of emitting particles.
  13913. */
  13914. minEmitPower: number;
  13915. /**
  13916. * Maximum power of emitting particles.
  13917. */
  13918. maxEmitPower: number;
  13919. /**
  13920. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13921. */
  13922. minAngularSpeed: number;
  13923. /**
  13924. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13925. */
  13926. maxAngularSpeed: number;
  13927. /**
  13928. * Gets or sets the minimal initial rotation in radians.
  13929. */
  13930. minInitialRotation: number;
  13931. /**
  13932. * Gets or sets the maximal initial rotation in radians.
  13933. */
  13934. maxInitialRotation: number;
  13935. /**
  13936. * The particle emitter type defines the emitter used by the particle system.
  13937. * It can be for example box, sphere, or cone...
  13938. */
  13939. particleEmitterType: Nullable<IParticleEmitterType>;
  13940. /**
  13941. * Defines the delay in milliseconds before starting the system (0 by default)
  13942. */
  13943. startDelay: number;
  13944. /**
  13945. * 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
  13946. */
  13947. preWarmCycles: number;
  13948. /**
  13949. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13950. */
  13951. preWarmStepOffset: number;
  13952. /**
  13953. * 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)
  13954. */
  13955. spriteCellChangeSpeed: number;
  13956. /**
  13957. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13958. */
  13959. startSpriteCellID: number;
  13960. /**
  13961. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13962. */
  13963. endSpriteCellID: number;
  13964. /**
  13965. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13966. */
  13967. spriteCellWidth: number;
  13968. /**
  13969. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13970. */
  13971. spriteCellHeight: number;
  13972. /**
  13973. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13974. */
  13975. spriteRandomStartCell: boolean;
  13976. /**
  13977. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13978. */
  13979. isAnimationSheetEnabled: boolean;
  13980. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13981. translationPivot: Vector2;
  13982. /**
  13983. * Gets or sets a texture used to add random noise to particle positions
  13984. */
  13985. noiseTexture: Nullable<BaseTexture>;
  13986. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13987. noiseStrength: Vector3;
  13988. /**
  13989. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13990. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13991. */
  13992. billboardMode: number;
  13993. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13994. limitVelocityDamping: number;
  13995. /**
  13996. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13997. */
  13998. beginAnimationOnStart: boolean;
  13999. /**
  14000. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14001. */
  14002. beginAnimationFrom: number;
  14003. /**
  14004. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14005. */
  14006. beginAnimationTo: number;
  14007. /**
  14008. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14009. */
  14010. beginAnimationLoop: boolean;
  14011. /**
  14012. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14013. */
  14014. disposeOnStop: boolean;
  14015. /**
  14016. * Specifies if the particles are updated in emitter local space or world space
  14017. */
  14018. isLocal: boolean;
  14019. /** Snippet ID if the particle system was created from the snippet server */
  14020. snippetId: string;
  14021. /**
  14022. * Gets the maximum number of particles active at the same time.
  14023. * @returns The max number of active particles.
  14024. */
  14025. getCapacity(): number;
  14026. /**
  14027. * Gets the number of particles active at the same time.
  14028. * @returns The number of active particles.
  14029. */
  14030. getActiveCount(): number;
  14031. /**
  14032. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14033. * @returns True if it has been started, otherwise false.
  14034. */
  14035. isStarted(): boolean;
  14036. /**
  14037. * Animates the particle system for this frame.
  14038. */
  14039. animate(): void;
  14040. /**
  14041. * Renders the particle system in its current state.
  14042. * @returns the current number of particles
  14043. */
  14044. render(): number;
  14045. /**
  14046. * Dispose the particle system and frees its associated resources.
  14047. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14048. */
  14049. dispose(disposeTexture?: boolean): void;
  14050. /**
  14051. * An event triggered when the system is disposed
  14052. */
  14053. onDisposeObservable: Observable<IParticleSystem>;
  14054. /**
  14055. * Clones the particle system.
  14056. * @param name The name of the cloned object
  14057. * @param newEmitter The new emitter to use
  14058. * @returns the cloned particle system
  14059. */
  14060. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14061. /**
  14062. * Serializes the particle system to a JSON object
  14063. * @param serializeTexture defines if the texture must be serialized as well
  14064. * @returns the JSON object
  14065. */
  14066. serialize(serializeTexture: boolean): any;
  14067. /**
  14068. * Rebuild the particle system
  14069. */
  14070. rebuild(): void;
  14071. /** Force the system to rebuild all gradients that need to be resync */
  14072. forceRefreshGradients(): void;
  14073. /**
  14074. * Starts the particle system and begins to emit
  14075. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14076. */
  14077. start(delay?: number): void;
  14078. /**
  14079. * Stops the particle system.
  14080. */
  14081. stop(): void;
  14082. /**
  14083. * Remove all active particles
  14084. */
  14085. reset(): void;
  14086. /**
  14087. * Gets a boolean indicating that the system is stopping
  14088. * @returns true if the system is currently stopping
  14089. */
  14090. isStopping(): boolean;
  14091. /**
  14092. * Is this system ready to be used/rendered
  14093. * @return true if the system is ready
  14094. */
  14095. isReady(): boolean;
  14096. /**
  14097. * Returns the string "ParticleSystem"
  14098. * @returns a string containing the class name
  14099. */
  14100. getClassName(): string;
  14101. /**
  14102. * Gets the custom effect used to render the particles
  14103. * @param blendMode Blend mode for which the effect should be retrieved
  14104. * @returns The effect
  14105. */
  14106. getCustomEffect(blendMode: number): Nullable<Effect>;
  14107. /**
  14108. * Sets the custom effect used to render the particles
  14109. * @param effect The effect to set
  14110. * @param blendMode Blend mode for which the effect should be set
  14111. */
  14112. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14113. /**
  14114. * Fill the defines array according to the current settings of the particle system
  14115. * @param defines Array to be updated
  14116. * @param blendMode blend mode to take into account when updating the array
  14117. */
  14118. fillDefines(defines: Array<string>, blendMode: number): void;
  14119. /**
  14120. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14121. * @param uniforms Uniforms array to fill
  14122. * @param attributes Attributes array to fill
  14123. * @param samplers Samplers array to fill
  14124. */
  14125. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14126. /**
  14127. * Observable that will be called just before the particles are drawn
  14128. */
  14129. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14130. /**
  14131. * Gets the name of the particle vertex shader
  14132. */
  14133. vertexShaderName: string;
  14134. /**
  14135. * Adds a new color gradient
  14136. * @param gradient defines the gradient to use (between 0 and 1)
  14137. * @param color1 defines the color to affect to the specified gradient
  14138. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14139. * @returns the current particle system
  14140. */
  14141. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14142. /**
  14143. * Remove a specific color gradient
  14144. * @param gradient defines the gradient to remove
  14145. * @returns the current particle system
  14146. */
  14147. removeColorGradient(gradient: number): IParticleSystem;
  14148. /**
  14149. * Adds a new size gradient
  14150. * @param gradient defines the gradient to use (between 0 and 1)
  14151. * @param factor defines the size factor to affect to the specified gradient
  14152. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14153. * @returns the current particle system
  14154. */
  14155. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14156. /**
  14157. * Remove a specific size gradient
  14158. * @param gradient defines the gradient to remove
  14159. * @returns the current particle system
  14160. */
  14161. removeSizeGradient(gradient: number): IParticleSystem;
  14162. /**
  14163. * Gets the current list of color gradients.
  14164. * You must use addColorGradient and removeColorGradient to udpate this list
  14165. * @returns the list of color gradients
  14166. */
  14167. getColorGradients(): Nullable<Array<ColorGradient>>;
  14168. /**
  14169. * Gets the current list of size gradients.
  14170. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14171. * @returns the list of size gradients
  14172. */
  14173. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14174. /**
  14175. * Gets the current list of angular speed gradients.
  14176. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14177. * @returns the list of angular speed gradients
  14178. */
  14179. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14180. /**
  14181. * Adds a new angular speed gradient
  14182. * @param gradient defines the gradient to use (between 0 and 1)
  14183. * @param factor defines the angular speed to affect to the specified gradient
  14184. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14185. * @returns the current particle system
  14186. */
  14187. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14188. /**
  14189. * Remove a specific angular speed gradient
  14190. * @param gradient defines the gradient to remove
  14191. * @returns the current particle system
  14192. */
  14193. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14194. /**
  14195. * Gets the current list of velocity gradients.
  14196. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14197. * @returns the list of velocity gradients
  14198. */
  14199. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14200. /**
  14201. * Adds a new velocity gradient
  14202. * @param gradient defines the gradient to use (between 0 and 1)
  14203. * @param factor defines the velocity to affect to the specified gradient
  14204. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14205. * @returns the current particle system
  14206. */
  14207. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14208. /**
  14209. * Remove a specific velocity gradient
  14210. * @param gradient defines the gradient to remove
  14211. * @returns the current particle system
  14212. */
  14213. removeVelocityGradient(gradient: number): IParticleSystem;
  14214. /**
  14215. * Gets the current list of limit velocity gradients.
  14216. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14217. * @returns the list of limit velocity gradients
  14218. */
  14219. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14220. /**
  14221. * Adds a new limit velocity gradient
  14222. * @param gradient defines the gradient to use (between 0 and 1)
  14223. * @param factor defines the limit velocity to affect to the specified gradient
  14224. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14225. * @returns the current particle system
  14226. */
  14227. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14228. /**
  14229. * Remove a specific limit velocity gradient
  14230. * @param gradient defines the gradient to remove
  14231. * @returns the current particle system
  14232. */
  14233. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14234. /**
  14235. * Adds a new drag gradient
  14236. * @param gradient defines the gradient to use (between 0 and 1)
  14237. * @param factor defines the drag to affect to the specified gradient
  14238. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14239. * @returns the current particle system
  14240. */
  14241. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14242. /**
  14243. * Remove a specific drag gradient
  14244. * @param gradient defines the gradient to remove
  14245. * @returns the current particle system
  14246. */
  14247. removeDragGradient(gradient: number): IParticleSystem;
  14248. /**
  14249. * Gets the current list of drag gradients.
  14250. * You must use addDragGradient and removeDragGradient to udpate this list
  14251. * @returns the list of drag gradients
  14252. */
  14253. getDragGradients(): Nullable<Array<FactorGradient>>;
  14254. /**
  14255. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14256. * @param gradient defines the gradient to use (between 0 and 1)
  14257. * @param factor defines the emit rate to affect to the specified gradient
  14258. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14259. * @returns the current particle system
  14260. */
  14261. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14262. /**
  14263. * Remove a specific emit rate gradient
  14264. * @param gradient defines the gradient to remove
  14265. * @returns the current particle system
  14266. */
  14267. removeEmitRateGradient(gradient: number): IParticleSystem;
  14268. /**
  14269. * Gets the current list of emit rate gradients.
  14270. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14271. * @returns the list of emit rate gradients
  14272. */
  14273. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14274. /**
  14275. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14276. * @param gradient defines the gradient to use (between 0 and 1)
  14277. * @param factor defines the start size to affect to the specified gradient
  14278. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14279. * @returns the current particle system
  14280. */
  14281. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14282. /**
  14283. * Remove a specific start size gradient
  14284. * @param gradient defines the gradient to remove
  14285. * @returns the current particle system
  14286. */
  14287. removeStartSizeGradient(gradient: number): IParticleSystem;
  14288. /**
  14289. * Gets the current list of start size gradients.
  14290. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14291. * @returns the list of start size gradients
  14292. */
  14293. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14294. /**
  14295. * Adds a new life time gradient
  14296. * @param gradient defines the gradient to use (between 0 and 1)
  14297. * @param factor defines the life time factor to affect to the specified gradient
  14298. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14299. * @returns the current particle system
  14300. */
  14301. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14302. /**
  14303. * Remove a specific life time gradient
  14304. * @param gradient defines the gradient to remove
  14305. * @returns the current particle system
  14306. */
  14307. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14308. /**
  14309. * Gets the current list of life time gradients.
  14310. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14311. * @returns the list of life time gradients
  14312. */
  14313. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14314. /**
  14315. * Gets the current list of color gradients.
  14316. * You must use addColorGradient and removeColorGradient to udpate this list
  14317. * @returns the list of color gradients
  14318. */
  14319. getColorGradients(): Nullable<Array<ColorGradient>>;
  14320. /**
  14321. * Adds a new ramp gradient used to remap particle colors
  14322. * @param gradient defines the gradient to use (between 0 and 1)
  14323. * @param color defines the color to affect to the specified gradient
  14324. * @returns the current particle system
  14325. */
  14326. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14327. /**
  14328. * Gets the current list of ramp gradients.
  14329. * You must use addRampGradient and removeRampGradient to udpate this list
  14330. * @returns the list of ramp gradients
  14331. */
  14332. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14333. /** Gets or sets a boolean indicating that ramp gradients must be used
  14334. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14335. */
  14336. useRampGradients: boolean;
  14337. /**
  14338. * Adds a new color remap gradient
  14339. * @param gradient defines the gradient to use (between 0 and 1)
  14340. * @param min defines the color remap minimal range
  14341. * @param max defines the color remap maximal range
  14342. * @returns the current particle system
  14343. */
  14344. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14345. /**
  14346. * Gets the current list of color remap gradients.
  14347. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14348. * @returns the list of color remap gradients
  14349. */
  14350. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14351. /**
  14352. * Adds a new alpha remap gradient
  14353. * @param gradient defines the gradient to use (between 0 and 1)
  14354. * @param min defines the alpha remap minimal range
  14355. * @param max defines the alpha remap maximal range
  14356. * @returns the current particle system
  14357. */
  14358. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14359. /**
  14360. * Gets the current list of alpha remap gradients.
  14361. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14362. * @returns the list of alpha remap gradients
  14363. */
  14364. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14365. /**
  14366. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14367. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14368. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14369. * @returns the emitter
  14370. */
  14371. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14372. /**
  14373. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14374. * @param radius The radius of the hemisphere to emit from
  14375. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14376. * @returns the emitter
  14377. */
  14378. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14379. /**
  14380. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14381. * @param radius The radius of the sphere to emit from
  14382. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14383. * @returns the emitter
  14384. */
  14385. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14386. /**
  14387. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14388. * @param radius The radius of the sphere to emit from
  14389. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14390. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14391. * @returns the emitter
  14392. */
  14393. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14394. /**
  14395. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14396. * @param radius The radius of the emission cylinder
  14397. * @param height The height of the emission cylinder
  14398. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14399. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14400. * @returns the emitter
  14401. */
  14402. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14403. /**
  14404. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14405. * @param radius The radius of the cylinder to emit from
  14406. * @param height The height of the emission cylinder
  14407. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14408. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14409. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14410. * @returns the emitter
  14411. */
  14412. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14413. /**
  14414. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14415. * @param radius The radius of the cone to emit from
  14416. * @param angle The base angle of the cone
  14417. * @returns the emitter
  14418. */
  14419. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14420. /**
  14421. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14422. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14423. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14424. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14425. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14426. * @returns the emitter
  14427. */
  14428. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14429. /**
  14430. * Get hosting scene
  14431. * @returns the scene
  14432. */
  14433. getScene(): Scene;
  14434. }
  14435. }
  14436. declare module BABYLON {
  14437. /**
  14438. * 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.
  14439. * @see https://doc.babylonjs.com/how_to/transformnode
  14440. */
  14441. export class TransformNode extends Node {
  14442. /**
  14443. * Object will not rotate to face the camera
  14444. */
  14445. static BILLBOARDMODE_NONE: number;
  14446. /**
  14447. * Object will rotate to face the camera but only on the x axis
  14448. */
  14449. static BILLBOARDMODE_X: number;
  14450. /**
  14451. * Object will rotate to face the camera but only on the y axis
  14452. */
  14453. static BILLBOARDMODE_Y: number;
  14454. /**
  14455. * Object will rotate to face the camera but only on the z axis
  14456. */
  14457. static BILLBOARDMODE_Z: number;
  14458. /**
  14459. * Object will rotate to face the camera
  14460. */
  14461. static BILLBOARDMODE_ALL: number;
  14462. /**
  14463. * Object will rotate to face the camera's position instead of orientation
  14464. */
  14465. static BILLBOARDMODE_USE_POSITION: number;
  14466. private static _TmpRotation;
  14467. private static _TmpScaling;
  14468. private static _TmpTranslation;
  14469. private _forward;
  14470. private _forwardInverted;
  14471. private _up;
  14472. private _right;
  14473. private _rightInverted;
  14474. private _position;
  14475. private _rotation;
  14476. private _rotationQuaternion;
  14477. protected _scaling: Vector3;
  14478. protected _isDirty: boolean;
  14479. private _transformToBoneReferal;
  14480. private _isAbsoluteSynced;
  14481. private _billboardMode;
  14482. /**
  14483. * Gets or sets the billboard mode. Default is 0.
  14484. *
  14485. * | Value | Type | Description |
  14486. * | --- | --- | --- |
  14487. * | 0 | BILLBOARDMODE_NONE | |
  14488. * | 1 | BILLBOARDMODE_X | |
  14489. * | 2 | BILLBOARDMODE_Y | |
  14490. * | 4 | BILLBOARDMODE_Z | |
  14491. * | 7 | BILLBOARDMODE_ALL | |
  14492. *
  14493. */
  14494. get billboardMode(): number;
  14495. set billboardMode(value: number);
  14496. private _preserveParentRotationForBillboard;
  14497. /**
  14498. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14499. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14500. */
  14501. get preserveParentRotationForBillboard(): boolean;
  14502. set preserveParentRotationForBillboard(value: boolean);
  14503. /**
  14504. * 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
  14505. */
  14506. scalingDeterminant: number;
  14507. private _infiniteDistance;
  14508. /**
  14509. * Gets or sets the distance of the object to max, often used by skybox
  14510. */
  14511. get infiniteDistance(): boolean;
  14512. set infiniteDistance(value: boolean);
  14513. /**
  14514. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14515. * By default the system will update normals to compensate
  14516. */
  14517. ignoreNonUniformScaling: boolean;
  14518. /**
  14519. * 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
  14520. */
  14521. reIntegrateRotationIntoRotationQuaternion: boolean;
  14522. /** @hidden */
  14523. _poseMatrix: Nullable<Matrix>;
  14524. /** @hidden */
  14525. _localMatrix: Matrix;
  14526. private _usePivotMatrix;
  14527. private _absolutePosition;
  14528. private _absoluteScaling;
  14529. private _absoluteRotationQuaternion;
  14530. private _pivotMatrix;
  14531. private _pivotMatrixInverse;
  14532. protected _postMultiplyPivotMatrix: boolean;
  14533. protected _isWorldMatrixFrozen: boolean;
  14534. /** @hidden */
  14535. _indexInSceneTransformNodesArray: number;
  14536. /**
  14537. * An event triggered after the world matrix is updated
  14538. */
  14539. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14540. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14541. /**
  14542. * Gets a string identifying the name of the class
  14543. * @returns "TransformNode" string
  14544. */
  14545. getClassName(): string;
  14546. /**
  14547. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14548. */
  14549. get position(): Vector3;
  14550. set position(newPosition: Vector3);
  14551. /**
  14552. * 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)).
  14553. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14554. */
  14555. get rotation(): Vector3;
  14556. set rotation(newRotation: Vector3);
  14557. /**
  14558. * 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)).
  14559. */
  14560. get scaling(): Vector3;
  14561. set scaling(newScaling: Vector3);
  14562. /**
  14563. * 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).
  14564. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14565. */
  14566. get rotationQuaternion(): Nullable<Quaternion>;
  14567. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14568. /**
  14569. * The forward direction of that transform in world space.
  14570. */
  14571. get forward(): Vector3;
  14572. /**
  14573. * The up direction of that transform in world space.
  14574. */
  14575. get up(): Vector3;
  14576. /**
  14577. * The right direction of that transform in world space.
  14578. */
  14579. get right(): Vector3;
  14580. /**
  14581. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14582. * @param matrix the matrix to copy the pose from
  14583. * @returns this TransformNode.
  14584. */
  14585. updatePoseMatrix(matrix: Matrix): TransformNode;
  14586. /**
  14587. * Returns the mesh Pose matrix.
  14588. * @returns the pose matrix
  14589. */
  14590. getPoseMatrix(): Matrix;
  14591. /** @hidden */
  14592. _isSynchronized(): boolean;
  14593. /** @hidden */
  14594. _initCache(): void;
  14595. /**
  14596. * Flag the transform node as dirty (Forcing it to update everything)
  14597. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14598. * @returns this transform node
  14599. */
  14600. markAsDirty(property: string): TransformNode;
  14601. /**
  14602. * Returns the current mesh absolute position.
  14603. * Returns a Vector3.
  14604. */
  14605. get absolutePosition(): Vector3;
  14606. /**
  14607. * Returns the current mesh absolute scaling.
  14608. * Returns a Vector3.
  14609. */
  14610. get absoluteScaling(): Vector3;
  14611. /**
  14612. * Returns the current mesh absolute rotation.
  14613. * Returns a Quaternion.
  14614. */
  14615. get absoluteRotationQuaternion(): Quaternion;
  14616. /**
  14617. * Sets a new matrix to apply before all other transformation
  14618. * @param matrix defines the transform matrix
  14619. * @returns the current TransformNode
  14620. */
  14621. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14622. /**
  14623. * Sets a new pivot matrix to the current node
  14624. * @param matrix defines the new pivot matrix to use
  14625. * @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
  14626. * @returns the current TransformNode
  14627. */
  14628. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14629. /**
  14630. * Returns the mesh pivot matrix.
  14631. * Default : Identity.
  14632. * @returns the matrix
  14633. */
  14634. getPivotMatrix(): Matrix;
  14635. /**
  14636. * Instantiate (when possible) or clone that node with its hierarchy
  14637. * @param newParent defines the new parent to use for the instance (or clone)
  14638. * @param options defines options to configure how copy is done
  14639. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14640. * @returns an instance (or a clone) of the current node with its hiearchy
  14641. */
  14642. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14643. doNotInstantiate: boolean;
  14644. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14645. /**
  14646. * Prevents the World matrix to be computed any longer
  14647. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14648. * @returns the TransformNode.
  14649. */
  14650. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14651. /**
  14652. * Allows back the World matrix computation.
  14653. * @returns the TransformNode.
  14654. */
  14655. unfreezeWorldMatrix(): this;
  14656. /**
  14657. * True if the World matrix has been frozen.
  14658. */
  14659. get isWorldMatrixFrozen(): boolean;
  14660. /**
  14661. * Retuns the mesh absolute position in the World.
  14662. * @returns a Vector3.
  14663. */
  14664. getAbsolutePosition(): Vector3;
  14665. /**
  14666. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14667. * @param absolutePosition the absolute position to set
  14668. * @returns the TransformNode.
  14669. */
  14670. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14671. /**
  14672. * Sets the mesh position in its local space.
  14673. * @param vector3 the position to set in localspace
  14674. * @returns the TransformNode.
  14675. */
  14676. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14677. /**
  14678. * Returns the mesh position in the local space from the current World matrix values.
  14679. * @returns a new Vector3.
  14680. */
  14681. getPositionExpressedInLocalSpace(): Vector3;
  14682. /**
  14683. * Translates the mesh along the passed Vector3 in its local space.
  14684. * @param vector3 the distance to translate in localspace
  14685. * @returns the TransformNode.
  14686. */
  14687. locallyTranslate(vector3: Vector3): TransformNode;
  14688. private static _lookAtVectorCache;
  14689. /**
  14690. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14691. * @param targetPoint the position (must be in same space as current mesh) to look at
  14692. * @param yawCor optional yaw (y-axis) correction in radians
  14693. * @param pitchCor optional pitch (x-axis) correction in radians
  14694. * @param rollCor optional roll (z-axis) correction in radians
  14695. * @param space the choosen space of the target
  14696. * @returns the TransformNode.
  14697. */
  14698. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14699. /**
  14700. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14701. * This Vector3 is expressed in the World space.
  14702. * @param localAxis axis to rotate
  14703. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14704. */
  14705. getDirection(localAxis: Vector3): Vector3;
  14706. /**
  14707. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14708. * localAxis is expressed in the mesh local space.
  14709. * result is computed in the Wordl space from the mesh World matrix.
  14710. * @param localAxis axis to rotate
  14711. * @param result the resulting transformnode
  14712. * @returns this TransformNode.
  14713. */
  14714. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14715. /**
  14716. * Sets this transform node rotation to the given local axis.
  14717. * @param localAxis the axis in local space
  14718. * @param yawCor optional yaw (y-axis) correction in radians
  14719. * @param pitchCor optional pitch (x-axis) correction in radians
  14720. * @param rollCor optional roll (z-axis) correction in radians
  14721. * @returns this TransformNode
  14722. */
  14723. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14724. /**
  14725. * Sets a new pivot point to the current node
  14726. * @param point defines the new pivot point to use
  14727. * @param space defines if the point is in world or local space (local by default)
  14728. * @returns the current TransformNode
  14729. */
  14730. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14731. /**
  14732. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14733. * @returns the pivot point
  14734. */
  14735. getPivotPoint(): Vector3;
  14736. /**
  14737. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14738. * @param result the vector3 to store the result
  14739. * @returns this TransformNode.
  14740. */
  14741. getPivotPointToRef(result: Vector3): TransformNode;
  14742. /**
  14743. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14744. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14745. */
  14746. getAbsolutePivotPoint(): Vector3;
  14747. /**
  14748. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14749. * @param result vector3 to store the result
  14750. * @returns this TransformNode.
  14751. */
  14752. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14753. /**
  14754. * Defines the passed node as the parent of the current node.
  14755. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14756. * @see https://doc.babylonjs.com/how_to/parenting
  14757. * @param node the node ot set as the parent
  14758. * @returns this TransformNode.
  14759. */
  14760. setParent(node: Nullable<Node>): TransformNode;
  14761. private _nonUniformScaling;
  14762. /**
  14763. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14764. */
  14765. get nonUniformScaling(): boolean;
  14766. /** @hidden */
  14767. _updateNonUniformScalingState(value: boolean): boolean;
  14768. /**
  14769. * Attach the current TransformNode to another TransformNode associated with a bone
  14770. * @param bone Bone affecting the TransformNode
  14771. * @param affectedTransformNode TransformNode associated with the bone
  14772. * @returns this object
  14773. */
  14774. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14775. /**
  14776. * Detach the transform node if its associated with a bone
  14777. * @returns this object
  14778. */
  14779. detachFromBone(): TransformNode;
  14780. private static _rotationAxisCache;
  14781. /**
  14782. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14783. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14784. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14785. * The passed axis is also normalized.
  14786. * @param axis the axis to rotate around
  14787. * @param amount the amount to rotate in radians
  14788. * @param space Space to rotate in (Default: local)
  14789. * @returns the TransformNode.
  14790. */
  14791. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14792. /**
  14793. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14794. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14795. * The passed axis is also normalized. .
  14796. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14797. * @param point the point to rotate around
  14798. * @param axis the axis to rotate around
  14799. * @param amount the amount to rotate in radians
  14800. * @returns the TransformNode
  14801. */
  14802. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14803. /**
  14804. * Translates the mesh along the axis vector for the passed distance in the given space.
  14805. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14806. * @param axis the axis to translate in
  14807. * @param distance the distance to translate
  14808. * @param space Space to rotate in (Default: local)
  14809. * @returns the TransformNode.
  14810. */
  14811. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14812. /**
  14813. * Adds a rotation step to the mesh current rotation.
  14814. * x, y, z are Euler angles expressed in radians.
  14815. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14816. * This means this rotation is made in the mesh local space only.
  14817. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14818. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14819. * ```javascript
  14820. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14821. * ```
  14822. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14823. * 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.
  14824. * @param x Rotation to add
  14825. * @param y Rotation to add
  14826. * @param z Rotation to add
  14827. * @returns the TransformNode.
  14828. */
  14829. addRotation(x: number, y: number, z: number): TransformNode;
  14830. /**
  14831. * @hidden
  14832. */
  14833. protected _getEffectiveParent(): Nullable<Node>;
  14834. /**
  14835. * Computes the world matrix of the node
  14836. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14837. * @returns the world matrix
  14838. */
  14839. computeWorldMatrix(force?: boolean): Matrix;
  14840. /**
  14841. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14842. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14843. */
  14844. resetLocalMatrix(independentOfChildren?: boolean): void;
  14845. protected _afterComputeWorldMatrix(): void;
  14846. /**
  14847. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14848. * @param func callback function to add
  14849. *
  14850. * @returns the TransformNode.
  14851. */
  14852. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14853. /**
  14854. * Removes a registered callback function.
  14855. * @param func callback function to remove
  14856. * @returns the TransformNode.
  14857. */
  14858. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14859. /**
  14860. * Gets the position of the current mesh in camera space
  14861. * @param camera defines the camera to use
  14862. * @returns a position
  14863. */
  14864. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14865. /**
  14866. * Returns the distance from the mesh to the active camera
  14867. * @param camera defines the camera to use
  14868. * @returns the distance
  14869. */
  14870. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14871. /**
  14872. * Clone the current transform node
  14873. * @param name Name of the new clone
  14874. * @param newParent New parent for the clone
  14875. * @param doNotCloneChildren Do not clone children hierarchy
  14876. * @returns the new transform node
  14877. */
  14878. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14879. /**
  14880. * Serializes the objects information.
  14881. * @param currentSerializationObject defines the object to serialize in
  14882. * @returns the serialized object
  14883. */
  14884. serialize(currentSerializationObject?: any): any;
  14885. /**
  14886. * Returns a new TransformNode object parsed from the source provided.
  14887. * @param parsedTransformNode is the source.
  14888. * @param scene the scne the object belongs to
  14889. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14890. * @returns a new TransformNode object parsed from the source provided.
  14891. */
  14892. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14893. /**
  14894. * Get all child-transformNodes of this node
  14895. * @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
  14896. * @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
  14897. * @returns an array of TransformNode
  14898. */
  14899. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14900. /**
  14901. * Releases resources associated with this transform node.
  14902. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14903. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14904. */
  14905. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14906. /**
  14907. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14908. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14909. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14910. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14911. * @returns the current mesh
  14912. */
  14913. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14914. private _syncAbsoluteScalingAndRotation;
  14915. }
  14916. }
  14917. declare module BABYLON {
  14918. /**
  14919. * Class used to override all child animations of a given target
  14920. */
  14921. export class AnimationPropertiesOverride {
  14922. /**
  14923. * Gets or sets a value indicating if animation blending must be used
  14924. */
  14925. enableBlending: boolean;
  14926. /**
  14927. * Gets or sets the blending speed to use when enableBlending is true
  14928. */
  14929. blendingSpeed: number;
  14930. /**
  14931. * Gets or sets the default loop mode to use
  14932. */
  14933. loopMode: number;
  14934. }
  14935. }
  14936. declare module BABYLON {
  14937. /**
  14938. * Class used to store bone information
  14939. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14940. */
  14941. export class Bone extends Node {
  14942. /**
  14943. * defines the bone name
  14944. */
  14945. name: string;
  14946. private static _tmpVecs;
  14947. private static _tmpQuat;
  14948. private static _tmpMats;
  14949. /**
  14950. * Gets the list of child bones
  14951. */
  14952. children: Bone[];
  14953. /** Gets the animations associated with this bone */
  14954. animations: Animation[];
  14955. /**
  14956. * Gets or sets bone length
  14957. */
  14958. length: number;
  14959. /**
  14960. * @hidden Internal only
  14961. * Set this value to map this bone to a different index in the transform matrices
  14962. * Set this value to -1 to exclude the bone from the transform matrices
  14963. */
  14964. _index: Nullable<number>;
  14965. private _skeleton;
  14966. private _localMatrix;
  14967. private _restPose;
  14968. private _baseMatrix;
  14969. private _absoluteTransform;
  14970. private _invertedAbsoluteTransform;
  14971. private _parent;
  14972. private _scalingDeterminant;
  14973. private _worldTransform;
  14974. private _localScaling;
  14975. private _localRotation;
  14976. private _localPosition;
  14977. private _needToDecompose;
  14978. private _needToCompose;
  14979. /** @hidden */
  14980. _linkedTransformNode: Nullable<TransformNode>;
  14981. /** @hidden */
  14982. _waitingTransformNodeId: Nullable<string>;
  14983. /** @hidden */
  14984. get _matrix(): Matrix;
  14985. /** @hidden */
  14986. set _matrix(value: Matrix);
  14987. /**
  14988. * Create a new bone
  14989. * @param name defines the bone name
  14990. * @param skeleton defines the parent skeleton
  14991. * @param parentBone defines the parent (can be null if the bone is the root)
  14992. * @param localMatrix defines the local matrix
  14993. * @param restPose defines the rest pose matrix
  14994. * @param baseMatrix defines the base matrix
  14995. * @param index defines index of the bone in the hiearchy
  14996. */
  14997. constructor(
  14998. /**
  14999. * defines the bone name
  15000. */
  15001. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15002. /**
  15003. * Gets the current object class name.
  15004. * @return the class name
  15005. */
  15006. getClassName(): string;
  15007. /**
  15008. * Gets the parent skeleton
  15009. * @returns a skeleton
  15010. */
  15011. getSkeleton(): Skeleton;
  15012. /**
  15013. * Gets parent bone
  15014. * @returns a bone or null if the bone is the root of the bone hierarchy
  15015. */
  15016. getParent(): Nullable<Bone>;
  15017. /**
  15018. * Returns an array containing the root bones
  15019. * @returns an array containing the root bones
  15020. */
  15021. getChildren(): Array<Bone>;
  15022. /**
  15023. * Gets the node index in matrix array generated for rendering
  15024. * @returns the node index
  15025. */
  15026. getIndex(): number;
  15027. /**
  15028. * Sets the parent bone
  15029. * @param parent defines the parent (can be null if the bone is the root)
  15030. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15031. */
  15032. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15033. /**
  15034. * Gets the local matrix
  15035. * @returns a matrix
  15036. */
  15037. getLocalMatrix(): Matrix;
  15038. /**
  15039. * Gets the base matrix (initial matrix which remains unchanged)
  15040. * @returns a matrix
  15041. */
  15042. getBaseMatrix(): Matrix;
  15043. /**
  15044. * Gets the rest pose matrix
  15045. * @returns a matrix
  15046. */
  15047. getRestPose(): Matrix;
  15048. /**
  15049. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15050. */
  15051. getWorldMatrix(): Matrix;
  15052. /**
  15053. * Sets the local matrix to rest pose matrix
  15054. */
  15055. returnToRest(): void;
  15056. /**
  15057. * Gets the inverse of the absolute transform matrix.
  15058. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15059. * @returns a matrix
  15060. */
  15061. getInvertedAbsoluteTransform(): Matrix;
  15062. /**
  15063. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15064. * @returns a matrix
  15065. */
  15066. getAbsoluteTransform(): Matrix;
  15067. /**
  15068. * Links with the given transform node.
  15069. * The local matrix of this bone is copied from the transform node every frame.
  15070. * @param transformNode defines the transform node to link to
  15071. */
  15072. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15073. /**
  15074. * Gets the node used to drive the bone's transformation
  15075. * @returns a transform node or null
  15076. */
  15077. getTransformNode(): Nullable<TransformNode>;
  15078. /** Gets or sets current position (in local space) */
  15079. get position(): Vector3;
  15080. set position(newPosition: Vector3);
  15081. /** Gets or sets current rotation (in local space) */
  15082. get rotation(): Vector3;
  15083. set rotation(newRotation: Vector3);
  15084. /** Gets or sets current rotation quaternion (in local space) */
  15085. get rotationQuaternion(): Quaternion;
  15086. set rotationQuaternion(newRotation: Quaternion);
  15087. /** Gets or sets current scaling (in local space) */
  15088. get scaling(): Vector3;
  15089. set scaling(newScaling: Vector3);
  15090. /**
  15091. * Gets the animation properties override
  15092. */
  15093. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15094. private _decompose;
  15095. private _compose;
  15096. /**
  15097. * Update the base and local matrices
  15098. * @param matrix defines the new base or local matrix
  15099. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15100. * @param updateLocalMatrix defines if the local matrix should be updated
  15101. */
  15102. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15103. /** @hidden */
  15104. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15105. /**
  15106. * Flag the bone as dirty (Forcing it to update everything)
  15107. */
  15108. markAsDirty(): void;
  15109. /** @hidden */
  15110. _markAsDirtyAndCompose(): void;
  15111. private _markAsDirtyAndDecompose;
  15112. /**
  15113. * Translate the bone in local or world space
  15114. * @param vec The amount to translate the bone
  15115. * @param space The space that the translation is in
  15116. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15117. */
  15118. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15119. /**
  15120. * Set the postion of the bone in local or world space
  15121. * @param position The position to set the bone
  15122. * @param space The space that the position is in
  15123. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15124. */
  15125. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15126. /**
  15127. * Set the absolute position of the bone (world space)
  15128. * @param position The position to set the bone
  15129. * @param mesh The mesh that this bone is attached to
  15130. */
  15131. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15132. /**
  15133. * Scale the bone on the x, y and z axes (in local space)
  15134. * @param x The amount to scale the bone on the x axis
  15135. * @param y The amount to scale the bone on the y axis
  15136. * @param z The amount to scale the bone on the z axis
  15137. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15138. */
  15139. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15140. /**
  15141. * Set the bone scaling in local space
  15142. * @param scale defines the scaling vector
  15143. */
  15144. setScale(scale: Vector3): void;
  15145. /**
  15146. * Gets the current scaling in local space
  15147. * @returns the current scaling vector
  15148. */
  15149. getScale(): Vector3;
  15150. /**
  15151. * Gets the current scaling in local space and stores it in a target vector
  15152. * @param result defines the target vector
  15153. */
  15154. getScaleToRef(result: Vector3): void;
  15155. /**
  15156. * Set the yaw, pitch, and roll of the bone in local or world space
  15157. * @param yaw The rotation of the bone on the y axis
  15158. * @param pitch The rotation of the bone on the x axis
  15159. * @param roll The rotation of the bone on the z axis
  15160. * @param space The space that the axes of rotation are in
  15161. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15162. */
  15163. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15164. /**
  15165. * Add a rotation to the bone on an axis in local or world space
  15166. * @param axis The axis to rotate the bone on
  15167. * @param amount The amount to rotate the bone
  15168. * @param space The space that the axis is in
  15169. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15170. */
  15171. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15172. /**
  15173. * Set the rotation of the bone to a particular axis angle in local or world space
  15174. * @param axis The axis to rotate the bone on
  15175. * @param angle The angle that the bone should be rotated to
  15176. * @param space The space that the axis is in
  15177. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15178. */
  15179. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15180. /**
  15181. * Set the euler rotation of the bone in local of world space
  15182. * @param rotation The euler rotation that the bone should be set to
  15183. * @param space The space that the rotation is in
  15184. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15185. */
  15186. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15187. /**
  15188. * Set the quaternion rotation of the bone in local of world space
  15189. * @param quat The quaternion rotation that the bone should be set to
  15190. * @param space The space that the rotation is in
  15191. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15192. */
  15193. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15194. /**
  15195. * Set the rotation matrix of the bone in local of world space
  15196. * @param rotMat The rotation matrix that the bone should be set to
  15197. * @param space The space that the rotation is in
  15198. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15199. */
  15200. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15201. private _rotateWithMatrix;
  15202. private _getNegativeRotationToRef;
  15203. /**
  15204. * Get the position of the bone in local or world space
  15205. * @param space The space that the returned position is in
  15206. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15207. * @returns The position of the bone
  15208. */
  15209. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15210. /**
  15211. * Copy the position of the bone to a vector3 in local or world space
  15212. * @param space The space that the returned position is in
  15213. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15214. * @param result The vector3 to copy the position to
  15215. */
  15216. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15217. /**
  15218. * Get the absolute position of the bone (world space)
  15219. * @param mesh The mesh that this bone is attached to
  15220. * @returns The absolute position of the bone
  15221. */
  15222. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15223. /**
  15224. * Copy the absolute position of the bone (world space) to the result param
  15225. * @param mesh The mesh that this bone is attached to
  15226. * @param result The vector3 to copy the absolute position to
  15227. */
  15228. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15229. /**
  15230. * Compute the absolute transforms of this bone and its children
  15231. */
  15232. computeAbsoluteTransforms(): void;
  15233. /**
  15234. * Get the world direction from an axis that is in the local space of the bone
  15235. * @param localAxis The local direction that is used to compute the world direction
  15236. * @param mesh The mesh that this bone is attached to
  15237. * @returns The world direction
  15238. */
  15239. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15240. /**
  15241. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15242. * @param localAxis The local direction that is used to compute the world direction
  15243. * @param mesh The mesh that this bone is attached to
  15244. * @param result The vector3 that the world direction will be copied to
  15245. */
  15246. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15247. /**
  15248. * Get the euler rotation of the bone in local or world space
  15249. * @param space The space that the rotation should be in
  15250. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15251. * @returns The euler rotation
  15252. */
  15253. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15254. /**
  15255. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15256. * @param space The space that the rotation should be in
  15257. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15258. * @param result The vector3 that the rotation should be copied to
  15259. */
  15260. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15261. /**
  15262. * Get the quaternion rotation of the bone in either local or world space
  15263. * @param space The space that the rotation should be in
  15264. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15265. * @returns The quaternion rotation
  15266. */
  15267. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15268. /**
  15269. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15270. * @param space The space that the rotation should be in
  15271. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15272. * @param result The quaternion that the rotation should be copied to
  15273. */
  15274. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15275. /**
  15276. * Get the rotation matrix of the bone in local or world space
  15277. * @param space The space that the rotation should be in
  15278. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15279. * @returns The rotation matrix
  15280. */
  15281. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15282. /**
  15283. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15284. * @param space The space that the rotation should be in
  15285. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15286. * @param result The quaternion that the rotation should be copied to
  15287. */
  15288. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15289. /**
  15290. * Get the world position of a point that is in the local space of the bone
  15291. * @param position The local position
  15292. * @param mesh The mesh that this bone is attached to
  15293. * @returns The world position
  15294. */
  15295. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15296. /**
  15297. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15298. * @param position The local position
  15299. * @param mesh The mesh that this bone is attached to
  15300. * @param result The vector3 that the world position should be copied to
  15301. */
  15302. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15303. /**
  15304. * Get the local position of a point that is in world space
  15305. * @param position The world position
  15306. * @param mesh The mesh that this bone is attached to
  15307. * @returns The local position
  15308. */
  15309. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15310. /**
  15311. * Get the local position of a point that is in world space and copy it to the result param
  15312. * @param position The world position
  15313. * @param mesh The mesh that this bone is attached to
  15314. * @param result The vector3 that the local position should be copied to
  15315. */
  15316. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15317. }
  15318. }
  15319. declare module BABYLON {
  15320. /**
  15321. * Defines a runtime animation
  15322. */
  15323. export class RuntimeAnimation {
  15324. private _events;
  15325. /**
  15326. * The current frame of the runtime animation
  15327. */
  15328. private _currentFrame;
  15329. /**
  15330. * The animation used by the runtime animation
  15331. */
  15332. private _animation;
  15333. /**
  15334. * The target of the runtime animation
  15335. */
  15336. private _target;
  15337. /**
  15338. * The initiating animatable
  15339. */
  15340. private _host;
  15341. /**
  15342. * The original value of the runtime animation
  15343. */
  15344. private _originalValue;
  15345. /**
  15346. * The original blend value of the runtime animation
  15347. */
  15348. private _originalBlendValue;
  15349. /**
  15350. * The offsets cache of the runtime animation
  15351. */
  15352. private _offsetsCache;
  15353. /**
  15354. * The high limits cache of the runtime animation
  15355. */
  15356. private _highLimitsCache;
  15357. /**
  15358. * Specifies if the runtime animation has been stopped
  15359. */
  15360. private _stopped;
  15361. /**
  15362. * The blending factor of the runtime animation
  15363. */
  15364. private _blendingFactor;
  15365. /**
  15366. * The BabylonJS scene
  15367. */
  15368. private _scene;
  15369. /**
  15370. * The current value of the runtime animation
  15371. */
  15372. private _currentValue;
  15373. /** @hidden */
  15374. _animationState: _IAnimationState;
  15375. /**
  15376. * The active target of the runtime animation
  15377. */
  15378. private _activeTargets;
  15379. private _currentActiveTarget;
  15380. private _directTarget;
  15381. /**
  15382. * The target path of the runtime animation
  15383. */
  15384. private _targetPath;
  15385. /**
  15386. * The weight of the runtime animation
  15387. */
  15388. private _weight;
  15389. /**
  15390. * The ratio offset of the runtime animation
  15391. */
  15392. private _ratioOffset;
  15393. /**
  15394. * The previous delay of the runtime animation
  15395. */
  15396. private _previousDelay;
  15397. /**
  15398. * The previous ratio of the runtime animation
  15399. */
  15400. private _previousRatio;
  15401. private _enableBlending;
  15402. private _keys;
  15403. private _minFrame;
  15404. private _maxFrame;
  15405. private _minValue;
  15406. private _maxValue;
  15407. private _targetIsArray;
  15408. /**
  15409. * Gets the current frame of the runtime animation
  15410. */
  15411. get currentFrame(): number;
  15412. /**
  15413. * Gets the weight of the runtime animation
  15414. */
  15415. get weight(): number;
  15416. /**
  15417. * Gets the current value of the runtime animation
  15418. */
  15419. get currentValue(): any;
  15420. /**
  15421. * Gets the target path of the runtime animation
  15422. */
  15423. get targetPath(): string;
  15424. /**
  15425. * Gets the actual target of the runtime animation
  15426. */
  15427. get target(): any;
  15428. /**
  15429. * Gets the additive state of the runtime animation
  15430. */
  15431. get isAdditive(): boolean;
  15432. /** @hidden */
  15433. _onLoop: () => void;
  15434. /**
  15435. * Create a new RuntimeAnimation object
  15436. * @param target defines the target of the animation
  15437. * @param animation defines the source animation object
  15438. * @param scene defines the hosting scene
  15439. * @param host defines the initiating Animatable
  15440. */
  15441. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15442. private _preparePath;
  15443. /**
  15444. * Gets the animation from the runtime animation
  15445. */
  15446. get animation(): Animation;
  15447. /**
  15448. * Resets the runtime animation to the beginning
  15449. * @param restoreOriginal defines whether to restore the target property to the original value
  15450. */
  15451. reset(restoreOriginal?: boolean): void;
  15452. /**
  15453. * Specifies if the runtime animation is stopped
  15454. * @returns Boolean specifying if the runtime animation is stopped
  15455. */
  15456. isStopped(): boolean;
  15457. /**
  15458. * Disposes of the runtime animation
  15459. */
  15460. dispose(): void;
  15461. /**
  15462. * Apply the interpolated value to the target
  15463. * @param currentValue defines the value computed by the animation
  15464. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15465. */
  15466. setValue(currentValue: any, weight: number): void;
  15467. private _getOriginalValues;
  15468. private _setValue;
  15469. /**
  15470. * Gets the loop pmode of the runtime animation
  15471. * @returns Loop Mode
  15472. */
  15473. private _getCorrectLoopMode;
  15474. /**
  15475. * Move the current animation to a given frame
  15476. * @param frame defines the frame to move to
  15477. */
  15478. goToFrame(frame: number): void;
  15479. /**
  15480. * @hidden Internal use only
  15481. */
  15482. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15483. /**
  15484. * Execute the current animation
  15485. * @param delay defines the delay to add to the current frame
  15486. * @param from defines the lower bound of the animation range
  15487. * @param to defines the upper bound of the animation range
  15488. * @param loop defines if the current animation must loop
  15489. * @param speedRatio defines the current speed ratio
  15490. * @param weight defines the weight of the animation (default is -1 so no weight)
  15491. * @param onLoop optional callback called when animation loops
  15492. * @returns a boolean indicating if the animation is running
  15493. */
  15494. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15495. }
  15496. }
  15497. declare module BABYLON {
  15498. /**
  15499. * Class used to store an actual running animation
  15500. */
  15501. export class Animatable {
  15502. /** defines the target object */
  15503. target: any;
  15504. /** defines the starting frame number (default is 0) */
  15505. fromFrame: number;
  15506. /** defines the ending frame number (default is 100) */
  15507. toFrame: number;
  15508. /** defines if the animation must loop (default is false) */
  15509. loopAnimation: boolean;
  15510. /** defines a callback to call when animation ends if it is not looping */
  15511. onAnimationEnd?: (() => void) | null | undefined;
  15512. /** defines a callback to call when animation loops */
  15513. onAnimationLoop?: (() => void) | null | undefined;
  15514. /** defines whether the animation should be evaluated additively */
  15515. isAdditive: boolean;
  15516. private _localDelayOffset;
  15517. private _pausedDelay;
  15518. private _runtimeAnimations;
  15519. private _paused;
  15520. private _scene;
  15521. private _speedRatio;
  15522. private _weight;
  15523. private _syncRoot;
  15524. /**
  15525. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15526. * This will only apply for non looping animation (default is true)
  15527. */
  15528. disposeOnEnd: boolean;
  15529. /**
  15530. * Gets a boolean indicating if the animation has started
  15531. */
  15532. animationStarted: boolean;
  15533. /**
  15534. * Observer raised when the animation ends
  15535. */
  15536. onAnimationEndObservable: Observable<Animatable>;
  15537. /**
  15538. * Observer raised when the animation loops
  15539. */
  15540. onAnimationLoopObservable: Observable<Animatable>;
  15541. /**
  15542. * Gets the root Animatable used to synchronize and normalize animations
  15543. */
  15544. get syncRoot(): Nullable<Animatable>;
  15545. /**
  15546. * Gets the current frame of the first RuntimeAnimation
  15547. * Used to synchronize Animatables
  15548. */
  15549. get masterFrame(): number;
  15550. /**
  15551. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15552. */
  15553. get weight(): number;
  15554. set weight(value: number);
  15555. /**
  15556. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15557. */
  15558. get speedRatio(): number;
  15559. set speedRatio(value: number);
  15560. /**
  15561. * Creates a new Animatable
  15562. * @param scene defines the hosting scene
  15563. * @param target defines the target object
  15564. * @param fromFrame defines the starting frame number (default is 0)
  15565. * @param toFrame defines the ending frame number (default is 100)
  15566. * @param loopAnimation defines if the animation must loop (default is false)
  15567. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15568. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15569. * @param animations defines a group of animation to add to the new Animatable
  15570. * @param onAnimationLoop defines a callback to call when animation loops
  15571. * @param isAdditive defines whether the animation should be evaluated additively
  15572. */
  15573. constructor(scene: Scene,
  15574. /** defines the target object */
  15575. target: any,
  15576. /** defines the starting frame number (default is 0) */
  15577. fromFrame?: number,
  15578. /** defines the ending frame number (default is 100) */
  15579. toFrame?: number,
  15580. /** defines if the animation must loop (default is false) */
  15581. loopAnimation?: boolean, speedRatio?: number,
  15582. /** defines a callback to call when animation ends if it is not looping */
  15583. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15584. /** defines a callback to call when animation loops */
  15585. onAnimationLoop?: (() => void) | null | undefined,
  15586. /** defines whether the animation should be evaluated additively */
  15587. isAdditive?: boolean);
  15588. /**
  15589. * Synchronize and normalize current Animatable with a source Animatable
  15590. * This is useful when using animation weights and when animations are not of the same length
  15591. * @param root defines the root Animatable to synchronize with
  15592. * @returns the current Animatable
  15593. */
  15594. syncWith(root: Animatable): Animatable;
  15595. /**
  15596. * Gets the list of runtime animations
  15597. * @returns an array of RuntimeAnimation
  15598. */
  15599. getAnimations(): RuntimeAnimation[];
  15600. /**
  15601. * Adds more animations to the current animatable
  15602. * @param target defines the target of the animations
  15603. * @param animations defines the new animations to add
  15604. */
  15605. appendAnimations(target: any, animations: Animation[]): void;
  15606. /**
  15607. * Gets the source animation for a specific property
  15608. * @param property defines the propertyu to look for
  15609. * @returns null or the source animation for the given property
  15610. */
  15611. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15612. /**
  15613. * Gets the runtime animation for a specific property
  15614. * @param property defines the propertyu to look for
  15615. * @returns null or the runtime animation for the given property
  15616. */
  15617. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15618. /**
  15619. * Resets the animatable to its original state
  15620. */
  15621. reset(): void;
  15622. /**
  15623. * Allows the animatable to blend with current running animations
  15624. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15625. * @param blendingSpeed defines the blending speed to use
  15626. */
  15627. enableBlending(blendingSpeed: number): void;
  15628. /**
  15629. * Disable animation blending
  15630. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15631. */
  15632. disableBlending(): void;
  15633. /**
  15634. * Jump directly to a given frame
  15635. * @param frame defines the frame to jump to
  15636. */
  15637. goToFrame(frame: number): void;
  15638. /**
  15639. * Pause the animation
  15640. */
  15641. pause(): void;
  15642. /**
  15643. * Restart the animation
  15644. */
  15645. restart(): void;
  15646. private _raiseOnAnimationEnd;
  15647. /**
  15648. * Stop and delete the current animation
  15649. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15650. * @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)
  15651. */
  15652. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15653. /**
  15654. * Wait asynchronously for the animation to end
  15655. * @returns a promise which will be fullfilled when the animation ends
  15656. */
  15657. waitAsync(): Promise<Animatable>;
  15658. /** @hidden */
  15659. _animate(delay: number): boolean;
  15660. }
  15661. interface Scene {
  15662. /** @hidden */
  15663. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15664. /** @hidden */
  15665. _processLateAnimationBindingsForMatrices(holder: {
  15666. totalWeight: number;
  15667. totalAdditiveWeight: number;
  15668. animations: RuntimeAnimation[];
  15669. additiveAnimations: RuntimeAnimation[];
  15670. originalValue: Matrix;
  15671. }): any;
  15672. /** @hidden */
  15673. _processLateAnimationBindingsForQuaternions(holder: {
  15674. totalWeight: number;
  15675. totalAdditiveWeight: number;
  15676. animations: RuntimeAnimation[];
  15677. additiveAnimations: RuntimeAnimation[];
  15678. originalValue: Quaternion;
  15679. }, refQuaternion: Quaternion): Quaternion;
  15680. /** @hidden */
  15681. _processLateAnimationBindings(): void;
  15682. /**
  15683. * Will start the animation sequence of a given target
  15684. * @param target defines the target
  15685. * @param from defines from which frame should animation start
  15686. * @param to defines until which frame should animation run.
  15687. * @param weight defines the weight to apply to the animation (1.0 by default)
  15688. * @param loop defines if the animation loops
  15689. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15690. * @param onAnimationEnd defines the function to be executed when the animation ends
  15691. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15692. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15693. * @param onAnimationLoop defines the callback to call when an animation loops
  15694. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15695. * @returns the animatable object created for this animation
  15696. */
  15697. 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;
  15698. /**
  15699. * Will start the animation sequence of a given target
  15700. * @param target defines the target
  15701. * @param from defines from which frame should animation start
  15702. * @param to defines until which frame should animation run.
  15703. * @param loop defines if the animation loops
  15704. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15705. * @param onAnimationEnd defines the function to be executed when the animation ends
  15706. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15707. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15708. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15709. * @param onAnimationLoop defines the callback to call when an animation loops
  15710. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15711. * @returns the animatable object created for this animation
  15712. */
  15713. 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;
  15714. /**
  15715. * Will start the animation sequence of a given target and its hierarchy
  15716. * @param target defines the target
  15717. * @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.
  15718. * @param from defines from which frame should animation start
  15719. * @param to defines until which frame should animation run.
  15720. * @param loop defines if the animation loops
  15721. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15722. * @param onAnimationEnd defines the function to be executed when the animation ends
  15723. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15724. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15725. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15726. * @param onAnimationLoop defines the callback to call when an animation loops
  15727. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15728. * @returns the list of created animatables
  15729. */
  15730. 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[];
  15731. /**
  15732. * Begin a new animation on a given node
  15733. * @param target defines the target where the animation will take place
  15734. * @param animations defines the list of animations to start
  15735. * @param from defines the initial value
  15736. * @param to defines the final value
  15737. * @param loop defines if you want animation to loop (off by default)
  15738. * @param speedRatio defines the speed ratio to apply to all animations
  15739. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15740. * @param onAnimationLoop defines the callback to call when an animation loops
  15741. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15742. * @returns the list of created animatables
  15743. */
  15744. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15745. /**
  15746. * Begin a new animation on a given node and its hierarchy
  15747. * @param target defines the root node where the animation will take place
  15748. * @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.
  15749. * @param animations defines the list of animations to start
  15750. * @param from defines the initial value
  15751. * @param to defines the final value
  15752. * @param loop defines if you want animation to loop (off by default)
  15753. * @param speedRatio defines the speed ratio to apply to all animations
  15754. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15755. * @param onAnimationLoop defines the callback to call when an animation loops
  15756. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15757. * @returns the list of animatables created for all nodes
  15758. */
  15759. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15760. /**
  15761. * Gets the animatable associated with a specific target
  15762. * @param target defines the target of the animatable
  15763. * @returns the required animatable if found
  15764. */
  15765. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15766. /**
  15767. * Gets all animatables associated with a given target
  15768. * @param target defines the target to look animatables for
  15769. * @returns an array of Animatables
  15770. */
  15771. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15772. /**
  15773. * Stops and removes all animations that have been applied to the scene
  15774. */
  15775. stopAllAnimations(): void;
  15776. /**
  15777. * Gets the current delta time used by animation engine
  15778. */
  15779. deltaTime: number;
  15780. }
  15781. interface Bone {
  15782. /**
  15783. * Copy an animation range from another bone
  15784. * @param source defines the source bone
  15785. * @param rangeName defines the range name to copy
  15786. * @param frameOffset defines the frame offset
  15787. * @param rescaleAsRequired defines if rescaling must be applied if required
  15788. * @param skelDimensionsRatio defines the scaling ratio
  15789. * @returns true if operation was successful
  15790. */
  15791. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15792. }
  15793. }
  15794. declare module BABYLON {
  15795. /**
  15796. * Class used to handle skinning animations
  15797. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15798. */
  15799. export class Skeleton implements IAnimatable {
  15800. /** defines the skeleton name */
  15801. name: string;
  15802. /** defines the skeleton Id */
  15803. id: string;
  15804. /**
  15805. * Defines the list of child bones
  15806. */
  15807. bones: Bone[];
  15808. /**
  15809. * Defines an estimate of the dimension of the skeleton at rest
  15810. */
  15811. dimensionsAtRest: Vector3;
  15812. /**
  15813. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15814. */
  15815. needInitialSkinMatrix: boolean;
  15816. /**
  15817. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15818. */
  15819. overrideMesh: Nullable<AbstractMesh>;
  15820. /**
  15821. * Gets the list of animations attached to this skeleton
  15822. */
  15823. animations: Array<Animation>;
  15824. private _scene;
  15825. private _isDirty;
  15826. private _transformMatrices;
  15827. private _transformMatrixTexture;
  15828. private _meshesWithPoseMatrix;
  15829. private _animatables;
  15830. private _identity;
  15831. private _synchronizedWithMesh;
  15832. private _ranges;
  15833. private _lastAbsoluteTransformsUpdateId;
  15834. private _canUseTextureForBones;
  15835. private _uniqueId;
  15836. /** @hidden */
  15837. _numBonesWithLinkedTransformNode: number;
  15838. /** @hidden */
  15839. _hasWaitingData: Nullable<boolean>;
  15840. /**
  15841. * Specifies if the skeleton should be serialized
  15842. */
  15843. doNotSerialize: boolean;
  15844. private _useTextureToStoreBoneMatrices;
  15845. /**
  15846. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15847. * Please note that this option is not available if the hardware does not support it
  15848. */
  15849. get useTextureToStoreBoneMatrices(): boolean;
  15850. set useTextureToStoreBoneMatrices(value: boolean);
  15851. private _animationPropertiesOverride;
  15852. /**
  15853. * Gets or sets the animation properties override
  15854. */
  15855. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15856. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15857. /**
  15858. * List of inspectable custom properties (used by the Inspector)
  15859. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15860. */
  15861. inspectableCustomProperties: IInspectable[];
  15862. /**
  15863. * An observable triggered before computing the skeleton's matrices
  15864. */
  15865. onBeforeComputeObservable: Observable<Skeleton>;
  15866. /**
  15867. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15868. */
  15869. get isUsingTextureForMatrices(): boolean;
  15870. /**
  15871. * Gets the unique ID of this skeleton
  15872. */
  15873. get uniqueId(): number;
  15874. /**
  15875. * Creates a new skeleton
  15876. * @param name defines the skeleton name
  15877. * @param id defines the skeleton Id
  15878. * @param scene defines the hosting scene
  15879. */
  15880. constructor(
  15881. /** defines the skeleton name */
  15882. name: string,
  15883. /** defines the skeleton Id */
  15884. id: string, scene: Scene);
  15885. /**
  15886. * Gets the current object class name.
  15887. * @return the class name
  15888. */
  15889. getClassName(): string;
  15890. /**
  15891. * Returns an array containing the root bones
  15892. * @returns an array containing the root bones
  15893. */
  15894. getChildren(): Array<Bone>;
  15895. /**
  15896. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15897. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15898. * @returns a Float32Array containing matrices data
  15899. */
  15900. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15901. /**
  15902. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15903. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15904. * @returns a raw texture containing the data
  15905. */
  15906. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15907. /**
  15908. * Gets the current hosting scene
  15909. * @returns a scene object
  15910. */
  15911. getScene(): Scene;
  15912. /**
  15913. * Gets a string representing the current skeleton data
  15914. * @param fullDetails defines a boolean indicating if we want a verbose version
  15915. * @returns a string representing the current skeleton data
  15916. */
  15917. toString(fullDetails?: boolean): string;
  15918. /**
  15919. * Get bone's index searching by name
  15920. * @param name defines bone's name to search for
  15921. * @return the indice of the bone. Returns -1 if not found
  15922. */
  15923. getBoneIndexByName(name: string): number;
  15924. /**
  15925. * Creater a new animation range
  15926. * @param name defines the name of the range
  15927. * @param from defines the start key
  15928. * @param to defines the end key
  15929. */
  15930. createAnimationRange(name: string, from: number, to: number): void;
  15931. /**
  15932. * Delete a specific animation range
  15933. * @param name defines the name of the range
  15934. * @param deleteFrames defines if frames must be removed as well
  15935. */
  15936. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15937. /**
  15938. * Gets a specific animation range
  15939. * @param name defines the name of the range to look for
  15940. * @returns the requested animation range or null if not found
  15941. */
  15942. getAnimationRange(name: string): Nullable<AnimationRange>;
  15943. /**
  15944. * Gets the list of all animation ranges defined on this skeleton
  15945. * @returns an array
  15946. */
  15947. getAnimationRanges(): Nullable<AnimationRange>[];
  15948. /**
  15949. * Copy animation range from a source skeleton.
  15950. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15951. * @param source defines the source skeleton
  15952. * @param name defines the name of the range to copy
  15953. * @param rescaleAsRequired defines if rescaling must be applied if required
  15954. * @returns true if operation was successful
  15955. */
  15956. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15957. /**
  15958. * Forces the skeleton to go to rest pose
  15959. */
  15960. returnToRest(): void;
  15961. private _getHighestAnimationFrame;
  15962. /**
  15963. * Begin a specific animation range
  15964. * @param name defines the name of the range to start
  15965. * @param loop defines if looping must be turned on (false by default)
  15966. * @param speedRatio defines the speed ratio to apply (1 by default)
  15967. * @param onAnimationEnd defines a callback which will be called when animation will end
  15968. * @returns a new animatable
  15969. */
  15970. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15971. /**
  15972. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  15973. * @param skeleton defines the Skeleton containing the animation range to convert
  15974. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  15975. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  15976. * @returns the original skeleton
  15977. */
  15978. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  15979. /** @hidden */
  15980. _markAsDirty(): void;
  15981. /** @hidden */
  15982. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15983. /** @hidden */
  15984. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15985. private _computeTransformMatrices;
  15986. /**
  15987. * Build all resources required to render a skeleton
  15988. */
  15989. prepare(): void;
  15990. /**
  15991. * Gets the list of animatables currently running for this skeleton
  15992. * @returns an array of animatables
  15993. */
  15994. getAnimatables(): IAnimatable[];
  15995. /**
  15996. * Clone the current skeleton
  15997. * @param name defines the name of the new skeleton
  15998. * @param id defines the id of the new skeleton
  15999. * @returns the new skeleton
  16000. */
  16001. clone(name: string, id?: string): Skeleton;
  16002. /**
  16003. * Enable animation blending for this skeleton
  16004. * @param blendingSpeed defines the blending speed to apply
  16005. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16006. */
  16007. enableBlending(blendingSpeed?: number): void;
  16008. /**
  16009. * Releases all resources associated with the current skeleton
  16010. */
  16011. dispose(): void;
  16012. /**
  16013. * Serialize the skeleton in a JSON object
  16014. * @returns a JSON object
  16015. */
  16016. serialize(): any;
  16017. /**
  16018. * Creates a new skeleton from serialized data
  16019. * @param parsedSkeleton defines the serialized data
  16020. * @param scene defines the hosting scene
  16021. * @returns a new skeleton
  16022. */
  16023. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16024. /**
  16025. * Compute all node absolute transforms
  16026. * @param forceUpdate defines if computation must be done even if cache is up to date
  16027. */
  16028. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16029. /**
  16030. * Gets the root pose matrix
  16031. * @returns a matrix
  16032. */
  16033. getPoseMatrix(): Nullable<Matrix>;
  16034. /**
  16035. * Sorts bones per internal index
  16036. */
  16037. sortBones(): void;
  16038. private _sortBones;
  16039. }
  16040. }
  16041. declare module BABYLON {
  16042. /**
  16043. * Creates an instance based on a source mesh.
  16044. */
  16045. export class InstancedMesh extends AbstractMesh {
  16046. private _sourceMesh;
  16047. private _currentLOD;
  16048. /** @hidden */
  16049. _indexInSourceMeshInstanceArray: number;
  16050. constructor(name: string, source: Mesh);
  16051. /**
  16052. * Returns the string "InstancedMesh".
  16053. */
  16054. getClassName(): string;
  16055. /** Gets the list of lights affecting that mesh */
  16056. get lightSources(): Light[];
  16057. _resyncLightSources(): void;
  16058. _resyncLightSource(light: Light): void;
  16059. _removeLightSource(light: Light, dispose: boolean): void;
  16060. /**
  16061. * If the source mesh receives shadows
  16062. */
  16063. get receiveShadows(): boolean;
  16064. /**
  16065. * The material of the source mesh
  16066. */
  16067. get material(): Nullable<Material>;
  16068. /**
  16069. * Visibility of the source mesh
  16070. */
  16071. get visibility(): number;
  16072. /**
  16073. * Skeleton of the source mesh
  16074. */
  16075. get skeleton(): Nullable<Skeleton>;
  16076. /**
  16077. * Rendering ground id of the source mesh
  16078. */
  16079. get renderingGroupId(): number;
  16080. set renderingGroupId(value: number);
  16081. /**
  16082. * Returns the total number of vertices (integer).
  16083. */
  16084. getTotalVertices(): number;
  16085. /**
  16086. * Returns a positive integer : the total number of indices in this mesh geometry.
  16087. * @returns the numner of indices or zero if the mesh has no geometry.
  16088. */
  16089. getTotalIndices(): number;
  16090. /**
  16091. * The source mesh of the instance
  16092. */
  16093. get sourceMesh(): Mesh;
  16094. /**
  16095. * Creates a new InstancedMesh object from the mesh model.
  16096. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16097. * @param name defines the name of the new instance
  16098. * @returns a new InstancedMesh
  16099. */
  16100. createInstance(name: string): InstancedMesh;
  16101. /**
  16102. * Is this node ready to be used/rendered
  16103. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16104. * @return {boolean} is it ready
  16105. */
  16106. isReady(completeCheck?: boolean): boolean;
  16107. /**
  16108. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16109. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16110. * @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.
  16111. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16112. */
  16113. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16114. /**
  16115. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16116. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16117. * The `data` are either a numeric array either a Float32Array.
  16118. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16119. * 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).
  16120. * Note that a new underlying VertexBuffer object is created each call.
  16121. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16122. *
  16123. * Possible `kind` values :
  16124. * - VertexBuffer.PositionKind
  16125. * - VertexBuffer.UVKind
  16126. * - VertexBuffer.UV2Kind
  16127. * - VertexBuffer.UV3Kind
  16128. * - VertexBuffer.UV4Kind
  16129. * - VertexBuffer.UV5Kind
  16130. * - VertexBuffer.UV6Kind
  16131. * - VertexBuffer.ColorKind
  16132. * - VertexBuffer.MatricesIndicesKind
  16133. * - VertexBuffer.MatricesIndicesExtraKind
  16134. * - VertexBuffer.MatricesWeightsKind
  16135. * - VertexBuffer.MatricesWeightsExtraKind
  16136. *
  16137. * Returns the Mesh.
  16138. */
  16139. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16140. /**
  16141. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16142. * If the mesh has no geometry, it is simply returned as it is.
  16143. * The `data` are either a numeric array either a Float32Array.
  16144. * No new underlying VertexBuffer object is created.
  16145. * 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.
  16146. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16147. *
  16148. * Possible `kind` values :
  16149. * - VertexBuffer.PositionKind
  16150. * - VertexBuffer.UVKind
  16151. * - VertexBuffer.UV2Kind
  16152. * - VertexBuffer.UV3Kind
  16153. * - VertexBuffer.UV4Kind
  16154. * - VertexBuffer.UV5Kind
  16155. * - VertexBuffer.UV6Kind
  16156. * - VertexBuffer.ColorKind
  16157. * - VertexBuffer.MatricesIndicesKind
  16158. * - VertexBuffer.MatricesIndicesExtraKind
  16159. * - VertexBuffer.MatricesWeightsKind
  16160. * - VertexBuffer.MatricesWeightsExtraKind
  16161. *
  16162. * Returns the Mesh.
  16163. */
  16164. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16165. /**
  16166. * Sets the mesh indices.
  16167. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16168. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16169. * This method creates a new index buffer each call.
  16170. * Returns the Mesh.
  16171. */
  16172. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16173. /**
  16174. * Boolean : True if the mesh owns the requested kind of data.
  16175. */
  16176. isVerticesDataPresent(kind: string): boolean;
  16177. /**
  16178. * Returns an array of indices (IndicesArray).
  16179. */
  16180. getIndices(): Nullable<IndicesArray>;
  16181. get _positions(): Nullable<Vector3[]>;
  16182. /**
  16183. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16184. * This means the mesh underlying bounding box and sphere are recomputed.
  16185. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16186. * @returns the current mesh
  16187. */
  16188. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16189. /** @hidden */
  16190. _preActivate(): InstancedMesh;
  16191. /** @hidden */
  16192. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16193. /** @hidden */
  16194. _postActivate(): void;
  16195. getWorldMatrix(): Matrix;
  16196. get isAnInstance(): boolean;
  16197. /**
  16198. * Returns the current associated LOD AbstractMesh.
  16199. */
  16200. getLOD(camera: Camera): AbstractMesh;
  16201. /** @hidden */
  16202. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16203. /** @hidden */
  16204. _syncSubMeshes(): InstancedMesh;
  16205. /** @hidden */
  16206. _generatePointsArray(): boolean;
  16207. /**
  16208. * Creates a new InstancedMesh from the current mesh.
  16209. * - name (string) : the cloned mesh name
  16210. * - newParent (optional Node) : the optional Node to parent the clone to.
  16211. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16212. *
  16213. * Returns the clone.
  16214. */
  16215. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16216. /**
  16217. * Disposes the InstancedMesh.
  16218. * Returns nothing.
  16219. */
  16220. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16221. }
  16222. interface Mesh {
  16223. /**
  16224. * Register a custom buffer that will be instanced
  16225. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16226. * @param kind defines the buffer kind
  16227. * @param stride defines the stride in floats
  16228. */
  16229. registerInstancedBuffer(kind: string, stride: number): void;
  16230. /**
  16231. * true to use the edge renderer for all instances of this mesh
  16232. */
  16233. edgesShareWithInstances: boolean;
  16234. /** @hidden */
  16235. _userInstancedBuffersStorage: {
  16236. data: {
  16237. [key: string]: Float32Array;
  16238. };
  16239. sizes: {
  16240. [key: string]: number;
  16241. };
  16242. vertexBuffers: {
  16243. [key: string]: Nullable<VertexBuffer>;
  16244. };
  16245. strides: {
  16246. [key: string]: number;
  16247. };
  16248. };
  16249. }
  16250. interface AbstractMesh {
  16251. /**
  16252. * Object used to store instanced buffers defined by user
  16253. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16254. */
  16255. instancedBuffers: {
  16256. [key: string]: any;
  16257. };
  16258. }
  16259. }
  16260. declare module BABYLON {
  16261. /**
  16262. * Defines the options associated with the creation of a shader material.
  16263. */
  16264. export interface IShaderMaterialOptions {
  16265. /**
  16266. * Does the material work in alpha blend mode
  16267. */
  16268. needAlphaBlending: boolean;
  16269. /**
  16270. * Does the material work in alpha test mode
  16271. */
  16272. needAlphaTesting: boolean;
  16273. /**
  16274. * The list of attribute names used in the shader
  16275. */
  16276. attributes: string[];
  16277. /**
  16278. * The list of unifrom names used in the shader
  16279. */
  16280. uniforms: string[];
  16281. /**
  16282. * The list of UBO names used in the shader
  16283. */
  16284. uniformBuffers: string[];
  16285. /**
  16286. * The list of sampler names used in the shader
  16287. */
  16288. samplers: string[];
  16289. /**
  16290. * The list of defines used in the shader
  16291. */
  16292. defines: string[];
  16293. }
  16294. /**
  16295. * 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.
  16296. *
  16297. * This returned material effects how the mesh will look based on the code in the shaders.
  16298. *
  16299. * @see https://doc.babylonjs.com/how_to/shader_material
  16300. */
  16301. export class ShaderMaterial extends Material {
  16302. private _shaderPath;
  16303. private _options;
  16304. private _textures;
  16305. private _textureArrays;
  16306. private _floats;
  16307. private _ints;
  16308. private _floatsArrays;
  16309. private _colors3;
  16310. private _colors3Arrays;
  16311. private _colors4;
  16312. private _colors4Arrays;
  16313. private _vectors2;
  16314. private _vectors3;
  16315. private _vectors4;
  16316. private _matrices;
  16317. private _matrixArrays;
  16318. private _matrices3x3;
  16319. private _matrices2x2;
  16320. private _vectors2Arrays;
  16321. private _vectors3Arrays;
  16322. private _vectors4Arrays;
  16323. private _cachedWorldViewMatrix;
  16324. private _cachedWorldViewProjectionMatrix;
  16325. private _renderId;
  16326. private _multiview;
  16327. private _cachedDefines;
  16328. /** Define the Url to load snippets */
  16329. static SnippetUrl: string;
  16330. /** Snippet ID if the material was created from the snippet server */
  16331. snippetId: string;
  16332. /**
  16333. * Instantiate a new shader material.
  16334. * 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.
  16335. * This returned material effects how the mesh will look based on the code in the shaders.
  16336. * @see https://doc.babylonjs.com/how_to/shader_material
  16337. * @param name Define the name of the material in the scene
  16338. * @param scene Define the scene the material belongs to
  16339. * @param shaderPath Defines the route to the shader code in one of three ways:
  16340. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16341. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16342. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16343. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16344. * @param options Define the options used to create the shader
  16345. */
  16346. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16347. /**
  16348. * Gets the shader path used to define the shader code
  16349. * It can be modified to trigger a new compilation
  16350. */
  16351. get shaderPath(): any;
  16352. /**
  16353. * Sets the shader path used to define the shader code
  16354. * It can be modified to trigger a new compilation
  16355. */
  16356. set shaderPath(shaderPath: any);
  16357. /**
  16358. * Gets the options used to compile the shader.
  16359. * They can be modified to trigger a new compilation
  16360. */
  16361. get options(): IShaderMaterialOptions;
  16362. /**
  16363. * Gets the current class name of the material e.g. "ShaderMaterial"
  16364. * Mainly use in serialization.
  16365. * @returns the class name
  16366. */
  16367. getClassName(): string;
  16368. /**
  16369. * Specifies if the material will require alpha blending
  16370. * @returns a boolean specifying if alpha blending is needed
  16371. */
  16372. needAlphaBlending(): boolean;
  16373. /**
  16374. * Specifies if this material should be rendered in alpha test mode
  16375. * @returns a boolean specifying if an alpha test is needed.
  16376. */
  16377. needAlphaTesting(): boolean;
  16378. private _checkUniform;
  16379. /**
  16380. * Set a texture in the shader.
  16381. * @param name Define the name of the uniform samplers as defined in the shader
  16382. * @param texture Define the texture to bind to this sampler
  16383. * @return the material itself allowing "fluent" like uniform updates
  16384. */
  16385. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16386. /**
  16387. * Set a texture array in the shader.
  16388. * @param name Define the name of the uniform sampler array as defined in the shader
  16389. * @param textures Define the list of textures to bind to this sampler
  16390. * @return the material itself allowing "fluent" like uniform updates
  16391. */
  16392. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16393. /**
  16394. * Set a float in the shader.
  16395. * @param name Define the name of the uniform as defined in the shader
  16396. * @param value Define the value to give to the uniform
  16397. * @return the material itself allowing "fluent" like uniform updates
  16398. */
  16399. setFloat(name: string, value: number): ShaderMaterial;
  16400. /**
  16401. * Set a int in the shader.
  16402. * @param name Define the name of the uniform as defined in the shader
  16403. * @param value Define the value to give to the uniform
  16404. * @return the material itself allowing "fluent" like uniform updates
  16405. */
  16406. setInt(name: string, value: number): ShaderMaterial;
  16407. /**
  16408. * Set an array of floats in the shader.
  16409. * @param name Define the name of the uniform as defined in the shader
  16410. * @param value Define the value to give to the uniform
  16411. * @return the material itself allowing "fluent" like uniform updates
  16412. */
  16413. setFloats(name: string, value: number[]): ShaderMaterial;
  16414. /**
  16415. * Set a vec3 in the shader from a Color3.
  16416. * @param name Define the name of the uniform as defined in the shader
  16417. * @param value Define the value to give to the uniform
  16418. * @return the material itself allowing "fluent" like uniform updates
  16419. */
  16420. setColor3(name: string, value: Color3): ShaderMaterial;
  16421. /**
  16422. * Set a vec3 array in the shader from a Color3 array.
  16423. * @param name Define the name of the uniform as defined in the shader
  16424. * @param value Define the value to give to the uniform
  16425. * @return the material itself allowing "fluent" like uniform updates
  16426. */
  16427. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16428. /**
  16429. * Set a vec4 in the shader from a Color4.
  16430. * @param name Define the name of the uniform as defined in the shader
  16431. * @param value Define the value to give to the uniform
  16432. * @return the material itself allowing "fluent" like uniform updates
  16433. */
  16434. setColor4(name: string, value: Color4): ShaderMaterial;
  16435. /**
  16436. * Set a vec4 array in the shader from a Color4 array.
  16437. * @param name Define the name of the uniform as defined in the shader
  16438. * @param value Define the value to give to the uniform
  16439. * @return the material itself allowing "fluent" like uniform updates
  16440. */
  16441. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16442. /**
  16443. * Set a vec2 in the shader from a Vector2.
  16444. * @param name Define the name of the uniform as defined in the shader
  16445. * @param value Define the value to give to the uniform
  16446. * @return the material itself allowing "fluent" like uniform updates
  16447. */
  16448. setVector2(name: string, value: Vector2): ShaderMaterial;
  16449. /**
  16450. * Set a vec3 in the shader from a Vector3.
  16451. * @param name Define the name of the uniform as defined in the shader
  16452. * @param value Define the value to give to the uniform
  16453. * @return the material itself allowing "fluent" like uniform updates
  16454. */
  16455. setVector3(name: string, value: Vector3): ShaderMaterial;
  16456. /**
  16457. * Set a vec4 in the shader from a Vector4.
  16458. * @param name Define the name of the uniform as defined in the shader
  16459. * @param value Define the value to give to the uniform
  16460. * @return the material itself allowing "fluent" like uniform updates
  16461. */
  16462. setVector4(name: string, value: Vector4): ShaderMaterial;
  16463. /**
  16464. * Set a mat4 in the shader from a Matrix.
  16465. * @param name Define the name of the uniform as defined in the shader
  16466. * @param value Define the value to give to the uniform
  16467. * @return the material itself allowing "fluent" like uniform updates
  16468. */
  16469. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16470. /**
  16471. * Set a float32Array in the shader from a matrix array.
  16472. * @param name Define the name of the uniform as defined in the shader
  16473. * @param value Define the value to give to the uniform
  16474. * @return the material itself allowing "fluent" like uniform updates
  16475. */
  16476. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16477. /**
  16478. * Set a mat3 in the shader from a Float32Array.
  16479. * @param name Define the name of the uniform as defined in the shader
  16480. * @param value Define the value to give to the uniform
  16481. * @return the material itself allowing "fluent" like uniform updates
  16482. */
  16483. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16484. /**
  16485. * Set a mat2 in the shader from a Float32Array.
  16486. * @param name Define the name of the uniform as defined in the shader
  16487. * @param value Define the value to give to the uniform
  16488. * @return the material itself allowing "fluent" like uniform updates
  16489. */
  16490. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16491. /**
  16492. * Set a vec2 array in the shader from a number array.
  16493. * @param name Define the name of the uniform as defined in the shader
  16494. * @param value Define the value to give to the uniform
  16495. * @return the material itself allowing "fluent" like uniform updates
  16496. */
  16497. setArray2(name: string, value: number[]): ShaderMaterial;
  16498. /**
  16499. * Set a vec3 array in the shader from a number array.
  16500. * @param name Define the name of the uniform as defined in the shader
  16501. * @param value Define the value to give to the uniform
  16502. * @return the material itself allowing "fluent" like uniform updates
  16503. */
  16504. setArray3(name: string, value: number[]): ShaderMaterial;
  16505. /**
  16506. * Set a vec4 array in the shader from a number array.
  16507. * @param name Define the name of the uniform as defined in the shader
  16508. * @param value Define the value to give to the uniform
  16509. * @return the material itself allowing "fluent" like uniform updates
  16510. */
  16511. setArray4(name: string, value: number[]): ShaderMaterial;
  16512. private _checkCache;
  16513. /**
  16514. * Specifies that the submesh is ready to be used
  16515. * @param mesh defines the mesh to check
  16516. * @param subMesh defines which submesh to check
  16517. * @param useInstances specifies that instances should be used
  16518. * @returns a boolean indicating that the submesh is ready or not
  16519. */
  16520. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16521. /**
  16522. * Checks if the material is ready to render the requested mesh
  16523. * @param mesh Define the mesh to render
  16524. * @param useInstances Define whether or not the material is used with instances
  16525. * @returns true if ready, otherwise false
  16526. */
  16527. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16528. /**
  16529. * Binds the world matrix to the material
  16530. * @param world defines the world transformation matrix
  16531. * @param effectOverride - If provided, use this effect instead of internal effect
  16532. */
  16533. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16534. /**
  16535. * Binds the submesh to this material by preparing the effect and shader to draw
  16536. * @param world defines the world transformation matrix
  16537. * @param mesh defines the mesh containing the submesh
  16538. * @param subMesh defines the submesh to bind the material to
  16539. */
  16540. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16541. /**
  16542. * Binds the material to the mesh
  16543. * @param world defines the world transformation matrix
  16544. * @param mesh defines the mesh to bind the material to
  16545. * @param effectOverride - If provided, use this effect instead of internal effect
  16546. */
  16547. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16548. protected _afterBind(mesh?: Mesh): void;
  16549. /**
  16550. * Gets the active textures from the material
  16551. * @returns an array of textures
  16552. */
  16553. getActiveTextures(): BaseTexture[];
  16554. /**
  16555. * Specifies if the material uses a texture
  16556. * @param texture defines the texture to check against the material
  16557. * @returns a boolean specifying if the material uses the texture
  16558. */
  16559. hasTexture(texture: BaseTexture): boolean;
  16560. /**
  16561. * Makes a duplicate of the material, and gives it a new name
  16562. * @param name defines the new name for the duplicated material
  16563. * @returns the cloned material
  16564. */
  16565. clone(name: string): ShaderMaterial;
  16566. /**
  16567. * Disposes the material
  16568. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16569. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16570. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16571. */
  16572. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16573. /**
  16574. * Serializes this material in a JSON representation
  16575. * @returns the serialized material object
  16576. */
  16577. serialize(): any;
  16578. /**
  16579. * Creates a shader material from parsed shader material data
  16580. * @param source defines the JSON represnetation of the material
  16581. * @param scene defines the hosting scene
  16582. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16583. * @returns a new material
  16584. */
  16585. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16586. /**
  16587. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16588. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16589. * @param url defines the url to load from
  16590. * @param scene defines the hosting scene
  16591. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16592. * @returns a promise that will resolve to the new ShaderMaterial
  16593. */
  16594. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16595. /**
  16596. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16597. * @param snippetId defines the snippet to load
  16598. * @param scene defines the hosting scene
  16599. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16600. * @returns a promise that will resolve to the new ShaderMaterial
  16601. */
  16602. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16603. }
  16604. }
  16605. declare module BABYLON {
  16606. /** @hidden */
  16607. export var colorPixelShader: {
  16608. name: string;
  16609. shader: string;
  16610. };
  16611. }
  16612. declare module BABYLON {
  16613. /** @hidden */
  16614. export var colorVertexShader: {
  16615. name: string;
  16616. shader: string;
  16617. };
  16618. }
  16619. declare module BABYLON {
  16620. /**
  16621. * Line mesh
  16622. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16623. */
  16624. export class LinesMesh extends Mesh {
  16625. /**
  16626. * If vertex color should be applied to the mesh
  16627. */
  16628. readonly useVertexColor?: boolean | undefined;
  16629. /**
  16630. * If vertex alpha should be applied to the mesh
  16631. */
  16632. readonly useVertexAlpha?: boolean | undefined;
  16633. /**
  16634. * Color of the line (Default: White)
  16635. */
  16636. color: Color3;
  16637. /**
  16638. * Alpha of the line (Default: 1)
  16639. */
  16640. alpha: number;
  16641. /**
  16642. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16643. * This margin is expressed in world space coordinates, so its value may vary.
  16644. * Default value is 0.1
  16645. */
  16646. intersectionThreshold: number;
  16647. private _colorShader;
  16648. private color4;
  16649. /**
  16650. * Creates a new LinesMesh
  16651. * @param name defines the name
  16652. * @param scene defines the hosting scene
  16653. * @param parent defines the parent mesh if any
  16654. * @param source defines the optional source LinesMesh used to clone data from
  16655. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16656. * When false, achieved by calling a clone(), also passing False.
  16657. * This will make creation of children, recursive.
  16658. * @param useVertexColor defines if this LinesMesh supports vertex color
  16659. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16660. */
  16661. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16662. /**
  16663. * If vertex color should be applied to the mesh
  16664. */
  16665. useVertexColor?: boolean | undefined,
  16666. /**
  16667. * If vertex alpha should be applied to the mesh
  16668. */
  16669. useVertexAlpha?: boolean | undefined);
  16670. private _addClipPlaneDefine;
  16671. private _removeClipPlaneDefine;
  16672. isReady(): boolean;
  16673. /**
  16674. * Returns the string "LineMesh"
  16675. */
  16676. getClassName(): string;
  16677. /**
  16678. * @hidden
  16679. */
  16680. get material(): Material;
  16681. /**
  16682. * @hidden
  16683. */
  16684. set material(value: Material);
  16685. /**
  16686. * @hidden
  16687. */
  16688. get checkCollisions(): boolean;
  16689. /** @hidden */
  16690. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16691. /** @hidden */
  16692. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16693. /**
  16694. * Disposes of the line mesh
  16695. * @param doNotRecurse If children should be disposed
  16696. */
  16697. dispose(doNotRecurse?: boolean): void;
  16698. /**
  16699. * Returns a new LineMesh object cloned from the current one.
  16700. */
  16701. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16702. /**
  16703. * Creates a new InstancedLinesMesh object from the mesh model.
  16704. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16705. * @param name defines the name of the new instance
  16706. * @returns a new InstancedLinesMesh
  16707. */
  16708. createInstance(name: string): InstancedLinesMesh;
  16709. }
  16710. /**
  16711. * Creates an instance based on a source LinesMesh
  16712. */
  16713. export class InstancedLinesMesh extends InstancedMesh {
  16714. /**
  16715. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16716. * This margin is expressed in world space coordinates, so its value may vary.
  16717. * Initilized with the intersectionThreshold value of the source LinesMesh
  16718. */
  16719. intersectionThreshold: number;
  16720. constructor(name: string, source: LinesMesh);
  16721. /**
  16722. * Returns the string "InstancedLinesMesh".
  16723. */
  16724. getClassName(): string;
  16725. }
  16726. }
  16727. declare module BABYLON {
  16728. /** @hidden */
  16729. export var linePixelShader: {
  16730. name: string;
  16731. shader: string;
  16732. };
  16733. }
  16734. declare module BABYLON {
  16735. /** @hidden */
  16736. export var lineVertexShader: {
  16737. name: string;
  16738. shader: string;
  16739. };
  16740. }
  16741. declare module BABYLON {
  16742. interface Scene {
  16743. /** @hidden */
  16744. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  16745. }
  16746. interface AbstractMesh {
  16747. /**
  16748. * Gets the edgesRenderer associated with the mesh
  16749. */
  16750. edgesRenderer: Nullable<EdgesRenderer>;
  16751. }
  16752. interface LinesMesh {
  16753. /**
  16754. * Enables the edge rendering mode on the mesh.
  16755. * This mode makes the mesh edges visible
  16756. * @param epsilon defines the maximal distance between two angles to detect a face
  16757. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16758. * @returns the currentAbstractMesh
  16759. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16760. */
  16761. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16762. }
  16763. interface InstancedLinesMesh {
  16764. /**
  16765. * Enables the edge rendering mode on the mesh.
  16766. * This mode makes the mesh edges visible
  16767. * @param epsilon defines the maximal distance between two angles to detect a face
  16768. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16769. * @returns the current InstancedLinesMesh
  16770. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16771. */
  16772. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16773. }
  16774. /**
  16775. * Defines the minimum contract an Edges renderer should follow.
  16776. */
  16777. export interface IEdgesRenderer extends IDisposable {
  16778. /**
  16779. * Gets or sets a boolean indicating if the edgesRenderer is active
  16780. */
  16781. isEnabled: boolean;
  16782. /**
  16783. * Renders the edges of the attached mesh,
  16784. */
  16785. render(): void;
  16786. /**
  16787. * Checks wether or not the edges renderer is ready to render.
  16788. * @return true if ready, otherwise false.
  16789. */
  16790. isReady(): boolean;
  16791. /**
  16792. * List of instances to render in case the source mesh has instances
  16793. */
  16794. customInstances: SmartArray<Matrix>;
  16795. }
  16796. /**
  16797. * Defines the additional options of the edges renderer
  16798. */
  16799. export interface IEdgesRendererOptions {
  16800. /**
  16801. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  16802. * If not defined, the default value is true
  16803. */
  16804. useAlternateEdgeFinder?: boolean;
  16805. /**
  16806. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  16807. * If not defined, the default value is true.
  16808. * 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)
  16809. * This option is used only if useAlternateEdgeFinder = true
  16810. */
  16811. useFastVertexMerger?: boolean;
  16812. /**
  16813. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  16814. * The default value is 1e-6
  16815. * This option is used only if useAlternateEdgeFinder = true
  16816. */
  16817. epsilonVertexMerge?: number;
  16818. /**
  16819. * 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
  16820. * 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.
  16821. * This option is used only if useAlternateEdgeFinder = true
  16822. */
  16823. applyTessellation?: boolean;
  16824. /**
  16825. * 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
  16826. * The default value is 1e-6
  16827. * This option is used only if useAlternateEdgeFinder = true
  16828. */
  16829. epsilonVertexAligned?: number;
  16830. }
  16831. /**
  16832. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16833. */
  16834. export class EdgesRenderer implements IEdgesRenderer {
  16835. /**
  16836. * Define the size of the edges with an orthographic camera
  16837. */
  16838. edgesWidthScalerForOrthographic: number;
  16839. /**
  16840. * Define the size of the edges with a perspective camera
  16841. */
  16842. edgesWidthScalerForPerspective: number;
  16843. protected _source: AbstractMesh;
  16844. protected _linesPositions: number[];
  16845. protected _linesNormals: number[];
  16846. protected _linesIndices: number[];
  16847. protected _epsilon: number;
  16848. protected _indicesCount: number;
  16849. protected _lineShader: ShaderMaterial;
  16850. protected _ib: DataBuffer;
  16851. protected _buffers: {
  16852. [key: string]: Nullable<VertexBuffer>;
  16853. };
  16854. protected _buffersForInstances: {
  16855. [key: string]: Nullable<VertexBuffer>;
  16856. };
  16857. protected _checkVerticesInsteadOfIndices: boolean;
  16858. protected _options: Nullable<IEdgesRendererOptions>;
  16859. private _meshRebuildObserver;
  16860. private _meshDisposeObserver;
  16861. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16862. isEnabled: boolean;
  16863. /**
  16864. * List of instances to render in case the source mesh has instances
  16865. */
  16866. customInstances: SmartArray<Matrix>;
  16867. private static GetShader;
  16868. /**
  16869. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16870. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16871. * @param source Mesh used to create edges
  16872. * @param epsilon sum of angles in adjacency to check for edge
  16873. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  16874. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16875. * @param options The options to apply when generating the edges
  16876. */
  16877. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  16878. protected _prepareRessources(): void;
  16879. /** @hidden */
  16880. _rebuild(): void;
  16881. /**
  16882. * Releases the required resources for the edges renderer
  16883. */
  16884. dispose(): void;
  16885. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16886. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16887. /**
  16888. * Checks if the pair of p0 and p1 is en edge
  16889. * @param faceIndex
  16890. * @param edge
  16891. * @param faceNormals
  16892. * @param p0
  16893. * @param p1
  16894. * @private
  16895. */
  16896. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16897. /**
  16898. * push line into the position, normal and index buffer
  16899. * @protected
  16900. */
  16901. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16902. /**
  16903. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  16904. */
  16905. private _tessellateTriangle;
  16906. private _generateEdgesLinesAlternate;
  16907. /**
  16908. * Generates lines edges from adjacencjes
  16909. * @private
  16910. */
  16911. _generateEdgesLines(): void;
  16912. /**
  16913. * Checks wether or not the edges renderer is ready to render.
  16914. * @return true if ready, otherwise false.
  16915. */
  16916. isReady(): boolean;
  16917. /**
  16918. * Renders the edges of the attached mesh,
  16919. */
  16920. render(): void;
  16921. }
  16922. /**
  16923. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16924. */
  16925. export class LineEdgesRenderer extends EdgesRenderer {
  16926. /**
  16927. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16928. * @param source LineMesh used to generate edges
  16929. * @param epsilon not important (specified angle for edge detection)
  16930. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16931. */
  16932. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16933. /**
  16934. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16935. */
  16936. _generateEdgesLines(): void;
  16937. }
  16938. }
  16939. declare module BABYLON {
  16940. /**
  16941. * This represents the object necessary to create a rendering group.
  16942. * This is exclusively used and created by the rendering manager.
  16943. * To modify the behavior, you use the available helpers in your scene or meshes.
  16944. * @hidden
  16945. */
  16946. export class RenderingGroup {
  16947. index: number;
  16948. private static _zeroVector;
  16949. private _scene;
  16950. private _opaqueSubMeshes;
  16951. private _transparentSubMeshes;
  16952. private _alphaTestSubMeshes;
  16953. private _depthOnlySubMeshes;
  16954. private _particleSystems;
  16955. private _spriteManagers;
  16956. private _opaqueSortCompareFn;
  16957. private _alphaTestSortCompareFn;
  16958. private _transparentSortCompareFn;
  16959. private _renderOpaque;
  16960. private _renderAlphaTest;
  16961. private _renderTransparent;
  16962. /** @hidden */
  16963. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  16964. onBeforeTransparentRendering: () => void;
  16965. /**
  16966. * Set the opaque sort comparison function.
  16967. * If null the sub meshes will be render in the order they were created
  16968. */
  16969. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16970. /**
  16971. * Set the alpha test sort comparison function.
  16972. * If null the sub meshes will be render in the order they were created
  16973. */
  16974. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16975. /**
  16976. * Set the transparent sort comparison function.
  16977. * If null the sub meshes will be render in the order they were created
  16978. */
  16979. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16980. /**
  16981. * Creates a new rendering group.
  16982. * @param index The rendering group index
  16983. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16984. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16985. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16986. */
  16987. 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>);
  16988. /**
  16989. * Render all the sub meshes contained in the group.
  16990. * @param customRenderFunction Used to override the default render behaviour of the group.
  16991. * @returns true if rendered some submeshes.
  16992. */
  16993. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16994. /**
  16995. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16996. * @param subMeshes The submeshes to render
  16997. */
  16998. private renderOpaqueSorted;
  16999. /**
  17000. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17001. * @param subMeshes The submeshes to render
  17002. */
  17003. private renderAlphaTestSorted;
  17004. /**
  17005. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17006. * @param subMeshes The submeshes to render
  17007. */
  17008. private renderTransparentSorted;
  17009. /**
  17010. * Renders the submeshes in a specified order.
  17011. * @param subMeshes The submeshes to sort before render
  17012. * @param sortCompareFn The comparison function use to sort
  17013. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17014. * @param transparent Specifies to activate blending if true
  17015. */
  17016. private static renderSorted;
  17017. /**
  17018. * Renders the submeshes in the order they were dispatched (no sort applied).
  17019. * @param subMeshes The submeshes to render
  17020. */
  17021. private static renderUnsorted;
  17022. /**
  17023. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17024. * are rendered back to front if in the same alpha index.
  17025. *
  17026. * @param a The first submesh
  17027. * @param b The second submesh
  17028. * @returns The result of the comparison
  17029. */
  17030. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17031. /**
  17032. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17033. * are rendered back to front.
  17034. *
  17035. * @param a The first submesh
  17036. * @param b The second submesh
  17037. * @returns The result of the comparison
  17038. */
  17039. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17040. /**
  17041. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17042. * are rendered front to back (prevent overdraw).
  17043. *
  17044. * @param a The first submesh
  17045. * @param b The second submesh
  17046. * @returns The result of the comparison
  17047. */
  17048. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17049. /**
  17050. * Resets the different lists of submeshes to prepare a new frame.
  17051. */
  17052. prepare(): void;
  17053. dispose(): void;
  17054. /**
  17055. * Inserts the submesh in its correct queue depending on its material.
  17056. * @param subMesh The submesh to dispatch
  17057. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17058. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17059. */
  17060. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17061. dispatchSprites(spriteManager: ISpriteManager): void;
  17062. dispatchParticles(particleSystem: IParticleSystem): void;
  17063. private _renderParticles;
  17064. private _renderSprites;
  17065. }
  17066. }
  17067. declare module BABYLON {
  17068. /**
  17069. * Interface describing the different options available in the rendering manager
  17070. * regarding Auto Clear between groups.
  17071. */
  17072. export interface IRenderingManagerAutoClearSetup {
  17073. /**
  17074. * Defines whether or not autoclear is enable.
  17075. */
  17076. autoClear: boolean;
  17077. /**
  17078. * Defines whether or not to autoclear the depth buffer.
  17079. */
  17080. depth: boolean;
  17081. /**
  17082. * Defines whether or not to autoclear the stencil buffer.
  17083. */
  17084. stencil: boolean;
  17085. }
  17086. /**
  17087. * This class is used by the onRenderingGroupObservable
  17088. */
  17089. export class RenderingGroupInfo {
  17090. /**
  17091. * The Scene that being rendered
  17092. */
  17093. scene: Scene;
  17094. /**
  17095. * The camera currently used for the rendering pass
  17096. */
  17097. camera: Nullable<Camera>;
  17098. /**
  17099. * The ID of the renderingGroup being processed
  17100. */
  17101. renderingGroupId: number;
  17102. }
  17103. /**
  17104. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17105. * It is enable to manage the different groups as well as the different necessary sort functions.
  17106. * This should not be used directly aside of the few static configurations
  17107. */
  17108. export class RenderingManager {
  17109. /**
  17110. * The max id used for rendering groups (not included)
  17111. */
  17112. static MAX_RENDERINGGROUPS: number;
  17113. /**
  17114. * The min id used for rendering groups (included)
  17115. */
  17116. static MIN_RENDERINGGROUPS: number;
  17117. /**
  17118. * Used to globally prevent autoclearing scenes.
  17119. */
  17120. static AUTOCLEAR: boolean;
  17121. /**
  17122. * @hidden
  17123. */
  17124. _useSceneAutoClearSetup: boolean;
  17125. private _scene;
  17126. private _renderingGroups;
  17127. private _depthStencilBufferAlreadyCleaned;
  17128. private _autoClearDepthStencil;
  17129. private _customOpaqueSortCompareFn;
  17130. private _customAlphaTestSortCompareFn;
  17131. private _customTransparentSortCompareFn;
  17132. private _renderingGroupInfo;
  17133. /**
  17134. * Instantiates a new rendering group for a particular scene
  17135. * @param scene Defines the scene the groups belongs to
  17136. */
  17137. constructor(scene: Scene);
  17138. private _clearDepthStencilBuffer;
  17139. /**
  17140. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17141. * @hidden
  17142. */
  17143. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17144. /**
  17145. * Resets the different information of the group to prepare a new frame
  17146. * @hidden
  17147. */
  17148. reset(): void;
  17149. /**
  17150. * Dispose and release the group and its associated resources.
  17151. * @hidden
  17152. */
  17153. dispose(): void;
  17154. /**
  17155. * Clear the info related to rendering groups preventing retention points during dispose.
  17156. */
  17157. freeRenderingGroups(): void;
  17158. private _prepareRenderingGroup;
  17159. /**
  17160. * Add a sprite manager to the rendering manager in order to render it this frame.
  17161. * @param spriteManager Define the sprite manager to render
  17162. */
  17163. dispatchSprites(spriteManager: ISpriteManager): void;
  17164. /**
  17165. * Add a particle system to the rendering manager in order to render it this frame.
  17166. * @param particleSystem Define the particle system to render
  17167. */
  17168. dispatchParticles(particleSystem: IParticleSystem): void;
  17169. /**
  17170. * Add a submesh to the manager in order to render it this frame
  17171. * @param subMesh The submesh to dispatch
  17172. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17173. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17174. */
  17175. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17176. /**
  17177. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17178. * This allowed control for front to back rendering or reversly depending of the special needs.
  17179. *
  17180. * @param renderingGroupId The rendering group id corresponding to its index
  17181. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17182. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17183. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17184. */
  17185. 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;
  17186. /**
  17187. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17188. *
  17189. * @param renderingGroupId The rendering group id corresponding to its index
  17190. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17191. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17192. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17193. */
  17194. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17195. /**
  17196. * Gets the current auto clear configuration for one rendering group of the rendering
  17197. * manager.
  17198. * @param index the rendering group index to get the information for
  17199. * @returns The auto clear setup for the requested rendering group
  17200. */
  17201. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17202. }
  17203. }
  17204. declare module BABYLON {
  17205. /**
  17206. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17207. */
  17208. export interface ICustomShaderOptions {
  17209. /**
  17210. * Gets or sets the custom shader name to use
  17211. */
  17212. shaderName: string;
  17213. /**
  17214. * The list of attribute names used in the shader
  17215. */
  17216. attributes?: string[];
  17217. /**
  17218. * The list of unifrom names used in the shader
  17219. */
  17220. uniforms?: string[];
  17221. /**
  17222. * The list of sampler names used in the shader
  17223. */
  17224. samplers?: string[];
  17225. /**
  17226. * The list of defines used in the shader
  17227. */
  17228. defines?: string[];
  17229. }
  17230. /**
  17231. * Interface to implement to create a shadow generator compatible with BJS.
  17232. */
  17233. export interface IShadowGenerator {
  17234. /**
  17235. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17236. * @returns The render target texture if present otherwise, null
  17237. */
  17238. getShadowMap(): Nullable<RenderTargetTexture>;
  17239. /**
  17240. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17241. * @param subMesh The submesh we want to render in the shadow map
  17242. * @param useInstances Defines wether will draw in the map using instances
  17243. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17244. * @returns true if ready otherwise, false
  17245. */
  17246. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17247. /**
  17248. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17249. * @param defines Defines of the material we want to update
  17250. * @param lightIndex Index of the light in the enabled light list of the material
  17251. */
  17252. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17253. /**
  17254. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17255. * defined in the generator but impacting the effect).
  17256. * It implies the unifroms available on the materials are the standard BJS ones.
  17257. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17258. * @param effect The effect we are binfing the information for
  17259. */
  17260. bindShadowLight(lightIndex: string, effect: Effect): void;
  17261. /**
  17262. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17263. * (eq to shadow prjection matrix * light transform matrix)
  17264. * @returns The transform matrix used to create the shadow map
  17265. */
  17266. getTransformMatrix(): Matrix;
  17267. /**
  17268. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17269. * Cube and 2D textures for instance.
  17270. */
  17271. recreateShadowMap(): void;
  17272. /**
  17273. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17274. * @param onCompiled Callback triggered at the and of the effects compilation
  17275. * @param options Sets of optional options forcing the compilation with different modes
  17276. */
  17277. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17278. useInstances: boolean;
  17279. }>): void;
  17280. /**
  17281. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17282. * @param options Sets of optional options forcing the compilation with different modes
  17283. * @returns A promise that resolves when the compilation completes
  17284. */
  17285. forceCompilationAsync(options?: Partial<{
  17286. useInstances: boolean;
  17287. }>): Promise<void>;
  17288. /**
  17289. * Serializes the shadow generator setup to a json object.
  17290. * @returns The serialized JSON object
  17291. */
  17292. serialize(): any;
  17293. /**
  17294. * Disposes the Shadow map and related Textures and effects.
  17295. */
  17296. dispose(): void;
  17297. }
  17298. /**
  17299. * Default implementation IShadowGenerator.
  17300. * This is the main object responsible of generating shadows in the framework.
  17301. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17302. */
  17303. export class ShadowGenerator implements IShadowGenerator {
  17304. /**
  17305. * Name of the shadow generator class
  17306. */
  17307. static CLASSNAME: string;
  17308. /**
  17309. * Shadow generator mode None: no filtering applied.
  17310. */
  17311. static readonly FILTER_NONE: number;
  17312. /**
  17313. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17314. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17315. */
  17316. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17317. /**
  17318. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17319. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17320. */
  17321. static readonly FILTER_POISSONSAMPLING: number;
  17322. /**
  17323. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17324. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17325. */
  17326. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17327. /**
  17328. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17329. * edge artifacts on steep falloff.
  17330. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17331. */
  17332. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17333. /**
  17334. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17335. * edge artifacts on steep falloff.
  17336. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17337. */
  17338. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17339. /**
  17340. * Shadow generator mode PCF: Percentage Closer Filtering
  17341. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17342. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17343. */
  17344. static readonly FILTER_PCF: number;
  17345. /**
  17346. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17347. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17348. * Contact Hardening
  17349. */
  17350. static readonly FILTER_PCSS: number;
  17351. /**
  17352. * Reserved for PCF and PCSS
  17353. * Highest Quality.
  17354. *
  17355. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17356. *
  17357. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17358. */
  17359. static readonly QUALITY_HIGH: number;
  17360. /**
  17361. * Reserved for PCF and PCSS
  17362. * Good tradeoff for quality/perf cross devices
  17363. *
  17364. * Execute PCF on a 3*3 kernel.
  17365. *
  17366. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17367. */
  17368. static readonly QUALITY_MEDIUM: number;
  17369. /**
  17370. * Reserved for PCF and PCSS
  17371. * The lowest quality but the fastest.
  17372. *
  17373. * Execute PCF on a 1*1 kernel.
  17374. *
  17375. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17376. */
  17377. static readonly QUALITY_LOW: number;
  17378. /** Gets or sets the custom shader name to use */
  17379. customShaderOptions: ICustomShaderOptions;
  17380. /**
  17381. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17382. */
  17383. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17384. /**
  17385. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17386. */
  17387. onAfterShadowMapRenderObservable: Observable<Effect>;
  17388. /**
  17389. * Observable triggered before a mesh is rendered in the shadow map.
  17390. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17391. */
  17392. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17393. /**
  17394. * Observable triggered after a mesh is rendered in the shadow map.
  17395. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17396. */
  17397. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17398. protected _bias: number;
  17399. /**
  17400. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17401. */
  17402. get bias(): number;
  17403. /**
  17404. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17405. */
  17406. set bias(bias: number);
  17407. protected _normalBias: number;
  17408. /**
  17409. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17410. */
  17411. get normalBias(): number;
  17412. /**
  17413. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17414. */
  17415. set normalBias(normalBias: number);
  17416. protected _blurBoxOffset: number;
  17417. /**
  17418. * Gets the blur box offset: offset applied during the blur pass.
  17419. * Only useful if useKernelBlur = false
  17420. */
  17421. get blurBoxOffset(): number;
  17422. /**
  17423. * Sets the blur box offset: offset applied during the blur pass.
  17424. * Only useful if useKernelBlur = false
  17425. */
  17426. set blurBoxOffset(value: number);
  17427. protected _blurScale: number;
  17428. /**
  17429. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17430. * 2 means half of the size.
  17431. */
  17432. get blurScale(): number;
  17433. /**
  17434. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17435. * 2 means half of the size.
  17436. */
  17437. set blurScale(value: number);
  17438. protected _blurKernel: number;
  17439. /**
  17440. * Gets the blur kernel: kernel size of the blur pass.
  17441. * Only useful if useKernelBlur = true
  17442. */
  17443. get blurKernel(): number;
  17444. /**
  17445. * Sets the blur kernel: kernel size of the blur pass.
  17446. * Only useful if useKernelBlur = true
  17447. */
  17448. set blurKernel(value: number);
  17449. protected _useKernelBlur: boolean;
  17450. /**
  17451. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17452. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17453. */
  17454. get useKernelBlur(): boolean;
  17455. /**
  17456. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17457. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17458. */
  17459. set useKernelBlur(value: boolean);
  17460. protected _depthScale: number;
  17461. /**
  17462. * Gets the depth scale used in ESM mode.
  17463. */
  17464. get depthScale(): number;
  17465. /**
  17466. * Sets the depth scale used in ESM mode.
  17467. * This can override the scale stored on the light.
  17468. */
  17469. set depthScale(value: number);
  17470. protected _validateFilter(filter: number): number;
  17471. protected _filter: number;
  17472. /**
  17473. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17474. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17475. */
  17476. get filter(): number;
  17477. /**
  17478. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17479. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17480. */
  17481. set filter(value: number);
  17482. /**
  17483. * Gets if the current filter is set to Poisson Sampling.
  17484. */
  17485. get usePoissonSampling(): boolean;
  17486. /**
  17487. * Sets the current filter to Poisson Sampling.
  17488. */
  17489. set usePoissonSampling(value: boolean);
  17490. /**
  17491. * Gets if the current filter is set to ESM.
  17492. */
  17493. get useExponentialShadowMap(): boolean;
  17494. /**
  17495. * Sets the current filter is to ESM.
  17496. */
  17497. set useExponentialShadowMap(value: boolean);
  17498. /**
  17499. * Gets if the current filter is set to filtered ESM.
  17500. */
  17501. get useBlurExponentialShadowMap(): boolean;
  17502. /**
  17503. * Gets if the current filter is set to filtered ESM.
  17504. */
  17505. set useBlurExponentialShadowMap(value: boolean);
  17506. /**
  17507. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17508. * exponential to prevent steep falloff artifacts).
  17509. */
  17510. get useCloseExponentialShadowMap(): boolean;
  17511. /**
  17512. * Sets the current filter to "close ESM" (using the inverse of the
  17513. * exponential to prevent steep falloff artifacts).
  17514. */
  17515. set useCloseExponentialShadowMap(value: boolean);
  17516. /**
  17517. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17518. * exponential to prevent steep falloff artifacts).
  17519. */
  17520. get useBlurCloseExponentialShadowMap(): boolean;
  17521. /**
  17522. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17523. * exponential to prevent steep falloff artifacts).
  17524. */
  17525. set useBlurCloseExponentialShadowMap(value: boolean);
  17526. /**
  17527. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17528. */
  17529. get usePercentageCloserFiltering(): boolean;
  17530. /**
  17531. * Sets the current filter to "PCF" (percentage closer filtering).
  17532. */
  17533. set usePercentageCloserFiltering(value: boolean);
  17534. protected _filteringQuality: number;
  17535. /**
  17536. * Gets the PCF or PCSS Quality.
  17537. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17538. */
  17539. get filteringQuality(): number;
  17540. /**
  17541. * Sets the PCF or PCSS Quality.
  17542. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17543. */
  17544. set filteringQuality(filteringQuality: number);
  17545. /**
  17546. * Gets if the current filter is set to "PCSS" (contact hardening).
  17547. */
  17548. get useContactHardeningShadow(): boolean;
  17549. /**
  17550. * Sets the current filter to "PCSS" (contact hardening).
  17551. */
  17552. set useContactHardeningShadow(value: boolean);
  17553. protected _contactHardeningLightSizeUVRatio: number;
  17554. /**
  17555. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17556. * Using a ratio helps keeping shape stability independently of the map size.
  17557. *
  17558. * It does not account for the light projection as it was having too much
  17559. * instability during the light setup or during light position changes.
  17560. *
  17561. * Only valid if useContactHardeningShadow is true.
  17562. */
  17563. get contactHardeningLightSizeUVRatio(): number;
  17564. /**
  17565. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17566. * Using a ratio helps keeping shape stability independently of the map size.
  17567. *
  17568. * It does not account for the light projection as it was having too much
  17569. * instability during the light setup or during light position changes.
  17570. *
  17571. * Only valid if useContactHardeningShadow is true.
  17572. */
  17573. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17574. protected _darkness: number;
  17575. /** Gets or sets the actual darkness of a shadow */
  17576. get darkness(): number;
  17577. set darkness(value: number);
  17578. /**
  17579. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17580. * 0 means strongest and 1 would means no shadow.
  17581. * @returns the darkness.
  17582. */
  17583. getDarkness(): number;
  17584. /**
  17585. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17586. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17587. * @returns the shadow generator allowing fluent coding.
  17588. */
  17589. setDarkness(darkness: number): ShadowGenerator;
  17590. protected _transparencyShadow: boolean;
  17591. /** Gets or sets the ability to have transparent shadow */
  17592. get transparencyShadow(): boolean;
  17593. set transparencyShadow(value: boolean);
  17594. /**
  17595. * Sets the ability to have transparent shadow (boolean).
  17596. * @param transparent True if transparent else False
  17597. * @returns the shadow generator allowing fluent coding
  17598. */
  17599. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17600. /**
  17601. * Enables or disables shadows with varying strength based on the transparency
  17602. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17603. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17604. * mesh.visibility * alphaTexture.a
  17605. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17606. */
  17607. enableSoftTransparentShadow: boolean;
  17608. protected _shadowMap: Nullable<RenderTargetTexture>;
  17609. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17610. /**
  17611. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17612. * @returns The render target texture if present otherwise, null
  17613. */
  17614. getShadowMap(): Nullable<RenderTargetTexture>;
  17615. /**
  17616. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17617. * @returns The render target texture if the shadow map is present otherwise, null
  17618. */
  17619. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17620. /**
  17621. * Gets the class name of that object
  17622. * @returns "ShadowGenerator"
  17623. */
  17624. getClassName(): string;
  17625. /**
  17626. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17627. * @param mesh Mesh to add
  17628. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17629. * @returns the Shadow Generator itself
  17630. */
  17631. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17632. /**
  17633. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17634. * @param mesh Mesh to remove
  17635. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17636. * @returns the Shadow Generator itself
  17637. */
  17638. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17639. /**
  17640. * Controls the extent to which the shadows fade out at the edge of the frustum
  17641. */
  17642. frustumEdgeFalloff: number;
  17643. protected _light: IShadowLight;
  17644. /**
  17645. * Returns the associated light object.
  17646. * @returns the light generating the shadow
  17647. */
  17648. getLight(): IShadowLight;
  17649. /**
  17650. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17651. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17652. * It might on the other hand introduce peter panning.
  17653. */
  17654. forceBackFacesOnly: boolean;
  17655. protected _scene: Scene;
  17656. protected _lightDirection: Vector3;
  17657. protected _effect: Effect;
  17658. protected _viewMatrix: Matrix;
  17659. protected _projectionMatrix: Matrix;
  17660. protected _transformMatrix: Matrix;
  17661. protected _cachedPosition: Vector3;
  17662. protected _cachedDirection: Vector3;
  17663. protected _cachedDefines: string;
  17664. protected _currentRenderID: number;
  17665. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17666. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17667. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17668. protected _blurPostProcesses: PostProcess[];
  17669. protected _mapSize: number;
  17670. protected _currentFaceIndex: number;
  17671. protected _currentFaceIndexCache: number;
  17672. protected _textureType: number;
  17673. protected _defaultTextureMatrix: Matrix;
  17674. protected _storedUniqueId: Nullable<number>;
  17675. /** @hidden */
  17676. static _SceneComponentInitialization: (scene: Scene) => void;
  17677. /**
  17678. * Creates a ShadowGenerator object.
  17679. * A ShadowGenerator is the required tool to use the shadows.
  17680. * Each light casting shadows needs to use its own ShadowGenerator.
  17681. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17682. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17683. * @param light The light object generating the shadows.
  17684. * @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.
  17685. */
  17686. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17687. protected _initializeGenerator(): void;
  17688. protected _createTargetRenderTexture(): void;
  17689. protected _initializeShadowMap(): void;
  17690. protected _initializeBlurRTTAndPostProcesses(): void;
  17691. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17692. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17693. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17694. protected _applyFilterValues(): void;
  17695. /**
  17696. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17697. * @param onCompiled Callback triggered at the and of the effects compilation
  17698. * @param options Sets of optional options forcing the compilation with different modes
  17699. */
  17700. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17701. useInstances: boolean;
  17702. }>): void;
  17703. /**
  17704. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17705. * @param options Sets of optional options forcing the compilation with different modes
  17706. * @returns A promise that resolves when the compilation completes
  17707. */
  17708. forceCompilationAsync(options?: Partial<{
  17709. useInstances: boolean;
  17710. }>): Promise<void>;
  17711. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17712. private _prepareShadowDefines;
  17713. /**
  17714. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17715. * @param subMesh The submesh we want to render in the shadow map
  17716. * @param useInstances Defines wether will draw in the map using instances
  17717. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17718. * @returns true if ready otherwise, false
  17719. */
  17720. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17721. /**
  17722. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17723. * @param defines Defines of the material we want to update
  17724. * @param lightIndex Index of the light in the enabled light list of the material
  17725. */
  17726. prepareDefines(defines: any, lightIndex: number): void;
  17727. /**
  17728. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17729. * defined in the generator but impacting the effect).
  17730. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17731. * @param effect The effect we are binfing the information for
  17732. */
  17733. bindShadowLight(lightIndex: string, effect: Effect): void;
  17734. /**
  17735. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17736. * (eq to shadow prjection matrix * light transform matrix)
  17737. * @returns The transform matrix used to create the shadow map
  17738. */
  17739. getTransformMatrix(): Matrix;
  17740. /**
  17741. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17742. * Cube and 2D textures for instance.
  17743. */
  17744. recreateShadowMap(): void;
  17745. protected _disposeBlurPostProcesses(): void;
  17746. protected _disposeRTTandPostProcesses(): void;
  17747. /**
  17748. * Disposes the ShadowGenerator.
  17749. * Returns nothing.
  17750. */
  17751. dispose(): void;
  17752. /**
  17753. * Serializes the shadow generator setup to a json object.
  17754. * @returns The serialized JSON object
  17755. */
  17756. serialize(): any;
  17757. /**
  17758. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17759. * @param parsedShadowGenerator The JSON object to parse
  17760. * @param scene The scene to create the shadow map for
  17761. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17762. * @returns The parsed shadow generator
  17763. */
  17764. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17765. }
  17766. }
  17767. declare module BABYLON {
  17768. /**
  17769. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17770. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17771. * 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.
  17772. */
  17773. export abstract class Light extends Node {
  17774. /**
  17775. * Falloff Default: light is falling off following the material specification:
  17776. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17777. */
  17778. static readonly FALLOFF_DEFAULT: number;
  17779. /**
  17780. * Falloff Physical: light is falling off following the inverse squared distance law.
  17781. */
  17782. static readonly FALLOFF_PHYSICAL: number;
  17783. /**
  17784. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17785. * to enhance interoperability with other engines.
  17786. */
  17787. static readonly FALLOFF_GLTF: number;
  17788. /**
  17789. * Falloff Standard: light is falling off like in the standard material
  17790. * to enhance interoperability with other materials.
  17791. */
  17792. static readonly FALLOFF_STANDARD: number;
  17793. /**
  17794. * If every light affecting the material is in this lightmapMode,
  17795. * material.lightmapTexture adds or multiplies
  17796. * (depends on material.useLightmapAsShadowmap)
  17797. * after every other light calculations.
  17798. */
  17799. static readonly LIGHTMAP_DEFAULT: number;
  17800. /**
  17801. * material.lightmapTexture as only diffuse lighting from this light
  17802. * adds only specular lighting from this light
  17803. * adds dynamic shadows
  17804. */
  17805. static readonly LIGHTMAP_SPECULAR: number;
  17806. /**
  17807. * material.lightmapTexture as only lighting
  17808. * no light calculation from this light
  17809. * only adds dynamic shadows from this light
  17810. */
  17811. static readonly LIGHTMAP_SHADOWSONLY: number;
  17812. /**
  17813. * Each light type uses the default quantity according to its type:
  17814. * point/spot lights use luminous intensity
  17815. * directional lights use illuminance
  17816. */
  17817. static readonly INTENSITYMODE_AUTOMATIC: number;
  17818. /**
  17819. * lumen (lm)
  17820. */
  17821. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17822. /**
  17823. * candela (lm/sr)
  17824. */
  17825. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17826. /**
  17827. * lux (lm/m^2)
  17828. */
  17829. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17830. /**
  17831. * nit (cd/m^2)
  17832. */
  17833. static readonly INTENSITYMODE_LUMINANCE: number;
  17834. /**
  17835. * Light type const id of the point light.
  17836. */
  17837. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17838. /**
  17839. * Light type const id of the directional light.
  17840. */
  17841. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17842. /**
  17843. * Light type const id of the spot light.
  17844. */
  17845. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17846. /**
  17847. * Light type const id of the hemispheric light.
  17848. */
  17849. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17850. /**
  17851. * Diffuse gives the basic color to an object.
  17852. */
  17853. diffuse: Color3;
  17854. /**
  17855. * Specular produces a highlight color on an object.
  17856. * Note: This is note affecting PBR materials.
  17857. */
  17858. specular: Color3;
  17859. /**
  17860. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17861. * falling off base on range or angle.
  17862. * This can be set to any values in Light.FALLOFF_x.
  17863. *
  17864. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17865. * other types of materials.
  17866. */
  17867. falloffType: number;
  17868. /**
  17869. * Strength of the light.
  17870. * Note: By default it is define in the framework own unit.
  17871. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17872. */
  17873. intensity: number;
  17874. private _range;
  17875. protected _inverseSquaredRange: number;
  17876. /**
  17877. * Defines how far from the source the light is impacting in scene units.
  17878. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17879. */
  17880. get range(): number;
  17881. /**
  17882. * Defines how far from the source the light is impacting in scene units.
  17883. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17884. */
  17885. set range(value: number);
  17886. /**
  17887. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17888. * of light.
  17889. */
  17890. private _photometricScale;
  17891. private _intensityMode;
  17892. /**
  17893. * Gets the photometric scale used to interpret the intensity.
  17894. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17895. */
  17896. get intensityMode(): number;
  17897. /**
  17898. * Sets the photometric scale used to interpret the intensity.
  17899. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17900. */
  17901. set intensityMode(value: number);
  17902. private _radius;
  17903. /**
  17904. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17905. */
  17906. get radius(): number;
  17907. /**
  17908. * sets the light radius used by PBR Materials to simulate soft area lights.
  17909. */
  17910. set radius(value: number);
  17911. private _renderPriority;
  17912. /**
  17913. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17914. * exceeding the number allowed of the materials.
  17915. */
  17916. renderPriority: number;
  17917. private _shadowEnabled;
  17918. /**
  17919. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17920. * the current shadow generator.
  17921. */
  17922. get shadowEnabled(): boolean;
  17923. /**
  17924. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17925. * the current shadow generator.
  17926. */
  17927. set shadowEnabled(value: boolean);
  17928. private _includedOnlyMeshes;
  17929. /**
  17930. * Gets the only meshes impacted by this light.
  17931. */
  17932. get includedOnlyMeshes(): AbstractMesh[];
  17933. /**
  17934. * Sets the only meshes impacted by this light.
  17935. */
  17936. set includedOnlyMeshes(value: AbstractMesh[]);
  17937. private _excludedMeshes;
  17938. /**
  17939. * Gets the meshes not impacted by this light.
  17940. */
  17941. get excludedMeshes(): AbstractMesh[];
  17942. /**
  17943. * Sets the meshes not impacted by this light.
  17944. */
  17945. set excludedMeshes(value: AbstractMesh[]);
  17946. private _excludeWithLayerMask;
  17947. /**
  17948. * Gets the layer id use to find what meshes are not impacted by the light.
  17949. * Inactive if 0
  17950. */
  17951. get excludeWithLayerMask(): number;
  17952. /**
  17953. * Sets the layer id use to find what meshes are not impacted by the light.
  17954. * Inactive if 0
  17955. */
  17956. set excludeWithLayerMask(value: number);
  17957. private _includeOnlyWithLayerMask;
  17958. /**
  17959. * Gets the layer id use to find what meshes are impacted by the light.
  17960. * Inactive if 0
  17961. */
  17962. get includeOnlyWithLayerMask(): number;
  17963. /**
  17964. * Sets the layer id use to find what meshes are impacted by the light.
  17965. * Inactive if 0
  17966. */
  17967. set includeOnlyWithLayerMask(value: number);
  17968. private _lightmapMode;
  17969. /**
  17970. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17971. */
  17972. get lightmapMode(): number;
  17973. /**
  17974. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17975. */
  17976. set lightmapMode(value: number);
  17977. /**
  17978. * Shadow generator associted to the light.
  17979. * @hidden Internal use only.
  17980. */
  17981. _shadowGenerator: Nullable<IShadowGenerator>;
  17982. /**
  17983. * @hidden Internal use only.
  17984. */
  17985. _excludedMeshesIds: string[];
  17986. /**
  17987. * @hidden Internal use only.
  17988. */
  17989. _includedOnlyMeshesIds: string[];
  17990. /**
  17991. * The current light unifom buffer.
  17992. * @hidden Internal use only.
  17993. */
  17994. _uniformBuffer: UniformBuffer;
  17995. /** @hidden */
  17996. _renderId: number;
  17997. /**
  17998. * Creates a Light object in the scene.
  17999. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18000. * @param name The firendly name of the light
  18001. * @param scene The scene the light belongs too
  18002. */
  18003. constructor(name: string, scene: Scene);
  18004. protected abstract _buildUniformLayout(): void;
  18005. /**
  18006. * Sets the passed Effect "effect" with the Light information.
  18007. * @param effect The effect to update
  18008. * @param lightIndex The index of the light in the effect to update
  18009. * @returns The light
  18010. */
  18011. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18012. /**
  18013. * Sets the passed Effect "effect" with the Light textures.
  18014. * @param effect The effect to update
  18015. * @param lightIndex The index of the light in the effect to update
  18016. * @returns The light
  18017. */
  18018. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18019. /**
  18020. * Binds the lights information from the scene to the effect for the given mesh.
  18021. * @param lightIndex Light index
  18022. * @param scene The scene where the light belongs to
  18023. * @param effect The effect we are binding the data to
  18024. * @param useSpecular Defines if specular is supported
  18025. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18026. */
  18027. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18028. /**
  18029. * Sets the passed Effect "effect" with the Light information.
  18030. * @param effect The effect to update
  18031. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18032. * @returns The light
  18033. */
  18034. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18035. /**
  18036. * Returns the string "Light".
  18037. * @returns the class name
  18038. */
  18039. getClassName(): string;
  18040. /** @hidden */
  18041. readonly _isLight: boolean;
  18042. /**
  18043. * Converts the light information to a readable string for debug purpose.
  18044. * @param fullDetails Supports for multiple levels of logging within scene loading
  18045. * @returns the human readable light info
  18046. */
  18047. toString(fullDetails?: boolean): string;
  18048. /** @hidden */
  18049. protected _syncParentEnabledState(): void;
  18050. /**
  18051. * Set the enabled state of this node.
  18052. * @param value - the new enabled state
  18053. */
  18054. setEnabled(value: boolean): void;
  18055. /**
  18056. * Returns the Light associated shadow generator if any.
  18057. * @return the associated shadow generator.
  18058. */
  18059. getShadowGenerator(): Nullable<IShadowGenerator>;
  18060. /**
  18061. * Returns a Vector3, the absolute light position in the World.
  18062. * @returns the world space position of the light
  18063. */
  18064. getAbsolutePosition(): Vector3;
  18065. /**
  18066. * Specifies if the light will affect the passed mesh.
  18067. * @param mesh The mesh to test against the light
  18068. * @return true the mesh is affected otherwise, false.
  18069. */
  18070. canAffectMesh(mesh: AbstractMesh): boolean;
  18071. /**
  18072. * Sort function to order lights for rendering.
  18073. * @param a First Light object to compare to second.
  18074. * @param b Second Light object to compare first.
  18075. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18076. */
  18077. static CompareLightsPriority(a: Light, b: Light): number;
  18078. /**
  18079. * Releases resources associated with this node.
  18080. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18081. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18082. */
  18083. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18084. /**
  18085. * Returns the light type ID (integer).
  18086. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18087. */
  18088. getTypeID(): number;
  18089. /**
  18090. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18091. * @returns the scaled intensity in intensity mode unit
  18092. */
  18093. getScaledIntensity(): number;
  18094. /**
  18095. * Returns a new Light object, named "name", from the current one.
  18096. * @param name The name of the cloned light
  18097. * @param newParent The parent of this light, if it has one
  18098. * @returns the new created light
  18099. */
  18100. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18101. /**
  18102. * Serializes the current light into a Serialization object.
  18103. * @returns the serialized object.
  18104. */
  18105. serialize(): any;
  18106. /**
  18107. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18108. * This new light is named "name" and added to the passed scene.
  18109. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18110. * @param name The friendly name of the light
  18111. * @param scene The scene the new light will belong to
  18112. * @returns the constructor function
  18113. */
  18114. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18115. /**
  18116. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18117. * @param parsedLight The JSON representation of the light
  18118. * @param scene The scene to create the parsed light in
  18119. * @returns the created light after parsing
  18120. */
  18121. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18122. private _hookArrayForExcluded;
  18123. private _hookArrayForIncludedOnly;
  18124. private _resyncMeshes;
  18125. /**
  18126. * Forces the meshes to update their light related information in their rendering used effects
  18127. * @hidden Internal Use Only
  18128. */
  18129. _markMeshesAsLightDirty(): void;
  18130. /**
  18131. * Recomputes the cached photometric scale if needed.
  18132. */
  18133. private _computePhotometricScale;
  18134. /**
  18135. * Returns the Photometric Scale according to the light type and intensity mode.
  18136. */
  18137. private _getPhotometricScale;
  18138. /**
  18139. * Reorder the light in the scene according to their defined priority.
  18140. * @hidden Internal Use Only
  18141. */
  18142. _reorderLightsInScene(): void;
  18143. /**
  18144. * Prepares the list of defines specific to the light type.
  18145. * @param defines the list of defines
  18146. * @param lightIndex defines the index of the light for the effect
  18147. */
  18148. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18149. }
  18150. }
  18151. declare module BABYLON {
  18152. /**
  18153. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18154. * This is the base of the follow, arc rotate cameras and Free camera
  18155. * @see https://doc.babylonjs.com/features/cameras
  18156. */
  18157. export class TargetCamera extends Camera {
  18158. private static _RigCamTransformMatrix;
  18159. private static _TargetTransformMatrix;
  18160. private static _TargetFocalPoint;
  18161. private _tmpUpVector;
  18162. private _tmpTargetVector;
  18163. /**
  18164. * Define the current direction the camera is moving to
  18165. */
  18166. cameraDirection: Vector3;
  18167. /**
  18168. * Define the current rotation the camera is rotating to
  18169. */
  18170. cameraRotation: Vector2;
  18171. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18172. ignoreParentScaling: boolean;
  18173. /**
  18174. * When set, the up vector of the camera will be updated by the rotation of the camera
  18175. */
  18176. updateUpVectorFromRotation: boolean;
  18177. private _tmpQuaternion;
  18178. /**
  18179. * Define the current rotation of the camera
  18180. */
  18181. rotation: Vector3;
  18182. /**
  18183. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18184. */
  18185. rotationQuaternion: Quaternion;
  18186. /**
  18187. * Define the current speed of the camera
  18188. */
  18189. speed: number;
  18190. /**
  18191. * Add constraint to the camera to prevent it to move freely in all directions and
  18192. * around all axis.
  18193. */
  18194. noRotationConstraint: boolean;
  18195. /**
  18196. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18197. * panning
  18198. */
  18199. invertRotation: boolean;
  18200. /**
  18201. * Speed multiplier for inverse camera panning
  18202. */
  18203. inverseRotationSpeed: number;
  18204. /**
  18205. * Define the current target of the camera as an object or a position.
  18206. */
  18207. lockedTarget: any;
  18208. /** @hidden */
  18209. _currentTarget: Vector3;
  18210. /** @hidden */
  18211. _initialFocalDistance: number;
  18212. /** @hidden */
  18213. _viewMatrix: Matrix;
  18214. /** @hidden */
  18215. _camMatrix: Matrix;
  18216. /** @hidden */
  18217. _cameraTransformMatrix: Matrix;
  18218. /** @hidden */
  18219. _cameraRotationMatrix: Matrix;
  18220. /** @hidden */
  18221. _referencePoint: Vector3;
  18222. /** @hidden */
  18223. _transformedReferencePoint: Vector3;
  18224. /** @hidden */
  18225. _reset: () => void;
  18226. private _defaultUp;
  18227. /**
  18228. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18229. * This is the base of the follow, arc rotate cameras and Free camera
  18230. * @see https://doc.babylonjs.com/features/cameras
  18231. * @param name Defines the name of the camera in the scene
  18232. * @param position Defines the start position of the camera in the scene
  18233. * @param scene Defines the scene the camera belongs to
  18234. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18235. */
  18236. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18237. /**
  18238. * Gets the position in front of the camera at a given distance.
  18239. * @param distance The distance from the camera we want the position to be
  18240. * @returns the position
  18241. */
  18242. getFrontPosition(distance: number): Vector3;
  18243. /** @hidden */
  18244. _getLockedTargetPosition(): Nullable<Vector3>;
  18245. private _storedPosition;
  18246. private _storedRotation;
  18247. private _storedRotationQuaternion;
  18248. /**
  18249. * Store current camera state of the camera (fov, position, rotation, etc..)
  18250. * @returns the camera
  18251. */
  18252. storeState(): Camera;
  18253. /**
  18254. * Restored camera state. You must call storeState() first
  18255. * @returns whether it was successful or not
  18256. * @hidden
  18257. */
  18258. _restoreStateValues(): boolean;
  18259. /** @hidden */
  18260. _initCache(): void;
  18261. /** @hidden */
  18262. _updateCache(ignoreParentClass?: boolean): void;
  18263. /** @hidden */
  18264. _isSynchronizedViewMatrix(): boolean;
  18265. /** @hidden */
  18266. _computeLocalCameraSpeed(): number;
  18267. /**
  18268. * Defines the target the camera should look at.
  18269. * @param target Defines the new target as a Vector or a mesh
  18270. */
  18271. setTarget(target: Vector3): void;
  18272. /**
  18273. * Return the current target position of the camera. This value is expressed in local space.
  18274. * @returns the target position
  18275. */
  18276. getTarget(): Vector3;
  18277. /** @hidden */
  18278. _decideIfNeedsToMove(): boolean;
  18279. /** @hidden */
  18280. _updatePosition(): void;
  18281. /** @hidden */
  18282. _checkInputs(): void;
  18283. protected _updateCameraRotationMatrix(): void;
  18284. /**
  18285. * 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)
  18286. * @returns the current camera
  18287. */
  18288. private _rotateUpVectorWithCameraRotationMatrix;
  18289. private _cachedRotationZ;
  18290. private _cachedQuaternionRotationZ;
  18291. /** @hidden */
  18292. _getViewMatrix(): Matrix;
  18293. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18294. /**
  18295. * @hidden
  18296. */
  18297. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18298. /**
  18299. * @hidden
  18300. */
  18301. _updateRigCameras(): void;
  18302. private _getRigCamPositionAndTarget;
  18303. /**
  18304. * Gets the current object class name.
  18305. * @return the class name
  18306. */
  18307. getClassName(): string;
  18308. }
  18309. }
  18310. declare module BABYLON {
  18311. /**
  18312. * Gather the list of keyboard event types as constants.
  18313. */
  18314. export class KeyboardEventTypes {
  18315. /**
  18316. * The keydown event is fired when a key becomes active (pressed).
  18317. */
  18318. static readonly KEYDOWN: number;
  18319. /**
  18320. * The keyup event is fired when a key has been released.
  18321. */
  18322. static readonly KEYUP: number;
  18323. }
  18324. /**
  18325. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18326. */
  18327. export class KeyboardInfo {
  18328. /**
  18329. * Defines the type of event (KeyboardEventTypes)
  18330. */
  18331. type: number;
  18332. /**
  18333. * Defines the related dom event
  18334. */
  18335. event: KeyboardEvent;
  18336. /**
  18337. * Instantiates a new keyboard info.
  18338. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18339. * @param type Defines the type of event (KeyboardEventTypes)
  18340. * @param event Defines the related dom event
  18341. */
  18342. constructor(
  18343. /**
  18344. * Defines the type of event (KeyboardEventTypes)
  18345. */
  18346. type: number,
  18347. /**
  18348. * Defines the related dom event
  18349. */
  18350. event: KeyboardEvent);
  18351. }
  18352. /**
  18353. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18354. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18355. */
  18356. export class KeyboardInfoPre extends KeyboardInfo {
  18357. /**
  18358. * Defines the type of event (KeyboardEventTypes)
  18359. */
  18360. type: number;
  18361. /**
  18362. * Defines the related dom event
  18363. */
  18364. event: KeyboardEvent;
  18365. /**
  18366. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18367. */
  18368. skipOnPointerObservable: boolean;
  18369. /**
  18370. * Instantiates a new keyboard pre info.
  18371. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18372. * @param type Defines the type of event (KeyboardEventTypes)
  18373. * @param event Defines the related dom event
  18374. */
  18375. constructor(
  18376. /**
  18377. * Defines the type of event (KeyboardEventTypes)
  18378. */
  18379. type: number,
  18380. /**
  18381. * Defines the related dom event
  18382. */
  18383. event: KeyboardEvent);
  18384. }
  18385. }
  18386. declare module BABYLON {
  18387. /**
  18388. * Manage the keyboard inputs to control the movement of a free camera.
  18389. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18390. */
  18391. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18392. /**
  18393. * Defines the camera the input is attached to.
  18394. */
  18395. camera: FreeCamera;
  18396. /**
  18397. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18398. */
  18399. keysUp: number[];
  18400. /**
  18401. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18402. */
  18403. keysUpward: number[];
  18404. /**
  18405. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18406. */
  18407. keysDown: number[];
  18408. /**
  18409. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18410. */
  18411. keysDownward: number[];
  18412. /**
  18413. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18414. */
  18415. keysLeft: number[];
  18416. /**
  18417. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18418. */
  18419. keysRight: number[];
  18420. private _keys;
  18421. private _onCanvasBlurObserver;
  18422. private _onKeyboardObserver;
  18423. private _engine;
  18424. private _scene;
  18425. /**
  18426. * Attach the input controls to a specific dom element to get the input from.
  18427. * @param element Defines the element the controls should be listened from
  18428. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18429. */
  18430. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18431. /**
  18432. * Detach the current controls from the specified dom element.
  18433. * @param element Defines the element to stop listening the inputs from
  18434. */
  18435. detachControl(element: Nullable<HTMLElement>): void;
  18436. /**
  18437. * Update the current camera state depending on the inputs that have been used this frame.
  18438. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18439. */
  18440. checkInputs(): void;
  18441. /**
  18442. * Gets the class name of the current intput.
  18443. * @returns the class name
  18444. */
  18445. getClassName(): string;
  18446. /** @hidden */
  18447. _onLostFocus(): void;
  18448. /**
  18449. * Get the friendly name associated with the input class.
  18450. * @returns the input friendly name
  18451. */
  18452. getSimpleName(): string;
  18453. }
  18454. }
  18455. declare module BABYLON {
  18456. /**
  18457. * Gather the list of pointer event types as constants.
  18458. */
  18459. export class PointerEventTypes {
  18460. /**
  18461. * 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.
  18462. */
  18463. static readonly POINTERDOWN: number;
  18464. /**
  18465. * The pointerup event is fired when a pointer is no longer active.
  18466. */
  18467. static readonly POINTERUP: number;
  18468. /**
  18469. * The pointermove event is fired when a pointer changes coordinates.
  18470. */
  18471. static readonly POINTERMOVE: number;
  18472. /**
  18473. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18474. */
  18475. static readonly POINTERWHEEL: number;
  18476. /**
  18477. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18478. */
  18479. static readonly POINTERPICK: number;
  18480. /**
  18481. * The pointertap event is fired when a the object has been touched and released without drag.
  18482. */
  18483. static readonly POINTERTAP: number;
  18484. /**
  18485. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18486. */
  18487. static readonly POINTERDOUBLETAP: number;
  18488. }
  18489. /**
  18490. * Base class of pointer info types.
  18491. */
  18492. export class PointerInfoBase {
  18493. /**
  18494. * Defines the type of event (PointerEventTypes)
  18495. */
  18496. type: number;
  18497. /**
  18498. * Defines the related dom event
  18499. */
  18500. event: PointerEvent | MouseWheelEvent;
  18501. /**
  18502. * Instantiates the base class of pointers info.
  18503. * @param type Defines the type of event (PointerEventTypes)
  18504. * @param event Defines the related dom event
  18505. */
  18506. constructor(
  18507. /**
  18508. * Defines the type of event (PointerEventTypes)
  18509. */
  18510. type: number,
  18511. /**
  18512. * Defines the related dom event
  18513. */
  18514. event: PointerEvent | MouseWheelEvent);
  18515. }
  18516. /**
  18517. * This class is used to store pointer related info for the onPrePointerObservable event.
  18518. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18519. */
  18520. export class PointerInfoPre extends PointerInfoBase {
  18521. /**
  18522. * Ray from a pointer if availible (eg. 6dof controller)
  18523. */
  18524. ray: Nullable<Ray>;
  18525. /**
  18526. * Defines the local position of the pointer on the canvas.
  18527. */
  18528. localPosition: Vector2;
  18529. /**
  18530. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18531. */
  18532. skipOnPointerObservable: boolean;
  18533. /**
  18534. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18535. * @param type Defines the type of event (PointerEventTypes)
  18536. * @param event Defines the related dom event
  18537. * @param localX Defines the local x coordinates of the pointer when the event occured
  18538. * @param localY Defines the local y coordinates of the pointer when the event occured
  18539. */
  18540. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18541. }
  18542. /**
  18543. * This type contains all the data related to a pointer event in Babylon.js.
  18544. * 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.
  18545. */
  18546. export class PointerInfo extends PointerInfoBase {
  18547. /**
  18548. * Defines the picking info associated to the info (if any)\
  18549. */
  18550. pickInfo: Nullable<PickingInfo>;
  18551. /**
  18552. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18553. * @param type Defines the type of event (PointerEventTypes)
  18554. * @param event Defines the related dom event
  18555. * @param pickInfo Defines the picking info associated to the info (if any)\
  18556. */
  18557. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18558. /**
  18559. * Defines the picking info associated to the info (if any)\
  18560. */
  18561. pickInfo: Nullable<PickingInfo>);
  18562. }
  18563. /**
  18564. * Data relating to a touch event on the screen.
  18565. */
  18566. export interface PointerTouch {
  18567. /**
  18568. * X coordinate of touch.
  18569. */
  18570. x: number;
  18571. /**
  18572. * Y coordinate of touch.
  18573. */
  18574. y: number;
  18575. /**
  18576. * Id of touch. Unique for each finger.
  18577. */
  18578. pointerId: number;
  18579. /**
  18580. * Event type passed from DOM.
  18581. */
  18582. type: any;
  18583. }
  18584. }
  18585. declare module BABYLON {
  18586. /**
  18587. * Manage the mouse inputs to control the movement of a free camera.
  18588. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18589. */
  18590. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18591. /**
  18592. * Define if touch is enabled in the mouse input
  18593. */
  18594. touchEnabled: boolean;
  18595. /**
  18596. * Defines the camera the input is attached to.
  18597. */
  18598. camera: FreeCamera;
  18599. /**
  18600. * Defines the buttons associated with the input to handle camera move.
  18601. */
  18602. buttons: number[];
  18603. /**
  18604. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18605. */
  18606. angularSensibility: number;
  18607. private _pointerInput;
  18608. private _onMouseMove;
  18609. private _observer;
  18610. private previousPosition;
  18611. /**
  18612. * Observable for when a pointer move event occurs containing the move offset
  18613. */
  18614. onPointerMovedObservable: Observable<{
  18615. offsetX: number;
  18616. offsetY: number;
  18617. }>;
  18618. /**
  18619. * @hidden
  18620. * If the camera should be rotated automatically based on pointer movement
  18621. */
  18622. _allowCameraRotation: boolean;
  18623. /**
  18624. * Manage the mouse inputs to control the movement of a free camera.
  18625. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18626. * @param touchEnabled Defines if touch is enabled or not
  18627. */
  18628. constructor(
  18629. /**
  18630. * Define if touch is enabled in the mouse input
  18631. */
  18632. touchEnabled?: boolean);
  18633. /**
  18634. * Attach the input controls to a specific dom element to get the input from.
  18635. * @param element Defines the element the controls should be listened from
  18636. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18637. */
  18638. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18639. /**
  18640. * Called on JS contextmenu event.
  18641. * Override this method to provide functionality.
  18642. */
  18643. protected onContextMenu(evt: PointerEvent): void;
  18644. /**
  18645. * Detach the current controls from the specified dom element.
  18646. * @param element Defines the element to stop listening the inputs from
  18647. */
  18648. detachControl(element: Nullable<HTMLElement>): void;
  18649. /**
  18650. * Gets the class name of the current intput.
  18651. * @returns the class name
  18652. */
  18653. getClassName(): string;
  18654. /**
  18655. * Get the friendly name associated with the input class.
  18656. * @returns the input friendly name
  18657. */
  18658. getSimpleName(): string;
  18659. }
  18660. }
  18661. declare module BABYLON {
  18662. /**
  18663. * Manage the touch inputs to control the movement of a free camera.
  18664. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18665. */
  18666. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18667. /**
  18668. * Defines the camera the input is attached to.
  18669. */
  18670. camera: FreeCamera;
  18671. /**
  18672. * Defines the touch sensibility for rotation.
  18673. * The higher the faster.
  18674. */
  18675. touchAngularSensibility: number;
  18676. /**
  18677. * Defines the touch sensibility for move.
  18678. * The higher the faster.
  18679. */
  18680. touchMoveSensibility: number;
  18681. private _offsetX;
  18682. private _offsetY;
  18683. private _pointerPressed;
  18684. private _pointerInput;
  18685. private _observer;
  18686. private _onLostFocus;
  18687. /**
  18688. * Attach the input controls to a specific dom element to get the input from.
  18689. * @param element Defines the element the controls should be listened from
  18690. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18691. */
  18692. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18693. /**
  18694. * Detach the current controls from the specified dom element.
  18695. * @param element Defines the element to stop listening the inputs from
  18696. */
  18697. detachControl(element: Nullable<HTMLElement>): void;
  18698. /**
  18699. * Update the current camera state depending on the inputs that have been used this frame.
  18700. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18701. */
  18702. checkInputs(): void;
  18703. /**
  18704. * Gets the class name of the current intput.
  18705. * @returns the class name
  18706. */
  18707. getClassName(): string;
  18708. /**
  18709. * Get the friendly name associated with the input class.
  18710. * @returns the input friendly name
  18711. */
  18712. getSimpleName(): string;
  18713. }
  18714. }
  18715. declare module BABYLON {
  18716. /**
  18717. * Default Inputs manager for the FreeCamera.
  18718. * It groups all the default supported inputs for ease of use.
  18719. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18720. */
  18721. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18722. /**
  18723. * @hidden
  18724. */
  18725. _mouseInput: Nullable<FreeCameraMouseInput>;
  18726. /**
  18727. * Instantiates a new FreeCameraInputsManager.
  18728. * @param camera Defines the camera the inputs belong to
  18729. */
  18730. constructor(camera: FreeCamera);
  18731. /**
  18732. * Add keyboard input support to the input manager.
  18733. * @returns the current input manager
  18734. */
  18735. addKeyboard(): FreeCameraInputsManager;
  18736. /**
  18737. * Add mouse input support to the input manager.
  18738. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18739. * @returns the current input manager
  18740. */
  18741. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18742. /**
  18743. * Removes the mouse input support from the manager
  18744. * @returns the current input manager
  18745. */
  18746. removeMouse(): FreeCameraInputsManager;
  18747. /**
  18748. * Add touch input support to the input manager.
  18749. * @returns the current input manager
  18750. */
  18751. addTouch(): FreeCameraInputsManager;
  18752. /**
  18753. * Remove all attached input methods from a camera
  18754. */
  18755. clear(): void;
  18756. }
  18757. }
  18758. declare module BABYLON {
  18759. /**
  18760. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18761. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18762. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  18763. */
  18764. export class FreeCamera extends TargetCamera {
  18765. /**
  18766. * Define the collision ellipsoid of the camera.
  18767. * This is helpful to simulate a camera body like the player body around the camera
  18768. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18769. */
  18770. ellipsoid: Vector3;
  18771. /**
  18772. * Define an offset for the position of the ellipsoid around the camera.
  18773. * This can be helpful to determine the center of the body near the gravity center of the body
  18774. * instead of its head.
  18775. */
  18776. ellipsoidOffset: Vector3;
  18777. /**
  18778. * Enable or disable collisions of the camera with the rest of the scene objects.
  18779. */
  18780. checkCollisions: boolean;
  18781. /**
  18782. * Enable or disable gravity on the camera.
  18783. */
  18784. applyGravity: boolean;
  18785. /**
  18786. * Define the input manager associated to the camera.
  18787. */
  18788. inputs: FreeCameraInputsManager;
  18789. /**
  18790. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18791. * Higher values reduce sensitivity.
  18792. */
  18793. get angularSensibility(): number;
  18794. /**
  18795. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18796. * Higher values reduce sensitivity.
  18797. */
  18798. set angularSensibility(value: number);
  18799. /**
  18800. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18801. */
  18802. get keysUp(): number[];
  18803. set keysUp(value: number[]);
  18804. /**
  18805. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18806. */
  18807. get keysUpward(): number[];
  18808. set keysUpward(value: number[]);
  18809. /**
  18810. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18811. */
  18812. get keysDown(): number[];
  18813. set keysDown(value: number[]);
  18814. /**
  18815. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18816. */
  18817. get keysDownward(): number[];
  18818. set keysDownward(value: number[]);
  18819. /**
  18820. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18821. */
  18822. get keysLeft(): number[];
  18823. set keysLeft(value: number[]);
  18824. /**
  18825. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18826. */
  18827. get keysRight(): number[];
  18828. set keysRight(value: number[]);
  18829. /**
  18830. * Event raised when the camera collide with a mesh in the scene.
  18831. */
  18832. onCollide: (collidedMesh: AbstractMesh) => void;
  18833. private _collider;
  18834. private _needMoveForGravity;
  18835. private _oldPosition;
  18836. private _diffPosition;
  18837. private _newPosition;
  18838. /** @hidden */
  18839. _localDirection: Vector3;
  18840. /** @hidden */
  18841. _transformedDirection: Vector3;
  18842. /**
  18843. * Instantiates a Free Camera.
  18844. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18845. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18846. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  18847. * @param name Define the name of the camera in the scene
  18848. * @param position Define the start position of the camera in the scene
  18849. * @param scene Define the scene the camera belongs to
  18850. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18851. */
  18852. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18853. /**
  18854. * Attached controls to the current camera.
  18855. * @param element Defines the element the controls should be listened from
  18856. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18857. */
  18858. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18859. /**
  18860. * Detach the current controls from the camera.
  18861. * The camera will stop reacting to inputs.
  18862. * @param element Defines the element to stop listening the inputs from
  18863. */
  18864. detachControl(element: HTMLElement): void;
  18865. private _collisionMask;
  18866. /**
  18867. * Define a collision mask to limit the list of object the camera can collide with
  18868. */
  18869. get collisionMask(): number;
  18870. set collisionMask(mask: number);
  18871. /** @hidden */
  18872. _collideWithWorld(displacement: Vector3): void;
  18873. private _onCollisionPositionChange;
  18874. /** @hidden */
  18875. _checkInputs(): void;
  18876. /** @hidden */
  18877. _decideIfNeedsToMove(): boolean;
  18878. /** @hidden */
  18879. _updatePosition(): void;
  18880. /**
  18881. * Destroy the camera and release the current resources hold by it.
  18882. */
  18883. dispose(): void;
  18884. /**
  18885. * Gets the current object class name.
  18886. * @return the class name
  18887. */
  18888. getClassName(): string;
  18889. }
  18890. }
  18891. declare module BABYLON {
  18892. /**
  18893. * Represents a gamepad control stick position
  18894. */
  18895. export class StickValues {
  18896. /**
  18897. * The x component of the control stick
  18898. */
  18899. x: number;
  18900. /**
  18901. * The y component of the control stick
  18902. */
  18903. y: number;
  18904. /**
  18905. * Initializes the gamepad x and y control stick values
  18906. * @param x The x component of the gamepad control stick value
  18907. * @param y The y component of the gamepad control stick value
  18908. */
  18909. constructor(
  18910. /**
  18911. * The x component of the control stick
  18912. */
  18913. x: number,
  18914. /**
  18915. * The y component of the control stick
  18916. */
  18917. y: number);
  18918. }
  18919. /**
  18920. * An interface which manages callbacks for gamepad button changes
  18921. */
  18922. export interface GamepadButtonChanges {
  18923. /**
  18924. * Called when a gamepad has been changed
  18925. */
  18926. changed: boolean;
  18927. /**
  18928. * Called when a gamepad press event has been triggered
  18929. */
  18930. pressChanged: boolean;
  18931. /**
  18932. * Called when a touch event has been triggered
  18933. */
  18934. touchChanged: boolean;
  18935. /**
  18936. * Called when a value has changed
  18937. */
  18938. valueChanged: boolean;
  18939. }
  18940. /**
  18941. * Represents a gamepad
  18942. */
  18943. export class Gamepad {
  18944. /**
  18945. * The id of the gamepad
  18946. */
  18947. id: string;
  18948. /**
  18949. * The index of the gamepad
  18950. */
  18951. index: number;
  18952. /**
  18953. * The browser gamepad
  18954. */
  18955. browserGamepad: any;
  18956. /**
  18957. * Specifies what type of gamepad this represents
  18958. */
  18959. type: number;
  18960. private _leftStick;
  18961. private _rightStick;
  18962. /** @hidden */
  18963. _isConnected: boolean;
  18964. private _leftStickAxisX;
  18965. private _leftStickAxisY;
  18966. private _rightStickAxisX;
  18967. private _rightStickAxisY;
  18968. /**
  18969. * Triggered when the left control stick has been changed
  18970. */
  18971. private _onleftstickchanged;
  18972. /**
  18973. * Triggered when the right control stick has been changed
  18974. */
  18975. private _onrightstickchanged;
  18976. /**
  18977. * Represents a gamepad controller
  18978. */
  18979. static GAMEPAD: number;
  18980. /**
  18981. * Represents a generic controller
  18982. */
  18983. static GENERIC: number;
  18984. /**
  18985. * Represents an XBox controller
  18986. */
  18987. static XBOX: number;
  18988. /**
  18989. * Represents a pose-enabled controller
  18990. */
  18991. static POSE_ENABLED: number;
  18992. /**
  18993. * Represents an Dual Shock controller
  18994. */
  18995. static DUALSHOCK: number;
  18996. /**
  18997. * Specifies whether the left control stick should be Y-inverted
  18998. */
  18999. protected _invertLeftStickY: boolean;
  19000. /**
  19001. * Specifies if the gamepad has been connected
  19002. */
  19003. get isConnected(): boolean;
  19004. /**
  19005. * Initializes the gamepad
  19006. * @param id The id of the gamepad
  19007. * @param index The index of the gamepad
  19008. * @param browserGamepad The browser gamepad
  19009. * @param leftStickX The x component of the left joystick
  19010. * @param leftStickY The y component of the left joystick
  19011. * @param rightStickX The x component of the right joystick
  19012. * @param rightStickY The y component of the right joystick
  19013. */
  19014. constructor(
  19015. /**
  19016. * The id of the gamepad
  19017. */
  19018. id: string,
  19019. /**
  19020. * The index of the gamepad
  19021. */
  19022. index: number,
  19023. /**
  19024. * The browser gamepad
  19025. */
  19026. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19027. /**
  19028. * Callback triggered when the left joystick has changed
  19029. * @param callback
  19030. */
  19031. onleftstickchanged(callback: (values: StickValues) => void): void;
  19032. /**
  19033. * Callback triggered when the right joystick has changed
  19034. * @param callback
  19035. */
  19036. onrightstickchanged(callback: (values: StickValues) => void): void;
  19037. /**
  19038. * Gets the left joystick
  19039. */
  19040. get leftStick(): StickValues;
  19041. /**
  19042. * Sets the left joystick values
  19043. */
  19044. set leftStick(newValues: StickValues);
  19045. /**
  19046. * Gets the right joystick
  19047. */
  19048. get rightStick(): StickValues;
  19049. /**
  19050. * Sets the right joystick value
  19051. */
  19052. set rightStick(newValues: StickValues);
  19053. /**
  19054. * Updates the gamepad joystick positions
  19055. */
  19056. update(): void;
  19057. /**
  19058. * Disposes the gamepad
  19059. */
  19060. dispose(): void;
  19061. }
  19062. /**
  19063. * Represents a generic gamepad
  19064. */
  19065. export class GenericPad extends Gamepad {
  19066. private _buttons;
  19067. private _onbuttondown;
  19068. private _onbuttonup;
  19069. /**
  19070. * Observable triggered when a button has been pressed
  19071. */
  19072. onButtonDownObservable: Observable<number>;
  19073. /**
  19074. * Observable triggered when a button has been released
  19075. */
  19076. onButtonUpObservable: Observable<number>;
  19077. /**
  19078. * Callback triggered when a button has been pressed
  19079. * @param callback Called when a button has been pressed
  19080. */
  19081. onbuttondown(callback: (buttonPressed: number) => void): void;
  19082. /**
  19083. * Callback triggered when a button has been released
  19084. * @param callback Called when a button has been released
  19085. */
  19086. onbuttonup(callback: (buttonReleased: number) => void): void;
  19087. /**
  19088. * Initializes the generic gamepad
  19089. * @param id The id of the generic gamepad
  19090. * @param index The index of the generic gamepad
  19091. * @param browserGamepad The browser gamepad
  19092. */
  19093. constructor(id: string, index: number, browserGamepad: any);
  19094. private _setButtonValue;
  19095. /**
  19096. * Updates the generic gamepad
  19097. */
  19098. update(): void;
  19099. /**
  19100. * Disposes the generic gamepad
  19101. */
  19102. dispose(): void;
  19103. }
  19104. }
  19105. declare module BABYLON {
  19106. /**
  19107. * Defines the types of pose enabled controllers that are supported
  19108. */
  19109. export enum PoseEnabledControllerType {
  19110. /**
  19111. * HTC Vive
  19112. */
  19113. VIVE = 0,
  19114. /**
  19115. * Oculus Rift
  19116. */
  19117. OCULUS = 1,
  19118. /**
  19119. * Windows mixed reality
  19120. */
  19121. WINDOWS = 2,
  19122. /**
  19123. * Samsung gear VR
  19124. */
  19125. GEAR_VR = 3,
  19126. /**
  19127. * Google Daydream
  19128. */
  19129. DAYDREAM = 4,
  19130. /**
  19131. * Generic
  19132. */
  19133. GENERIC = 5
  19134. }
  19135. /**
  19136. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19137. */
  19138. export interface MutableGamepadButton {
  19139. /**
  19140. * Value of the button/trigger
  19141. */
  19142. value: number;
  19143. /**
  19144. * If the button/trigger is currently touched
  19145. */
  19146. touched: boolean;
  19147. /**
  19148. * If the button/trigger is currently pressed
  19149. */
  19150. pressed: boolean;
  19151. }
  19152. /**
  19153. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19154. * @hidden
  19155. */
  19156. export interface ExtendedGamepadButton extends GamepadButton {
  19157. /**
  19158. * If the button/trigger is currently pressed
  19159. */
  19160. readonly pressed: boolean;
  19161. /**
  19162. * If the button/trigger is currently touched
  19163. */
  19164. readonly touched: boolean;
  19165. /**
  19166. * Value of the button/trigger
  19167. */
  19168. readonly value: number;
  19169. }
  19170. /** @hidden */
  19171. export interface _GamePadFactory {
  19172. /**
  19173. * Returns whether or not the current gamepad can be created for this type of controller.
  19174. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19175. * @returns true if it can be created, otherwise false
  19176. */
  19177. canCreate(gamepadInfo: any): boolean;
  19178. /**
  19179. * Creates a new instance of the Gamepad.
  19180. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19181. * @returns the new gamepad instance
  19182. */
  19183. create(gamepadInfo: any): Gamepad;
  19184. }
  19185. /**
  19186. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19187. */
  19188. export class PoseEnabledControllerHelper {
  19189. /** @hidden */
  19190. static _ControllerFactories: _GamePadFactory[];
  19191. /** @hidden */
  19192. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19193. /**
  19194. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19195. * @param vrGamepad the gamepad to initialized
  19196. * @returns a vr controller of the type the gamepad identified as
  19197. */
  19198. static InitiateController(vrGamepad: any): Gamepad;
  19199. }
  19200. /**
  19201. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19202. */
  19203. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19204. /**
  19205. * If the controller is used in a webXR session
  19206. */
  19207. isXR: boolean;
  19208. private _deviceRoomPosition;
  19209. private _deviceRoomRotationQuaternion;
  19210. /**
  19211. * The device position in babylon space
  19212. */
  19213. devicePosition: Vector3;
  19214. /**
  19215. * The device rotation in babylon space
  19216. */
  19217. deviceRotationQuaternion: Quaternion;
  19218. /**
  19219. * The scale factor of the device in babylon space
  19220. */
  19221. deviceScaleFactor: number;
  19222. /**
  19223. * (Likely devicePosition should be used instead) The device position in its room space
  19224. */
  19225. position: Vector3;
  19226. /**
  19227. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19228. */
  19229. rotationQuaternion: Quaternion;
  19230. /**
  19231. * The type of controller (Eg. Windows mixed reality)
  19232. */
  19233. controllerType: PoseEnabledControllerType;
  19234. protected _calculatedPosition: Vector3;
  19235. private _calculatedRotation;
  19236. /**
  19237. * The raw pose from the device
  19238. */
  19239. rawPose: DevicePose;
  19240. private _trackPosition;
  19241. private _maxRotationDistFromHeadset;
  19242. private _draggedRoomRotation;
  19243. /**
  19244. * @hidden
  19245. */
  19246. _disableTrackPosition(fixedPosition: Vector3): void;
  19247. /**
  19248. * Internal, the mesh attached to the controller
  19249. * @hidden
  19250. */
  19251. _mesh: Nullable<AbstractMesh>;
  19252. private _poseControlledCamera;
  19253. private _leftHandSystemQuaternion;
  19254. /**
  19255. * Internal, matrix used to convert room space to babylon space
  19256. * @hidden
  19257. */
  19258. _deviceToWorld: Matrix;
  19259. /**
  19260. * Node to be used when casting a ray from the controller
  19261. * @hidden
  19262. */
  19263. _pointingPoseNode: Nullable<TransformNode>;
  19264. /**
  19265. * Name of the child mesh that can be used to cast a ray from the controller
  19266. */
  19267. static readonly POINTING_POSE: string;
  19268. /**
  19269. * Creates a new PoseEnabledController from a gamepad
  19270. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19271. */
  19272. constructor(browserGamepad: any);
  19273. private _workingMatrix;
  19274. /**
  19275. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19276. */
  19277. update(): void;
  19278. /**
  19279. * Updates only the pose device and mesh without doing any button event checking
  19280. */
  19281. protected _updatePoseAndMesh(): void;
  19282. /**
  19283. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19284. * @param poseData raw pose fromthe device
  19285. */
  19286. updateFromDevice(poseData: DevicePose): void;
  19287. /**
  19288. * @hidden
  19289. */
  19290. _meshAttachedObservable: Observable<AbstractMesh>;
  19291. /**
  19292. * Attaches a mesh to the controller
  19293. * @param mesh the mesh to be attached
  19294. */
  19295. attachToMesh(mesh: AbstractMesh): void;
  19296. /**
  19297. * Attaches the controllers mesh to a camera
  19298. * @param camera the camera the mesh should be attached to
  19299. */
  19300. attachToPoseControlledCamera(camera: TargetCamera): void;
  19301. /**
  19302. * Disposes of the controller
  19303. */
  19304. dispose(): void;
  19305. /**
  19306. * The mesh that is attached to the controller
  19307. */
  19308. get mesh(): Nullable<AbstractMesh>;
  19309. /**
  19310. * Gets the ray of the controller in the direction the controller is pointing
  19311. * @param length the length the resulting ray should be
  19312. * @returns a ray in the direction the controller is pointing
  19313. */
  19314. getForwardRay(length?: number): Ray;
  19315. }
  19316. }
  19317. declare module BABYLON {
  19318. /**
  19319. * Defines the WebVRController object that represents controllers tracked in 3D space
  19320. */
  19321. export abstract class WebVRController extends PoseEnabledController {
  19322. /**
  19323. * Internal, the default controller model for the controller
  19324. */
  19325. protected _defaultModel: Nullable<AbstractMesh>;
  19326. /**
  19327. * Fired when the trigger state has changed
  19328. */
  19329. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19330. /**
  19331. * Fired when the main button state has changed
  19332. */
  19333. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19334. /**
  19335. * Fired when the secondary button state has changed
  19336. */
  19337. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19338. /**
  19339. * Fired when the pad state has changed
  19340. */
  19341. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19342. /**
  19343. * Fired when controllers stick values have changed
  19344. */
  19345. onPadValuesChangedObservable: Observable<StickValues>;
  19346. /**
  19347. * Array of button availible on the controller
  19348. */
  19349. protected _buttons: Array<MutableGamepadButton>;
  19350. private _onButtonStateChange;
  19351. /**
  19352. * Fired when a controller button's state has changed
  19353. * @param callback the callback containing the button that was modified
  19354. */
  19355. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19356. /**
  19357. * X and Y axis corresponding to the controllers joystick
  19358. */
  19359. pad: StickValues;
  19360. /**
  19361. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19362. */
  19363. hand: string;
  19364. /**
  19365. * The default controller model for the controller
  19366. */
  19367. get defaultModel(): Nullable<AbstractMesh>;
  19368. /**
  19369. * Creates a new WebVRController from a gamepad
  19370. * @param vrGamepad the gamepad that the WebVRController should be created from
  19371. */
  19372. constructor(vrGamepad: any);
  19373. /**
  19374. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19375. */
  19376. update(): void;
  19377. /**
  19378. * Function to be called when a button is modified
  19379. */
  19380. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19381. /**
  19382. * Loads a mesh and attaches it to the controller
  19383. * @param scene the scene the mesh should be added to
  19384. * @param meshLoaded callback for when the mesh has been loaded
  19385. */
  19386. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19387. private _setButtonValue;
  19388. private _changes;
  19389. private _checkChanges;
  19390. /**
  19391. * Disposes of th webVRCOntroller
  19392. */
  19393. dispose(): void;
  19394. }
  19395. }
  19396. declare module BABYLON {
  19397. /**
  19398. * The HemisphericLight simulates the ambient environment light,
  19399. * so the passed direction is the light reflection direction, not the incoming direction.
  19400. */
  19401. export class HemisphericLight extends Light {
  19402. /**
  19403. * The groundColor is the light in the opposite direction to the one specified during creation.
  19404. * 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.
  19405. */
  19406. groundColor: Color3;
  19407. /**
  19408. * The light reflection direction, not the incoming direction.
  19409. */
  19410. direction: Vector3;
  19411. /**
  19412. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19413. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19414. * The HemisphericLight can't cast shadows.
  19415. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19416. * @param name The friendly name of the light
  19417. * @param direction The direction of the light reflection
  19418. * @param scene The scene the light belongs to
  19419. */
  19420. constructor(name: string, direction: Vector3, scene: Scene);
  19421. protected _buildUniformLayout(): void;
  19422. /**
  19423. * Returns the string "HemisphericLight".
  19424. * @return The class name
  19425. */
  19426. getClassName(): string;
  19427. /**
  19428. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19429. * Returns the updated direction.
  19430. * @param target The target the direction should point to
  19431. * @return The computed direction
  19432. */
  19433. setDirectionToTarget(target: Vector3): Vector3;
  19434. /**
  19435. * Returns the shadow generator associated to the light.
  19436. * @returns Always null for hemispheric lights because it does not support shadows.
  19437. */
  19438. getShadowGenerator(): Nullable<IShadowGenerator>;
  19439. /**
  19440. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19441. * @param effect The effect to update
  19442. * @param lightIndex The index of the light in the effect to update
  19443. * @returns The hemispheric light
  19444. */
  19445. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19446. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19447. /**
  19448. * Computes the world matrix of the node
  19449. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19450. * @param useWasUpdatedFlag defines a reserved property
  19451. * @returns the world matrix
  19452. */
  19453. computeWorldMatrix(): Matrix;
  19454. /**
  19455. * Returns the integer 3.
  19456. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19457. */
  19458. getTypeID(): number;
  19459. /**
  19460. * Prepares the list of defines specific to the light type.
  19461. * @param defines the list of defines
  19462. * @param lightIndex defines the index of the light for the effect
  19463. */
  19464. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19465. }
  19466. }
  19467. declare module BABYLON {
  19468. /** @hidden */
  19469. export var vrMultiviewToSingleviewPixelShader: {
  19470. name: string;
  19471. shader: string;
  19472. };
  19473. }
  19474. declare module BABYLON {
  19475. /**
  19476. * Renders to multiple views with a single draw call
  19477. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19478. */
  19479. export class MultiviewRenderTarget extends RenderTargetTexture {
  19480. /**
  19481. * Creates a multiview render target
  19482. * @param scene scene used with the render target
  19483. * @param size the size of the render target (used for each view)
  19484. */
  19485. constructor(scene: Scene, size?: number | {
  19486. width: number;
  19487. height: number;
  19488. } | {
  19489. ratio: number;
  19490. });
  19491. /**
  19492. * @hidden
  19493. * @param faceIndex the face index, if its a cube texture
  19494. */
  19495. _bindFrameBuffer(faceIndex?: number): void;
  19496. /**
  19497. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19498. * @returns the view count
  19499. */
  19500. getViewCount(): number;
  19501. }
  19502. }
  19503. declare module BABYLON {
  19504. interface Engine {
  19505. /**
  19506. * Creates a new multiview render target
  19507. * @param width defines the width of the texture
  19508. * @param height defines the height of the texture
  19509. * @returns the created multiview texture
  19510. */
  19511. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19512. /**
  19513. * Binds a multiview framebuffer to be drawn to
  19514. * @param multiviewTexture texture to bind
  19515. */
  19516. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19517. }
  19518. interface Camera {
  19519. /**
  19520. * @hidden
  19521. * 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)
  19522. */
  19523. _useMultiviewToSingleView: boolean;
  19524. /**
  19525. * @hidden
  19526. * 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)
  19527. */
  19528. _multiviewTexture: Nullable<RenderTargetTexture>;
  19529. /**
  19530. * @hidden
  19531. * ensures the multiview texture of the camera exists and has the specified width/height
  19532. * @param width height to set on the multiview texture
  19533. * @param height width to set on the multiview texture
  19534. */
  19535. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19536. }
  19537. interface Scene {
  19538. /** @hidden */
  19539. _transformMatrixR: Matrix;
  19540. /** @hidden */
  19541. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19542. /** @hidden */
  19543. _createMultiviewUbo(): void;
  19544. /** @hidden */
  19545. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19546. /** @hidden */
  19547. _renderMultiviewToSingleView(camera: Camera): void;
  19548. }
  19549. }
  19550. declare module BABYLON {
  19551. /**
  19552. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19553. * This will not be used for webXR as it supports displaying texture arrays directly
  19554. */
  19555. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19556. /**
  19557. * Initializes a VRMultiviewToSingleview
  19558. * @param name name of the post process
  19559. * @param camera camera to be applied to
  19560. * @param scaleFactor scaling factor to the size of the output texture
  19561. */
  19562. constructor(name: string, camera: Camera, scaleFactor: number);
  19563. }
  19564. }
  19565. declare module BABYLON {
  19566. /**
  19567. * Interface used to define additional presentation attributes
  19568. */
  19569. export interface IVRPresentationAttributes {
  19570. /**
  19571. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19572. */
  19573. highRefreshRate: boolean;
  19574. /**
  19575. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19576. */
  19577. foveationLevel: number;
  19578. }
  19579. interface Engine {
  19580. /** @hidden */
  19581. _vrDisplay: any;
  19582. /** @hidden */
  19583. _vrSupported: boolean;
  19584. /** @hidden */
  19585. _oldSize: Size;
  19586. /** @hidden */
  19587. _oldHardwareScaleFactor: number;
  19588. /** @hidden */
  19589. _vrExclusivePointerMode: boolean;
  19590. /** @hidden */
  19591. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19592. /** @hidden */
  19593. _onVRDisplayPointerRestricted: () => void;
  19594. /** @hidden */
  19595. _onVRDisplayPointerUnrestricted: () => void;
  19596. /** @hidden */
  19597. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19598. /** @hidden */
  19599. _onVrDisplayDisconnect: Nullable<() => void>;
  19600. /** @hidden */
  19601. _onVrDisplayPresentChange: Nullable<() => void>;
  19602. /**
  19603. * Observable signaled when VR display mode changes
  19604. */
  19605. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19606. /**
  19607. * Observable signaled when VR request present is complete
  19608. */
  19609. onVRRequestPresentComplete: Observable<boolean>;
  19610. /**
  19611. * Observable signaled when VR request present starts
  19612. */
  19613. onVRRequestPresentStart: Observable<Engine>;
  19614. /**
  19615. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19616. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19617. */
  19618. isInVRExclusivePointerMode: boolean;
  19619. /**
  19620. * Gets a boolean indicating if a webVR device was detected
  19621. * @returns true if a webVR device was detected
  19622. */
  19623. isVRDevicePresent(): boolean;
  19624. /**
  19625. * Gets the current webVR device
  19626. * @returns the current webVR device (or null)
  19627. */
  19628. getVRDevice(): any;
  19629. /**
  19630. * Initializes a webVR display and starts listening to display change events
  19631. * The onVRDisplayChangedObservable will be notified upon these changes
  19632. * @returns A promise containing a VRDisplay and if vr is supported
  19633. */
  19634. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19635. /** @hidden */
  19636. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19637. /**
  19638. * Gets or sets the presentation attributes used to configure VR rendering
  19639. */
  19640. vrPresentationAttributes?: IVRPresentationAttributes;
  19641. /**
  19642. * Call this function to switch to webVR mode
  19643. * Will do nothing if webVR is not supported or if there is no webVR device
  19644. * @param options the webvr options provided to the camera. mainly used for multiview
  19645. * @see https://doc.babylonjs.com/how_to/webvr_camera
  19646. */
  19647. enableVR(options: WebVROptions): void;
  19648. /** @hidden */
  19649. _onVRFullScreenTriggered(): void;
  19650. }
  19651. }
  19652. declare module BABYLON {
  19653. /**
  19654. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19655. * IMPORTANT!! The data is right-hand data.
  19656. * @export
  19657. * @interface DevicePose
  19658. */
  19659. export interface DevicePose {
  19660. /**
  19661. * The position of the device, values in array are [x,y,z].
  19662. */
  19663. readonly position: Nullable<Float32Array>;
  19664. /**
  19665. * The linearVelocity of the device, values in array are [x,y,z].
  19666. */
  19667. readonly linearVelocity: Nullable<Float32Array>;
  19668. /**
  19669. * The linearAcceleration of the device, values in array are [x,y,z].
  19670. */
  19671. readonly linearAcceleration: Nullable<Float32Array>;
  19672. /**
  19673. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19674. */
  19675. readonly orientation: Nullable<Float32Array>;
  19676. /**
  19677. * The angularVelocity of the device, values in array are [x,y,z].
  19678. */
  19679. readonly angularVelocity: Nullable<Float32Array>;
  19680. /**
  19681. * The angularAcceleration of the device, values in array are [x,y,z].
  19682. */
  19683. readonly angularAcceleration: Nullable<Float32Array>;
  19684. }
  19685. /**
  19686. * Interface representing a pose controlled object in Babylon.
  19687. * A pose controlled object has both regular pose values as well as pose values
  19688. * from an external device such as a VR head mounted display
  19689. */
  19690. export interface PoseControlled {
  19691. /**
  19692. * The position of the object in babylon space.
  19693. */
  19694. position: Vector3;
  19695. /**
  19696. * The rotation quaternion of the object in babylon space.
  19697. */
  19698. rotationQuaternion: Quaternion;
  19699. /**
  19700. * The position of the device in babylon space.
  19701. */
  19702. devicePosition?: Vector3;
  19703. /**
  19704. * The rotation quaternion of the device in babylon space.
  19705. */
  19706. deviceRotationQuaternion: Quaternion;
  19707. /**
  19708. * The raw pose coming from the device.
  19709. */
  19710. rawPose: Nullable<DevicePose>;
  19711. /**
  19712. * The scale of the device to be used when translating from device space to babylon space.
  19713. */
  19714. deviceScaleFactor: number;
  19715. /**
  19716. * Updates the poseControlled values based on the input device pose.
  19717. * @param poseData the pose data to update the object with
  19718. */
  19719. updateFromDevice(poseData: DevicePose): void;
  19720. }
  19721. /**
  19722. * Set of options to customize the webVRCamera
  19723. */
  19724. export interface WebVROptions {
  19725. /**
  19726. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19727. */
  19728. trackPosition?: boolean;
  19729. /**
  19730. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19731. */
  19732. positionScale?: number;
  19733. /**
  19734. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19735. */
  19736. displayName?: string;
  19737. /**
  19738. * Should the native controller meshes be initialized. (default: true)
  19739. */
  19740. controllerMeshes?: boolean;
  19741. /**
  19742. * Creating a default HemiLight only on controllers. (default: true)
  19743. */
  19744. defaultLightingOnControllers?: boolean;
  19745. /**
  19746. * If you don't want to use the default VR button of the helper. (default: false)
  19747. */
  19748. useCustomVRButton?: boolean;
  19749. /**
  19750. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19751. */
  19752. customVRButton?: HTMLButtonElement;
  19753. /**
  19754. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19755. */
  19756. rayLength?: number;
  19757. /**
  19758. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19759. */
  19760. defaultHeight?: number;
  19761. /**
  19762. * If multiview should be used if availible (default: false)
  19763. */
  19764. useMultiview?: boolean;
  19765. }
  19766. /**
  19767. * This represents a WebVR camera.
  19768. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19769. * @example https://doc.babylonjs.com/how_to/webvr_camera
  19770. */
  19771. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19772. private webVROptions;
  19773. /**
  19774. * @hidden
  19775. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19776. */
  19777. _vrDevice: any;
  19778. /**
  19779. * The rawPose of the vrDevice.
  19780. */
  19781. rawPose: Nullable<DevicePose>;
  19782. private _onVREnabled;
  19783. private _specsVersion;
  19784. private _attached;
  19785. private _frameData;
  19786. protected _descendants: Array<Node>;
  19787. private _deviceRoomPosition;
  19788. /** @hidden */
  19789. _deviceRoomRotationQuaternion: Quaternion;
  19790. private _standingMatrix;
  19791. /**
  19792. * Represents device position in babylon space.
  19793. */
  19794. devicePosition: Vector3;
  19795. /**
  19796. * Represents device rotation in babylon space.
  19797. */
  19798. deviceRotationQuaternion: Quaternion;
  19799. /**
  19800. * The scale of the device to be used when translating from device space to babylon space.
  19801. */
  19802. deviceScaleFactor: number;
  19803. private _deviceToWorld;
  19804. private _worldToDevice;
  19805. /**
  19806. * References to the webVR controllers for the vrDevice.
  19807. */
  19808. controllers: Array<WebVRController>;
  19809. /**
  19810. * Emits an event when a controller is attached.
  19811. */
  19812. onControllersAttachedObservable: Observable<WebVRController[]>;
  19813. /**
  19814. * Emits an event when a controller's mesh has been loaded;
  19815. */
  19816. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19817. /**
  19818. * Emits an event when the HMD's pose has been updated.
  19819. */
  19820. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19821. private _poseSet;
  19822. /**
  19823. * If the rig cameras be used as parent instead of this camera.
  19824. */
  19825. rigParenting: boolean;
  19826. private _lightOnControllers;
  19827. private _defaultHeight?;
  19828. /**
  19829. * Instantiates a WebVRFreeCamera.
  19830. * @param name The name of the WebVRFreeCamera
  19831. * @param position The starting anchor position for the camera
  19832. * @param scene The scene the camera belongs to
  19833. * @param webVROptions a set of customizable options for the webVRCamera
  19834. */
  19835. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19836. /**
  19837. * Gets the device distance from the ground in meters.
  19838. * @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.
  19839. */
  19840. deviceDistanceToRoomGround(): number;
  19841. /**
  19842. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19843. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19844. */
  19845. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19846. /**
  19847. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19848. * @returns A promise with a boolean set to if the standing matrix is supported.
  19849. */
  19850. useStandingMatrixAsync(): Promise<boolean>;
  19851. /**
  19852. * Disposes the camera
  19853. */
  19854. dispose(): void;
  19855. /**
  19856. * Gets a vrController by name.
  19857. * @param name The name of the controller to retreive
  19858. * @returns the controller matching the name specified or null if not found
  19859. */
  19860. getControllerByName(name: string): Nullable<WebVRController>;
  19861. private _leftController;
  19862. /**
  19863. * The controller corresponding to the users left hand.
  19864. */
  19865. get leftController(): Nullable<WebVRController>;
  19866. private _rightController;
  19867. /**
  19868. * The controller corresponding to the users right hand.
  19869. */
  19870. get rightController(): Nullable<WebVRController>;
  19871. /**
  19872. * Casts a ray forward from the vrCamera's gaze.
  19873. * @param length Length of the ray (default: 100)
  19874. * @returns the ray corresponding to the gaze
  19875. */
  19876. getForwardRay(length?: number): Ray;
  19877. /**
  19878. * @hidden
  19879. * Updates the camera based on device's frame data
  19880. */
  19881. _checkInputs(): void;
  19882. /**
  19883. * Updates the poseControlled values based on the input device pose.
  19884. * @param poseData Pose coming from the device
  19885. */
  19886. updateFromDevice(poseData: DevicePose): void;
  19887. private _htmlElementAttached;
  19888. private _detachIfAttached;
  19889. /**
  19890. * WebVR's attach control will start broadcasting frames to the device.
  19891. * Note that in certain browsers (chrome for example) this function must be called
  19892. * within a user-interaction callback. Example:
  19893. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19894. *
  19895. * @param element html element to attach the vrDevice to
  19896. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19897. */
  19898. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19899. /**
  19900. * Detaches the camera from the html element and disables VR
  19901. *
  19902. * @param element html element to detach from
  19903. */
  19904. detachControl(element: HTMLElement): void;
  19905. /**
  19906. * @returns the name of this class
  19907. */
  19908. getClassName(): string;
  19909. /**
  19910. * Calls resetPose on the vrDisplay
  19911. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19912. */
  19913. resetToCurrentRotation(): void;
  19914. /**
  19915. * @hidden
  19916. * Updates the rig cameras (left and right eye)
  19917. */
  19918. _updateRigCameras(): void;
  19919. private _workingVector;
  19920. private _oneVector;
  19921. private _workingMatrix;
  19922. private updateCacheCalled;
  19923. private _correctPositionIfNotTrackPosition;
  19924. /**
  19925. * @hidden
  19926. * Updates the cached values of the camera
  19927. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19928. */
  19929. _updateCache(ignoreParentClass?: boolean): void;
  19930. /**
  19931. * @hidden
  19932. * Get current device position in babylon world
  19933. */
  19934. _computeDevicePosition(): void;
  19935. /**
  19936. * Updates the current device position and rotation in the babylon world
  19937. */
  19938. update(): void;
  19939. /**
  19940. * @hidden
  19941. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19942. * @returns an identity matrix
  19943. */
  19944. _getViewMatrix(): Matrix;
  19945. private _tmpMatrix;
  19946. /**
  19947. * This function is called by the two RIG cameras.
  19948. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19949. * @hidden
  19950. */
  19951. _getWebVRViewMatrix(): Matrix;
  19952. /** @hidden */
  19953. _getWebVRProjectionMatrix(): Matrix;
  19954. private _onGamepadConnectedObserver;
  19955. private _onGamepadDisconnectedObserver;
  19956. private _updateCacheWhenTrackingDisabledObserver;
  19957. /**
  19958. * Initializes the controllers and their meshes
  19959. */
  19960. initControllers(): void;
  19961. }
  19962. }
  19963. declare module BABYLON {
  19964. /**
  19965. * "Static Class" containing the most commonly used helper while dealing with material for
  19966. * rendering purpose.
  19967. *
  19968. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  19969. *
  19970. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  19971. */
  19972. export class MaterialHelper {
  19973. /**
  19974. * Bind the current view position to an effect.
  19975. * @param effect The effect to be bound
  19976. * @param scene The scene the eyes position is used from
  19977. * @param variableName name of the shader variable that will hold the eye position
  19978. */
  19979. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  19980. /**
  19981. * Helps preparing the defines values about the UVs in used in the effect.
  19982. * UVs are shared as much as we can accross channels in the shaders.
  19983. * @param texture The texture we are preparing the UVs for
  19984. * @param defines The defines to update
  19985. * @param key The channel key "diffuse", "specular"... used in the shader
  19986. */
  19987. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  19988. /**
  19989. * Binds a texture matrix value to its corrsponding uniform
  19990. * @param texture The texture to bind the matrix for
  19991. * @param uniformBuffer The uniform buffer receivin the data
  19992. * @param key The channel key "diffuse", "specular"... used in the shader
  19993. */
  19994. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  19995. /**
  19996. * Gets the current status of the fog (should it be enabled?)
  19997. * @param mesh defines the mesh to evaluate for fog support
  19998. * @param scene defines the hosting scene
  19999. * @returns true if fog must be enabled
  20000. */
  20001. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20002. /**
  20003. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20004. * @param mesh defines the current mesh
  20005. * @param scene defines the current scene
  20006. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20007. * @param pointsCloud defines if point cloud rendering has to be turned on
  20008. * @param fogEnabled defines if fog has to be turned on
  20009. * @param alphaTest defines if alpha testing has to be turned on
  20010. * @param defines defines the current list of defines
  20011. */
  20012. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20013. /**
  20014. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20015. * @param scene defines the current scene
  20016. * @param engine defines the current engine
  20017. * @param defines specifies the list of active defines
  20018. * @param useInstances defines if instances have to be turned on
  20019. * @param useClipPlane defines if clip plane have to be turned on
  20020. * @param useInstances defines if instances have to be turned on
  20021. * @param useThinInstances defines if thin instances have to be turned on
  20022. */
  20023. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20024. /**
  20025. * Prepares the defines for bones
  20026. * @param mesh The mesh containing the geometry data we will draw
  20027. * @param defines The defines to update
  20028. */
  20029. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20030. /**
  20031. * Prepares the defines for morph targets
  20032. * @param mesh The mesh containing the geometry data we will draw
  20033. * @param defines The defines to update
  20034. */
  20035. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20036. /**
  20037. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20038. * @param mesh The mesh containing the geometry data we will draw
  20039. * @param defines The defines to update
  20040. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20041. * @param useBones Precise whether bones should be used or not (override mesh info)
  20042. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20043. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20044. * @returns false if defines are considered not dirty and have not been checked
  20045. */
  20046. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20047. /**
  20048. * Prepares the defines related to multiview
  20049. * @param scene The scene we are intending to draw
  20050. * @param defines The defines to update
  20051. */
  20052. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20053. /**
  20054. * Prepares the defines related to the prepass
  20055. * @param scene The scene we are intending to draw
  20056. * @param defines The defines to update
  20057. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20058. */
  20059. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20060. /**
  20061. * Prepares the defines related to the light information passed in parameter
  20062. * @param scene The scene we are intending to draw
  20063. * @param mesh The mesh the effect is compiling for
  20064. * @param light The light the effect is compiling for
  20065. * @param lightIndex The index of the light
  20066. * @param defines The defines to update
  20067. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20068. * @param state Defines the current state regarding what is needed (normals, etc...)
  20069. */
  20070. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20071. needNormals: boolean;
  20072. needRebuild: boolean;
  20073. shadowEnabled: boolean;
  20074. specularEnabled: boolean;
  20075. lightmapMode: boolean;
  20076. }): void;
  20077. /**
  20078. * Prepares the defines related to the light information passed in parameter
  20079. * @param scene The scene we are intending to draw
  20080. * @param mesh The mesh the effect is compiling for
  20081. * @param defines The defines to update
  20082. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20083. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20084. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20085. * @returns true if normals will be required for the rest of the effect
  20086. */
  20087. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20088. /**
  20089. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20090. * @param lightIndex defines the light index
  20091. * @param uniformsList The uniform list
  20092. * @param samplersList The sampler list
  20093. * @param projectedLightTexture defines if projected texture must be used
  20094. * @param uniformBuffersList defines an optional list of uniform buffers
  20095. */
  20096. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20097. /**
  20098. * Prepares the uniforms and samplers list to be used in the effect
  20099. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20100. * @param samplersList The sampler list
  20101. * @param defines The defines helping in the list generation
  20102. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20103. */
  20104. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20105. /**
  20106. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20107. * @param defines The defines to update while falling back
  20108. * @param fallbacks The authorized effect fallbacks
  20109. * @param maxSimultaneousLights The maximum number of lights allowed
  20110. * @param rank the current rank of the Effect
  20111. * @returns The newly affected rank
  20112. */
  20113. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20114. private static _TmpMorphInfluencers;
  20115. /**
  20116. * Prepares the list of attributes required for morph targets according to the effect defines.
  20117. * @param attribs The current list of supported attribs
  20118. * @param mesh The mesh to prepare the morph targets attributes for
  20119. * @param influencers The number of influencers
  20120. */
  20121. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20122. /**
  20123. * Prepares the list of attributes required for morph targets according to the effect defines.
  20124. * @param attribs The current list of supported attribs
  20125. * @param mesh The mesh to prepare the morph targets attributes for
  20126. * @param defines The current Defines of the effect
  20127. */
  20128. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20129. /**
  20130. * Prepares the list of attributes required for bones according to the effect defines.
  20131. * @param attribs The current list of supported attribs
  20132. * @param mesh The mesh to prepare the bones attributes for
  20133. * @param defines The current Defines of the effect
  20134. * @param fallbacks The current efffect fallback strategy
  20135. */
  20136. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20137. /**
  20138. * Check and prepare the list of attributes required for instances according to the effect defines.
  20139. * @param attribs The current list of supported attribs
  20140. * @param defines The current MaterialDefines of the effect
  20141. */
  20142. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20143. /**
  20144. * Add the list of attributes required for instances to the attribs array.
  20145. * @param attribs The current list of supported attribs
  20146. */
  20147. static PushAttributesForInstances(attribs: string[]): void;
  20148. /**
  20149. * Binds the light information to the effect.
  20150. * @param light The light containing the generator
  20151. * @param effect The effect we are binding the data to
  20152. * @param lightIndex The light index in the effect used to render
  20153. */
  20154. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20155. /**
  20156. * Binds the lights information from the scene to the effect for the given mesh.
  20157. * @param light Light to bind
  20158. * @param lightIndex Light index
  20159. * @param scene The scene where the light belongs to
  20160. * @param effect The effect we are binding the data to
  20161. * @param useSpecular Defines if specular is supported
  20162. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20163. */
  20164. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20165. /**
  20166. * Binds the lights information from the scene to the effect for the given mesh.
  20167. * @param scene The scene the lights belongs to
  20168. * @param mesh The mesh we are binding the information to render
  20169. * @param effect The effect we are binding the data to
  20170. * @param defines The generated defines for the effect
  20171. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20172. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20173. */
  20174. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20175. private static _tempFogColor;
  20176. /**
  20177. * Binds the fog information from the scene to the effect for the given mesh.
  20178. * @param scene The scene the lights belongs to
  20179. * @param mesh The mesh we are binding the information to render
  20180. * @param effect The effect we are binding the data to
  20181. * @param linearSpace Defines if the fog effect is applied in linear space
  20182. */
  20183. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20184. /**
  20185. * Binds the bones information from the mesh to the effect.
  20186. * @param mesh The mesh we are binding the information to render
  20187. * @param effect The effect we are binding the data to
  20188. */
  20189. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20190. /**
  20191. * Binds the morph targets information from the mesh to the effect.
  20192. * @param abstractMesh The mesh we are binding the information to render
  20193. * @param effect The effect we are binding the data to
  20194. */
  20195. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20196. /**
  20197. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20198. * @param defines The generated defines used in the effect
  20199. * @param effect The effect we are binding the data to
  20200. * @param scene The scene we are willing to render with logarithmic scale for
  20201. */
  20202. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20203. /**
  20204. * Binds the clip plane information from the scene to the effect.
  20205. * @param scene The scene the clip plane information are extracted from
  20206. * @param effect The effect we are binding the data to
  20207. */
  20208. static BindClipPlane(effect: Effect, scene: Scene): void;
  20209. }
  20210. }
  20211. declare module BABYLON {
  20212. /**
  20213. * Block used to expose an input value
  20214. */
  20215. export class InputBlock extends NodeMaterialBlock {
  20216. private _mode;
  20217. private _associatedVariableName;
  20218. private _storedValue;
  20219. private _valueCallback;
  20220. private _type;
  20221. private _animationType;
  20222. /** Gets or set a value used to limit the range of float values */
  20223. min: number;
  20224. /** Gets or set a value used to limit the range of float values */
  20225. max: number;
  20226. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20227. isBoolean: boolean;
  20228. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20229. matrixMode: number;
  20230. /** @hidden */
  20231. _systemValue: Nullable<NodeMaterialSystemValues>;
  20232. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20233. visibleInInspector: boolean;
  20234. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20235. isConstant: boolean;
  20236. /** Gets or sets the group to use to display this block in the Inspector */
  20237. groupInInspector: string;
  20238. /** Gets an observable raised when the value is changed */
  20239. onValueChangedObservable: Observable<InputBlock>;
  20240. /**
  20241. * Gets or sets the connection point type (default is float)
  20242. */
  20243. get type(): NodeMaterialBlockConnectionPointTypes;
  20244. /**
  20245. * Creates a new InputBlock
  20246. * @param name defines the block name
  20247. * @param target defines the target of that block (Vertex by default)
  20248. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20249. */
  20250. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20251. /**
  20252. * Validates if a name is a reserve word.
  20253. * @param newName the new name to be given to the node.
  20254. * @returns false if the name is a reserve word, else true.
  20255. */
  20256. validateBlockName(newName: string): boolean;
  20257. /**
  20258. * Gets the output component
  20259. */
  20260. get output(): NodeMaterialConnectionPoint;
  20261. /**
  20262. * Set the source of this connection point to a vertex attribute
  20263. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20264. * @returns the current connection point
  20265. */
  20266. setAsAttribute(attributeName?: string): InputBlock;
  20267. /**
  20268. * Set the source of this connection point to a system value
  20269. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20270. * @returns the current connection point
  20271. */
  20272. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20273. /**
  20274. * Gets or sets the value of that point.
  20275. * Please note that this value will be ignored if valueCallback is defined
  20276. */
  20277. get value(): any;
  20278. set value(value: any);
  20279. /**
  20280. * Gets or sets a callback used to get the value of that point.
  20281. * Please note that setting this value will force the connection point to ignore the value property
  20282. */
  20283. get valueCallback(): () => any;
  20284. set valueCallback(value: () => any);
  20285. /**
  20286. * Gets or sets the associated variable name in the shader
  20287. */
  20288. get associatedVariableName(): string;
  20289. set associatedVariableName(value: string);
  20290. /** Gets or sets the type of animation applied to the input */
  20291. get animationType(): AnimatedInputBlockTypes;
  20292. set animationType(value: AnimatedInputBlockTypes);
  20293. /**
  20294. * Gets a boolean indicating that this connection point not defined yet
  20295. */
  20296. get isUndefined(): boolean;
  20297. /**
  20298. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20299. * In this case the connection point name must be the name of the uniform to use.
  20300. * Can only be set on inputs
  20301. */
  20302. get isUniform(): boolean;
  20303. set isUniform(value: boolean);
  20304. /**
  20305. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20306. * In this case the connection point name must be the name of the attribute to use
  20307. * Can only be set on inputs
  20308. */
  20309. get isAttribute(): boolean;
  20310. set isAttribute(value: boolean);
  20311. /**
  20312. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20313. * Can only be set on exit points
  20314. */
  20315. get isVarying(): boolean;
  20316. set isVarying(value: boolean);
  20317. /**
  20318. * Gets a boolean indicating that the current connection point is a system value
  20319. */
  20320. get isSystemValue(): boolean;
  20321. /**
  20322. * Gets or sets the current well known value or null if not defined as a system value
  20323. */
  20324. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20325. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20326. /**
  20327. * Gets the current class name
  20328. * @returns the class name
  20329. */
  20330. getClassName(): string;
  20331. /**
  20332. * Animate the input if animationType !== None
  20333. * @param scene defines the rendering scene
  20334. */
  20335. animate(scene: Scene): void;
  20336. private _emitDefine;
  20337. initialize(state: NodeMaterialBuildState): void;
  20338. /**
  20339. * Set the input block to its default value (based on its type)
  20340. */
  20341. setDefaultValue(): void;
  20342. private _emitConstant;
  20343. /** @hidden */
  20344. get _noContextSwitch(): boolean;
  20345. private _emit;
  20346. /** @hidden */
  20347. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20348. /** @hidden */
  20349. _transmit(effect: Effect, scene: Scene): void;
  20350. protected _buildBlock(state: NodeMaterialBuildState): void;
  20351. protected _dumpPropertiesCode(): string;
  20352. dispose(): void;
  20353. serialize(): any;
  20354. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20355. }
  20356. }
  20357. declare module BABYLON {
  20358. /**
  20359. * Enum used to define the compatibility state between two connection points
  20360. */
  20361. export enum NodeMaterialConnectionPointCompatibilityStates {
  20362. /** Points are compatibles */
  20363. Compatible = 0,
  20364. /** Points are incompatible because of their types */
  20365. TypeIncompatible = 1,
  20366. /** Points are incompatible because of their targets (vertex vs fragment) */
  20367. TargetIncompatible = 2
  20368. }
  20369. /**
  20370. * Defines the direction of a connection point
  20371. */
  20372. export enum NodeMaterialConnectionPointDirection {
  20373. /** Input */
  20374. Input = 0,
  20375. /** Output */
  20376. Output = 1
  20377. }
  20378. /**
  20379. * Defines a connection point for a block
  20380. */
  20381. export class NodeMaterialConnectionPoint {
  20382. /** @hidden */
  20383. _ownerBlock: NodeMaterialBlock;
  20384. /** @hidden */
  20385. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20386. private _endpoints;
  20387. private _associatedVariableName;
  20388. private _direction;
  20389. /** @hidden */
  20390. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20391. /** @hidden */
  20392. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20393. private _type;
  20394. /** @hidden */
  20395. _enforceAssociatedVariableName: boolean;
  20396. /** Gets the direction of the point */
  20397. get direction(): NodeMaterialConnectionPointDirection;
  20398. /** Indicates that this connection point needs dual validation before being connected to another point */
  20399. needDualDirectionValidation: boolean;
  20400. /**
  20401. * Gets or sets the additional types supported by this connection point
  20402. */
  20403. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20404. /**
  20405. * Gets or sets the additional types excluded by this connection point
  20406. */
  20407. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20408. /**
  20409. * Observable triggered when this point is connected
  20410. */
  20411. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20412. /**
  20413. * Gets or sets the associated variable name in the shader
  20414. */
  20415. get associatedVariableName(): string;
  20416. set associatedVariableName(value: string);
  20417. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20418. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20419. /**
  20420. * Gets or sets the connection point type (default is float)
  20421. */
  20422. get type(): NodeMaterialBlockConnectionPointTypes;
  20423. set type(value: NodeMaterialBlockConnectionPointTypes);
  20424. /**
  20425. * Gets or sets the connection point name
  20426. */
  20427. name: string;
  20428. /**
  20429. * Gets or sets the connection point name
  20430. */
  20431. displayName: string;
  20432. /**
  20433. * Gets or sets a boolean indicating that this connection point can be omitted
  20434. */
  20435. isOptional: boolean;
  20436. /**
  20437. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20438. */
  20439. isExposedOnFrame: boolean;
  20440. /**
  20441. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20442. */
  20443. define: string;
  20444. /** @hidden */
  20445. _prioritizeVertex: boolean;
  20446. private _target;
  20447. /** Gets or sets the target of that connection point */
  20448. get target(): NodeMaterialBlockTargets;
  20449. set target(value: NodeMaterialBlockTargets);
  20450. /**
  20451. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20452. */
  20453. get isConnected(): boolean;
  20454. /**
  20455. * Gets a boolean indicating that the current point is connected to an input block
  20456. */
  20457. get isConnectedToInputBlock(): boolean;
  20458. /**
  20459. * Gets a the connected input block (if any)
  20460. */
  20461. get connectInputBlock(): Nullable<InputBlock>;
  20462. /** Get the other side of the connection (if any) */
  20463. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20464. /** Get the block that owns this connection point */
  20465. get ownerBlock(): NodeMaterialBlock;
  20466. /** Get the block connected on the other side of this connection (if any) */
  20467. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20468. /** Get the block connected on the endpoints of this connection (if any) */
  20469. get connectedBlocks(): Array<NodeMaterialBlock>;
  20470. /** Gets the list of connected endpoints */
  20471. get endpoints(): NodeMaterialConnectionPoint[];
  20472. /** Gets a boolean indicating if that output point is connected to at least one input */
  20473. get hasEndpoints(): boolean;
  20474. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20475. get isConnectedInVertexShader(): boolean;
  20476. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20477. get isConnectedInFragmentShader(): boolean;
  20478. /**
  20479. * Creates a block suitable to be used as an input for this input point.
  20480. * If null is returned, a block based on the point type will be created.
  20481. * @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
  20482. */
  20483. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20484. /**
  20485. * Creates a new connection point
  20486. * @param name defines the connection point name
  20487. * @param ownerBlock defines the block hosting this connection point
  20488. * @param direction defines the direction of the connection point
  20489. */
  20490. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20491. /**
  20492. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20493. * @returns the class name
  20494. */
  20495. getClassName(): string;
  20496. /**
  20497. * Gets a boolean indicating if the current point can be connected to another point
  20498. * @param connectionPoint defines the other connection point
  20499. * @returns a boolean
  20500. */
  20501. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20502. /**
  20503. * Gets a number indicating if the current point can be connected to another point
  20504. * @param connectionPoint defines the other connection point
  20505. * @returns a number defining the compatibility state
  20506. */
  20507. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20508. /**
  20509. * Connect this point to another connection point
  20510. * @param connectionPoint defines the other connection point
  20511. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20512. * @returns the current connection point
  20513. */
  20514. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20515. /**
  20516. * Disconnect this point from one of his endpoint
  20517. * @param endpoint defines the other connection point
  20518. * @returns the current connection point
  20519. */
  20520. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20521. /**
  20522. * Serializes this point in a JSON representation
  20523. * @param isInput defines if the connection point is an input (default is true)
  20524. * @returns the serialized point object
  20525. */
  20526. serialize(isInput?: boolean): any;
  20527. /**
  20528. * Release resources
  20529. */
  20530. dispose(): void;
  20531. }
  20532. }
  20533. declare module BABYLON {
  20534. /**
  20535. * Enum used to define the material modes
  20536. */
  20537. export enum NodeMaterialModes {
  20538. /** Regular material */
  20539. Material = 0,
  20540. /** For post process */
  20541. PostProcess = 1,
  20542. /** For particle system */
  20543. Particle = 2
  20544. }
  20545. }
  20546. declare module BABYLON {
  20547. /**
  20548. * Block used to read a texture from a sampler
  20549. */
  20550. export class TextureBlock extends NodeMaterialBlock {
  20551. private _defineName;
  20552. private _linearDefineName;
  20553. private _gammaDefineName;
  20554. private _tempTextureRead;
  20555. private _samplerName;
  20556. private _transformedUVName;
  20557. private _textureTransformName;
  20558. private _textureInfoName;
  20559. private _mainUVName;
  20560. private _mainUVDefineName;
  20561. private _fragmentOnly;
  20562. /**
  20563. * Gets or sets the texture associated with the node
  20564. */
  20565. texture: Nullable<Texture>;
  20566. /**
  20567. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20568. */
  20569. convertToGammaSpace: boolean;
  20570. /**
  20571. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20572. */
  20573. convertToLinearSpace: boolean;
  20574. /**
  20575. * Create a new TextureBlock
  20576. * @param name defines the block name
  20577. */
  20578. constructor(name: string, fragmentOnly?: boolean);
  20579. /**
  20580. * Gets the current class name
  20581. * @returns the class name
  20582. */
  20583. getClassName(): string;
  20584. /**
  20585. * Gets the uv input component
  20586. */
  20587. get uv(): NodeMaterialConnectionPoint;
  20588. /**
  20589. * Gets the rgba output component
  20590. */
  20591. get rgba(): NodeMaterialConnectionPoint;
  20592. /**
  20593. * Gets the rgb output component
  20594. */
  20595. get rgb(): NodeMaterialConnectionPoint;
  20596. /**
  20597. * Gets the r output component
  20598. */
  20599. get r(): NodeMaterialConnectionPoint;
  20600. /**
  20601. * Gets the g output component
  20602. */
  20603. get g(): NodeMaterialConnectionPoint;
  20604. /**
  20605. * Gets the b output component
  20606. */
  20607. get b(): NodeMaterialConnectionPoint;
  20608. /**
  20609. * Gets the a output component
  20610. */
  20611. get a(): NodeMaterialConnectionPoint;
  20612. get target(): NodeMaterialBlockTargets;
  20613. autoConfigure(material: NodeMaterial): void;
  20614. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20615. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20616. isReady(): boolean;
  20617. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20618. private get _isMixed();
  20619. private _injectVertexCode;
  20620. private _writeTextureRead;
  20621. private _writeOutput;
  20622. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20623. protected _dumpPropertiesCode(): string;
  20624. serialize(): any;
  20625. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20626. }
  20627. }
  20628. declare module BABYLON {
  20629. /** @hidden */
  20630. export var reflectionFunction: {
  20631. name: string;
  20632. shader: string;
  20633. };
  20634. }
  20635. declare module BABYLON {
  20636. /**
  20637. * Base block used to read a reflection texture from a sampler
  20638. */
  20639. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20640. /** @hidden */
  20641. _define3DName: string;
  20642. /** @hidden */
  20643. _defineCubicName: string;
  20644. /** @hidden */
  20645. _defineExplicitName: string;
  20646. /** @hidden */
  20647. _defineProjectionName: string;
  20648. /** @hidden */
  20649. _defineLocalCubicName: string;
  20650. /** @hidden */
  20651. _defineSphericalName: string;
  20652. /** @hidden */
  20653. _definePlanarName: string;
  20654. /** @hidden */
  20655. _defineEquirectangularName: string;
  20656. /** @hidden */
  20657. _defineMirroredEquirectangularFixedName: string;
  20658. /** @hidden */
  20659. _defineEquirectangularFixedName: string;
  20660. /** @hidden */
  20661. _defineSkyboxName: string;
  20662. /** @hidden */
  20663. _defineOppositeZ: string;
  20664. /** @hidden */
  20665. _cubeSamplerName: string;
  20666. /** @hidden */
  20667. _2DSamplerName: string;
  20668. protected _positionUVWName: string;
  20669. protected _directionWName: string;
  20670. protected _reflectionVectorName: string;
  20671. /** @hidden */
  20672. _reflectionCoordsName: string;
  20673. /** @hidden */
  20674. _reflectionMatrixName: string;
  20675. protected _reflectionColorName: string;
  20676. /**
  20677. * Gets or sets the texture associated with the node
  20678. */
  20679. texture: Nullable<BaseTexture>;
  20680. /**
  20681. * Create a new ReflectionTextureBaseBlock
  20682. * @param name defines the block name
  20683. */
  20684. constructor(name: string);
  20685. /**
  20686. * Gets the current class name
  20687. * @returns the class name
  20688. */
  20689. getClassName(): string;
  20690. /**
  20691. * Gets the world position input component
  20692. */
  20693. abstract get position(): NodeMaterialConnectionPoint;
  20694. /**
  20695. * Gets the world position input component
  20696. */
  20697. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20698. /**
  20699. * Gets the world normal input component
  20700. */
  20701. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20702. /**
  20703. * Gets the world input component
  20704. */
  20705. abstract get world(): NodeMaterialConnectionPoint;
  20706. /**
  20707. * Gets the camera (or eye) position component
  20708. */
  20709. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  20710. /**
  20711. * Gets the view input component
  20712. */
  20713. abstract get view(): NodeMaterialConnectionPoint;
  20714. protected _getTexture(): Nullable<BaseTexture>;
  20715. autoConfigure(material: NodeMaterial): void;
  20716. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20717. isReady(): boolean;
  20718. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20719. /**
  20720. * Gets the code to inject in the vertex shader
  20721. * @param state current state of the node material building
  20722. * @returns the shader code
  20723. */
  20724. handleVertexSide(state: NodeMaterialBuildState): string;
  20725. /**
  20726. * Handles the inits for the fragment code path
  20727. * @param state node material build state
  20728. */
  20729. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  20730. /**
  20731. * Generates the reflection coords code for the fragment code path
  20732. * @param worldNormalVarName name of the world normal variable
  20733. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  20734. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  20735. * @returns the shader code
  20736. */
  20737. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  20738. /**
  20739. * Generates the reflection color code for the fragment code path
  20740. * @param lodVarName name of the lod variable
  20741. * @param swizzleLookupTexture swizzle to use for the final color variable
  20742. * @returns the shader code
  20743. */
  20744. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  20745. /**
  20746. * Generates the code corresponding to the connected output points
  20747. * @param state node material build state
  20748. * @param varName name of the variable to output
  20749. * @returns the shader code
  20750. */
  20751. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  20752. protected _buildBlock(state: NodeMaterialBuildState): this;
  20753. protected _dumpPropertiesCode(): string;
  20754. serialize(): any;
  20755. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20756. }
  20757. }
  20758. declare module BABYLON {
  20759. /**
  20760. * Defines a connection point to be used for points with a custom object type
  20761. */
  20762. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  20763. private _blockType;
  20764. private _blockName;
  20765. private _nameForCheking?;
  20766. /**
  20767. * Creates a new connection point
  20768. * @param name defines the connection point name
  20769. * @param ownerBlock defines the block hosting this connection point
  20770. * @param direction defines the direction of the connection point
  20771. */
  20772. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  20773. /**
  20774. * Gets a number indicating if the current point can be connected to another point
  20775. * @param connectionPoint defines the other connection point
  20776. * @returns a number defining the compatibility state
  20777. */
  20778. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20779. /**
  20780. * Creates a block suitable to be used as an input for this input point.
  20781. * If null is returned, a block based on the point type will be created.
  20782. * @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
  20783. */
  20784. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20785. }
  20786. }
  20787. declare module BABYLON {
  20788. /**
  20789. * Enum defining the type of properties that can be edited in the property pages in the NME
  20790. */
  20791. export enum PropertyTypeForEdition {
  20792. /** property is a boolean */
  20793. Boolean = 0,
  20794. /** property is a float */
  20795. Float = 1,
  20796. /** property is a Vector2 */
  20797. Vector2 = 2,
  20798. /** property is a list of values */
  20799. List = 3
  20800. }
  20801. /**
  20802. * Interface that defines an option in a variable of type list
  20803. */
  20804. export interface IEditablePropertyListOption {
  20805. /** label of the option */
  20806. "label": string;
  20807. /** value of the option */
  20808. "value": number;
  20809. }
  20810. /**
  20811. * Interface that defines the options available for an editable property
  20812. */
  20813. export interface IEditablePropertyOption {
  20814. /** min value */
  20815. "min"?: number;
  20816. /** max value */
  20817. "max"?: number;
  20818. /** notifiers: indicates which actions to take when the property is changed */
  20819. "notifiers"?: {
  20820. /** the material should be rebuilt */
  20821. "rebuild"?: boolean;
  20822. /** the preview should be updated */
  20823. "update"?: boolean;
  20824. };
  20825. /** list of the options for a variable of type list */
  20826. "options"?: IEditablePropertyListOption[];
  20827. }
  20828. /**
  20829. * Interface that describes an editable property
  20830. */
  20831. export interface IPropertyDescriptionForEdition {
  20832. /** name of the property */
  20833. "propertyName": string;
  20834. /** display name of the property */
  20835. "displayName": string;
  20836. /** type of the property */
  20837. "type": PropertyTypeForEdition;
  20838. /** group of the property - all properties with the same group value will be displayed in a specific section */
  20839. "groupName": string;
  20840. /** options for the property */
  20841. "options": IEditablePropertyOption;
  20842. }
  20843. /**
  20844. * Decorator that flags a property in a node material block as being editable
  20845. */
  20846. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  20847. }
  20848. declare module BABYLON {
  20849. /**
  20850. * Block used to implement the refraction part of the sub surface module of the PBR material
  20851. */
  20852. export class RefractionBlock extends NodeMaterialBlock {
  20853. /** @hidden */
  20854. _define3DName: string;
  20855. /** @hidden */
  20856. _refractionMatrixName: string;
  20857. /** @hidden */
  20858. _defineLODRefractionAlpha: string;
  20859. /** @hidden */
  20860. _defineLinearSpecularRefraction: string;
  20861. /** @hidden */
  20862. _defineOppositeZ: string;
  20863. /** @hidden */
  20864. _cubeSamplerName: string;
  20865. /** @hidden */
  20866. _2DSamplerName: string;
  20867. /** @hidden */
  20868. _vRefractionMicrosurfaceInfosName: string;
  20869. /** @hidden */
  20870. _vRefractionInfosName: string;
  20871. private _scene;
  20872. /**
  20873. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20874. * Materials half opaque for instance using refraction could benefit from this control.
  20875. */
  20876. linkRefractionWithTransparency: boolean;
  20877. /**
  20878. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20879. */
  20880. invertRefractionY: boolean;
  20881. /**
  20882. * Gets or sets the texture associated with the node
  20883. */
  20884. texture: Nullable<BaseTexture>;
  20885. /**
  20886. * Create a new RefractionBlock
  20887. * @param name defines the block name
  20888. */
  20889. constructor(name: string);
  20890. /**
  20891. * Gets the current class name
  20892. * @returns the class name
  20893. */
  20894. getClassName(): string;
  20895. /**
  20896. * Gets the intensity input component
  20897. */
  20898. get intensity(): NodeMaterialConnectionPoint;
  20899. /**
  20900. * Gets the index of refraction input component
  20901. */
  20902. get indexOfRefraction(): NodeMaterialConnectionPoint;
  20903. /**
  20904. * Gets the tint at distance input component
  20905. */
  20906. get tintAtDistance(): NodeMaterialConnectionPoint;
  20907. /**
  20908. * Gets the view input component
  20909. */
  20910. get view(): NodeMaterialConnectionPoint;
  20911. /**
  20912. * Gets the refraction object output component
  20913. */
  20914. get refraction(): NodeMaterialConnectionPoint;
  20915. /**
  20916. * Returns true if the block has a texture
  20917. */
  20918. get hasTexture(): boolean;
  20919. protected _getTexture(): Nullable<BaseTexture>;
  20920. autoConfigure(material: NodeMaterial): void;
  20921. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20922. isReady(): boolean;
  20923. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  20924. /**
  20925. * Gets the main code of the block (fragment side)
  20926. * @param state current state of the node material building
  20927. * @returns the shader code
  20928. */
  20929. getCode(state: NodeMaterialBuildState): string;
  20930. protected _buildBlock(state: NodeMaterialBuildState): this;
  20931. protected _dumpPropertiesCode(): string;
  20932. serialize(): any;
  20933. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20934. }
  20935. }
  20936. declare module BABYLON {
  20937. /**
  20938. * Base block used as input for post process
  20939. */
  20940. export class CurrentScreenBlock extends NodeMaterialBlock {
  20941. private _samplerName;
  20942. private _linearDefineName;
  20943. private _gammaDefineName;
  20944. private _mainUVName;
  20945. private _tempTextureRead;
  20946. /**
  20947. * Gets or sets the texture associated with the node
  20948. */
  20949. texture: Nullable<BaseTexture>;
  20950. /**
  20951. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20952. */
  20953. convertToGammaSpace: boolean;
  20954. /**
  20955. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20956. */
  20957. convertToLinearSpace: boolean;
  20958. /**
  20959. * Create a new CurrentScreenBlock
  20960. * @param name defines the block name
  20961. */
  20962. constructor(name: string);
  20963. /**
  20964. * Gets the current class name
  20965. * @returns the class name
  20966. */
  20967. getClassName(): string;
  20968. /**
  20969. * Gets the uv input component
  20970. */
  20971. get uv(): NodeMaterialConnectionPoint;
  20972. /**
  20973. * Gets the rgba output component
  20974. */
  20975. get rgba(): NodeMaterialConnectionPoint;
  20976. /**
  20977. * Gets the rgb output component
  20978. */
  20979. get rgb(): NodeMaterialConnectionPoint;
  20980. /**
  20981. * Gets the r output component
  20982. */
  20983. get r(): NodeMaterialConnectionPoint;
  20984. /**
  20985. * Gets the g output component
  20986. */
  20987. get g(): NodeMaterialConnectionPoint;
  20988. /**
  20989. * Gets the b output component
  20990. */
  20991. get b(): NodeMaterialConnectionPoint;
  20992. /**
  20993. * Gets the a output component
  20994. */
  20995. get a(): NodeMaterialConnectionPoint;
  20996. /**
  20997. * Initialize the block and prepare the context for build
  20998. * @param state defines the state that will be used for the build
  20999. */
  21000. initialize(state: NodeMaterialBuildState): void;
  21001. get target(): NodeMaterialBlockTargets;
  21002. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21003. isReady(): boolean;
  21004. private _injectVertexCode;
  21005. private _writeTextureRead;
  21006. private _writeOutput;
  21007. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21008. serialize(): any;
  21009. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21010. }
  21011. }
  21012. declare module BABYLON {
  21013. /**
  21014. * Base block used for the particle texture
  21015. */
  21016. export class ParticleTextureBlock extends NodeMaterialBlock {
  21017. private _samplerName;
  21018. private _linearDefineName;
  21019. private _gammaDefineName;
  21020. private _tempTextureRead;
  21021. /**
  21022. * Gets or sets the texture associated with the node
  21023. */
  21024. texture: Nullable<BaseTexture>;
  21025. /**
  21026. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21027. */
  21028. convertToGammaSpace: boolean;
  21029. /**
  21030. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21031. */
  21032. convertToLinearSpace: boolean;
  21033. /**
  21034. * Create a new ParticleTextureBlock
  21035. * @param name defines the block name
  21036. */
  21037. constructor(name: string);
  21038. /**
  21039. * Gets the current class name
  21040. * @returns the class name
  21041. */
  21042. getClassName(): string;
  21043. /**
  21044. * Gets the uv input component
  21045. */
  21046. get uv(): NodeMaterialConnectionPoint;
  21047. /**
  21048. * Gets the rgba output component
  21049. */
  21050. get rgba(): NodeMaterialConnectionPoint;
  21051. /**
  21052. * Gets the rgb output component
  21053. */
  21054. get rgb(): NodeMaterialConnectionPoint;
  21055. /**
  21056. * Gets the r output component
  21057. */
  21058. get r(): NodeMaterialConnectionPoint;
  21059. /**
  21060. * Gets the g output component
  21061. */
  21062. get g(): NodeMaterialConnectionPoint;
  21063. /**
  21064. * Gets the b output component
  21065. */
  21066. get b(): NodeMaterialConnectionPoint;
  21067. /**
  21068. * Gets the a output component
  21069. */
  21070. get a(): NodeMaterialConnectionPoint;
  21071. /**
  21072. * Initialize the block and prepare the context for build
  21073. * @param state defines the state that will be used for the build
  21074. */
  21075. initialize(state: NodeMaterialBuildState): void;
  21076. autoConfigure(material: NodeMaterial): void;
  21077. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21078. isReady(): boolean;
  21079. private _writeOutput;
  21080. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21081. serialize(): any;
  21082. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21083. }
  21084. }
  21085. declare module BABYLON {
  21086. /**
  21087. * Class used to store shared data between 2 NodeMaterialBuildState
  21088. */
  21089. export class NodeMaterialBuildStateSharedData {
  21090. /**
  21091. * Gets the list of emitted varyings
  21092. */
  21093. temps: string[];
  21094. /**
  21095. * Gets the list of emitted varyings
  21096. */
  21097. varyings: string[];
  21098. /**
  21099. * Gets the varying declaration string
  21100. */
  21101. varyingDeclaration: string;
  21102. /**
  21103. * Input blocks
  21104. */
  21105. inputBlocks: InputBlock[];
  21106. /**
  21107. * Input blocks
  21108. */
  21109. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21110. /**
  21111. * Bindable blocks (Blocks that need to set data to the effect)
  21112. */
  21113. bindableBlocks: NodeMaterialBlock[];
  21114. /**
  21115. * List of blocks that can provide a compilation fallback
  21116. */
  21117. blocksWithFallbacks: NodeMaterialBlock[];
  21118. /**
  21119. * List of blocks that can provide a define update
  21120. */
  21121. blocksWithDefines: NodeMaterialBlock[];
  21122. /**
  21123. * List of blocks that can provide a repeatable content
  21124. */
  21125. repeatableContentBlocks: NodeMaterialBlock[];
  21126. /**
  21127. * List of blocks that can provide a dynamic list of uniforms
  21128. */
  21129. dynamicUniformBlocks: NodeMaterialBlock[];
  21130. /**
  21131. * List of blocks that can block the isReady function for the material
  21132. */
  21133. blockingBlocks: NodeMaterialBlock[];
  21134. /**
  21135. * Gets the list of animated inputs
  21136. */
  21137. animatedInputs: InputBlock[];
  21138. /**
  21139. * Build Id used to avoid multiple recompilations
  21140. */
  21141. buildId: number;
  21142. /** List of emitted variables */
  21143. variableNames: {
  21144. [key: string]: number;
  21145. };
  21146. /** List of emitted defines */
  21147. defineNames: {
  21148. [key: string]: number;
  21149. };
  21150. /** Should emit comments? */
  21151. emitComments: boolean;
  21152. /** Emit build activity */
  21153. verbose: boolean;
  21154. /** Gets or sets the hosting scene */
  21155. scene: Scene;
  21156. /**
  21157. * Gets the compilation hints emitted at compilation time
  21158. */
  21159. hints: {
  21160. needWorldViewMatrix: boolean;
  21161. needWorldViewProjectionMatrix: boolean;
  21162. needAlphaBlending: boolean;
  21163. needAlphaTesting: boolean;
  21164. };
  21165. /**
  21166. * List of compilation checks
  21167. */
  21168. checks: {
  21169. emitVertex: boolean;
  21170. emitFragment: boolean;
  21171. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21172. };
  21173. /**
  21174. * Is vertex program allowed to be empty?
  21175. */
  21176. allowEmptyVertexProgram: boolean;
  21177. /** Creates a new shared data */
  21178. constructor();
  21179. /**
  21180. * Emits console errors and exceptions if there is a failing check
  21181. */
  21182. emitErrors(): void;
  21183. }
  21184. }
  21185. declare module BABYLON {
  21186. /**
  21187. * Class used to store node based material build state
  21188. */
  21189. export class NodeMaterialBuildState {
  21190. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21191. supportUniformBuffers: boolean;
  21192. /**
  21193. * Gets the list of emitted attributes
  21194. */
  21195. attributes: string[];
  21196. /**
  21197. * Gets the list of emitted uniforms
  21198. */
  21199. uniforms: string[];
  21200. /**
  21201. * Gets the list of emitted constants
  21202. */
  21203. constants: string[];
  21204. /**
  21205. * Gets the list of emitted samplers
  21206. */
  21207. samplers: string[];
  21208. /**
  21209. * Gets the list of emitted functions
  21210. */
  21211. functions: {
  21212. [key: string]: string;
  21213. };
  21214. /**
  21215. * Gets the list of emitted extensions
  21216. */
  21217. extensions: {
  21218. [key: string]: string;
  21219. };
  21220. /**
  21221. * Gets the target of the compilation state
  21222. */
  21223. target: NodeMaterialBlockTargets;
  21224. /**
  21225. * Gets the list of emitted counters
  21226. */
  21227. counters: {
  21228. [key: string]: number;
  21229. };
  21230. /**
  21231. * Shared data between multiple NodeMaterialBuildState instances
  21232. */
  21233. sharedData: NodeMaterialBuildStateSharedData;
  21234. /** @hidden */
  21235. _vertexState: NodeMaterialBuildState;
  21236. /** @hidden */
  21237. _attributeDeclaration: string;
  21238. /** @hidden */
  21239. _uniformDeclaration: string;
  21240. /** @hidden */
  21241. _constantDeclaration: string;
  21242. /** @hidden */
  21243. _samplerDeclaration: string;
  21244. /** @hidden */
  21245. _varyingTransfer: string;
  21246. /** @hidden */
  21247. _injectAtEnd: string;
  21248. private _repeatableContentAnchorIndex;
  21249. /** @hidden */
  21250. _builtCompilationString: string;
  21251. /**
  21252. * Gets the emitted compilation strings
  21253. */
  21254. compilationString: string;
  21255. /**
  21256. * Finalize the compilation strings
  21257. * @param state defines the current compilation state
  21258. */
  21259. finalize(state: NodeMaterialBuildState): void;
  21260. /** @hidden */
  21261. get _repeatableContentAnchor(): string;
  21262. /** @hidden */
  21263. _getFreeVariableName(prefix: string): string;
  21264. /** @hidden */
  21265. _getFreeDefineName(prefix: string): string;
  21266. /** @hidden */
  21267. _excludeVariableName(name: string): void;
  21268. /** @hidden */
  21269. _emit2DSampler(name: string): void;
  21270. /** @hidden */
  21271. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21272. /** @hidden */
  21273. _emitExtension(name: string, extension: string, define?: string): void;
  21274. /** @hidden */
  21275. _emitFunction(name: string, code: string, comments: string): void;
  21276. /** @hidden */
  21277. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21278. replaceStrings?: {
  21279. search: RegExp;
  21280. replace: string;
  21281. }[];
  21282. repeatKey?: string;
  21283. }): string;
  21284. /** @hidden */
  21285. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21286. repeatKey?: string;
  21287. removeAttributes?: boolean;
  21288. removeUniforms?: boolean;
  21289. removeVaryings?: boolean;
  21290. removeIfDef?: boolean;
  21291. replaceStrings?: {
  21292. search: RegExp;
  21293. replace: string;
  21294. }[];
  21295. }, storeKey?: string): void;
  21296. /** @hidden */
  21297. _registerTempVariable(name: string): boolean;
  21298. /** @hidden */
  21299. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21300. /** @hidden */
  21301. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21302. /** @hidden */
  21303. _emitFloat(value: number): string;
  21304. }
  21305. }
  21306. declare module BABYLON {
  21307. /**
  21308. * Helper class used to generate session unique ID
  21309. */
  21310. export class UniqueIdGenerator {
  21311. private static _UniqueIdCounter;
  21312. /**
  21313. * Gets an unique (relatively to the current scene) Id
  21314. */
  21315. static get UniqueId(): number;
  21316. }
  21317. }
  21318. declare module BABYLON {
  21319. /**
  21320. * Defines a block that can be used inside a node based material
  21321. */
  21322. export class NodeMaterialBlock {
  21323. private _buildId;
  21324. private _buildTarget;
  21325. private _target;
  21326. private _isFinalMerger;
  21327. private _isInput;
  21328. private _name;
  21329. protected _isUnique: boolean;
  21330. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21331. inputsAreExclusive: boolean;
  21332. /** @hidden */
  21333. _codeVariableName: string;
  21334. /** @hidden */
  21335. _inputs: NodeMaterialConnectionPoint[];
  21336. /** @hidden */
  21337. _outputs: NodeMaterialConnectionPoint[];
  21338. /** @hidden */
  21339. _preparationId: number;
  21340. /**
  21341. * Gets the name of the block
  21342. */
  21343. get name(): string;
  21344. /**
  21345. * Sets the name of the block. Will check if the name is valid.
  21346. */
  21347. set name(newName: string);
  21348. /**
  21349. * Gets or sets the unique id of the node
  21350. */
  21351. uniqueId: number;
  21352. /**
  21353. * Gets or sets the comments associated with this block
  21354. */
  21355. comments: string;
  21356. /**
  21357. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21358. */
  21359. get isUnique(): boolean;
  21360. /**
  21361. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21362. */
  21363. get isFinalMerger(): boolean;
  21364. /**
  21365. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21366. */
  21367. get isInput(): boolean;
  21368. /**
  21369. * Gets or sets the build Id
  21370. */
  21371. get buildId(): number;
  21372. set buildId(value: number);
  21373. /**
  21374. * Gets or sets the target of the block
  21375. */
  21376. get target(): NodeMaterialBlockTargets;
  21377. set target(value: NodeMaterialBlockTargets);
  21378. /**
  21379. * Gets the list of input points
  21380. */
  21381. get inputs(): NodeMaterialConnectionPoint[];
  21382. /** Gets the list of output points */
  21383. get outputs(): NodeMaterialConnectionPoint[];
  21384. /**
  21385. * Find an input by its name
  21386. * @param name defines the name of the input to look for
  21387. * @returns the input or null if not found
  21388. */
  21389. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21390. /**
  21391. * Find an output by its name
  21392. * @param name defines the name of the outputto look for
  21393. * @returns the output or null if not found
  21394. */
  21395. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21396. /**
  21397. * Creates a new NodeMaterialBlock
  21398. * @param name defines the block name
  21399. * @param target defines the target of that block (Vertex by default)
  21400. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21401. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21402. */
  21403. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21404. /**
  21405. * Initialize the block and prepare the context for build
  21406. * @param state defines the state that will be used for the build
  21407. */
  21408. initialize(state: NodeMaterialBuildState): void;
  21409. /**
  21410. * Bind data to effect. Will only be called for blocks with isBindable === true
  21411. * @param effect defines the effect to bind data to
  21412. * @param nodeMaterial defines the hosting NodeMaterial
  21413. * @param mesh defines the mesh that will be rendered
  21414. * @param subMesh defines the submesh that will be rendered
  21415. */
  21416. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21417. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21418. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21419. protected _writeFloat(value: number): string;
  21420. /**
  21421. * Gets the current class name e.g. "NodeMaterialBlock"
  21422. * @returns the class name
  21423. */
  21424. getClassName(): string;
  21425. /**
  21426. * Register a new input. Must be called inside a block constructor
  21427. * @param name defines the connection point name
  21428. * @param type defines the connection point type
  21429. * @param isOptional defines a boolean indicating that this input can be omitted
  21430. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21431. * @param point an already created connection point. If not provided, create a new one
  21432. * @returns the current block
  21433. */
  21434. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21435. /**
  21436. * Register a new output. Must be called inside a block constructor
  21437. * @param name defines the connection point name
  21438. * @param type defines the connection point type
  21439. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21440. * @param point an already created connection point. If not provided, create a new one
  21441. * @returns the current block
  21442. */
  21443. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21444. /**
  21445. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21446. * @param forOutput defines an optional connection point to check compatibility with
  21447. * @returns the first available input or null
  21448. */
  21449. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21450. /**
  21451. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21452. * @param forBlock defines an optional block to check compatibility with
  21453. * @returns the first available input or null
  21454. */
  21455. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21456. /**
  21457. * Gets the sibling of the given output
  21458. * @param current defines the current output
  21459. * @returns the next output in the list or null
  21460. */
  21461. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21462. /**
  21463. * Connect current block with another block
  21464. * @param other defines the block to connect with
  21465. * @param options define the various options to help pick the right connections
  21466. * @returns the current block
  21467. */
  21468. connectTo(other: NodeMaterialBlock, options?: {
  21469. input?: string;
  21470. output?: string;
  21471. outputSwizzle?: string;
  21472. }): this | undefined;
  21473. protected _buildBlock(state: NodeMaterialBuildState): void;
  21474. /**
  21475. * Add uniforms, samplers and uniform buffers at compilation time
  21476. * @param state defines the state to update
  21477. * @param nodeMaterial defines the node material requesting the update
  21478. * @param defines defines the material defines to update
  21479. * @param uniformBuffers defines the list of uniform buffer names
  21480. */
  21481. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21482. /**
  21483. * Add potential fallbacks if shader compilation fails
  21484. * @param mesh defines the mesh to be rendered
  21485. * @param fallbacks defines the current prioritized list of fallbacks
  21486. */
  21487. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21488. /**
  21489. * Initialize defines for shader compilation
  21490. * @param mesh defines the mesh to be rendered
  21491. * @param nodeMaterial defines the node material requesting the update
  21492. * @param defines defines the material defines to update
  21493. * @param useInstances specifies that instances should be used
  21494. */
  21495. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21496. /**
  21497. * Update defines for shader compilation
  21498. * @param mesh defines the mesh to be rendered
  21499. * @param nodeMaterial defines the node material requesting the update
  21500. * @param defines defines the material defines to update
  21501. * @param useInstances specifies that instances should be used
  21502. * @param subMesh defines which submesh to render
  21503. */
  21504. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21505. /**
  21506. * Lets the block try to connect some inputs automatically
  21507. * @param material defines the hosting NodeMaterial
  21508. */
  21509. autoConfigure(material: NodeMaterial): void;
  21510. /**
  21511. * Function called when a block is declared as repeatable content generator
  21512. * @param vertexShaderState defines the current compilation state for the vertex shader
  21513. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21514. * @param mesh defines the mesh to be rendered
  21515. * @param defines defines the material defines to update
  21516. */
  21517. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21518. /**
  21519. * Checks if the block is ready
  21520. * @param mesh defines the mesh to be rendered
  21521. * @param nodeMaterial defines the node material requesting the update
  21522. * @param defines defines the material defines to update
  21523. * @param useInstances specifies that instances should be used
  21524. * @returns true if the block is ready
  21525. */
  21526. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21527. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21528. private _processBuild;
  21529. /**
  21530. * Validates the new name for the block node.
  21531. * @param newName the new name to be given to the node.
  21532. * @returns false if the name is a reserve word, else true.
  21533. */
  21534. validateBlockName(newName: string): boolean;
  21535. /**
  21536. * Compile the current node and generate the shader code
  21537. * @param state defines the current compilation state (uniforms, samplers, current string)
  21538. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21539. * @returns true if already built
  21540. */
  21541. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21542. protected _inputRename(name: string): string;
  21543. protected _outputRename(name: string): string;
  21544. protected _dumpPropertiesCode(): string;
  21545. /** @hidden */
  21546. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21547. /** @hidden */
  21548. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21549. /**
  21550. * Clone the current block to a new identical block
  21551. * @param scene defines the hosting scene
  21552. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21553. * @returns a copy of the current block
  21554. */
  21555. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21556. /**
  21557. * Serializes this block in a JSON representation
  21558. * @returns the serialized block object
  21559. */
  21560. serialize(): any;
  21561. /** @hidden */
  21562. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21563. private _deserializePortDisplayNamesAndExposedOnFrame;
  21564. /**
  21565. * Release resources
  21566. */
  21567. dispose(): void;
  21568. }
  21569. }
  21570. declare module BABYLON {
  21571. /**
  21572. * Base class of materials working in push mode in babylon JS
  21573. * @hidden
  21574. */
  21575. export class PushMaterial extends Material {
  21576. protected _activeEffect: Effect;
  21577. protected _normalMatrix: Matrix;
  21578. constructor(name: string, scene: Scene);
  21579. getEffect(): Effect;
  21580. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21581. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21582. /**
  21583. * Binds the given world matrix to the active effect
  21584. *
  21585. * @param world the matrix to bind
  21586. */
  21587. bindOnlyWorldMatrix(world: Matrix): void;
  21588. /**
  21589. * Binds the given normal matrix to the active effect
  21590. *
  21591. * @param normalMatrix the matrix to bind
  21592. */
  21593. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21594. bind(world: Matrix, mesh?: Mesh): void;
  21595. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21596. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21597. }
  21598. }
  21599. declare module BABYLON {
  21600. /**
  21601. * Root class for all node material optimizers
  21602. */
  21603. export class NodeMaterialOptimizer {
  21604. /**
  21605. * Function used to optimize a NodeMaterial graph
  21606. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21607. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21608. */
  21609. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21610. }
  21611. }
  21612. declare module BABYLON {
  21613. /**
  21614. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21615. */
  21616. export class TransformBlock extends NodeMaterialBlock {
  21617. /**
  21618. * Defines the value to use to complement W value to transform it to a Vector4
  21619. */
  21620. complementW: number;
  21621. /**
  21622. * Defines the value to use to complement z value to transform it to a Vector4
  21623. */
  21624. complementZ: number;
  21625. /**
  21626. * Creates a new TransformBlock
  21627. * @param name defines the block name
  21628. */
  21629. constructor(name: string);
  21630. /**
  21631. * Gets the current class name
  21632. * @returns the class name
  21633. */
  21634. getClassName(): string;
  21635. /**
  21636. * Gets the vector input
  21637. */
  21638. get vector(): NodeMaterialConnectionPoint;
  21639. /**
  21640. * Gets the output component
  21641. */
  21642. get output(): NodeMaterialConnectionPoint;
  21643. /**
  21644. * Gets the xyz output component
  21645. */
  21646. get xyz(): NodeMaterialConnectionPoint;
  21647. /**
  21648. * Gets the matrix transform input
  21649. */
  21650. get transform(): NodeMaterialConnectionPoint;
  21651. protected _buildBlock(state: NodeMaterialBuildState): this;
  21652. /**
  21653. * Update defines for shader compilation
  21654. * @param mesh defines the mesh to be rendered
  21655. * @param nodeMaterial defines the node material requesting the update
  21656. * @param defines defines the material defines to update
  21657. * @param useInstances specifies that instances should be used
  21658. * @param subMesh defines which submesh to render
  21659. */
  21660. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21661. serialize(): any;
  21662. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21663. protected _dumpPropertiesCode(): string;
  21664. }
  21665. }
  21666. declare module BABYLON {
  21667. /**
  21668. * Block used to output the vertex position
  21669. */
  21670. export class VertexOutputBlock extends NodeMaterialBlock {
  21671. /**
  21672. * Creates a new VertexOutputBlock
  21673. * @param name defines the block name
  21674. */
  21675. constructor(name: string);
  21676. /**
  21677. * Gets the current class name
  21678. * @returns the class name
  21679. */
  21680. getClassName(): string;
  21681. /**
  21682. * Gets the vector input component
  21683. */
  21684. get vector(): NodeMaterialConnectionPoint;
  21685. protected _buildBlock(state: NodeMaterialBuildState): this;
  21686. }
  21687. }
  21688. declare module BABYLON {
  21689. /**
  21690. * Block used to output the final color
  21691. */
  21692. export class FragmentOutputBlock extends NodeMaterialBlock {
  21693. /**
  21694. * Create a new FragmentOutputBlock
  21695. * @param name defines the block name
  21696. */
  21697. constructor(name: string);
  21698. /**
  21699. * Gets the current class name
  21700. * @returns the class name
  21701. */
  21702. getClassName(): string;
  21703. /**
  21704. * Gets the rgba input component
  21705. */
  21706. get rgba(): NodeMaterialConnectionPoint;
  21707. /**
  21708. * Gets the rgb input component
  21709. */
  21710. get rgb(): NodeMaterialConnectionPoint;
  21711. /**
  21712. * Gets the a input component
  21713. */
  21714. get a(): NodeMaterialConnectionPoint;
  21715. protected _buildBlock(state: NodeMaterialBuildState): this;
  21716. }
  21717. }
  21718. declare module BABYLON {
  21719. /**
  21720. * Block used for the particle ramp gradient section
  21721. */
  21722. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  21723. /**
  21724. * Create a new ParticleRampGradientBlock
  21725. * @param name defines the block name
  21726. */
  21727. constructor(name: string);
  21728. /**
  21729. * Gets the current class name
  21730. * @returns the class name
  21731. */
  21732. getClassName(): string;
  21733. /**
  21734. * Gets the color input component
  21735. */
  21736. get color(): NodeMaterialConnectionPoint;
  21737. /**
  21738. * Gets the rampColor output component
  21739. */
  21740. get rampColor(): NodeMaterialConnectionPoint;
  21741. /**
  21742. * Initialize the block and prepare the context for build
  21743. * @param state defines the state that will be used for the build
  21744. */
  21745. initialize(state: NodeMaterialBuildState): void;
  21746. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21747. }
  21748. }
  21749. declare module BABYLON {
  21750. /**
  21751. * Block used for the particle blend multiply section
  21752. */
  21753. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  21754. /**
  21755. * Create a new ParticleBlendMultiplyBlock
  21756. * @param name defines the block name
  21757. */
  21758. constructor(name: string);
  21759. /**
  21760. * Gets the current class name
  21761. * @returns the class name
  21762. */
  21763. getClassName(): string;
  21764. /**
  21765. * Gets the color input component
  21766. */
  21767. get color(): NodeMaterialConnectionPoint;
  21768. /**
  21769. * Gets the alphaTexture input component
  21770. */
  21771. get alphaTexture(): NodeMaterialConnectionPoint;
  21772. /**
  21773. * Gets the alphaColor input component
  21774. */
  21775. get alphaColor(): NodeMaterialConnectionPoint;
  21776. /**
  21777. * Gets the blendColor output component
  21778. */
  21779. get blendColor(): NodeMaterialConnectionPoint;
  21780. /**
  21781. * Initialize the block and prepare the context for build
  21782. * @param state defines the state that will be used for the build
  21783. */
  21784. initialize(state: NodeMaterialBuildState): void;
  21785. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21786. }
  21787. }
  21788. declare module BABYLON {
  21789. /**
  21790. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  21791. */
  21792. export class VectorMergerBlock extends NodeMaterialBlock {
  21793. /**
  21794. * Create a new VectorMergerBlock
  21795. * @param name defines the block name
  21796. */
  21797. constructor(name: string);
  21798. /**
  21799. * Gets the current class name
  21800. * @returns the class name
  21801. */
  21802. getClassName(): string;
  21803. /**
  21804. * Gets the xyz component (input)
  21805. */
  21806. get xyzIn(): NodeMaterialConnectionPoint;
  21807. /**
  21808. * Gets the xy component (input)
  21809. */
  21810. get xyIn(): NodeMaterialConnectionPoint;
  21811. /**
  21812. * Gets the x component (input)
  21813. */
  21814. get x(): NodeMaterialConnectionPoint;
  21815. /**
  21816. * Gets the y component (input)
  21817. */
  21818. get y(): NodeMaterialConnectionPoint;
  21819. /**
  21820. * Gets the z component (input)
  21821. */
  21822. get z(): NodeMaterialConnectionPoint;
  21823. /**
  21824. * Gets the w component (input)
  21825. */
  21826. get w(): NodeMaterialConnectionPoint;
  21827. /**
  21828. * Gets the xyzw component (output)
  21829. */
  21830. get xyzw(): NodeMaterialConnectionPoint;
  21831. /**
  21832. * Gets the xyz component (output)
  21833. */
  21834. get xyzOut(): NodeMaterialConnectionPoint;
  21835. /**
  21836. * Gets the xy component (output)
  21837. */
  21838. get xyOut(): NodeMaterialConnectionPoint;
  21839. /**
  21840. * Gets the xy component (output)
  21841. * @deprecated Please use xyOut instead.
  21842. */
  21843. get xy(): NodeMaterialConnectionPoint;
  21844. /**
  21845. * Gets the xyz component (output)
  21846. * @deprecated Please use xyzOut instead.
  21847. */
  21848. get xyz(): NodeMaterialConnectionPoint;
  21849. protected _buildBlock(state: NodeMaterialBuildState): this;
  21850. }
  21851. }
  21852. declare module BABYLON {
  21853. /**
  21854. * Block used to remap a float from a range to a new one
  21855. */
  21856. export class RemapBlock extends NodeMaterialBlock {
  21857. /**
  21858. * Gets or sets the source range
  21859. */
  21860. sourceRange: Vector2;
  21861. /**
  21862. * Gets or sets the target range
  21863. */
  21864. targetRange: Vector2;
  21865. /**
  21866. * Creates a new RemapBlock
  21867. * @param name defines the block name
  21868. */
  21869. constructor(name: string);
  21870. /**
  21871. * Gets the current class name
  21872. * @returns the class name
  21873. */
  21874. getClassName(): string;
  21875. /**
  21876. * Gets the input component
  21877. */
  21878. get input(): NodeMaterialConnectionPoint;
  21879. /**
  21880. * Gets the source min input component
  21881. */
  21882. get sourceMin(): NodeMaterialConnectionPoint;
  21883. /**
  21884. * Gets the source max input component
  21885. */
  21886. get sourceMax(): NodeMaterialConnectionPoint;
  21887. /**
  21888. * Gets the target min input component
  21889. */
  21890. get targetMin(): NodeMaterialConnectionPoint;
  21891. /**
  21892. * Gets the target max input component
  21893. */
  21894. get targetMax(): NodeMaterialConnectionPoint;
  21895. /**
  21896. * Gets the output component
  21897. */
  21898. get output(): NodeMaterialConnectionPoint;
  21899. protected _buildBlock(state: NodeMaterialBuildState): this;
  21900. protected _dumpPropertiesCode(): string;
  21901. serialize(): any;
  21902. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21903. }
  21904. }
  21905. declare module BABYLON {
  21906. /**
  21907. * Block used to multiply 2 values
  21908. */
  21909. export class MultiplyBlock extends NodeMaterialBlock {
  21910. /**
  21911. * Creates a new MultiplyBlock
  21912. * @param name defines the block name
  21913. */
  21914. constructor(name: string);
  21915. /**
  21916. * Gets the current class name
  21917. * @returns the class name
  21918. */
  21919. getClassName(): string;
  21920. /**
  21921. * Gets the left operand input component
  21922. */
  21923. get left(): NodeMaterialConnectionPoint;
  21924. /**
  21925. * Gets the right operand input component
  21926. */
  21927. get right(): NodeMaterialConnectionPoint;
  21928. /**
  21929. * Gets the output component
  21930. */
  21931. get output(): NodeMaterialConnectionPoint;
  21932. protected _buildBlock(state: NodeMaterialBuildState): this;
  21933. }
  21934. }
  21935. declare module BABYLON {
  21936. /**
  21937. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  21938. */
  21939. export class ColorSplitterBlock extends NodeMaterialBlock {
  21940. /**
  21941. * Create a new ColorSplitterBlock
  21942. * @param name defines the block name
  21943. */
  21944. constructor(name: string);
  21945. /**
  21946. * Gets the current class name
  21947. * @returns the class name
  21948. */
  21949. getClassName(): string;
  21950. /**
  21951. * Gets the rgba component (input)
  21952. */
  21953. get rgba(): NodeMaterialConnectionPoint;
  21954. /**
  21955. * Gets the rgb component (input)
  21956. */
  21957. get rgbIn(): NodeMaterialConnectionPoint;
  21958. /**
  21959. * Gets the rgb component (output)
  21960. */
  21961. get rgbOut(): NodeMaterialConnectionPoint;
  21962. /**
  21963. * Gets the r component (output)
  21964. */
  21965. get r(): NodeMaterialConnectionPoint;
  21966. /**
  21967. * Gets the g component (output)
  21968. */
  21969. get g(): NodeMaterialConnectionPoint;
  21970. /**
  21971. * Gets the b component (output)
  21972. */
  21973. get b(): NodeMaterialConnectionPoint;
  21974. /**
  21975. * Gets the a component (output)
  21976. */
  21977. get a(): NodeMaterialConnectionPoint;
  21978. protected _inputRename(name: string): string;
  21979. protected _outputRename(name: string): string;
  21980. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21981. }
  21982. }
  21983. declare module BABYLON {
  21984. /**
  21985. * Interface used to configure the node material editor
  21986. */
  21987. export interface INodeMaterialEditorOptions {
  21988. /** Define the URl to load node editor script */
  21989. editorURL?: string;
  21990. }
  21991. /** @hidden */
  21992. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  21993. NORMAL: boolean;
  21994. TANGENT: boolean;
  21995. UV1: boolean;
  21996. /** BONES */
  21997. NUM_BONE_INFLUENCERS: number;
  21998. BonesPerMesh: number;
  21999. BONETEXTURE: boolean;
  22000. /** MORPH TARGETS */
  22001. MORPHTARGETS: boolean;
  22002. MORPHTARGETS_NORMAL: boolean;
  22003. MORPHTARGETS_TANGENT: boolean;
  22004. MORPHTARGETS_UV: boolean;
  22005. NUM_MORPH_INFLUENCERS: number;
  22006. /** IMAGE PROCESSING */
  22007. IMAGEPROCESSING: boolean;
  22008. VIGNETTE: boolean;
  22009. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22010. VIGNETTEBLENDMODEOPAQUE: boolean;
  22011. TONEMAPPING: boolean;
  22012. TONEMAPPING_ACES: boolean;
  22013. CONTRAST: boolean;
  22014. EXPOSURE: boolean;
  22015. COLORCURVES: boolean;
  22016. COLORGRADING: boolean;
  22017. COLORGRADING3D: boolean;
  22018. SAMPLER3DGREENDEPTH: boolean;
  22019. SAMPLER3DBGRMAP: boolean;
  22020. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22021. /** MISC. */
  22022. BUMPDIRECTUV: number;
  22023. constructor();
  22024. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22025. }
  22026. /**
  22027. * Class used to configure NodeMaterial
  22028. */
  22029. export interface INodeMaterialOptions {
  22030. /**
  22031. * Defines if blocks should emit comments
  22032. */
  22033. emitComments: boolean;
  22034. }
  22035. /**
  22036. * Class used to create a node based material built by assembling shader blocks
  22037. */
  22038. export class NodeMaterial extends PushMaterial {
  22039. private static _BuildIdGenerator;
  22040. private _options;
  22041. private _vertexCompilationState;
  22042. private _fragmentCompilationState;
  22043. private _sharedData;
  22044. private _buildId;
  22045. private _buildWasSuccessful;
  22046. private _cachedWorldViewMatrix;
  22047. private _cachedWorldViewProjectionMatrix;
  22048. private _optimizers;
  22049. private _animationFrame;
  22050. /** Define the Url to load node editor script */
  22051. static EditorURL: string;
  22052. /** Define the Url to load snippets */
  22053. static SnippetUrl: string;
  22054. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22055. static IgnoreTexturesAtLoadTime: boolean;
  22056. private BJSNODEMATERIALEDITOR;
  22057. /** Get the inspector from bundle or global */
  22058. private _getGlobalNodeMaterialEditor;
  22059. /**
  22060. * Snippet ID if the material was created from the snippet server
  22061. */
  22062. snippetId: string;
  22063. /**
  22064. * Gets or sets data used by visual editor
  22065. * @see https://nme.babylonjs.com
  22066. */
  22067. editorData: any;
  22068. /**
  22069. * 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)
  22070. */
  22071. ignoreAlpha: boolean;
  22072. /**
  22073. * Defines the maximum number of lights that can be used in the material
  22074. */
  22075. maxSimultaneousLights: number;
  22076. /**
  22077. * Observable raised when the material is built
  22078. */
  22079. onBuildObservable: Observable<NodeMaterial>;
  22080. /**
  22081. * Gets or sets the root nodes of the material vertex shader
  22082. */
  22083. _vertexOutputNodes: NodeMaterialBlock[];
  22084. /**
  22085. * Gets or sets the root nodes of the material fragment (pixel) shader
  22086. */
  22087. _fragmentOutputNodes: NodeMaterialBlock[];
  22088. /** Gets or sets options to control the node material overall behavior */
  22089. get options(): INodeMaterialOptions;
  22090. set options(options: INodeMaterialOptions);
  22091. /**
  22092. * Default configuration related to image processing available in the standard Material.
  22093. */
  22094. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22095. /**
  22096. * Gets the image processing configuration used either in this material.
  22097. */
  22098. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22099. /**
  22100. * Sets the Default image processing configuration used either in the this material.
  22101. *
  22102. * If sets to null, the scene one is in use.
  22103. */
  22104. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22105. /**
  22106. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22107. */
  22108. attachedBlocks: NodeMaterialBlock[];
  22109. /**
  22110. * Specifies the mode of the node material
  22111. * @hidden
  22112. */
  22113. _mode: NodeMaterialModes;
  22114. /**
  22115. * Gets the mode property
  22116. */
  22117. get mode(): NodeMaterialModes;
  22118. /**
  22119. * Create a new node based material
  22120. * @param name defines the material name
  22121. * @param scene defines the hosting scene
  22122. * @param options defines creation option
  22123. */
  22124. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22125. /**
  22126. * Gets the current class name of the material e.g. "NodeMaterial"
  22127. * @returns the class name
  22128. */
  22129. getClassName(): string;
  22130. /**
  22131. * Keep track of the image processing observer to allow dispose and replace.
  22132. */
  22133. private _imageProcessingObserver;
  22134. /**
  22135. * Attaches a new image processing configuration to the Standard Material.
  22136. * @param configuration
  22137. */
  22138. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22139. /**
  22140. * Get a block by its name
  22141. * @param name defines the name of the block to retrieve
  22142. * @returns the required block or null if not found
  22143. */
  22144. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22145. /**
  22146. * Get a block by its name
  22147. * @param predicate defines the predicate used to find the good candidate
  22148. * @returns the required block or null if not found
  22149. */
  22150. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22151. /**
  22152. * Get an input block by its name
  22153. * @param predicate defines the predicate used to find the good candidate
  22154. * @returns the required input block or null if not found
  22155. */
  22156. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22157. /**
  22158. * Gets the list of input blocks attached to this material
  22159. * @returns an array of InputBlocks
  22160. */
  22161. getInputBlocks(): InputBlock[];
  22162. /**
  22163. * Adds a new optimizer to the list of optimizers
  22164. * @param optimizer defines the optimizers to add
  22165. * @returns the current material
  22166. */
  22167. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22168. /**
  22169. * Remove an optimizer from the list of optimizers
  22170. * @param optimizer defines the optimizers to remove
  22171. * @returns the current material
  22172. */
  22173. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22174. /**
  22175. * Add a new block to the list of output nodes
  22176. * @param node defines the node to add
  22177. * @returns the current material
  22178. */
  22179. addOutputNode(node: NodeMaterialBlock): this;
  22180. /**
  22181. * Remove a block from the list of root nodes
  22182. * @param node defines the node to remove
  22183. * @returns the current material
  22184. */
  22185. removeOutputNode(node: NodeMaterialBlock): this;
  22186. private _addVertexOutputNode;
  22187. private _removeVertexOutputNode;
  22188. private _addFragmentOutputNode;
  22189. private _removeFragmentOutputNode;
  22190. /**
  22191. * Specifies if the material will require alpha blending
  22192. * @returns a boolean specifying if alpha blending is needed
  22193. */
  22194. needAlphaBlending(): boolean;
  22195. /**
  22196. * Specifies if this material should be rendered in alpha test mode
  22197. * @returns a boolean specifying if an alpha test is needed.
  22198. */
  22199. needAlphaTesting(): boolean;
  22200. private _initializeBlock;
  22201. private _resetDualBlocks;
  22202. /**
  22203. * Remove a block from the current node material
  22204. * @param block defines the block to remove
  22205. */
  22206. removeBlock(block: NodeMaterialBlock): void;
  22207. /**
  22208. * Build the material and generates the inner effect
  22209. * @param verbose defines if the build should log activity
  22210. */
  22211. build(verbose?: boolean): void;
  22212. /**
  22213. * Runs an otpimization phase to try to improve the shader code
  22214. */
  22215. optimize(): void;
  22216. private _prepareDefinesForAttributes;
  22217. /**
  22218. * Create a post process from the material
  22219. * @param camera The camera to apply the render pass to.
  22220. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22221. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22222. * @param engine The engine which the post process will be applied. (default: current engine)
  22223. * @param reusable If the post process can be reused on the same frame. (default: false)
  22224. * @param textureType Type of textures used when performing the post process. (default: 0)
  22225. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22226. * @returns the post process created
  22227. */
  22228. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22229. /**
  22230. * Create the post process effect from the material
  22231. * @param postProcess The post process to create the effect for
  22232. */
  22233. createEffectForPostProcess(postProcess: PostProcess): void;
  22234. private _createEffectOrPostProcess;
  22235. private _createEffectForParticles;
  22236. /**
  22237. * Create the effect to be used as the custom effect for a particle system
  22238. * @param particleSystem Particle system to create the effect for
  22239. * @param onCompiled defines a function to call when the effect creation is successful
  22240. * @param onError defines a function to call when the effect creation has failed
  22241. */
  22242. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22243. private _processDefines;
  22244. /**
  22245. * Get if the submesh is ready to be used and all its information available.
  22246. * Child classes can use it to update shaders
  22247. * @param mesh defines the mesh to check
  22248. * @param subMesh defines which submesh to check
  22249. * @param useInstances specifies that instances should be used
  22250. * @returns a boolean indicating that the submesh is ready or not
  22251. */
  22252. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22253. /**
  22254. * Get a string representing the shaders built by the current node graph
  22255. */
  22256. get compiledShaders(): string;
  22257. /**
  22258. * Binds the world matrix to the material
  22259. * @param world defines the world transformation matrix
  22260. */
  22261. bindOnlyWorldMatrix(world: Matrix): void;
  22262. /**
  22263. * Binds the submesh to this material by preparing the effect and shader to draw
  22264. * @param world defines the world transformation matrix
  22265. * @param mesh defines the mesh containing the submesh
  22266. * @param subMesh defines the submesh to bind the material to
  22267. */
  22268. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22269. /**
  22270. * Gets the active textures from the material
  22271. * @returns an array of textures
  22272. */
  22273. getActiveTextures(): BaseTexture[];
  22274. /**
  22275. * Gets the list of texture blocks
  22276. * @returns an array of texture blocks
  22277. */
  22278. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22279. /**
  22280. * Specifies if the material uses a texture
  22281. * @param texture defines the texture to check against the material
  22282. * @returns a boolean specifying if the material uses the texture
  22283. */
  22284. hasTexture(texture: BaseTexture): boolean;
  22285. /**
  22286. * Disposes the material
  22287. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22288. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22289. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22290. */
  22291. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22292. /** Creates the node editor window. */
  22293. private _createNodeEditor;
  22294. /**
  22295. * Launch the node material editor
  22296. * @param config Define the configuration of the editor
  22297. * @return a promise fulfilled when the node editor is visible
  22298. */
  22299. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22300. /**
  22301. * Clear the current material
  22302. */
  22303. clear(): void;
  22304. /**
  22305. * Clear the current material and set it to a default state
  22306. */
  22307. setToDefault(): void;
  22308. /**
  22309. * Clear the current material and set it to a default state for post process
  22310. */
  22311. setToDefaultPostProcess(): void;
  22312. /**
  22313. * Clear the current material and set it to a default state for particle
  22314. */
  22315. setToDefaultParticle(): void;
  22316. /**
  22317. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22318. * @param url defines the url to load from
  22319. * @returns a promise that will fullfil when the material is fully loaded
  22320. */
  22321. loadAsync(url: string): Promise<void>;
  22322. private _gatherBlocks;
  22323. /**
  22324. * Generate a string containing the code declaration required to create an equivalent of this material
  22325. * @returns a string
  22326. */
  22327. generateCode(): string;
  22328. /**
  22329. * Serializes this material in a JSON representation
  22330. * @returns the serialized material object
  22331. */
  22332. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22333. private _restoreConnections;
  22334. /**
  22335. * Clear the current graph and load a new one from a serialization object
  22336. * @param source defines the JSON representation of the material
  22337. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22338. * @param merge defines whether or not the source must be merged or replace the current content
  22339. */
  22340. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  22341. /**
  22342. * Makes a duplicate of the current material.
  22343. * @param name - name to use for the new material.
  22344. */
  22345. clone(name: string): NodeMaterial;
  22346. /**
  22347. * Creates a node material from parsed material data
  22348. * @param source defines the JSON representation of the material
  22349. * @param scene defines the hosting scene
  22350. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22351. * @returns a new node material
  22352. */
  22353. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22354. /**
  22355. * Creates a node material from a snippet saved in a remote file
  22356. * @param name defines the name of the material to create
  22357. * @param url defines the url to load from
  22358. * @param scene defines the hosting scene
  22359. * @returns a promise that will resolve to the new node material
  22360. */
  22361. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22362. /**
  22363. * Creates a node material from a snippet saved by the node material editor
  22364. * @param snippetId defines the snippet to load
  22365. * @param scene defines the hosting scene
  22366. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22367. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22368. * @returns a promise that will resolve to the new node material
  22369. */
  22370. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22371. /**
  22372. * Creates a new node material set to default basic configuration
  22373. * @param name defines the name of the material
  22374. * @param scene defines the hosting scene
  22375. * @returns a new NodeMaterial
  22376. */
  22377. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22378. }
  22379. }
  22380. declare module BABYLON {
  22381. /**
  22382. * Size options for a post process
  22383. */
  22384. export type PostProcessOptions = {
  22385. width: number;
  22386. height: number;
  22387. };
  22388. /**
  22389. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22390. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22391. */
  22392. export class PostProcess {
  22393. /** Name of the PostProcess. */
  22394. name: string;
  22395. /**
  22396. * Gets or sets the unique id of the post process
  22397. */
  22398. uniqueId: number;
  22399. /**
  22400. * Width of the texture to apply the post process on
  22401. */
  22402. width: number;
  22403. /**
  22404. * Height of the texture to apply the post process on
  22405. */
  22406. height: number;
  22407. /**
  22408. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22409. */
  22410. nodeMaterialSource: Nullable<NodeMaterial>;
  22411. /**
  22412. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22413. * @hidden
  22414. */
  22415. _outputTexture: Nullable<InternalTexture>;
  22416. /**
  22417. * Sampling mode used by the shader
  22418. * See https://doc.babylonjs.com/classes/3.1/texture
  22419. */
  22420. renderTargetSamplingMode: number;
  22421. /**
  22422. * Clear color to use when screen clearing
  22423. */
  22424. clearColor: Color4;
  22425. /**
  22426. * If the buffer needs to be cleared before applying the post process. (default: true)
  22427. * Should be set to false if shader will overwrite all previous pixels.
  22428. */
  22429. autoClear: boolean;
  22430. /**
  22431. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22432. */
  22433. alphaMode: number;
  22434. /**
  22435. * Sets the setAlphaBlendConstants of the babylon engine
  22436. */
  22437. alphaConstants: Color4;
  22438. /**
  22439. * Animations to be used for the post processing
  22440. */
  22441. animations: Animation[];
  22442. /**
  22443. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22444. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22445. */
  22446. enablePixelPerfectMode: boolean;
  22447. /**
  22448. * Force the postprocess to be applied without taking in account viewport
  22449. */
  22450. forceFullscreenViewport: boolean;
  22451. /**
  22452. * List of inspectable custom properties (used by the Inspector)
  22453. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22454. */
  22455. inspectableCustomProperties: IInspectable[];
  22456. /**
  22457. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22458. *
  22459. * | Value | Type | Description |
  22460. * | ----- | ----------------------------------- | ----------- |
  22461. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22462. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22463. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22464. *
  22465. */
  22466. scaleMode: number;
  22467. /**
  22468. * Force textures to be a power of two (default: false)
  22469. */
  22470. alwaysForcePOT: boolean;
  22471. private _samples;
  22472. /**
  22473. * Number of sample textures (default: 1)
  22474. */
  22475. get samples(): number;
  22476. set samples(n: number);
  22477. /**
  22478. * Modify the scale of the post process to be the same as the viewport (default: false)
  22479. */
  22480. adaptScaleToCurrentViewport: boolean;
  22481. private _camera;
  22482. protected _scene: Scene;
  22483. private _engine;
  22484. private _options;
  22485. private _reusable;
  22486. private _textureType;
  22487. private _textureFormat;
  22488. /**
  22489. * Smart array of input and output textures for the post process.
  22490. * @hidden
  22491. */
  22492. _textures: SmartArray<InternalTexture>;
  22493. /**
  22494. * The index in _textures that corresponds to the output texture.
  22495. * @hidden
  22496. */
  22497. _currentRenderTextureInd: number;
  22498. private _effect;
  22499. private _samplers;
  22500. private _fragmentUrl;
  22501. private _vertexUrl;
  22502. private _parameters;
  22503. private _scaleRatio;
  22504. protected _indexParameters: any;
  22505. private _shareOutputWithPostProcess;
  22506. private _texelSize;
  22507. private _forcedOutputTexture;
  22508. /**
  22509. * Returns the fragment url or shader name used in the post process.
  22510. * @returns the fragment url or name in the shader store.
  22511. */
  22512. getEffectName(): string;
  22513. /**
  22514. * An event triggered when the postprocess is activated.
  22515. */
  22516. onActivateObservable: Observable<Camera>;
  22517. private _onActivateObserver;
  22518. /**
  22519. * A function that is added to the onActivateObservable
  22520. */
  22521. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22522. /**
  22523. * An event triggered when the postprocess changes its size.
  22524. */
  22525. onSizeChangedObservable: Observable<PostProcess>;
  22526. private _onSizeChangedObserver;
  22527. /**
  22528. * A function that is added to the onSizeChangedObservable
  22529. */
  22530. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22531. /**
  22532. * An event triggered when the postprocess applies its effect.
  22533. */
  22534. onApplyObservable: Observable<Effect>;
  22535. private _onApplyObserver;
  22536. /**
  22537. * A function that is added to the onApplyObservable
  22538. */
  22539. set onApply(callback: (effect: Effect) => void);
  22540. /**
  22541. * An event triggered before rendering the postprocess
  22542. */
  22543. onBeforeRenderObservable: Observable<Effect>;
  22544. private _onBeforeRenderObserver;
  22545. /**
  22546. * A function that is added to the onBeforeRenderObservable
  22547. */
  22548. set onBeforeRender(callback: (effect: Effect) => void);
  22549. /**
  22550. * An event triggered after rendering the postprocess
  22551. */
  22552. onAfterRenderObservable: Observable<Effect>;
  22553. private _onAfterRenderObserver;
  22554. /**
  22555. * A function that is added to the onAfterRenderObservable
  22556. */
  22557. set onAfterRender(callback: (efect: Effect) => void);
  22558. /**
  22559. * 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
  22560. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22561. */
  22562. get inputTexture(): InternalTexture;
  22563. set inputTexture(value: InternalTexture);
  22564. /**
  22565. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  22566. * the only way to unset it is to use this function to restore its internal state
  22567. */
  22568. restoreDefaultInputTexture(): void;
  22569. /**
  22570. * Gets the camera which post process is applied to.
  22571. * @returns The camera the post process is applied to.
  22572. */
  22573. getCamera(): Camera;
  22574. /**
  22575. * Gets the texel size of the postprocess.
  22576. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22577. */
  22578. get texelSize(): Vector2;
  22579. /**
  22580. * Creates a new instance PostProcess
  22581. * @param name The name of the PostProcess.
  22582. * @param fragmentUrl The url of the fragment shader to be used.
  22583. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22584. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22585. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22586. * @param camera The camera to apply the render pass to.
  22587. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22588. * @param engine The engine which the post process will be applied. (default: current engine)
  22589. * @param reusable If the post process can be reused on the same frame. (default: false)
  22590. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22591. * @param textureType Type of textures used when performing the post process. (default: 0)
  22592. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22593. * @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
  22594. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  22595. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22596. */
  22597. constructor(
  22598. /** Name of the PostProcess. */
  22599. 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);
  22600. /**
  22601. * Gets a string idenfifying the name of the class
  22602. * @returns "PostProcess" string
  22603. */
  22604. getClassName(): string;
  22605. /**
  22606. * Gets the engine which this post process belongs to.
  22607. * @returns The engine the post process was enabled with.
  22608. */
  22609. getEngine(): Engine;
  22610. /**
  22611. * The effect that is created when initializing the post process.
  22612. * @returns The created effect corresponding the the postprocess.
  22613. */
  22614. getEffect(): Effect;
  22615. /**
  22616. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22617. * @param postProcess The post process to share the output with.
  22618. * @returns This post process.
  22619. */
  22620. shareOutputWith(postProcess: PostProcess): PostProcess;
  22621. /**
  22622. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22623. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22624. */
  22625. useOwnOutput(): void;
  22626. /**
  22627. * Updates the effect with the current post process compile time values and recompiles the shader.
  22628. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22629. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22630. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22631. * @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
  22632. * @param onCompiled Called when the shader has been compiled.
  22633. * @param onError Called if there is an error when compiling a shader.
  22634. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22635. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22636. */
  22637. 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;
  22638. /**
  22639. * The post process is reusable if it can be used multiple times within one frame.
  22640. * @returns If the post process is reusable
  22641. */
  22642. isReusable(): boolean;
  22643. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22644. markTextureDirty(): void;
  22645. /**
  22646. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22647. * 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.
  22648. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22649. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22650. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22651. * @returns The target texture that was bound to be written to.
  22652. */
  22653. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22654. /**
  22655. * If the post process is supported.
  22656. */
  22657. get isSupported(): boolean;
  22658. /**
  22659. * The aspect ratio of the output texture.
  22660. */
  22661. get aspectRatio(): number;
  22662. /**
  22663. * Get a value indicating if the post-process is ready to be used
  22664. * @returns true if the post-process is ready (shader is compiled)
  22665. */
  22666. isReady(): boolean;
  22667. /**
  22668. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22669. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22670. */
  22671. apply(): Nullable<Effect>;
  22672. private _disposeTextures;
  22673. /**
  22674. * Disposes the post process.
  22675. * @param camera The camera to dispose the post process on.
  22676. */
  22677. dispose(camera?: Camera): void;
  22678. }
  22679. }
  22680. declare module BABYLON {
  22681. /** @hidden */
  22682. export var kernelBlurVaryingDeclaration: {
  22683. name: string;
  22684. shader: string;
  22685. };
  22686. }
  22687. declare module BABYLON {
  22688. /** @hidden */
  22689. export var kernelBlurFragment: {
  22690. name: string;
  22691. shader: string;
  22692. };
  22693. }
  22694. declare module BABYLON {
  22695. /** @hidden */
  22696. export var kernelBlurFragment2: {
  22697. name: string;
  22698. shader: string;
  22699. };
  22700. }
  22701. declare module BABYLON {
  22702. /** @hidden */
  22703. export var kernelBlurPixelShader: {
  22704. name: string;
  22705. shader: string;
  22706. };
  22707. }
  22708. declare module BABYLON {
  22709. /** @hidden */
  22710. export var kernelBlurVertex: {
  22711. name: string;
  22712. shader: string;
  22713. };
  22714. }
  22715. declare module BABYLON {
  22716. /** @hidden */
  22717. export var kernelBlurVertexShader: {
  22718. name: string;
  22719. shader: string;
  22720. };
  22721. }
  22722. declare module BABYLON {
  22723. /**
  22724. * The Blur Post Process which blurs an image based on a kernel and direction.
  22725. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22726. */
  22727. export class BlurPostProcess extends PostProcess {
  22728. /** The direction in which to blur the image. */
  22729. direction: Vector2;
  22730. private blockCompilation;
  22731. protected _kernel: number;
  22732. protected _idealKernel: number;
  22733. protected _packedFloat: boolean;
  22734. private _staticDefines;
  22735. /**
  22736. * Sets the length in pixels of the blur sample region
  22737. */
  22738. set kernel(v: number);
  22739. /**
  22740. * Gets the length in pixels of the blur sample region
  22741. */
  22742. get kernel(): number;
  22743. /**
  22744. * Sets wether or not the blur needs to unpack/repack floats
  22745. */
  22746. set packedFloat(v: boolean);
  22747. /**
  22748. * Gets wether or not the blur is unpacking/repacking floats
  22749. */
  22750. get packedFloat(): boolean;
  22751. /**
  22752. * Creates a new instance BlurPostProcess
  22753. * @param name The name of the effect.
  22754. * @param direction The direction in which to blur the image.
  22755. * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.
  22756. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22757. * @param camera The camera to apply the render pass to.
  22758. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22759. * @param engine The engine which the post process will be applied. (default: current engine)
  22760. * @param reusable If the post process can be reused on the same frame. (default: false)
  22761. * @param textureType Type of textures used when performing the post process. (default: 0)
  22762. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  22763. */
  22764. constructor(name: string,
  22765. /** The direction in which to blur the image. */
  22766. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  22767. /**
  22768. * Updates the effect with the current post process compile time values and recompiles the shader.
  22769. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22770. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22771. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22772. * @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
  22773. * @param onCompiled Called when the shader has been compiled.
  22774. * @param onError Called if there is an error when compiling a shader.
  22775. */
  22776. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22777. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22778. /**
  22779. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  22780. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  22781. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  22782. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  22783. * The gaps between physical kernels are compensated for in the weighting of the samples
  22784. * @param idealKernel Ideal blur kernel.
  22785. * @return Nearest best kernel.
  22786. */
  22787. protected _nearestBestKernel(idealKernel: number): number;
  22788. /**
  22789. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  22790. * @param x The point on the Gaussian distribution to sample.
  22791. * @return the value of the Gaussian function at x.
  22792. */
  22793. protected _gaussianWeight(x: number): number;
  22794. /**
  22795. * Generates a string that can be used as a floating point number in GLSL.
  22796. * @param x Value to print.
  22797. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  22798. * @return GLSL float string.
  22799. */
  22800. protected _glslFloat(x: number, decimalFigures?: number): string;
  22801. }
  22802. }
  22803. declare module BABYLON {
  22804. /**
  22805. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22806. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22807. * You can then easily use it as a reflectionTexture on a flat surface.
  22808. * In case the surface is not a plane, please consider relying on reflection probes.
  22809. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22810. */
  22811. export class MirrorTexture extends RenderTargetTexture {
  22812. private scene;
  22813. /**
  22814. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  22815. * It is possible to directly set the mirrorPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  22816. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22817. */
  22818. mirrorPlane: Plane;
  22819. /**
  22820. * Define the blur ratio used to blur the reflection if needed.
  22821. */
  22822. set blurRatio(value: number);
  22823. get blurRatio(): number;
  22824. /**
  22825. * Define the adaptive blur kernel used to blur the reflection if needed.
  22826. * This will autocompute the closest best match for the `blurKernel`
  22827. */
  22828. set adaptiveBlurKernel(value: number);
  22829. /**
  22830. * Define the blur kernel used to blur the reflection if needed.
  22831. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22832. */
  22833. set blurKernel(value: number);
  22834. /**
  22835. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  22836. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22837. */
  22838. set blurKernelX(value: number);
  22839. get blurKernelX(): number;
  22840. /**
  22841. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  22842. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22843. */
  22844. set blurKernelY(value: number);
  22845. get blurKernelY(): number;
  22846. private _autoComputeBlurKernel;
  22847. protected _onRatioRescale(): void;
  22848. private _updateGammaSpace;
  22849. private _imageProcessingConfigChangeObserver;
  22850. private _transformMatrix;
  22851. private _mirrorMatrix;
  22852. private _savedViewMatrix;
  22853. private _blurX;
  22854. private _blurY;
  22855. private _adaptiveBlurKernel;
  22856. private _blurKernelX;
  22857. private _blurKernelY;
  22858. private _blurRatio;
  22859. /**
  22860. * Instantiates a Mirror Texture.
  22861. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22862. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22863. * You can then easily use it as a reflectionTexture on a flat surface.
  22864. * In case the surface is not a plane, please consider relying on reflection probes.
  22865. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22866. * @param name
  22867. * @param size
  22868. * @param scene
  22869. * @param generateMipMaps
  22870. * @param type
  22871. * @param samplingMode
  22872. * @param generateDepthBuffer
  22873. */
  22874. constructor(name: string, size: number | {
  22875. width: number;
  22876. height: number;
  22877. } | {
  22878. ratio: number;
  22879. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  22880. private _preparePostProcesses;
  22881. /**
  22882. * Clone the mirror texture.
  22883. * @returns the cloned texture
  22884. */
  22885. clone(): MirrorTexture;
  22886. /**
  22887. * Serialize the texture to a JSON representation you could use in Parse later on
  22888. * @returns the serialized JSON representation
  22889. */
  22890. serialize(): any;
  22891. /**
  22892. * Dispose the texture and release its associated resources.
  22893. */
  22894. dispose(): void;
  22895. }
  22896. }
  22897. declare module BABYLON {
  22898. /**
  22899. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22900. * @see https://doc.babylonjs.com/babylon101/materials#texture
  22901. */
  22902. export class Texture extends BaseTexture {
  22903. /**
  22904. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  22905. */
  22906. static SerializeBuffers: boolean;
  22907. /** @hidden */
  22908. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  22909. /** @hidden */
  22910. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  22911. /** @hidden */
  22912. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  22913. /** nearest is mag = nearest and min = nearest and mip = linear */
  22914. static readonly NEAREST_SAMPLINGMODE: number;
  22915. /** nearest is mag = nearest and min = nearest and mip = linear */
  22916. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  22917. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22918. static readonly BILINEAR_SAMPLINGMODE: number;
  22919. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22920. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  22921. /** Trilinear is mag = linear and min = linear and mip = linear */
  22922. static readonly TRILINEAR_SAMPLINGMODE: number;
  22923. /** Trilinear is mag = linear and min = linear and mip = linear */
  22924. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  22925. /** mag = nearest and min = nearest and mip = nearest */
  22926. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  22927. /** mag = nearest and min = linear and mip = nearest */
  22928. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  22929. /** mag = nearest and min = linear and mip = linear */
  22930. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  22931. /** mag = nearest and min = linear and mip = none */
  22932. static readonly NEAREST_LINEAR: number;
  22933. /** mag = nearest and min = nearest and mip = none */
  22934. static readonly NEAREST_NEAREST: number;
  22935. /** mag = linear and min = nearest and mip = nearest */
  22936. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  22937. /** mag = linear and min = nearest and mip = linear */
  22938. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  22939. /** mag = linear and min = linear and mip = none */
  22940. static readonly LINEAR_LINEAR: number;
  22941. /** mag = linear and min = nearest and mip = none */
  22942. static readonly LINEAR_NEAREST: number;
  22943. /** Explicit coordinates mode */
  22944. static readonly EXPLICIT_MODE: number;
  22945. /** Spherical coordinates mode */
  22946. static readonly SPHERICAL_MODE: number;
  22947. /** Planar coordinates mode */
  22948. static readonly PLANAR_MODE: number;
  22949. /** Cubic coordinates mode */
  22950. static readonly CUBIC_MODE: number;
  22951. /** Projection coordinates mode */
  22952. static readonly PROJECTION_MODE: number;
  22953. /** Inverse Cubic coordinates mode */
  22954. static readonly SKYBOX_MODE: number;
  22955. /** Inverse Cubic coordinates mode */
  22956. static readonly INVCUBIC_MODE: number;
  22957. /** Equirectangular coordinates mode */
  22958. static readonly EQUIRECTANGULAR_MODE: number;
  22959. /** Equirectangular Fixed coordinates mode */
  22960. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  22961. /** Equirectangular Fixed Mirrored coordinates mode */
  22962. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  22963. /** Texture is not repeating outside of 0..1 UVs */
  22964. static readonly CLAMP_ADDRESSMODE: number;
  22965. /** Texture is repeating outside of 0..1 UVs */
  22966. static readonly WRAP_ADDRESSMODE: number;
  22967. /** Texture is repeating and mirrored */
  22968. static readonly MIRROR_ADDRESSMODE: number;
  22969. /**
  22970. * 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
  22971. */
  22972. static UseSerializedUrlIfAny: boolean;
  22973. /**
  22974. * Define the url of the texture.
  22975. */
  22976. url: Nullable<string>;
  22977. /**
  22978. * Define an offset on the texture to offset the u coordinates of the UVs
  22979. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  22980. */
  22981. uOffset: number;
  22982. /**
  22983. * Define an offset on the texture to offset the v coordinates of the UVs
  22984. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  22985. */
  22986. vOffset: number;
  22987. /**
  22988. * Define an offset on the texture to scale the u coordinates of the UVs
  22989. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  22990. */
  22991. uScale: number;
  22992. /**
  22993. * Define an offset on the texture to scale the v coordinates of the UVs
  22994. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  22995. */
  22996. vScale: number;
  22997. /**
  22998. * Define an offset on the texture to rotate around the u coordinates of the UVs
  22999. * @see https://doc.babylonjs.com/how_to/more_materials
  23000. */
  23001. uAng: number;
  23002. /**
  23003. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23004. * @see https://doc.babylonjs.com/how_to/more_materials
  23005. */
  23006. vAng: number;
  23007. /**
  23008. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23009. * @see https://doc.babylonjs.com/how_to/more_materials
  23010. */
  23011. wAng: number;
  23012. /**
  23013. * Defines the center of rotation (U)
  23014. */
  23015. uRotationCenter: number;
  23016. /**
  23017. * Defines the center of rotation (V)
  23018. */
  23019. vRotationCenter: number;
  23020. /**
  23021. * Defines the center of rotation (W)
  23022. */
  23023. wRotationCenter: number;
  23024. /**
  23025. * Are mip maps generated for this texture or not.
  23026. */
  23027. get noMipmap(): boolean;
  23028. /**
  23029. * List of inspectable custom properties (used by the Inspector)
  23030. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23031. */
  23032. inspectableCustomProperties: Nullable<IInspectable[]>;
  23033. private _noMipmap;
  23034. /** @hidden */
  23035. _invertY: boolean;
  23036. private _rowGenerationMatrix;
  23037. private _cachedTextureMatrix;
  23038. private _projectionModeMatrix;
  23039. private _t0;
  23040. private _t1;
  23041. private _t2;
  23042. private _cachedUOffset;
  23043. private _cachedVOffset;
  23044. private _cachedUScale;
  23045. private _cachedVScale;
  23046. private _cachedUAng;
  23047. private _cachedVAng;
  23048. private _cachedWAng;
  23049. private _cachedProjectionMatrixId;
  23050. private _cachedCoordinatesMode;
  23051. /** @hidden */
  23052. protected _initialSamplingMode: number;
  23053. /** @hidden */
  23054. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23055. private _deleteBuffer;
  23056. protected _format: Nullable<number>;
  23057. private _delayedOnLoad;
  23058. private _delayedOnError;
  23059. private _mimeType?;
  23060. /**
  23061. * Observable triggered once the texture has been loaded.
  23062. */
  23063. onLoadObservable: Observable<Texture>;
  23064. protected _isBlocking: boolean;
  23065. /**
  23066. * Is the texture preventing material to render while loading.
  23067. * If false, a default texture will be used instead of the loading one during the preparation step.
  23068. */
  23069. set isBlocking(value: boolean);
  23070. get isBlocking(): boolean;
  23071. /**
  23072. * Get the current sampling mode associated with the texture.
  23073. */
  23074. get samplingMode(): number;
  23075. /**
  23076. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23077. */
  23078. get invertY(): boolean;
  23079. /**
  23080. * Instantiates a new texture.
  23081. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23082. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23083. * @param url defines the url of the picture to load as a texture
  23084. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23085. * @param noMipmap defines if the texture will require mip maps or not
  23086. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23087. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23088. * @param onLoad defines a callback triggered when the texture has been loaded
  23089. * @param onError defines a callback triggered when an error occurred during the loading session
  23090. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23091. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23092. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23093. * @param mimeType defines an optional mime type information
  23094. */
  23095. 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);
  23096. /**
  23097. * Update the url (and optional buffer) of this texture if url was null during construction.
  23098. * @param url the url of the texture
  23099. * @param buffer the buffer of the texture (defaults to null)
  23100. * @param onLoad callback called when the texture is loaded (defaults to null)
  23101. */
  23102. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23103. /**
  23104. * Finish the loading sequence of a texture flagged as delayed load.
  23105. * @hidden
  23106. */
  23107. delayLoad(): void;
  23108. private _prepareRowForTextureGeneration;
  23109. /**
  23110. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23111. * @returns the transform matrix of the texture.
  23112. */
  23113. getTextureMatrix(uBase?: number): Matrix;
  23114. /**
  23115. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23116. * @returns The reflection texture transform
  23117. */
  23118. getReflectionTextureMatrix(): Matrix;
  23119. /**
  23120. * Clones the texture.
  23121. * @returns the cloned texture
  23122. */
  23123. clone(): Texture;
  23124. /**
  23125. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23126. * @returns The JSON representation of the texture
  23127. */
  23128. serialize(): any;
  23129. /**
  23130. * Get the current class name of the texture useful for serialization or dynamic coding.
  23131. * @returns "Texture"
  23132. */
  23133. getClassName(): string;
  23134. /**
  23135. * Dispose the texture and release its associated resources.
  23136. */
  23137. dispose(): void;
  23138. /**
  23139. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23140. * @param parsedTexture Define the JSON representation of the texture
  23141. * @param scene Define the scene the parsed texture should be instantiated in
  23142. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23143. * @returns The parsed texture if successful
  23144. */
  23145. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23146. /**
  23147. * Creates a texture from its base 64 representation.
  23148. * @param data Define the base64 payload without the data: prefix
  23149. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23150. * @param scene Define the scene the texture should belong to
  23151. * @param noMipmap Forces the texture to not create mip map information if true
  23152. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23153. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23154. * @param onLoad define a callback triggered when the texture has been loaded
  23155. * @param onError define a callback triggered when an error occurred during the loading session
  23156. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23157. * @returns the created texture
  23158. */
  23159. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23160. /**
  23161. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23162. * @param data Define the base64 payload without the data: prefix
  23163. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23164. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23165. * @param scene Define the scene the texture should belong to
  23166. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23167. * @param noMipmap Forces the texture to not create mip map information if true
  23168. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23169. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23170. * @param onLoad define a callback triggered when the texture has been loaded
  23171. * @param onError define a callback triggered when an error occurred during the loading session
  23172. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23173. * @returns the created texture
  23174. */
  23175. 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;
  23176. }
  23177. }
  23178. declare module BABYLON {
  23179. /**
  23180. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23181. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23182. */
  23183. export class PostProcessManager {
  23184. private _scene;
  23185. private _indexBuffer;
  23186. private _vertexBuffers;
  23187. /**
  23188. * Creates a new instance PostProcess
  23189. * @param scene The scene that the post process is associated with.
  23190. */
  23191. constructor(scene: Scene);
  23192. private _prepareBuffers;
  23193. private _buildIndexBuffer;
  23194. /**
  23195. * Rebuilds the vertex buffers of the manager.
  23196. * @hidden
  23197. */
  23198. _rebuild(): void;
  23199. /**
  23200. * Prepares a frame to be run through a post process.
  23201. * @param sourceTexture The input texture to the post procesess. (default: null)
  23202. * @param postProcesses An array of post processes to be run. (default: null)
  23203. * @returns True if the post processes were able to be run.
  23204. * @hidden
  23205. */
  23206. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23207. /**
  23208. * Manually render a set of post processes to a texture.
  23209. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23210. * @param postProcesses An array of post processes to be run.
  23211. * @param targetTexture The target texture to render to.
  23212. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23213. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23214. * @param lodLevel defines which lod of the texture to render to
  23215. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  23216. */
  23217. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  23218. /**
  23219. * Finalize the result of the output of the postprocesses.
  23220. * @param doNotPresent If true the result will not be displayed to the screen.
  23221. * @param targetTexture The target texture to render to.
  23222. * @param faceIndex The index of the face to bind the target texture to.
  23223. * @param postProcesses The array of post processes to render.
  23224. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23225. * @hidden
  23226. */
  23227. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23228. /**
  23229. * Disposes of the post process manager.
  23230. */
  23231. dispose(): void;
  23232. }
  23233. }
  23234. declare module BABYLON {
  23235. /**
  23236. * This Helps creating a texture that will be created from a camera in your scene.
  23237. * It is basically a dynamic texture that could be used to create special effects for instance.
  23238. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23239. */
  23240. export class RenderTargetTexture extends Texture {
  23241. isCube: boolean;
  23242. /**
  23243. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23244. */
  23245. static readonly REFRESHRATE_RENDER_ONCE: number;
  23246. /**
  23247. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23248. */
  23249. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23250. /**
  23251. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23252. * the central point of your effect and can save a lot of performances.
  23253. */
  23254. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23255. /**
  23256. * Use this predicate to dynamically define the list of mesh you want to render.
  23257. * If set, the renderList property will be overwritten.
  23258. */
  23259. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23260. private _renderList;
  23261. /**
  23262. * Use this list to define the list of mesh you want to render.
  23263. */
  23264. get renderList(): Nullable<Array<AbstractMesh>>;
  23265. set renderList(value: Nullable<Array<AbstractMesh>>);
  23266. /**
  23267. * Use this function to overload the renderList array at rendering time.
  23268. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23269. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23270. * the cube (if the RTT is a cube, else layerOrFace=0).
  23271. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23272. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23273. * hold dummy elements!
  23274. */
  23275. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23276. private _hookArray;
  23277. /**
  23278. * Define if particles should be rendered in your texture.
  23279. */
  23280. renderParticles: boolean;
  23281. /**
  23282. * Define if sprites should be rendered in your texture.
  23283. */
  23284. renderSprites: boolean;
  23285. /**
  23286. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  23287. */
  23288. coordinatesMode: number;
  23289. /**
  23290. * Define the camera used to render the texture.
  23291. */
  23292. activeCamera: Nullable<Camera>;
  23293. /**
  23294. * Override the mesh isReady function with your own one.
  23295. */
  23296. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23297. /**
  23298. * Override the render function of the texture with your own one.
  23299. */
  23300. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23301. /**
  23302. * Define if camera post processes should be use while rendering the texture.
  23303. */
  23304. useCameraPostProcesses: boolean;
  23305. /**
  23306. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23307. */
  23308. ignoreCameraViewport: boolean;
  23309. private _postProcessManager;
  23310. private _postProcesses;
  23311. private _resizeObserver;
  23312. /**
  23313. * An event triggered when the texture is unbind.
  23314. */
  23315. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23316. /**
  23317. * An event triggered when the texture is unbind.
  23318. */
  23319. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23320. private _onAfterUnbindObserver;
  23321. /**
  23322. * Set a after unbind callback in the texture.
  23323. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23324. */
  23325. set onAfterUnbind(callback: () => void);
  23326. /**
  23327. * An event triggered before rendering the texture
  23328. */
  23329. onBeforeRenderObservable: Observable<number>;
  23330. private _onBeforeRenderObserver;
  23331. /**
  23332. * Set a before render callback in the texture.
  23333. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23334. */
  23335. set onBeforeRender(callback: (faceIndex: number) => void);
  23336. /**
  23337. * An event triggered after rendering the texture
  23338. */
  23339. onAfterRenderObservable: Observable<number>;
  23340. private _onAfterRenderObserver;
  23341. /**
  23342. * Set a after render callback in the texture.
  23343. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23344. */
  23345. set onAfterRender(callback: (faceIndex: number) => void);
  23346. /**
  23347. * An event triggered after the texture clear
  23348. */
  23349. onClearObservable: Observable<Engine>;
  23350. private _onClearObserver;
  23351. /**
  23352. * Set a clear callback in the texture.
  23353. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23354. */
  23355. set onClear(callback: (Engine: Engine) => void);
  23356. /**
  23357. * An event triggered when the texture is resized.
  23358. */
  23359. onResizeObservable: Observable<RenderTargetTexture>;
  23360. /**
  23361. * Define the clear color of the Render Target if it should be different from the scene.
  23362. */
  23363. clearColor: Color4;
  23364. protected _size: number | {
  23365. width: number;
  23366. height: number;
  23367. layers?: number;
  23368. };
  23369. protected _initialSizeParameter: number | {
  23370. width: number;
  23371. height: number;
  23372. } | {
  23373. ratio: number;
  23374. };
  23375. protected _sizeRatio: Nullable<number>;
  23376. /** @hidden */
  23377. _generateMipMaps: boolean;
  23378. protected _renderingManager: RenderingManager;
  23379. /** @hidden */
  23380. _waitingRenderList: string[];
  23381. protected _doNotChangeAspectRatio: boolean;
  23382. protected _currentRefreshId: number;
  23383. protected _refreshRate: number;
  23384. protected _textureMatrix: Matrix;
  23385. protected _samples: number;
  23386. protected _renderTargetOptions: RenderTargetCreationOptions;
  23387. /**
  23388. * Gets render target creation options that were used.
  23389. */
  23390. get renderTargetOptions(): RenderTargetCreationOptions;
  23391. protected _onRatioRescale(): void;
  23392. /**
  23393. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23394. * It must define where the camera used to render the texture is set
  23395. */
  23396. boundingBoxPosition: Vector3;
  23397. private _boundingBoxSize;
  23398. /**
  23399. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23400. * When defined, the cubemap will switch to local mode
  23401. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23402. * @example https://www.babylonjs-playground.com/#RNASML
  23403. */
  23404. set boundingBoxSize(value: Vector3);
  23405. get boundingBoxSize(): Vector3;
  23406. /**
  23407. * In case the RTT has been created with a depth texture, get the associated
  23408. * depth texture.
  23409. * Otherwise, return null.
  23410. */
  23411. get depthStencilTexture(): Nullable<InternalTexture>;
  23412. /**
  23413. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23414. * or used a shadow, depth texture...
  23415. * @param name The friendly name of the texture
  23416. * @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)
  23417. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23418. * @param generateMipMaps True if mip maps need to be generated after render.
  23419. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23420. * @param type The type of the buffer in the RTT (int, half float, float...)
  23421. * @param isCube True if a cube texture needs to be created
  23422. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23423. * @param generateDepthBuffer True to generate a depth buffer
  23424. * @param generateStencilBuffer True to generate a stencil buffer
  23425. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23426. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23427. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23428. */
  23429. constructor(name: string, size: number | {
  23430. width: number;
  23431. height: number;
  23432. layers?: number;
  23433. } | {
  23434. ratio: number;
  23435. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23436. /**
  23437. * Creates a depth stencil texture.
  23438. * This is only available in WebGL 2 or with the depth texture extension available.
  23439. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23440. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23441. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23442. */
  23443. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23444. private _processSizeParameter;
  23445. /**
  23446. * Define the number of samples to use in case of MSAA.
  23447. * It defaults to one meaning no MSAA has been enabled.
  23448. */
  23449. get samples(): number;
  23450. set samples(value: number);
  23451. /**
  23452. * Resets the refresh counter of the texture and start bak from scratch.
  23453. * Could be useful to regenerate the texture if it is setup to render only once.
  23454. */
  23455. resetRefreshCounter(): void;
  23456. /**
  23457. * Define the refresh rate of the texture or the rendering frequency.
  23458. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23459. */
  23460. get refreshRate(): number;
  23461. set refreshRate(value: number);
  23462. /**
  23463. * Adds a post process to the render target rendering passes.
  23464. * @param postProcess define the post process to add
  23465. */
  23466. addPostProcess(postProcess: PostProcess): void;
  23467. /**
  23468. * Clear all the post processes attached to the render target
  23469. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23470. */
  23471. clearPostProcesses(dispose?: boolean): void;
  23472. /**
  23473. * Remove one of the post process from the list of attached post processes to the texture
  23474. * @param postProcess define the post process to remove from the list
  23475. */
  23476. removePostProcess(postProcess: PostProcess): void;
  23477. /** @hidden */
  23478. _shouldRender(): boolean;
  23479. /**
  23480. * Gets the actual render size of the texture.
  23481. * @returns the width of the render size
  23482. */
  23483. getRenderSize(): number;
  23484. /**
  23485. * Gets the actual render width of the texture.
  23486. * @returns the width of the render size
  23487. */
  23488. getRenderWidth(): number;
  23489. /**
  23490. * Gets the actual render height of the texture.
  23491. * @returns the height of the render size
  23492. */
  23493. getRenderHeight(): number;
  23494. /**
  23495. * Gets the actual number of layers of the texture.
  23496. * @returns the number of layers
  23497. */
  23498. getRenderLayers(): number;
  23499. /**
  23500. * Get if the texture can be rescaled or not.
  23501. */
  23502. get canRescale(): boolean;
  23503. /**
  23504. * Resize the texture using a ratio.
  23505. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23506. */
  23507. scale(ratio: number): void;
  23508. /**
  23509. * Get the texture reflection matrix used to rotate/transform the reflection.
  23510. * @returns the reflection matrix
  23511. */
  23512. getReflectionTextureMatrix(): Matrix;
  23513. /**
  23514. * Resize the texture to a new desired size.
  23515. * Be carrefull as it will recreate all the data in the new texture.
  23516. * @param size Define the new size. It can be:
  23517. * - a number for squared texture,
  23518. * - an object containing { width: number, height: number }
  23519. * - or an object containing a ratio { ratio: number }
  23520. */
  23521. resize(size: number | {
  23522. width: number;
  23523. height: number;
  23524. } | {
  23525. ratio: number;
  23526. }): void;
  23527. private _defaultRenderListPrepared;
  23528. /**
  23529. * Renders all the objects from the render list into the texture.
  23530. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23531. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23532. */
  23533. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23534. private _bestReflectionRenderTargetDimension;
  23535. private _prepareRenderingManager;
  23536. /**
  23537. * @hidden
  23538. * @param faceIndex face index to bind to if this is a cubetexture
  23539. * @param layer defines the index of the texture to bind in the array
  23540. */
  23541. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23542. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23543. private renderToTarget;
  23544. /**
  23545. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23546. * This allowed control for front to back rendering or reversly depending of the special needs.
  23547. *
  23548. * @param renderingGroupId The rendering group id corresponding to its index
  23549. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23550. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23551. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23552. */
  23553. 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;
  23554. /**
  23555. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23556. *
  23557. * @param renderingGroupId The rendering group id corresponding to its index
  23558. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23559. */
  23560. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23561. /**
  23562. * Clones the texture.
  23563. * @returns the cloned texture
  23564. */
  23565. clone(): RenderTargetTexture;
  23566. /**
  23567. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23568. * @returns The JSON representation of the texture
  23569. */
  23570. serialize(): any;
  23571. /**
  23572. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23573. */
  23574. disposeFramebufferObjects(): void;
  23575. /**
  23576. * Dispose the texture and release its associated resources.
  23577. */
  23578. dispose(): void;
  23579. /** @hidden */
  23580. _rebuild(): void;
  23581. /**
  23582. * Clear the info related to rendering groups preventing retention point in material dispose.
  23583. */
  23584. freeRenderingGroups(): void;
  23585. /**
  23586. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23587. * @returns the view count
  23588. */
  23589. getViewCount(): number;
  23590. }
  23591. }
  23592. declare module BABYLON {
  23593. /**
  23594. * Class used to manipulate GUIDs
  23595. */
  23596. export class GUID {
  23597. /**
  23598. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23599. * Be aware Math.random() could cause collisions, but:
  23600. * "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"
  23601. * @returns a pseudo random id
  23602. */
  23603. static RandomId(): string;
  23604. }
  23605. }
  23606. declare module BABYLON {
  23607. /**
  23608. * Options to be used when creating a shadow depth material
  23609. */
  23610. export interface IIOptionShadowDepthMaterial {
  23611. /** Variables in the vertex shader code that need to have their names remapped.
  23612. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  23613. * "var_name" should be either: worldPos or vNormalW
  23614. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  23615. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  23616. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  23617. */
  23618. remappedVariables?: string[];
  23619. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  23620. standalone?: boolean;
  23621. }
  23622. /**
  23623. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  23624. */
  23625. export class ShadowDepthWrapper {
  23626. private _scene;
  23627. private _options?;
  23628. private _baseMaterial;
  23629. private _onEffectCreatedObserver;
  23630. private _subMeshToEffect;
  23631. private _subMeshToDepthEffect;
  23632. private _meshes;
  23633. /** @hidden */
  23634. _matriceNames: any;
  23635. /** Gets the standalone status of the wrapper */
  23636. get standalone(): boolean;
  23637. /** Gets the base material the wrapper is built upon */
  23638. get baseMaterial(): Material;
  23639. /**
  23640. * Instantiate a new shadow depth wrapper.
  23641. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  23642. * generate the shadow depth map. For more information, please refer to the documentation:
  23643. * https://doc.babylonjs.com/babylon101/shadows
  23644. * @param baseMaterial Material to wrap
  23645. * @param scene Define the scene the material belongs to
  23646. * @param options Options used to create the wrapper
  23647. */
  23648. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  23649. /**
  23650. * Gets the effect to use to generate the depth map
  23651. * @param subMesh subMesh to get the effect for
  23652. * @param shadowGenerator shadow generator to get the effect for
  23653. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  23654. */
  23655. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  23656. /**
  23657. * Specifies that the submesh is ready to be used for depth rendering
  23658. * @param subMesh submesh to check
  23659. * @param defines the list of defines to take into account when checking the effect
  23660. * @param shadowGenerator combined with subMesh, it defines the effect to check
  23661. * @param useInstances specifies that instances should be used
  23662. * @returns a boolean indicating that the submesh is ready or not
  23663. */
  23664. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  23665. /**
  23666. * Disposes the resources
  23667. */
  23668. dispose(): void;
  23669. private _makeEffect;
  23670. }
  23671. }
  23672. declare module BABYLON {
  23673. interface ThinEngine {
  23674. /**
  23675. * Unbind a list of render target textures from the webGL context
  23676. * This is used only when drawBuffer extension or webGL2 are active
  23677. * @param textures defines the render target textures to unbind
  23678. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  23679. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  23680. */
  23681. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  23682. /**
  23683. * Create a multi render target texture
  23684. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  23685. * @param size defines the size of the texture
  23686. * @param options defines the creation options
  23687. * @returns the cube texture as an InternalTexture
  23688. */
  23689. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  23690. /**
  23691. * Update the sample count for a given multiple render target texture
  23692. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  23693. * @param textures defines the textures to update
  23694. * @param samples defines the sample count to set
  23695. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  23696. */
  23697. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  23698. /**
  23699. * Select a subsets of attachments to draw to.
  23700. * @param attachments gl attachments
  23701. */
  23702. bindAttachments(attachments: number[]): void;
  23703. }
  23704. }
  23705. declare module BABYLON {
  23706. /**
  23707. * Creation options of the multi render target texture.
  23708. */
  23709. export interface IMultiRenderTargetOptions {
  23710. /**
  23711. * Define if the texture needs to create mip maps after render.
  23712. */
  23713. generateMipMaps?: boolean;
  23714. /**
  23715. * Define the types of all the draw buffers we want to create
  23716. */
  23717. types?: number[];
  23718. /**
  23719. * Define the sampling modes of all the draw buffers we want to create
  23720. */
  23721. samplingModes?: number[];
  23722. /**
  23723. * Define if a depth buffer is required
  23724. */
  23725. generateDepthBuffer?: boolean;
  23726. /**
  23727. * Define if a stencil buffer is required
  23728. */
  23729. generateStencilBuffer?: boolean;
  23730. /**
  23731. * Define if a depth texture is required instead of a depth buffer
  23732. */
  23733. generateDepthTexture?: boolean;
  23734. /**
  23735. * Define the number of desired draw buffers
  23736. */
  23737. textureCount?: number;
  23738. /**
  23739. * Define if aspect ratio should be adapted to the texture or stay the scene one
  23740. */
  23741. doNotChangeAspectRatio?: boolean;
  23742. /**
  23743. * Define the default type of the buffers we are creating
  23744. */
  23745. defaultType?: number;
  23746. }
  23747. /**
  23748. * A multi render target, like a render target provides the ability to render to a texture.
  23749. * Unlike the render target, it can render to several draw buffers in one draw.
  23750. * This is specially interesting in deferred rendering or for any effects requiring more than
  23751. * just one color from a single pass.
  23752. */
  23753. export class MultiRenderTarget extends RenderTargetTexture {
  23754. private _internalTextures;
  23755. private _textures;
  23756. private _multiRenderTargetOptions;
  23757. private _count;
  23758. /**
  23759. * Get if draw buffers are currently supported by the used hardware and browser.
  23760. */
  23761. get isSupported(): boolean;
  23762. /**
  23763. * Get the list of textures generated by the multi render target.
  23764. */
  23765. get textures(): Texture[];
  23766. /**
  23767. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  23768. */
  23769. get count(): number;
  23770. /**
  23771. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  23772. */
  23773. get depthTexture(): Texture;
  23774. /**
  23775. * Set the wrapping mode on U of all the textures we are rendering to.
  23776. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23777. */
  23778. set wrapU(wrap: number);
  23779. /**
  23780. * Set the wrapping mode on V of all the textures we are rendering to.
  23781. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23782. */
  23783. set wrapV(wrap: number);
  23784. /**
  23785. * Instantiate a new multi render target texture.
  23786. * A multi render target, like a render target provides the ability to render to a texture.
  23787. * Unlike the render target, it can render to several draw buffers in one draw.
  23788. * This is specially interesting in deferred rendering or for any effects requiring more than
  23789. * just one color from a single pass.
  23790. * @param name Define the name of the texture
  23791. * @param size Define the size of the buffers to render to
  23792. * @param count Define the number of target we are rendering into
  23793. * @param scene Define the scene the texture belongs to
  23794. * @param options Define the options used to create the multi render target
  23795. */
  23796. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  23797. /** @hidden */
  23798. _rebuild(): void;
  23799. private _createInternalTextures;
  23800. private _createTextures;
  23801. /**
  23802. * Define the number of samples used if MSAA is enabled.
  23803. */
  23804. get samples(): number;
  23805. set samples(value: number);
  23806. /**
  23807. * Resize all the textures in the multi render target.
  23808. * Be carrefull as it will recreate all the data in the new texture.
  23809. * @param size Define the new size
  23810. */
  23811. resize(size: any): void;
  23812. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23813. /**
  23814. * Dispose the render targets and their associated resources
  23815. */
  23816. dispose(): void;
  23817. /**
  23818. * Release all the underlying texture used as draw buffers.
  23819. */
  23820. releaseInternalTextures(): void;
  23821. }
  23822. }
  23823. declare module BABYLON {
  23824. /** @hidden */
  23825. export var imageProcessingPixelShader: {
  23826. name: string;
  23827. shader: string;
  23828. };
  23829. }
  23830. declare module BABYLON {
  23831. /**
  23832. * ImageProcessingPostProcess
  23833. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  23834. */
  23835. export class ImageProcessingPostProcess extends PostProcess {
  23836. /**
  23837. * Default configuration related to image processing available in the PBR Material.
  23838. */
  23839. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23840. /**
  23841. * Gets the image processing configuration used either in this material.
  23842. */
  23843. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23844. /**
  23845. * Sets the Default image processing configuration used either in the this material.
  23846. *
  23847. * If sets to null, the scene one is in use.
  23848. */
  23849. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23850. /**
  23851. * Keep track of the image processing observer to allow dispose and replace.
  23852. */
  23853. private _imageProcessingObserver;
  23854. /**
  23855. * Attaches a new image processing configuration to the PBR Material.
  23856. * @param configuration
  23857. */
  23858. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  23859. /**
  23860. * If the post process is supported.
  23861. */
  23862. get isSupported(): boolean;
  23863. /**
  23864. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23865. */
  23866. get colorCurves(): Nullable<ColorCurves>;
  23867. /**
  23868. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23869. */
  23870. set colorCurves(value: Nullable<ColorCurves>);
  23871. /**
  23872. * Gets wether the color curves effect is enabled.
  23873. */
  23874. get colorCurvesEnabled(): boolean;
  23875. /**
  23876. * Sets wether the color curves effect is enabled.
  23877. */
  23878. set colorCurvesEnabled(value: boolean);
  23879. /**
  23880. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23881. */
  23882. get colorGradingTexture(): Nullable<BaseTexture>;
  23883. /**
  23884. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23885. */
  23886. set colorGradingTexture(value: Nullable<BaseTexture>);
  23887. /**
  23888. * Gets wether the color grading effect is enabled.
  23889. */
  23890. get colorGradingEnabled(): boolean;
  23891. /**
  23892. * Gets wether the color grading effect is enabled.
  23893. */
  23894. set colorGradingEnabled(value: boolean);
  23895. /**
  23896. * Gets exposure used in the effect.
  23897. */
  23898. get exposure(): number;
  23899. /**
  23900. * Sets exposure used in the effect.
  23901. */
  23902. set exposure(value: number);
  23903. /**
  23904. * Gets wether tonemapping is enabled or not.
  23905. */
  23906. get toneMappingEnabled(): boolean;
  23907. /**
  23908. * Sets wether tonemapping is enabled or not
  23909. */
  23910. set toneMappingEnabled(value: boolean);
  23911. /**
  23912. * Gets the type of tone mapping effect.
  23913. */
  23914. get toneMappingType(): number;
  23915. /**
  23916. * Sets the type of tone mapping effect.
  23917. */
  23918. set toneMappingType(value: number);
  23919. /**
  23920. * Gets contrast used in the effect.
  23921. */
  23922. get contrast(): number;
  23923. /**
  23924. * Sets contrast used in the effect.
  23925. */
  23926. set contrast(value: number);
  23927. /**
  23928. * Gets Vignette stretch size.
  23929. */
  23930. get vignetteStretch(): number;
  23931. /**
  23932. * Sets Vignette stretch size.
  23933. */
  23934. set vignetteStretch(value: number);
  23935. /**
  23936. * Gets Vignette centre X Offset.
  23937. */
  23938. get vignetteCentreX(): number;
  23939. /**
  23940. * Sets Vignette centre X Offset.
  23941. */
  23942. set vignetteCentreX(value: number);
  23943. /**
  23944. * Gets Vignette centre Y Offset.
  23945. */
  23946. get vignetteCentreY(): number;
  23947. /**
  23948. * Sets Vignette centre Y Offset.
  23949. */
  23950. set vignetteCentreY(value: number);
  23951. /**
  23952. * Gets Vignette weight or intensity of the vignette effect.
  23953. */
  23954. get vignetteWeight(): number;
  23955. /**
  23956. * Sets Vignette weight or intensity of the vignette effect.
  23957. */
  23958. set vignetteWeight(value: number);
  23959. /**
  23960. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23961. * if vignetteEnabled is set to true.
  23962. */
  23963. get vignetteColor(): Color4;
  23964. /**
  23965. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23966. * if vignetteEnabled is set to true.
  23967. */
  23968. set vignetteColor(value: Color4);
  23969. /**
  23970. * Gets Camera field of view used by the Vignette effect.
  23971. */
  23972. get vignetteCameraFov(): number;
  23973. /**
  23974. * Sets Camera field of view used by the Vignette effect.
  23975. */
  23976. set vignetteCameraFov(value: number);
  23977. /**
  23978. * Gets the vignette blend mode allowing different kind of effect.
  23979. */
  23980. get vignetteBlendMode(): number;
  23981. /**
  23982. * Sets the vignette blend mode allowing different kind of effect.
  23983. */
  23984. set vignetteBlendMode(value: number);
  23985. /**
  23986. * Gets wether the vignette effect is enabled.
  23987. */
  23988. get vignetteEnabled(): boolean;
  23989. /**
  23990. * Sets wether the vignette effect is enabled.
  23991. */
  23992. set vignetteEnabled(value: boolean);
  23993. private _fromLinearSpace;
  23994. /**
  23995. * Gets wether the input of the processing is in Gamma or Linear Space.
  23996. */
  23997. get fromLinearSpace(): boolean;
  23998. /**
  23999. * Sets wether the input of the processing is in Gamma or Linear Space.
  24000. */
  24001. set fromLinearSpace(value: boolean);
  24002. /**
  24003. * Defines cache preventing GC.
  24004. */
  24005. private _defines;
  24006. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  24007. /**
  24008. * "ImageProcessingPostProcess"
  24009. * @returns "ImageProcessingPostProcess"
  24010. */
  24011. getClassName(): string;
  24012. /**
  24013. * @hidden
  24014. */
  24015. _updateParameters(): void;
  24016. dispose(camera?: Camera): void;
  24017. }
  24018. }
  24019. declare module BABYLON {
  24020. /** @hidden */
  24021. export var fibonacci: {
  24022. name: string;
  24023. shader: string;
  24024. };
  24025. }
  24026. declare module BABYLON {
  24027. /** @hidden */
  24028. export var subSurfaceScatteringFunctions: {
  24029. name: string;
  24030. shader: string;
  24031. };
  24032. }
  24033. declare module BABYLON {
  24034. /** @hidden */
  24035. export var diffusionProfile: {
  24036. name: string;
  24037. shader: string;
  24038. };
  24039. }
  24040. declare module BABYLON {
  24041. /** @hidden */
  24042. export var subSurfaceScatteringPixelShader: {
  24043. name: string;
  24044. shader: string;
  24045. };
  24046. }
  24047. declare module BABYLON {
  24048. /**
  24049. * Sub surface scattering post process
  24050. */
  24051. export class SubSurfaceScatteringPostProcess extends PostProcess {
  24052. /** @hidden */
  24053. texelWidth: number;
  24054. /** @hidden */
  24055. texelHeight: number;
  24056. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  24057. }
  24058. }
  24059. declare module BABYLON {
  24060. /**
  24061. * Interface for defining prepass effects in the prepass post-process pipeline
  24062. */
  24063. export interface PrePassEffectConfiguration {
  24064. /**
  24065. * Post process to attach for this effect
  24066. */
  24067. postProcess: PostProcess;
  24068. /**
  24069. * Is the effect enabled
  24070. */
  24071. enabled: boolean;
  24072. /**
  24073. * Disposes the effect configuration
  24074. */
  24075. dispose(): void;
  24076. /**
  24077. * Disposes the effect configuration
  24078. */
  24079. createPostProcess: () => PostProcess;
  24080. }
  24081. }
  24082. declare module BABYLON {
  24083. /**
  24084. * Contains all parameters needed for the prepass to perform
  24085. * screen space subsurface scattering
  24086. */
  24087. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  24088. private _ssDiffusionS;
  24089. private _ssFilterRadii;
  24090. private _ssDiffusionD;
  24091. /**
  24092. * Post process to attach for screen space subsurface scattering
  24093. */
  24094. postProcess: SubSurfaceScatteringPostProcess;
  24095. /**
  24096. * Diffusion profile color for subsurface scattering
  24097. */
  24098. get ssDiffusionS(): number[];
  24099. /**
  24100. * Diffusion profile max color channel value for subsurface scattering
  24101. */
  24102. get ssDiffusionD(): number[];
  24103. /**
  24104. * Diffusion profile filter radius for subsurface scattering
  24105. */
  24106. get ssFilterRadii(): number[];
  24107. /**
  24108. * Is subsurface enabled
  24109. */
  24110. enabled: boolean;
  24111. /**
  24112. * Diffusion profile colors for subsurface scattering
  24113. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  24114. * See ...
  24115. * Note that you can only store up to 5 of them
  24116. */
  24117. ssDiffusionProfileColors: Color3[];
  24118. /**
  24119. * Defines the ratio real world => scene units.
  24120. * Used for subsurface scattering
  24121. */
  24122. metersPerUnit: number;
  24123. private _scene;
  24124. /**
  24125. * Builds a subsurface configuration object
  24126. * @param scene The scene
  24127. */
  24128. constructor(scene: Scene);
  24129. /**
  24130. * Adds a new diffusion profile.
  24131. * Useful for more realistic subsurface scattering on diverse materials.
  24132. * @param color The color of the diffusion profile. Should be the average color of the material.
  24133. * @return The index of the diffusion profile for the material subsurface configuration
  24134. */
  24135. addDiffusionProfile(color: Color3): number;
  24136. /**
  24137. * Creates the sss post process
  24138. * @return The created post process
  24139. */
  24140. createPostProcess(): SubSurfaceScatteringPostProcess;
  24141. /**
  24142. * Deletes all diffusion profiles.
  24143. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  24144. */
  24145. clearAllDiffusionProfiles(): void;
  24146. /**
  24147. * Disposes this object
  24148. */
  24149. dispose(): void;
  24150. /**
  24151. * @hidden
  24152. * https://zero-radiance.github.io/post/sampling-diffusion/
  24153. *
  24154. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  24155. * ------------------------------------------------------------------------------------
  24156. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  24157. * PDF[r, phi, s] = r * R[r, phi, s]
  24158. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  24159. * ------------------------------------------------------------------------------------
  24160. * We importance sample the color channel with the widest scattering distance.
  24161. */
  24162. getDiffusionProfileParameters(color: Color3): number;
  24163. /**
  24164. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  24165. * 'u' is the random number (the value of the CDF): [0, 1).
  24166. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  24167. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  24168. */
  24169. private _sampleBurleyDiffusionProfile;
  24170. }
  24171. }
  24172. declare module BABYLON {
  24173. /**
  24174. * Renders a pre pass of the scene
  24175. * This means every mesh in the scene will be rendered to a render target texture
  24176. * And then this texture will be composited to the rendering canvas with post processes
  24177. * It is necessary for effects like subsurface scattering or deferred shading
  24178. */
  24179. export class PrePassRenderer {
  24180. /** @hidden */
  24181. static _SceneComponentInitialization: (scene: Scene) => void;
  24182. private _scene;
  24183. private _engine;
  24184. private _isDirty;
  24185. /**
  24186. * Number of textures in the multi render target texture where the scene is directly rendered
  24187. */
  24188. readonly mrtCount: number;
  24189. /**
  24190. * The render target where the scene is directly rendered
  24191. */
  24192. prePassRT: MultiRenderTarget;
  24193. private _mrtTypes;
  24194. private _multiRenderAttachments;
  24195. private _defaultAttachments;
  24196. private _clearAttachments;
  24197. private _postProcesses;
  24198. private readonly _clearColor;
  24199. /**
  24200. * Image processing post process for composition
  24201. */
  24202. imageProcessingPostProcess: ImageProcessingPostProcess;
  24203. /**
  24204. * Configuration for sub surface scattering post process
  24205. */
  24206. subSurfaceConfiguration: SubSurfaceConfiguration;
  24207. /**
  24208. * Should materials render their geometry on the MRT
  24209. */
  24210. materialsShouldRenderGeometry: boolean;
  24211. /**
  24212. * Should materials render the irradiance information on the MRT
  24213. */
  24214. materialsShouldRenderIrradiance: boolean;
  24215. private _enabled;
  24216. /**
  24217. * Indicates if the prepass is enabled
  24218. */
  24219. get enabled(): boolean;
  24220. /**
  24221. * How many samples are used for MSAA of the scene render target
  24222. */
  24223. get samples(): number;
  24224. set samples(n: number);
  24225. /**
  24226. * Instanciates a prepass renderer
  24227. * @param scene The scene
  24228. */
  24229. constructor(scene: Scene);
  24230. private _initializeAttachments;
  24231. private _createCompositionEffect;
  24232. /**
  24233. * Indicates if rendering a prepass is supported
  24234. */
  24235. get isSupported(): boolean;
  24236. /**
  24237. * Sets the proper output textures to draw in the engine.
  24238. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  24239. */
  24240. bindAttachmentsForEffect(effect: Effect): void;
  24241. /**
  24242. * @hidden
  24243. */
  24244. _beforeCameraDraw(): void;
  24245. /**
  24246. * @hidden
  24247. */
  24248. _afterCameraDraw(): void;
  24249. private _checkRTSize;
  24250. private _bindFrameBuffer;
  24251. /**
  24252. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  24253. */
  24254. clear(): void;
  24255. private _setState;
  24256. private _enable;
  24257. private _disable;
  24258. private _resetPostProcessChain;
  24259. private _bindPostProcessChain;
  24260. /**
  24261. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  24262. */
  24263. markAsDirty(): void;
  24264. private _update;
  24265. /**
  24266. * Disposes the prepass renderer.
  24267. */
  24268. dispose(): void;
  24269. }
  24270. }
  24271. declare module BABYLON {
  24272. /**
  24273. * Options for compiling materials.
  24274. */
  24275. export interface IMaterialCompilationOptions {
  24276. /**
  24277. * Defines whether clip planes are enabled.
  24278. */
  24279. clipPlane: boolean;
  24280. /**
  24281. * Defines whether instances are enabled.
  24282. */
  24283. useInstances: boolean;
  24284. }
  24285. /**
  24286. * Options passed when calling customShaderNameResolve
  24287. */
  24288. export interface ICustomShaderNameResolveOptions {
  24289. /**
  24290. * 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
  24291. */
  24292. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  24293. }
  24294. /**
  24295. * Base class for the main features of a material in Babylon.js
  24296. */
  24297. export class Material implements IAnimatable {
  24298. /**
  24299. * Returns the triangle fill mode
  24300. */
  24301. static readonly TriangleFillMode: number;
  24302. /**
  24303. * Returns the wireframe mode
  24304. */
  24305. static readonly WireFrameFillMode: number;
  24306. /**
  24307. * Returns the point fill mode
  24308. */
  24309. static readonly PointFillMode: number;
  24310. /**
  24311. * Returns the point list draw mode
  24312. */
  24313. static readonly PointListDrawMode: number;
  24314. /**
  24315. * Returns the line list draw mode
  24316. */
  24317. static readonly LineListDrawMode: number;
  24318. /**
  24319. * Returns the line loop draw mode
  24320. */
  24321. static readonly LineLoopDrawMode: number;
  24322. /**
  24323. * Returns the line strip draw mode
  24324. */
  24325. static readonly LineStripDrawMode: number;
  24326. /**
  24327. * Returns the triangle strip draw mode
  24328. */
  24329. static readonly TriangleStripDrawMode: number;
  24330. /**
  24331. * Returns the triangle fan draw mode
  24332. */
  24333. static readonly TriangleFanDrawMode: number;
  24334. /**
  24335. * Stores the clock-wise side orientation
  24336. */
  24337. static readonly ClockWiseSideOrientation: number;
  24338. /**
  24339. * Stores the counter clock-wise side orientation
  24340. */
  24341. static readonly CounterClockWiseSideOrientation: number;
  24342. /**
  24343. * The dirty texture flag value
  24344. */
  24345. static readonly TextureDirtyFlag: number;
  24346. /**
  24347. * The dirty light flag value
  24348. */
  24349. static readonly LightDirtyFlag: number;
  24350. /**
  24351. * The dirty fresnel flag value
  24352. */
  24353. static readonly FresnelDirtyFlag: number;
  24354. /**
  24355. * The dirty attribute flag value
  24356. */
  24357. static readonly AttributesDirtyFlag: number;
  24358. /**
  24359. * The dirty misc flag value
  24360. */
  24361. static readonly MiscDirtyFlag: number;
  24362. /**
  24363. * The all dirty flag value
  24364. */
  24365. static readonly AllDirtyFlag: number;
  24366. /**
  24367. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  24368. */
  24369. static readonly MATERIAL_OPAQUE: number;
  24370. /**
  24371. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  24372. */
  24373. static readonly MATERIAL_ALPHATEST: number;
  24374. /**
  24375. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24376. */
  24377. static readonly MATERIAL_ALPHABLEND: number;
  24378. /**
  24379. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24380. * They are also discarded below the alpha cutoff threshold to improve performances.
  24381. */
  24382. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  24383. /**
  24384. * The Whiteout method is used to blend normals.
  24385. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24386. */
  24387. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  24388. /**
  24389. * The Reoriented Normal Mapping method is used to blend normals.
  24390. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24391. */
  24392. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  24393. /**
  24394. * Custom callback helping to override the default shader used in the material.
  24395. */
  24396. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  24397. /**
  24398. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  24399. */
  24400. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  24401. /**
  24402. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  24403. * This means that the material can keep using a previous shader while a new one is being compiled.
  24404. * This is mostly used when shader parallel compilation is supported (true by default)
  24405. */
  24406. allowShaderHotSwapping: boolean;
  24407. /**
  24408. * The ID of the material
  24409. */
  24410. id: string;
  24411. /**
  24412. * Gets or sets the unique id of the material
  24413. */
  24414. uniqueId: number;
  24415. /**
  24416. * The name of the material
  24417. */
  24418. name: string;
  24419. /**
  24420. * Gets or sets user defined metadata
  24421. */
  24422. metadata: any;
  24423. /**
  24424. * For internal use only. Please do not use.
  24425. */
  24426. reservedDataStore: any;
  24427. /**
  24428. * Specifies if the ready state should be checked on each call
  24429. */
  24430. checkReadyOnEveryCall: boolean;
  24431. /**
  24432. * Specifies if the ready state should be checked once
  24433. */
  24434. checkReadyOnlyOnce: boolean;
  24435. /**
  24436. * The state of the material
  24437. */
  24438. state: string;
  24439. /**
  24440. * If the material can be rendered to several textures with MRT extension
  24441. */
  24442. get canRenderToMRT(): boolean;
  24443. /**
  24444. * The alpha value of the material
  24445. */
  24446. protected _alpha: number;
  24447. /**
  24448. * List of inspectable custom properties (used by the Inspector)
  24449. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24450. */
  24451. inspectableCustomProperties: IInspectable[];
  24452. /**
  24453. * Sets the alpha value of the material
  24454. */
  24455. set alpha(value: number);
  24456. /**
  24457. * Gets the alpha value of the material
  24458. */
  24459. get alpha(): number;
  24460. /**
  24461. * Specifies if back face culling is enabled
  24462. */
  24463. protected _backFaceCulling: boolean;
  24464. /**
  24465. * Sets the back-face culling state
  24466. */
  24467. set backFaceCulling(value: boolean);
  24468. /**
  24469. * Gets the back-face culling state
  24470. */
  24471. get backFaceCulling(): boolean;
  24472. /**
  24473. * Stores the value for side orientation
  24474. */
  24475. sideOrientation: number;
  24476. /**
  24477. * Callback triggered when the material is compiled
  24478. */
  24479. onCompiled: Nullable<(effect: Effect) => void>;
  24480. /**
  24481. * Callback triggered when an error occurs
  24482. */
  24483. onError: Nullable<(effect: Effect, errors: string) => void>;
  24484. /**
  24485. * Callback triggered to get the render target textures
  24486. */
  24487. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  24488. /**
  24489. * Gets a boolean indicating that current material needs to register RTT
  24490. */
  24491. get hasRenderTargetTextures(): boolean;
  24492. /**
  24493. * Specifies if the material should be serialized
  24494. */
  24495. doNotSerialize: boolean;
  24496. /**
  24497. * @hidden
  24498. */
  24499. _storeEffectOnSubMeshes: boolean;
  24500. /**
  24501. * Stores the animations for the material
  24502. */
  24503. animations: Nullable<Array<Animation>>;
  24504. /**
  24505. * An event triggered when the material is disposed
  24506. */
  24507. onDisposeObservable: Observable<Material>;
  24508. /**
  24509. * An observer which watches for dispose events
  24510. */
  24511. private _onDisposeObserver;
  24512. private _onUnBindObservable;
  24513. /**
  24514. * Called during a dispose event
  24515. */
  24516. set onDispose(callback: () => void);
  24517. private _onBindObservable;
  24518. /**
  24519. * An event triggered when the material is bound
  24520. */
  24521. get onBindObservable(): Observable<AbstractMesh>;
  24522. /**
  24523. * An observer which watches for bind events
  24524. */
  24525. private _onBindObserver;
  24526. /**
  24527. * Called during a bind event
  24528. */
  24529. set onBind(callback: (Mesh: AbstractMesh) => void);
  24530. /**
  24531. * An event triggered when the material is unbound
  24532. */
  24533. get onUnBindObservable(): Observable<Material>;
  24534. protected _onEffectCreatedObservable: Nullable<Observable<{
  24535. effect: Effect;
  24536. subMesh: Nullable<SubMesh>;
  24537. }>>;
  24538. /**
  24539. * An event triggered when the effect is (re)created
  24540. */
  24541. get onEffectCreatedObservable(): Observable<{
  24542. effect: Effect;
  24543. subMesh: Nullable<SubMesh>;
  24544. }>;
  24545. /**
  24546. * Stores the value of the alpha mode
  24547. */
  24548. private _alphaMode;
  24549. /**
  24550. * Sets the value of the alpha mode.
  24551. *
  24552. * | Value | Type | Description |
  24553. * | --- | --- | --- |
  24554. * | 0 | ALPHA_DISABLE | |
  24555. * | 1 | ALPHA_ADD | |
  24556. * | 2 | ALPHA_COMBINE | |
  24557. * | 3 | ALPHA_SUBTRACT | |
  24558. * | 4 | ALPHA_MULTIPLY | |
  24559. * | 5 | ALPHA_MAXIMIZED | |
  24560. * | 6 | ALPHA_ONEONE | |
  24561. * | 7 | ALPHA_PREMULTIPLIED | |
  24562. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  24563. * | 9 | ALPHA_INTERPOLATE | |
  24564. * | 10 | ALPHA_SCREENMODE | |
  24565. *
  24566. */
  24567. set alphaMode(value: number);
  24568. /**
  24569. * Gets the value of the alpha mode
  24570. */
  24571. get alphaMode(): number;
  24572. /**
  24573. * Stores the state of the need depth pre-pass value
  24574. */
  24575. private _needDepthPrePass;
  24576. /**
  24577. * Sets the need depth pre-pass value
  24578. */
  24579. set needDepthPrePass(value: boolean);
  24580. /**
  24581. * Gets the depth pre-pass value
  24582. */
  24583. get needDepthPrePass(): boolean;
  24584. /**
  24585. * Specifies if depth writing should be disabled
  24586. */
  24587. disableDepthWrite: boolean;
  24588. /**
  24589. * Specifies if color writing should be disabled
  24590. */
  24591. disableColorWrite: boolean;
  24592. /**
  24593. * Specifies if depth writing should be forced
  24594. */
  24595. forceDepthWrite: boolean;
  24596. /**
  24597. * Specifies the depth function that should be used. 0 means the default engine function
  24598. */
  24599. depthFunction: number;
  24600. /**
  24601. * Specifies if there should be a separate pass for culling
  24602. */
  24603. separateCullingPass: boolean;
  24604. /**
  24605. * Stores the state specifing if fog should be enabled
  24606. */
  24607. private _fogEnabled;
  24608. /**
  24609. * Sets the state for enabling fog
  24610. */
  24611. set fogEnabled(value: boolean);
  24612. /**
  24613. * Gets the value of the fog enabled state
  24614. */
  24615. get fogEnabled(): boolean;
  24616. /**
  24617. * Stores the size of points
  24618. */
  24619. pointSize: number;
  24620. /**
  24621. * Stores the z offset value
  24622. */
  24623. zOffset: number;
  24624. get wireframe(): boolean;
  24625. /**
  24626. * Sets the state of wireframe mode
  24627. */
  24628. set wireframe(value: boolean);
  24629. /**
  24630. * Gets the value specifying if point clouds are enabled
  24631. */
  24632. get pointsCloud(): boolean;
  24633. /**
  24634. * Sets the state of point cloud mode
  24635. */
  24636. set pointsCloud(value: boolean);
  24637. /**
  24638. * Gets the material fill mode
  24639. */
  24640. get fillMode(): number;
  24641. /**
  24642. * Sets the material fill mode
  24643. */
  24644. set fillMode(value: number);
  24645. /**
  24646. * @hidden
  24647. * Stores the effects for the material
  24648. */
  24649. _effect: Nullable<Effect>;
  24650. /**
  24651. * Specifies if uniform buffers should be used
  24652. */
  24653. private _useUBO;
  24654. /**
  24655. * Stores a reference to the scene
  24656. */
  24657. private _scene;
  24658. /**
  24659. * Stores the fill mode state
  24660. */
  24661. private _fillMode;
  24662. /**
  24663. * Specifies if the depth write state should be cached
  24664. */
  24665. private _cachedDepthWriteState;
  24666. /**
  24667. * Specifies if the color write state should be cached
  24668. */
  24669. private _cachedColorWriteState;
  24670. /**
  24671. * Specifies if the depth function state should be cached
  24672. */
  24673. private _cachedDepthFunctionState;
  24674. /**
  24675. * Stores the uniform buffer
  24676. */
  24677. protected _uniformBuffer: UniformBuffer;
  24678. /** @hidden */
  24679. _indexInSceneMaterialArray: number;
  24680. /** @hidden */
  24681. meshMap: Nullable<{
  24682. [id: string]: AbstractMesh | undefined;
  24683. }>;
  24684. /**
  24685. * Creates a material instance
  24686. * @param name defines the name of the material
  24687. * @param scene defines the scene to reference
  24688. * @param doNotAdd specifies if the material should be added to the scene
  24689. */
  24690. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24691. /**
  24692. * Returns a string representation of the current material
  24693. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24694. * @returns a string with material information
  24695. */
  24696. toString(fullDetails?: boolean): string;
  24697. /**
  24698. * Gets the class name of the material
  24699. * @returns a string with the class name of the material
  24700. */
  24701. getClassName(): string;
  24702. /**
  24703. * Specifies if updates for the material been locked
  24704. */
  24705. get isFrozen(): boolean;
  24706. /**
  24707. * Locks updates for the material
  24708. */
  24709. freeze(): void;
  24710. /**
  24711. * Unlocks updates for the material
  24712. */
  24713. unfreeze(): void;
  24714. /**
  24715. * Specifies if the material is ready to be used
  24716. * @param mesh defines the mesh to check
  24717. * @param useInstances specifies if instances should be used
  24718. * @returns a boolean indicating if the material is ready to be used
  24719. */
  24720. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24721. /**
  24722. * Specifies that the submesh is ready to be used
  24723. * @param mesh defines the mesh to check
  24724. * @param subMesh defines which submesh to check
  24725. * @param useInstances specifies that instances should be used
  24726. * @returns a boolean indicating that the submesh is ready or not
  24727. */
  24728. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24729. /**
  24730. * Returns the material effect
  24731. * @returns the effect associated with the material
  24732. */
  24733. getEffect(): Nullable<Effect>;
  24734. /**
  24735. * Returns the current scene
  24736. * @returns a Scene
  24737. */
  24738. getScene(): Scene;
  24739. /**
  24740. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24741. */
  24742. protected _forceAlphaTest: boolean;
  24743. /**
  24744. * The transparency mode of the material.
  24745. */
  24746. protected _transparencyMode: Nullable<number>;
  24747. /**
  24748. * Gets the current transparency mode.
  24749. */
  24750. get transparencyMode(): Nullable<number>;
  24751. /**
  24752. * Sets the transparency mode of the material.
  24753. *
  24754. * | Value | Type | Description |
  24755. * | ----- | ----------------------------------- | ----------- |
  24756. * | 0 | OPAQUE | |
  24757. * | 1 | ALPHATEST | |
  24758. * | 2 | ALPHABLEND | |
  24759. * | 3 | ALPHATESTANDBLEND | |
  24760. *
  24761. */
  24762. set transparencyMode(value: Nullable<number>);
  24763. /**
  24764. * Returns true if alpha blending should be disabled.
  24765. */
  24766. protected get _disableAlphaBlending(): boolean;
  24767. /**
  24768. * Specifies whether or not this material should be rendered in alpha blend mode.
  24769. * @returns a boolean specifying if alpha blending is needed
  24770. */
  24771. needAlphaBlending(): boolean;
  24772. /**
  24773. * Specifies if the mesh will require alpha blending
  24774. * @param mesh defines the mesh to check
  24775. * @returns a boolean specifying if alpha blending is needed for the mesh
  24776. */
  24777. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  24778. /**
  24779. * Specifies whether or not this material should be rendered in alpha test mode.
  24780. * @returns a boolean specifying if an alpha test is needed.
  24781. */
  24782. needAlphaTesting(): boolean;
  24783. /**
  24784. * Specifies if material alpha testing should be turned on for the mesh
  24785. * @param mesh defines the mesh to check
  24786. */
  24787. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  24788. /**
  24789. * Gets the texture used for the alpha test
  24790. * @returns the texture to use for alpha testing
  24791. */
  24792. getAlphaTestTexture(): Nullable<BaseTexture>;
  24793. /**
  24794. * Marks the material to indicate that it needs to be re-calculated
  24795. */
  24796. markDirty(): void;
  24797. /** @hidden */
  24798. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  24799. /**
  24800. * Binds the material to the mesh
  24801. * @param world defines the world transformation matrix
  24802. * @param mesh defines the mesh to bind the material to
  24803. */
  24804. bind(world: Matrix, mesh?: Mesh): void;
  24805. /**
  24806. * Binds the submesh to the material
  24807. * @param world defines the world transformation matrix
  24808. * @param mesh defines the mesh containing the submesh
  24809. * @param subMesh defines the submesh to bind the material to
  24810. */
  24811. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24812. /**
  24813. * Binds the world matrix to the material
  24814. * @param world defines the world transformation matrix
  24815. */
  24816. bindOnlyWorldMatrix(world: Matrix): void;
  24817. /**
  24818. * Binds the scene's uniform buffer to the effect.
  24819. * @param effect defines the effect to bind to the scene uniform buffer
  24820. * @param sceneUbo defines the uniform buffer storing scene data
  24821. */
  24822. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  24823. /**
  24824. * Binds the view matrix to the effect
  24825. * @param effect defines the effect to bind the view matrix to
  24826. */
  24827. bindView(effect: Effect): void;
  24828. /**
  24829. * Binds the view projection matrix to the effect
  24830. * @param effect defines the effect to bind the view projection matrix to
  24831. */
  24832. bindViewProjection(effect: Effect): void;
  24833. /**
  24834. * Processes to execute after binding the material to a mesh
  24835. * @param mesh defines the rendered mesh
  24836. */
  24837. protected _afterBind(mesh?: Mesh): void;
  24838. /**
  24839. * Unbinds the material from the mesh
  24840. */
  24841. unbind(): void;
  24842. /**
  24843. * Gets the active textures from the material
  24844. * @returns an array of textures
  24845. */
  24846. getActiveTextures(): BaseTexture[];
  24847. /**
  24848. * Specifies if the material uses a texture
  24849. * @param texture defines the texture to check against the material
  24850. * @returns a boolean specifying if the material uses the texture
  24851. */
  24852. hasTexture(texture: BaseTexture): boolean;
  24853. /**
  24854. * Makes a duplicate of the material, and gives it a new name
  24855. * @param name defines the new name for the duplicated material
  24856. * @returns the cloned material
  24857. */
  24858. clone(name: string): Nullable<Material>;
  24859. /**
  24860. * Gets the meshes bound to the material
  24861. * @returns an array of meshes bound to the material
  24862. */
  24863. getBindedMeshes(): AbstractMesh[];
  24864. /**
  24865. * Force shader compilation
  24866. * @param mesh defines the mesh associated with this material
  24867. * @param onCompiled defines a function to execute once the material is compiled
  24868. * @param options defines the options to configure the compilation
  24869. * @param onError defines a function to execute if the material fails compiling
  24870. */
  24871. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  24872. /**
  24873. * Force shader compilation
  24874. * @param mesh defines the mesh that will use this material
  24875. * @param options defines additional options for compiling the shaders
  24876. * @returns a promise that resolves when the compilation completes
  24877. */
  24878. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  24879. private static readonly _AllDirtyCallBack;
  24880. private static readonly _ImageProcessingDirtyCallBack;
  24881. private static readonly _TextureDirtyCallBack;
  24882. private static readonly _FresnelDirtyCallBack;
  24883. private static readonly _MiscDirtyCallBack;
  24884. private static readonly _LightsDirtyCallBack;
  24885. private static readonly _AttributeDirtyCallBack;
  24886. private static _FresnelAndMiscDirtyCallBack;
  24887. private static _TextureAndMiscDirtyCallBack;
  24888. private static readonly _DirtyCallbackArray;
  24889. private static readonly _RunDirtyCallBacks;
  24890. /**
  24891. * Marks a define in the material to indicate that it needs to be re-computed
  24892. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  24893. */
  24894. markAsDirty(flag: number): void;
  24895. /**
  24896. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  24897. * @param func defines a function which checks material defines against the submeshes
  24898. */
  24899. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  24900. /**
  24901. * Indicates that the scene should check if the rendering now needs a prepass
  24902. */
  24903. protected _markScenePrePassDirty(): void;
  24904. /**
  24905. * Indicates that we need to re-calculated for all submeshes
  24906. */
  24907. protected _markAllSubMeshesAsAllDirty(): void;
  24908. /**
  24909. * Indicates that image processing needs to be re-calculated for all submeshes
  24910. */
  24911. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  24912. /**
  24913. * Indicates that textures need to be re-calculated for all submeshes
  24914. */
  24915. protected _markAllSubMeshesAsTexturesDirty(): void;
  24916. /**
  24917. * Indicates that fresnel needs to be re-calculated for all submeshes
  24918. */
  24919. protected _markAllSubMeshesAsFresnelDirty(): void;
  24920. /**
  24921. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  24922. */
  24923. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  24924. /**
  24925. * Indicates that lights need to be re-calculated for all submeshes
  24926. */
  24927. protected _markAllSubMeshesAsLightsDirty(): void;
  24928. /**
  24929. * Indicates that attributes need to be re-calculated for all submeshes
  24930. */
  24931. protected _markAllSubMeshesAsAttributesDirty(): void;
  24932. /**
  24933. * Indicates that misc needs to be re-calculated for all submeshes
  24934. */
  24935. protected _markAllSubMeshesAsMiscDirty(): void;
  24936. /**
  24937. * Indicates that textures and misc need to be re-calculated for all submeshes
  24938. */
  24939. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  24940. /**
  24941. * Sets the required values to the prepass renderer.
  24942. * @param prePassRenderer defines the prepass renderer to setup.
  24943. * @returns true if the pre pass is needed.
  24944. */
  24945. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  24946. /**
  24947. * Disposes the material
  24948. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  24949. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  24950. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  24951. */
  24952. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  24953. /** @hidden */
  24954. private releaseVertexArrayObject;
  24955. /**
  24956. * Serializes this material
  24957. * @returns the serialized material object
  24958. */
  24959. serialize(): any;
  24960. /**
  24961. * Creates a material from parsed material data
  24962. * @param parsedMaterial defines parsed material data
  24963. * @param scene defines the hosting scene
  24964. * @param rootUrl defines the root URL to use to load textures
  24965. * @returns a new material
  24966. */
  24967. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  24968. }
  24969. }
  24970. declare module BABYLON {
  24971. /**
  24972. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24973. * separate meshes. This can be use to improve performances.
  24974. * @see https://doc.babylonjs.com/how_to/multi_materials
  24975. */
  24976. export class MultiMaterial extends Material {
  24977. private _subMaterials;
  24978. /**
  24979. * Gets or Sets the list of Materials used within the multi material.
  24980. * They need to be ordered according to the submeshes order in the associated mesh
  24981. */
  24982. get subMaterials(): Nullable<Material>[];
  24983. set subMaterials(value: Nullable<Material>[]);
  24984. /**
  24985. * Function used to align with Node.getChildren()
  24986. * @returns the list of Materials used within the multi material
  24987. */
  24988. getChildren(): Nullable<Material>[];
  24989. /**
  24990. * Instantiates a new Multi Material
  24991. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24992. * separate meshes. This can be use to improve performances.
  24993. * @see https://doc.babylonjs.com/how_to/multi_materials
  24994. * @param name Define the name in the scene
  24995. * @param scene Define the scene the material belongs to
  24996. */
  24997. constructor(name: string, scene: Scene);
  24998. private _hookArray;
  24999. /**
  25000. * Get one of the submaterial by its index in the submaterials array
  25001. * @param index The index to look the sub material at
  25002. * @returns The Material if the index has been defined
  25003. */
  25004. getSubMaterial(index: number): Nullable<Material>;
  25005. /**
  25006. * Get the list of active textures for the whole sub materials list.
  25007. * @returns All the textures that will be used during the rendering
  25008. */
  25009. getActiveTextures(): BaseTexture[];
  25010. /**
  25011. * Gets the current class name of the material e.g. "MultiMaterial"
  25012. * Mainly use in serialization.
  25013. * @returns the class name
  25014. */
  25015. getClassName(): string;
  25016. /**
  25017. * Checks if the material is ready to render the requested sub mesh
  25018. * @param mesh Define the mesh the submesh belongs to
  25019. * @param subMesh Define the sub mesh to look readyness for
  25020. * @param useInstances Define whether or not the material is used with instances
  25021. * @returns true if ready, otherwise false
  25022. */
  25023. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25024. /**
  25025. * Clones the current material and its related sub materials
  25026. * @param name Define the name of the newly cloned material
  25027. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25028. * @returns the cloned material
  25029. */
  25030. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  25031. /**
  25032. * Serializes the materials into a JSON representation.
  25033. * @returns the JSON representation
  25034. */
  25035. serialize(): any;
  25036. /**
  25037. * Dispose the material and release its associated resources
  25038. * @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)
  25039. * @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)
  25040. * @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)
  25041. */
  25042. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  25043. /**
  25044. * Creates a MultiMaterial from parsed MultiMaterial data.
  25045. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  25046. * @param scene defines the hosting scene
  25047. * @returns a new MultiMaterial
  25048. */
  25049. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  25050. }
  25051. }
  25052. declare module BABYLON {
  25053. /**
  25054. * Defines a subdivision inside a mesh
  25055. */
  25056. export class SubMesh implements ICullable {
  25057. /** the material index to use */
  25058. materialIndex: number;
  25059. /** vertex index start */
  25060. verticesStart: number;
  25061. /** vertices count */
  25062. verticesCount: number;
  25063. /** index start */
  25064. indexStart: number;
  25065. /** indices count */
  25066. indexCount: number;
  25067. /** @hidden */
  25068. _materialDefines: Nullable<MaterialDefines>;
  25069. /** @hidden */
  25070. _materialEffect: Nullable<Effect>;
  25071. /** @hidden */
  25072. _effectOverride: Nullable<Effect>;
  25073. /**
  25074. * Gets material defines used by the effect associated to the sub mesh
  25075. */
  25076. get materialDefines(): Nullable<MaterialDefines>;
  25077. /**
  25078. * Sets material defines used by the effect associated to the sub mesh
  25079. */
  25080. set materialDefines(defines: Nullable<MaterialDefines>);
  25081. /**
  25082. * Gets associated effect
  25083. */
  25084. get effect(): Nullable<Effect>;
  25085. /**
  25086. * Sets associated effect (effect used to render this submesh)
  25087. * @param effect defines the effect to associate with
  25088. * @param defines defines the set of defines used to compile this effect
  25089. */
  25090. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  25091. /** @hidden */
  25092. _linesIndexCount: number;
  25093. private _mesh;
  25094. private _renderingMesh;
  25095. private _boundingInfo;
  25096. private _linesIndexBuffer;
  25097. /** @hidden */
  25098. _lastColliderWorldVertices: Nullable<Vector3[]>;
  25099. /** @hidden */
  25100. _trianglePlanes: Plane[];
  25101. /** @hidden */
  25102. _lastColliderTransformMatrix: Nullable<Matrix>;
  25103. /** @hidden */
  25104. _renderId: number;
  25105. /** @hidden */
  25106. _alphaIndex: number;
  25107. /** @hidden */
  25108. _distanceToCamera: number;
  25109. /** @hidden */
  25110. _id: number;
  25111. private _currentMaterial;
  25112. /**
  25113. * Add a new submesh to a mesh
  25114. * @param materialIndex defines the material index to use
  25115. * @param verticesStart defines vertex index start
  25116. * @param verticesCount defines vertices count
  25117. * @param indexStart defines index start
  25118. * @param indexCount defines indices count
  25119. * @param mesh defines the parent mesh
  25120. * @param renderingMesh defines an optional rendering mesh
  25121. * @param createBoundingBox defines if bounding box should be created for this submesh
  25122. * @returns the new submesh
  25123. */
  25124. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  25125. /**
  25126. * Creates a new submesh
  25127. * @param materialIndex defines the material index to use
  25128. * @param verticesStart defines vertex index start
  25129. * @param verticesCount defines vertices count
  25130. * @param indexStart defines index start
  25131. * @param indexCount defines indices count
  25132. * @param mesh defines the parent mesh
  25133. * @param renderingMesh defines an optional rendering mesh
  25134. * @param createBoundingBox defines if bounding box should be created for this submesh
  25135. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  25136. */
  25137. constructor(
  25138. /** the material index to use */
  25139. materialIndex: number,
  25140. /** vertex index start */
  25141. verticesStart: number,
  25142. /** vertices count */
  25143. verticesCount: number,
  25144. /** index start */
  25145. indexStart: number,
  25146. /** indices count */
  25147. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  25148. /**
  25149. * Returns true if this submesh covers the entire parent mesh
  25150. * @ignorenaming
  25151. */
  25152. get IsGlobal(): boolean;
  25153. /**
  25154. * Returns the submesh BoudingInfo object
  25155. * @returns current bounding info (or mesh's one if the submesh is global)
  25156. */
  25157. getBoundingInfo(): BoundingInfo;
  25158. /**
  25159. * Sets the submesh BoundingInfo
  25160. * @param boundingInfo defines the new bounding info to use
  25161. * @returns the SubMesh
  25162. */
  25163. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  25164. /**
  25165. * Returns the mesh of the current submesh
  25166. * @return the parent mesh
  25167. */
  25168. getMesh(): AbstractMesh;
  25169. /**
  25170. * Returns the rendering mesh of the submesh
  25171. * @returns the rendering mesh (could be different from parent mesh)
  25172. */
  25173. getRenderingMesh(): Mesh;
  25174. /**
  25175. * Returns the replacement mesh of the submesh
  25176. * @returns the replacement mesh (could be different from parent mesh)
  25177. */
  25178. getReplacementMesh(): Nullable<AbstractMesh>;
  25179. /**
  25180. * Returns the effective mesh of the submesh
  25181. * @returns the effective mesh (could be different from parent mesh)
  25182. */
  25183. getEffectiveMesh(): AbstractMesh;
  25184. /**
  25185. * Returns the submesh material
  25186. * @returns null or the current material
  25187. */
  25188. getMaterial(): Nullable<Material>;
  25189. private _IsMultiMaterial;
  25190. /**
  25191. * Sets a new updated BoundingInfo object to the submesh
  25192. * @param data defines an optional position array to use to determine the bounding info
  25193. * @returns the SubMesh
  25194. */
  25195. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  25196. /** @hidden */
  25197. _checkCollision(collider: Collider): boolean;
  25198. /**
  25199. * Updates the submesh BoundingInfo
  25200. * @param world defines the world matrix to use to update the bounding info
  25201. * @returns the submesh
  25202. */
  25203. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  25204. /**
  25205. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  25206. * @param frustumPlanes defines the frustum planes
  25207. * @returns true if the submesh is intersecting with the frustum
  25208. */
  25209. isInFrustum(frustumPlanes: Plane[]): boolean;
  25210. /**
  25211. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  25212. * @param frustumPlanes defines the frustum planes
  25213. * @returns true if the submesh is inside the frustum
  25214. */
  25215. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25216. /**
  25217. * Renders the submesh
  25218. * @param enableAlphaMode defines if alpha needs to be used
  25219. * @returns the submesh
  25220. */
  25221. render(enableAlphaMode: boolean): SubMesh;
  25222. /**
  25223. * @hidden
  25224. */
  25225. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  25226. /**
  25227. * Checks if the submesh intersects with a ray
  25228. * @param ray defines the ray to test
  25229. * @returns true is the passed ray intersects the submesh bounding box
  25230. */
  25231. canIntersects(ray: Ray): boolean;
  25232. /**
  25233. * Intersects current submesh with a ray
  25234. * @param ray defines the ray to test
  25235. * @param positions defines mesh's positions array
  25236. * @param indices defines mesh's indices array
  25237. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25238. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25239. * @returns intersection info or null if no intersection
  25240. */
  25241. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  25242. /** @hidden */
  25243. private _intersectLines;
  25244. /** @hidden */
  25245. private _intersectUnIndexedLines;
  25246. /** @hidden */
  25247. private _intersectTriangles;
  25248. /** @hidden */
  25249. private _intersectUnIndexedTriangles;
  25250. /** @hidden */
  25251. _rebuild(): void;
  25252. /**
  25253. * Creates a new submesh from the passed mesh
  25254. * @param newMesh defines the new hosting mesh
  25255. * @param newRenderingMesh defines an optional rendering mesh
  25256. * @returns the new submesh
  25257. */
  25258. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  25259. /**
  25260. * Release associated resources
  25261. */
  25262. dispose(): void;
  25263. /**
  25264. * Gets the class name
  25265. * @returns the string "SubMesh".
  25266. */
  25267. getClassName(): string;
  25268. /**
  25269. * Creates a new submesh from indices data
  25270. * @param materialIndex the index of the main mesh material
  25271. * @param startIndex the index where to start the copy in the mesh indices array
  25272. * @param indexCount the number of indices to copy then from the startIndex
  25273. * @param mesh the main mesh to create the submesh from
  25274. * @param renderingMesh the optional rendering mesh
  25275. * @returns a new submesh
  25276. */
  25277. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  25278. }
  25279. }
  25280. declare module BABYLON {
  25281. /**
  25282. * Class used to represent data loading progression
  25283. */
  25284. export class SceneLoaderFlags {
  25285. private static _ForceFullSceneLoadingForIncremental;
  25286. private static _ShowLoadingScreen;
  25287. private static _CleanBoneMatrixWeights;
  25288. private static _loggingLevel;
  25289. /**
  25290. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  25291. */
  25292. static get ForceFullSceneLoadingForIncremental(): boolean;
  25293. static set ForceFullSceneLoadingForIncremental(value: boolean);
  25294. /**
  25295. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  25296. */
  25297. static get ShowLoadingScreen(): boolean;
  25298. static set ShowLoadingScreen(value: boolean);
  25299. /**
  25300. * Defines the current logging level (while loading the scene)
  25301. * @ignorenaming
  25302. */
  25303. static get loggingLevel(): number;
  25304. static set loggingLevel(value: number);
  25305. /**
  25306. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  25307. */
  25308. static get CleanBoneMatrixWeights(): boolean;
  25309. static set CleanBoneMatrixWeights(value: boolean);
  25310. }
  25311. }
  25312. declare module BABYLON {
  25313. /**
  25314. * Class used to store geometry data (vertex buffers + index buffer)
  25315. */
  25316. export class Geometry implements IGetSetVerticesData {
  25317. /**
  25318. * Gets or sets the ID of the geometry
  25319. */
  25320. id: string;
  25321. /**
  25322. * Gets or sets the unique ID of the geometry
  25323. */
  25324. uniqueId: number;
  25325. /**
  25326. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25327. */
  25328. delayLoadState: number;
  25329. /**
  25330. * Gets the file containing the data to load when running in delay load state
  25331. */
  25332. delayLoadingFile: Nullable<string>;
  25333. /**
  25334. * Callback called when the geometry is updated
  25335. */
  25336. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25337. private _scene;
  25338. private _engine;
  25339. private _meshes;
  25340. private _totalVertices;
  25341. /** @hidden */
  25342. _indices: IndicesArray;
  25343. /** @hidden */
  25344. _vertexBuffers: {
  25345. [key: string]: VertexBuffer;
  25346. };
  25347. private _isDisposed;
  25348. private _extend;
  25349. private _boundingBias;
  25350. /** @hidden */
  25351. _delayInfo: Array<string>;
  25352. private _indexBuffer;
  25353. private _indexBufferIsUpdatable;
  25354. /** @hidden */
  25355. _boundingInfo: Nullable<BoundingInfo>;
  25356. /** @hidden */
  25357. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25358. /** @hidden */
  25359. _softwareSkinningFrameId: number;
  25360. private _vertexArrayObjects;
  25361. private _updatable;
  25362. /** @hidden */
  25363. _positions: Nullable<Vector3[]>;
  25364. /**
  25365. * 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
  25366. */
  25367. get boundingBias(): Vector2;
  25368. /**
  25369. * 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
  25370. */
  25371. set boundingBias(value: Vector2);
  25372. /**
  25373. * Static function used to attach a new empty geometry to a mesh
  25374. * @param mesh defines the mesh to attach the geometry to
  25375. * @returns the new Geometry
  25376. */
  25377. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25378. /** Get the list of meshes using this geometry */
  25379. get meshes(): Mesh[];
  25380. /**
  25381. * 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
  25382. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  25383. */
  25384. useBoundingInfoFromGeometry: boolean;
  25385. /**
  25386. * Creates a new geometry
  25387. * @param id defines the unique ID
  25388. * @param scene defines the hosting scene
  25389. * @param vertexData defines the VertexData used to get geometry data
  25390. * @param updatable defines if geometry must be updatable (false by default)
  25391. * @param mesh defines the mesh that will be associated with the geometry
  25392. */
  25393. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25394. /**
  25395. * Gets the current extend of the geometry
  25396. */
  25397. get extend(): {
  25398. minimum: Vector3;
  25399. maximum: Vector3;
  25400. };
  25401. /**
  25402. * Gets the hosting scene
  25403. * @returns the hosting Scene
  25404. */
  25405. getScene(): Scene;
  25406. /**
  25407. * Gets the hosting engine
  25408. * @returns the hosting Engine
  25409. */
  25410. getEngine(): Engine;
  25411. /**
  25412. * Defines if the geometry is ready to use
  25413. * @returns true if the geometry is ready to be used
  25414. */
  25415. isReady(): boolean;
  25416. /**
  25417. * Gets a value indicating that the geometry should not be serialized
  25418. */
  25419. get doNotSerialize(): boolean;
  25420. /** @hidden */
  25421. _rebuild(): void;
  25422. /**
  25423. * Affects all geometry data in one call
  25424. * @param vertexData defines the geometry data
  25425. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25426. */
  25427. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25428. /**
  25429. * Set specific vertex data
  25430. * @param kind defines the data kind (Position, normal, etc...)
  25431. * @param data defines the vertex data to use
  25432. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25433. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25434. */
  25435. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25436. /**
  25437. * Removes a specific vertex data
  25438. * @param kind defines the data kind (Position, normal, etc...)
  25439. */
  25440. removeVerticesData(kind: string): void;
  25441. /**
  25442. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25443. * @param buffer defines the vertex buffer to use
  25444. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25445. */
  25446. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25447. /**
  25448. * Update a specific vertex buffer
  25449. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  25450. * It will do nothing if the buffer is not updatable
  25451. * @param kind defines the data kind (Position, normal, etc...)
  25452. * @param data defines the data to use
  25453. * @param offset defines the offset in the target buffer where to store the data
  25454. * @param useBytes set to true if the offset is in bytes
  25455. */
  25456. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25457. /**
  25458. * Update a specific vertex buffer
  25459. * This function will create a new buffer if the current one is not updatable
  25460. * @param kind defines the data kind (Position, normal, etc...)
  25461. * @param data defines the data to use
  25462. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25463. */
  25464. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25465. private _updateBoundingInfo;
  25466. /** @hidden */
  25467. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  25468. /**
  25469. * Gets total number of vertices
  25470. * @returns the total number of vertices
  25471. */
  25472. getTotalVertices(): number;
  25473. /**
  25474. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25475. * @param kind defines the data kind (Position, normal, etc...)
  25476. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25477. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25478. * @returns a float array containing vertex data
  25479. */
  25480. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25481. /**
  25482. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25483. * @param kind defines the data kind (Position, normal, etc...)
  25484. * @returns true if the vertex buffer with the specified kind is updatable
  25485. */
  25486. isVertexBufferUpdatable(kind: string): boolean;
  25487. /**
  25488. * Gets a specific vertex buffer
  25489. * @param kind defines the data kind (Position, normal, etc...)
  25490. * @returns a VertexBuffer
  25491. */
  25492. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25493. /**
  25494. * Returns all vertex buffers
  25495. * @return an object holding all vertex buffers indexed by kind
  25496. */
  25497. getVertexBuffers(): Nullable<{
  25498. [key: string]: VertexBuffer;
  25499. }>;
  25500. /**
  25501. * Gets a boolean indicating if specific vertex buffer is present
  25502. * @param kind defines the data kind (Position, normal, etc...)
  25503. * @returns true if data is present
  25504. */
  25505. isVerticesDataPresent(kind: string): boolean;
  25506. /**
  25507. * Gets a list of all attached data kinds (Position, normal, etc...)
  25508. * @returns a list of string containing all kinds
  25509. */
  25510. getVerticesDataKinds(): string[];
  25511. /**
  25512. * Update index buffer
  25513. * @param indices defines the indices to store in the index buffer
  25514. * @param offset defines the offset in the target buffer where to store the data
  25515. * @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)
  25516. */
  25517. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  25518. /**
  25519. * Creates a new index buffer
  25520. * @param indices defines the indices to store in the index buffer
  25521. * @param totalVertices defines the total number of vertices (could be null)
  25522. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25523. */
  25524. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25525. /**
  25526. * Return the total number of indices
  25527. * @returns the total number of indices
  25528. */
  25529. getTotalIndices(): number;
  25530. /**
  25531. * Gets the index buffer array
  25532. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25533. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25534. * @returns the index buffer array
  25535. */
  25536. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25537. /**
  25538. * Gets the index buffer
  25539. * @return the index buffer
  25540. */
  25541. getIndexBuffer(): Nullable<DataBuffer>;
  25542. /** @hidden */
  25543. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25544. /**
  25545. * Release the associated resources for a specific mesh
  25546. * @param mesh defines the source mesh
  25547. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25548. */
  25549. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25550. /**
  25551. * Apply current geometry to a given mesh
  25552. * @param mesh defines the mesh to apply geometry to
  25553. */
  25554. applyToMesh(mesh: Mesh): void;
  25555. private _updateExtend;
  25556. private _applyToMesh;
  25557. private notifyUpdate;
  25558. /**
  25559. * Load the geometry if it was flagged as delay loaded
  25560. * @param scene defines the hosting scene
  25561. * @param onLoaded defines a callback called when the geometry is loaded
  25562. */
  25563. load(scene: Scene, onLoaded?: () => void): void;
  25564. private _queueLoad;
  25565. /**
  25566. * Invert the geometry to move from a right handed system to a left handed one.
  25567. */
  25568. toLeftHanded(): void;
  25569. /** @hidden */
  25570. _resetPointsArrayCache(): void;
  25571. /** @hidden */
  25572. _generatePointsArray(): boolean;
  25573. /**
  25574. * Gets a value indicating if the geometry is disposed
  25575. * @returns true if the geometry was disposed
  25576. */
  25577. isDisposed(): boolean;
  25578. private _disposeVertexArrayObjects;
  25579. /**
  25580. * Free all associated resources
  25581. */
  25582. dispose(): void;
  25583. /**
  25584. * Clone the current geometry into a new geometry
  25585. * @param id defines the unique ID of the new geometry
  25586. * @returns a new geometry object
  25587. */
  25588. copy(id: string): Geometry;
  25589. /**
  25590. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25591. * @return a JSON representation of the current geometry data (without the vertices data)
  25592. */
  25593. serialize(): any;
  25594. private toNumberArray;
  25595. /**
  25596. * Serialize all vertices data into a JSON oject
  25597. * @returns a JSON representation of the current geometry data
  25598. */
  25599. serializeVerticeData(): any;
  25600. /**
  25601. * Extracts a clone of a mesh geometry
  25602. * @param mesh defines the source mesh
  25603. * @param id defines the unique ID of the new geometry object
  25604. * @returns the new geometry object
  25605. */
  25606. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25607. /**
  25608. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25609. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25610. * Be aware Math.random() could cause collisions, but:
  25611. * "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"
  25612. * @returns a string containing a new GUID
  25613. */
  25614. static RandomId(): string;
  25615. /** @hidden */
  25616. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25617. private static _CleanMatricesWeights;
  25618. /**
  25619. * Create a new geometry from persisted data (Using .babylon file format)
  25620. * @param parsedVertexData defines the persisted data
  25621. * @param scene defines the hosting scene
  25622. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25623. * @returns the new geometry object
  25624. */
  25625. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25626. }
  25627. }
  25628. declare module BABYLON {
  25629. /**
  25630. * Define an interface for all classes that will get and set the data on vertices
  25631. */
  25632. export interface IGetSetVerticesData {
  25633. /**
  25634. * Gets a boolean indicating if specific vertex data is present
  25635. * @param kind defines the vertex data kind to use
  25636. * @returns true is data kind is present
  25637. */
  25638. isVerticesDataPresent(kind: string): boolean;
  25639. /**
  25640. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25641. * @param kind defines the data kind (Position, normal, etc...)
  25642. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25643. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25644. * @returns a float array containing vertex data
  25645. */
  25646. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25647. /**
  25648. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25649. * @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.
  25650. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25651. * @returns the indices array or an empty array if the mesh has no geometry
  25652. */
  25653. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25654. /**
  25655. * Set specific vertex data
  25656. * @param kind defines the data kind (Position, normal, etc...)
  25657. * @param data defines the vertex data to use
  25658. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25659. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25660. */
  25661. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25662. /**
  25663. * Update a specific associated vertex buffer
  25664. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25665. * - VertexBuffer.PositionKind
  25666. * - VertexBuffer.UVKind
  25667. * - VertexBuffer.UV2Kind
  25668. * - VertexBuffer.UV3Kind
  25669. * - VertexBuffer.UV4Kind
  25670. * - VertexBuffer.UV5Kind
  25671. * - VertexBuffer.UV6Kind
  25672. * - VertexBuffer.ColorKind
  25673. * - VertexBuffer.MatricesIndicesKind
  25674. * - VertexBuffer.MatricesIndicesExtraKind
  25675. * - VertexBuffer.MatricesWeightsKind
  25676. * - VertexBuffer.MatricesWeightsExtraKind
  25677. * @param data defines the data source
  25678. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25679. * @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)
  25680. */
  25681. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25682. /**
  25683. * Creates a new index buffer
  25684. * @param indices defines the indices to store in the index buffer
  25685. * @param totalVertices defines the total number of vertices (could be null)
  25686. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25687. */
  25688. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25689. }
  25690. /**
  25691. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25692. */
  25693. export class VertexData {
  25694. /**
  25695. * Mesh side orientation : usually the external or front surface
  25696. */
  25697. static readonly FRONTSIDE: number;
  25698. /**
  25699. * Mesh side orientation : usually the internal or back surface
  25700. */
  25701. static readonly BACKSIDE: number;
  25702. /**
  25703. * Mesh side orientation : both internal and external or front and back surfaces
  25704. */
  25705. static readonly DOUBLESIDE: number;
  25706. /**
  25707. * Mesh side orientation : by default, `FRONTSIDE`
  25708. */
  25709. static readonly DEFAULTSIDE: number;
  25710. /**
  25711. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25712. */
  25713. positions: Nullable<FloatArray>;
  25714. /**
  25715. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25716. */
  25717. normals: Nullable<FloatArray>;
  25718. /**
  25719. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25720. */
  25721. tangents: Nullable<FloatArray>;
  25722. /**
  25723. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25724. */
  25725. uvs: Nullable<FloatArray>;
  25726. /**
  25727. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25728. */
  25729. uvs2: Nullable<FloatArray>;
  25730. /**
  25731. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25732. */
  25733. uvs3: Nullable<FloatArray>;
  25734. /**
  25735. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25736. */
  25737. uvs4: Nullable<FloatArray>;
  25738. /**
  25739. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25740. */
  25741. uvs5: Nullable<FloatArray>;
  25742. /**
  25743. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25744. */
  25745. uvs6: Nullable<FloatArray>;
  25746. /**
  25747. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25748. */
  25749. colors: Nullable<FloatArray>;
  25750. /**
  25751. * 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).
  25752. */
  25753. matricesIndices: Nullable<FloatArray>;
  25754. /**
  25755. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25756. */
  25757. matricesWeights: Nullable<FloatArray>;
  25758. /**
  25759. * An array extending the number of possible indices
  25760. */
  25761. matricesIndicesExtra: Nullable<FloatArray>;
  25762. /**
  25763. * An array extending the number of possible weights when the number of indices is extended
  25764. */
  25765. matricesWeightsExtra: Nullable<FloatArray>;
  25766. /**
  25767. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25768. */
  25769. indices: Nullable<IndicesArray>;
  25770. /**
  25771. * Uses the passed data array to set the set the values for the specified kind of data
  25772. * @param data a linear array of floating numbers
  25773. * @param kind the type of data that is being set, eg positions, colors etc
  25774. */
  25775. set(data: FloatArray, kind: string): void;
  25776. /**
  25777. * Associates the vertexData to the passed Mesh.
  25778. * Sets it as updatable or not (default `false`)
  25779. * @param mesh the mesh the vertexData is applied to
  25780. * @param updatable when used and having the value true allows new data to update the vertexData
  25781. * @returns the VertexData
  25782. */
  25783. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25784. /**
  25785. * Associates the vertexData to the passed Geometry.
  25786. * Sets it as updatable or not (default `false`)
  25787. * @param geometry the geometry the vertexData is applied to
  25788. * @param updatable when used and having the value true allows new data to update the vertexData
  25789. * @returns VertexData
  25790. */
  25791. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  25792. /**
  25793. * Updates the associated mesh
  25794. * @param mesh the mesh to be updated
  25795. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25796. * @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
  25797. * @returns VertexData
  25798. */
  25799. updateMesh(mesh: Mesh): VertexData;
  25800. /**
  25801. * Updates the associated geometry
  25802. * @param geometry the geometry to be updated
  25803. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25804. * @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
  25805. * @returns VertexData.
  25806. */
  25807. updateGeometry(geometry: Geometry): VertexData;
  25808. private _applyTo;
  25809. private _update;
  25810. /**
  25811. * Transforms each position and each normal of the vertexData according to the passed Matrix
  25812. * @param matrix the transforming matrix
  25813. * @returns the VertexData
  25814. */
  25815. transform(matrix: Matrix): VertexData;
  25816. /**
  25817. * Merges the passed VertexData into the current one
  25818. * @param other the VertexData to be merged into the current one
  25819. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  25820. * @returns the modified VertexData
  25821. */
  25822. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  25823. private _mergeElement;
  25824. private _validate;
  25825. /**
  25826. * Serializes the VertexData
  25827. * @returns a serialized object
  25828. */
  25829. serialize(): any;
  25830. /**
  25831. * Extracts the vertexData from a mesh
  25832. * @param mesh the mesh from which to extract the VertexData
  25833. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  25834. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25835. * @returns the object VertexData associated to the passed mesh
  25836. */
  25837. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25838. /**
  25839. * Extracts the vertexData from the geometry
  25840. * @param geometry the geometry from which to extract the VertexData
  25841. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  25842. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25843. * @returns the object VertexData associated to the passed mesh
  25844. */
  25845. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25846. private static _ExtractFrom;
  25847. /**
  25848. * Creates the VertexData for a Ribbon
  25849. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  25850. * * pathArray array of paths, each of which an array of successive Vector3
  25851. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  25852. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  25853. * * 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
  25854. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25855. * * 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)
  25856. * * 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)
  25857. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  25858. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  25859. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  25860. * @returns the VertexData of the ribbon
  25861. */
  25862. static CreateRibbon(options: {
  25863. pathArray: Vector3[][];
  25864. closeArray?: boolean;
  25865. closePath?: boolean;
  25866. offset?: number;
  25867. sideOrientation?: number;
  25868. frontUVs?: Vector4;
  25869. backUVs?: Vector4;
  25870. invertUV?: boolean;
  25871. uvs?: Vector2[];
  25872. colors?: Color4[];
  25873. }): VertexData;
  25874. /**
  25875. * Creates the VertexData for a box
  25876. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25877. * * size sets the width, height and depth of the box to the value of size, optional default 1
  25878. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  25879. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  25880. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  25881. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25882. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25883. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25884. * * 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)
  25885. * * 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)
  25886. * @returns the VertexData of the box
  25887. */
  25888. static CreateBox(options: {
  25889. size?: number;
  25890. width?: number;
  25891. height?: number;
  25892. depth?: number;
  25893. faceUV?: Vector4[];
  25894. faceColors?: Color4[];
  25895. sideOrientation?: number;
  25896. frontUVs?: Vector4;
  25897. backUVs?: Vector4;
  25898. }): VertexData;
  25899. /**
  25900. * Creates the VertexData for a tiled box
  25901. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25902. * * faceTiles sets the pattern, tile size and number of tiles for a face
  25903. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25904. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25905. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25906. * @returns the VertexData of the box
  25907. */
  25908. static CreateTiledBox(options: {
  25909. pattern?: number;
  25910. width?: number;
  25911. height?: number;
  25912. depth?: number;
  25913. tileSize?: number;
  25914. tileWidth?: number;
  25915. tileHeight?: number;
  25916. alignHorizontal?: number;
  25917. alignVertical?: number;
  25918. faceUV?: Vector4[];
  25919. faceColors?: Color4[];
  25920. sideOrientation?: number;
  25921. }): VertexData;
  25922. /**
  25923. * Creates the VertexData for a tiled plane
  25924. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25925. * * pattern a limited pattern arrangement depending on the number
  25926. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  25927. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  25928. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  25929. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25930. * * 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)
  25931. * * 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)
  25932. * @returns the VertexData of the tiled plane
  25933. */
  25934. static CreateTiledPlane(options: {
  25935. pattern?: number;
  25936. tileSize?: number;
  25937. tileWidth?: number;
  25938. tileHeight?: number;
  25939. size?: number;
  25940. width?: number;
  25941. height?: number;
  25942. alignHorizontal?: number;
  25943. alignVertical?: number;
  25944. sideOrientation?: number;
  25945. frontUVs?: Vector4;
  25946. backUVs?: Vector4;
  25947. }): VertexData;
  25948. /**
  25949. * Creates the VertexData for an ellipsoid, defaults to a sphere
  25950. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25951. * * segments sets the number of horizontal strips optional, default 32
  25952. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  25953. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  25954. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  25955. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  25956. * * 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
  25957. * * 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
  25958. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25959. * * 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)
  25960. * * 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)
  25961. * @returns the VertexData of the ellipsoid
  25962. */
  25963. static CreateSphere(options: {
  25964. segments?: number;
  25965. diameter?: number;
  25966. diameterX?: number;
  25967. diameterY?: number;
  25968. diameterZ?: number;
  25969. arc?: number;
  25970. slice?: number;
  25971. sideOrientation?: number;
  25972. frontUVs?: Vector4;
  25973. backUVs?: Vector4;
  25974. }): VertexData;
  25975. /**
  25976. * Creates the VertexData for a cylinder, cone or prism
  25977. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25978. * * height sets the height (y direction) of the cylinder, optional, default 2
  25979. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  25980. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  25981. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  25982. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25983. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  25984. * * 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
  25985. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25986. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25987. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  25988. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  25989. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25990. * * 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)
  25991. * * 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)
  25992. * @returns the VertexData of the cylinder, cone or prism
  25993. */
  25994. static CreateCylinder(options: {
  25995. height?: number;
  25996. diameterTop?: number;
  25997. diameterBottom?: number;
  25998. diameter?: number;
  25999. tessellation?: number;
  26000. subdivisions?: number;
  26001. arc?: number;
  26002. faceColors?: Color4[];
  26003. faceUV?: Vector4[];
  26004. hasRings?: boolean;
  26005. enclose?: boolean;
  26006. sideOrientation?: number;
  26007. frontUVs?: Vector4;
  26008. backUVs?: Vector4;
  26009. }): VertexData;
  26010. /**
  26011. * Creates the VertexData for a torus
  26012. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26013. * * diameter the diameter of the torus, optional default 1
  26014. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26015. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26016. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26017. * * 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)
  26018. * * 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)
  26019. * @returns the VertexData of the torus
  26020. */
  26021. static CreateTorus(options: {
  26022. diameter?: number;
  26023. thickness?: number;
  26024. tessellation?: number;
  26025. sideOrientation?: number;
  26026. frontUVs?: Vector4;
  26027. backUVs?: Vector4;
  26028. }): VertexData;
  26029. /**
  26030. * Creates the VertexData of the LineSystem
  26031. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26032. * - lines an array of lines, each line being an array of successive Vector3
  26033. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26034. * @returns the VertexData of the LineSystem
  26035. */
  26036. static CreateLineSystem(options: {
  26037. lines: Vector3[][];
  26038. colors?: Nullable<Color4[][]>;
  26039. }): VertexData;
  26040. /**
  26041. * Create the VertexData for a DashedLines
  26042. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26043. * - points an array successive Vector3
  26044. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26045. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26046. * - dashNb the intended total number of dashes, optional, default 200
  26047. * @returns the VertexData for the DashedLines
  26048. */
  26049. static CreateDashedLines(options: {
  26050. points: Vector3[];
  26051. dashSize?: number;
  26052. gapSize?: number;
  26053. dashNb?: number;
  26054. }): VertexData;
  26055. /**
  26056. * Creates the VertexData for a Ground
  26057. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26058. * - width the width (x direction) of the ground, optional, default 1
  26059. * - height the height (z direction) of the ground, optional, default 1
  26060. * - subdivisions the number of subdivisions per side, optional, default 1
  26061. * @returns the VertexData of the Ground
  26062. */
  26063. static CreateGround(options: {
  26064. width?: number;
  26065. height?: number;
  26066. subdivisions?: number;
  26067. subdivisionsX?: number;
  26068. subdivisionsY?: number;
  26069. }): VertexData;
  26070. /**
  26071. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  26072. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26073. * * xmin the ground minimum X coordinate, optional, default -1
  26074. * * zmin the ground minimum Z coordinate, optional, default -1
  26075. * * xmax the ground maximum X coordinate, optional, default 1
  26076. * * zmax the ground maximum Z coordinate, optional, default 1
  26077. * * 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}
  26078. * * 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}
  26079. * @returns the VertexData of the TiledGround
  26080. */
  26081. static CreateTiledGround(options: {
  26082. xmin: number;
  26083. zmin: number;
  26084. xmax: number;
  26085. zmax: number;
  26086. subdivisions?: {
  26087. w: number;
  26088. h: number;
  26089. };
  26090. precision?: {
  26091. w: number;
  26092. h: number;
  26093. };
  26094. }): VertexData;
  26095. /**
  26096. * Creates the VertexData of the Ground designed from a heightmap
  26097. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  26098. * * width the width (x direction) of the ground
  26099. * * height the height (z direction) of the ground
  26100. * * subdivisions the number of subdivisions per side
  26101. * * minHeight the minimum altitude on the ground, optional, default 0
  26102. * * maxHeight the maximum altitude on the ground, optional default 1
  26103. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  26104. * * buffer the array holding the image color data
  26105. * * bufferWidth the width of image
  26106. * * bufferHeight the height of image
  26107. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  26108. * @returns the VertexData of the Ground designed from a heightmap
  26109. */
  26110. static CreateGroundFromHeightMap(options: {
  26111. width: number;
  26112. height: number;
  26113. subdivisions: number;
  26114. minHeight: number;
  26115. maxHeight: number;
  26116. colorFilter: Color3;
  26117. buffer: Uint8Array;
  26118. bufferWidth: number;
  26119. bufferHeight: number;
  26120. alphaFilter: number;
  26121. }): VertexData;
  26122. /**
  26123. * Creates the VertexData for a Plane
  26124. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  26125. * * size sets the width and height of the plane to the value of size, optional default 1
  26126. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  26127. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  26128. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26129. * * 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)
  26130. * * 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)
  26131. * @returns the VertexData of the box
  26132. */
  26133. static CreatePlane(options: {
  26134. size?: number;
  26135. width?: number;
  26136. height?: number;
  26137. sideOrientation?: number;
  26138. frontUVs?: Vector4;
  26139. backUVs?: Vector4;
  26140. }): VertexData;
  26141. /**
  26142. * Creates the VertexData of the Disc or regular Polygon
  26143. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  26144. * * radius the radius of the disc, optional default 0.5
  26145. * * tessellation the number of polygon sides, optional, default 64
  26146. * * 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
  26147. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26148. * * 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)
  26149. * * 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)
  26150. * @returns the VertexData of the box
  26151. */
  26152. static CreateDisc(options: {
  26153. radius?: number;
  26154. tessellation?: number;
  26155. arc?: number;
  26156. sideOrientation?: number;
  26157. frontUVs?: Vector4;
  26158. backUVs?: Vector4;
  26159. }): VertexData;
  26160. /**
  26161. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  26162. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  26163. * @param polygon a mesh built from polygonTriangulation.build()
  26164. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26165. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26166. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26167. * @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)
  26168. * @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)
  26169. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  26170. * @returns the VertexData of the Polygon
  26171. */
  26172. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  26173. /**
  26174. * Creates the VertexData of the IcoSphere
  26175. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  26176. * * radius the radius of the IcoSphere, optional default 1
  26177. * * radiusX allows stretching in the x direction, optional, default radius
  26178. * * radiusY allows stretching in the y direction, optional, default radius
  26179. * * radiusZ allows stretching in the z direction, optional, default radius
  26180. * * flat when true creates a flat shaded mesh, optional, default true
  26181. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26182. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26183. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  26184. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  26185. * @returns the VertexData of the IcoSphere
  26186. */
  26187. static CreateIcoSphere(options: {
  26188. radius?: number;
  26189. radiusX?: number;
  26190. radiusY?: number;
  26191. radiusZ?: number;
  26192. flat?: boolean;
  26193. subdivisions?: number;
  26194. sideOrientation?: number;
  26195. frontUVs?: Vector4;
  26196. backUVs?: Vector4;
  26197. }): VertexData;
  26198. /**
  26199. * Creates the VertexData for a Polyhedron
  26200. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  26201. * * type provided types are:
  26202. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  26203. * * 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)
  26204. * * size the size of the IcoSphere, optional default 1
  26205. * * sizeX allows stretching in the x direction, optional, default size
  26206. * * sizeY allows stretching in the y direction, optional, default size
  26207. * * sizeZ allows stretching in the z direction, optional, default size
  26208. * * 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
  26209. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26210. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26211. * * flat when true creates a flat shaded mesh, optional, default true
  26212. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26213. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26214. * * 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)
  26215. * * 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)
  26216. * @returns the VertexData of the Polyhedron
  26217. */
  26218. static CreatePolyhedron(options: {
  26219. type?: number;
  26220. size?: number;
  26221. sizeX?: number;
  26222. sizeY?: number;
  26223. sizeZ?: number;
  26224. custom?: any;
  26225. faceUV?: Vector4[];
  26226. faceColors?: Color4[];
  26227. flat?: boolean;
  26228. sideOrientation?: number;
  26229. frontUVs?: Vector4;
  26230. backUVs?: Vector4;
  26231. }): VertexData;
  26232. /**
  26233. * Creates the VertexData for a TorusKnot
  26234. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  26235. * * radius the radius of the torus knot, optional, default 2
  26236. * * tube the thickness of the tube, optional, default 0.5
  26237. * * radialSegments the number of sides on each tube segments, optional, default 32
  26238. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  26239. * * p the number of windings around the z axis, optional, default 2
  26240. * * q the number of windings around the x axis, optional, default 3
  26241. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26242. * * 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)
  26243. * * 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)
  26244. * @returns the VertexData of the Torus Knot
  26245. */
  26246. static CreateTorusKnot(options: {
  26247. radius?: number;
  26248. tube?: number;
  26249. radialSegments?: number;
  26250. tubularSegments?: number;
  26251. p?: number;
  26252. q?: number;
  26253. sideOrientation?: number;
  26254. frontUVs?: Vector4;
  26255. backUVs?: Vector4;
  26256. }): VertexData;
  26257. /**
  26258. * Compute normals for given positions and indices
  26259. * @param positions an array of vertex positions, [...., x, y, z, ......]
  26260. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  26261. * @param normals an array of vertex normals, [...., x, y, z, ......]
  26262. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  26263. * * facetNormals : optional array of facet normals (vector3)
  26264. * * facetPositions : optional array of facet positions (vector3)
  26265. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  26266. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  26267. * * bInfo : optional bounding info, required for facetPartitioning computation
  26268. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  26269. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  26270. * * useRightHandedSystem: optional boolean to for right handed system computation
  26271. * * depthSort : optional boolean to enable the facet depth sort computation
  26272. * * distanceTo : optional Vector3 to compute the facet depth from this location
  26273. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  26274. */
  26275. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  26276. facetNormals?: any;
  26277. facetPositions?: any;
  26278. facetPartitioning?: any;
  26279. ratio?: number;
  26280. bInfo?: any;
  26281. bbSize?: Vector3;
  26282. subDiv?: any;
  26283. useRightHandedSystem?: boolean;
  26284. depthSort?: boolean;
  26285. distanceTo?: Vector3;
  26286. depthSortedFacets?: any;
  26287. }): void;
  26288. /** @hidden */
  26289. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  26290. /**
  26291. * Applies VertexData created from the imported parameters to the geometry
  26292. * @param parsedVertexData the parsed data from an imported file
  26293. * @param geometry the geometry to apply the VertexData to
  26294. */
  26295. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  26296. }
  26297. }
  26298. declare module BABYLON {
  26299. /**
  26300. * Defines a target to use with MorphTargetManager
  26301. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26302. */
  26303. export class MorphTarget implements IAnimatable {
  26304. /** defines the name of the target */
  26305. name: string;
  26306. /**
  26307. * Gets or sets the list of animations
  26308. */
  26309. animations: Animation[];
  26310. private _scene;
  26311. private _positions;
  26312. private _normals;
  26313. private _tangents;
  26314. private _uvs;
  26315. private _influence;
  26316. private _uniqueId;
  26317. /**
  26318. * Observable raised when the influence changes
  26319. */
  26320. onInfluenceChanged: Observable<boolean>;
  26321. /** @hidden */
  26322. _onDataLayoutChanged: Observable<void>;
  26323. /**
  26324. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  26325. */
  26326. get influence(): number;
  26327. set influence(influence: number);
  26328. /**
  26329. * Gets or sets the id of the morph Target
  26330. */
  26331. id: string;
  26332. private _animationPropertiesOverride;
  26333. /**
  26334. * Gets or sets the animation properties override
  26335. */
  26336. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26337. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26338. /**
  26339. * Creates a new MorphTarget
  26340. * @param name defines the name of the target
  26341. * @param influence defines the influence to use
  26342. * @param scene defines the scene the morphtarget belongs to
  26343. */
  26344. constructor(
  26345. /** defines the name of the target */
  26346. name: string, influence?: number, scene?: Nullable<Scene>);
  26347. /**
  26348. * Gets the unique ID of this manager
  26349. */
  26350. get uniqueId(): number;
  26351. /**
  26352. * Gets a boolean defining if the target contains position data
  26353. */
  26354. get hasPositions(): boolean;
  26355. /**
  26356. * Gets a boolean defining if the target contains normal data
  26357. */
  26358. get hasNormals(): boolean;
  26359. /**
  26360. * Gets a boolean defining if the target contains tangent data
  26361. */
  26362. get hasTangents(): boolean;
  26363. /**
  26364. * Gets a boolean defining if the target contains texture coordinates data
  26365. */
  26366. get hasUVs(): boolean;
  26367. /**
  26368. * Affects position data to this target
  26369. * @param data defines the position data to use
  26370. */
  26371. setPositions(data: Nullable<FloatArray>): void;
  26372. /**
  26373. * Gets the position data stored in this target
  26374. * @returns a FloatArray containing the position data (or null if not present)
  26375. */
  26376. getPositions(): Nullable<FloatArray>;
  26377. /**
  26378. * Affects normal data to this target
  26379. * @param data defines the normal data to use
  26380. */
  26381. setNormals(data: Nullable<FloatArray>): void;
  26382. /**
  26383. * Gets the normal data stored in this target
  26384. * @returns a FloatArray containing the normal data (or null if not present)
  26385. */
  26386. getNormals(): Nullable<FloatArray>;
  26387. /**
  26388. * Affects tangent data to this target
  26389. * @param data defines the tangent data to use
  26390. */
  26391. setTangents(data: Nullable<FloatArray>): void;
  26392. /**
  26393. * Gets the tangent data stored in this target
  26394. * @returns a FloatArray containing the tangent data (or null if not present)
  26395. */
  26396. getTangents(): Nullable<FloatArray>;
  26397. /**
  26398. * Affects texture coordinates data to this target
  26399. * @param data defines the texture coordinates data to use
  26400. */
  26401. setUVs(data: Nullable<FloatArray>): void;
  26402. /**
  26403. * Gets the texture coordinates data stored in this target
  26404. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  26405. */
  26406. getUVs(): Nullable<FloatArray>;
  26407. /**
  26408. * Clone the current target
  26409. * @returns a new MorphTarget
  26410. */
  26411. clone(): MorphTarget;
  26412. /**
  26413. * Serializes the current target into a Serialization object
  26414. * @returns the serialized object
  26415. */
  26416. serialize(): any;
  26417. /**
  26418. * Returns the string "MorphTarget"
  26419. * @returns "MorphTarget"
  26420. */
  26421. getClassName(): string;
  26422. /**
  26423. * Creates a new target from serialized data
  26424. * @param serializationObject defines the serialized data to use
  26425. * @returns a new MorphTarget
  26426. */
  26427. static Parse(serializationObject: any): MorphTarget;
  26428. /**
  26429. * Creates a MorphTarget from mesh data
  26430. * @param mesh defines the source mesh
  26431. * @param name defines the name to use for the new target
  26432. * @param influence defines the influence to attach to the target
  26433. * @returns a new MorphTarget
  26434. */
  26435. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  26436. }
  26437. }
  26438. declare module BABYLON {
  26439. /**
  26440. * This class is used to deform meshes using morphing between different targets
  26441. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26442. */
  26443. export class MorphTargetManager {
  26444. private _targets;
  26445. private _targetInfluenceChangedObservers;
  26446. private _targetDataLayoutChangedObservers;
  26447. private _activeTargets;
  26448. private _scene;
  26449. private _influences;
  26450. private _supportsNormals;
  26451. private _supportsTangents;
  26452. private _supportsUVs;
  26453. private _vertexCount;
  26454. private _uniqueId;
  26455. private _tempInfluences;
  26456. /**
  26457. * Gets or sets a boolean indicating if normals must be morphed
  26458. */
  26459. enableNormalMorphing: boolean;
  26460. /**
  26461. * Gets or sets a boolean indicating if tangents must be morphed
  26462. */
  26463. enableTangentMorphing: boolean;
  26464. /**
  26465. * Gets or sets a boolean indicating if UV must be morphed
  26466. */
  26467. enableUVMorphing: boolean;
  26468. /**
  26469. * Creates a new MorphTargetManager
  26470. * @param scene defines the current scene
  26471. */
  26472. constructor(scene?: Nullable<Scene>);
  26473. /**
  26474. * Gets the unique ID of this manager
  26475. */
  26476. get uniqueId(): number;
  26477. /**
  26478. * Gets the number of vertices handled by this manager
  26479. */
  26480. get vertexCount(): number;
  26481. /**
  26482. * Gets a boolean indicating if this manager supports morphing of normals
  26483. */
  26484. get supportsNormals(): boolean;
  26485. /**
  26486. * Gets a boolean indicating if this manager supports morphing of tangents
  26487. */
  26488. get supportsTangents(): boolean;
  26489. /**
  26490. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  26491. */
  26492. get supportsUVs(): boolean;
  26493. /**
  26494. * Gets the number of targets stored in this manager
  26495. */
  26496. get numTargets(): number;
  26497. /**
  26498. * Gets the number of influencers (ie. the number of targets with influences > 0)
  26499. */
  26500. get numInfluencers(): number;
  26501. /**
  26502. * Gets the list of influences (one per target)
  26503. */
  26504. get influences(): Float32Array;
  26505. /**
  26506. * Gets the active target at specified index. An active target is a target with an influence > 0
  26507. * @param index defines the index to check
  26508. * @returns the requested target
  26509. */
  26510. getActiveTarget(index: number): MorphTarget;
  26511. /**
  26512. * Gets the target at specified index
  26513. * @param index defines the index to check
  26514. * @returns the requested target
  26515. */
  26516. getTarget(index: number): MorphTarget;
  26517. /**
  26518. * Add a new target to this manager
  26519. * @param target defines the target to add
  26520. */
  26521. addTarget(target: MorphTarget): void;
  26522. /**
  26523. * Removes a target from the manager
  26524. * @param target defines the target to remove
  26525. */
  26526. removeTarget(target: MorphTarget): void;
  26527. /**
  26528. * Clone the current manager
  26529. * @returns a new MorphTargetManager
  26530. */
  26531. clone(): MorphTargetManager;
  26532. /**
  26533. * Serializes the current manager into a Serialization object
  26534. * @returns the serialized object
  26535. */
  26536. serialize(): any;
  26537. private _syncActiveTargets;
  26538. /**
  26539. * Syncrhonize the targets with all the meshes using this morph target manager
  26540. */
  26541. synchronize(): void;
  26542. /**
  26543. * Creates a new MorphTargetManager from serialized data
  26544. * @param serializationObject defines the serialized data
  26545. * @param scene defines the hosting scene
  26546. * @returns the new MorphTargetManager
  26547. */
  26548. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  26549. }
  26550. }
  26551. declare module BABYLON {
  26552. /**
  26553. * Class used to represent a specific level of detail of a mesh
  26554. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26555. */
  26556. export class MeshLODLevel {
  26557. /** Defines the distance where this level should start being displayed */
  26558. distance: number;
  26559. /** Defines the mesh to use to render this level */
  26560. mesh: Nullable<Mesh>;
  26561. /**
  26562. * Creates a new LOD level
  26563. * @param distance defines the distance where this level should star being displayed
  26564. * @param mesh defines the mesh to use to render this level
  26565. */
  26566. constructor(
  26567. /** Defines the distance where this level should start being displayed */
  26568. distance: number,
  26569. /** Defines the mesh to use to render this level */
  26570. mesh: Nullable<Mesh>);
  26571. }
  26572. }
  26573. declare module BABYLON {
  26574. /**
  26575. * Helper class used to generate a canvas to manipulate images
  26576. */
  26577. export class CanvasGenerator {
  26578. /**
  26579. * Create a new canvas (or offscreen canvas depending on the context)
  26580. * @param width defines the expected width
  26581. * @param height defines the expected height
  26582. * @return a new canvas or offscreen canvas
  26583. */
  26584. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  26585. }
  26586. }
  26587. declare module BABYLON {
  26588. /**
  26589. * Mesh representing the gorund
  26590. */
  26591. export class GroundMesh extends Mesh {
  26592. /** If octree should be generated */
  26593. generateOctree: boolean;
  26594. private _heightQuads;
  26595. /** @hidden */
  26596. _subdivisionsX: number;
  26597. /** @hidden */
  26598. _subdivisionsY: number;
  26599. /** @hidden */
  26600. _width: number;
  26601. /** @hidden */
  26602. _height: number;
  26603. /** @hidden */
  26604. _minX: number;
  26605. /** @hidden */
  26606. _maxX: number;
  26607. /** @hidden */
  26608. _minZ: number;
  26609. /** @hidden */
  26610. _maxZ: number;
  26611. constructor(name: string, scene: Scene);
  26612. /**
  26613. * "GroundMesh"
  26614. * @returns "GroundMesh"
  26615. */
  26616. getClassName(): string;
  26617. /**
  26618. * The minimum of x and y subdivisions
  26619. */
  26620. get subdivisions(): number;
  26621. /**
  26622. * X subdivisions
  26623. */
  26624. get subdivisionsX(): number;
  26625. /**
  26626. * Y subdivisions
  26627. */
  26628. get subdivisionsY(): number;
  26629. /**
  26630. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26631. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26632. * @param chunksCount the number of subdivisions for x and y
  26633. * @param octreeBlocksSize (Default: 32)
  26634. */
  26635. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26636. /**
  26637. * Returns a height (y) value in the Worl system :
  26638. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26639. * @param x x coordinate
  26640. * @param z z coordinate
  26641. * @returns the ground y position if (x, z) are outside the ground surface.
  26642. */
  26643. getHeightAtCoordinates(x: number, z: number): number;
  26644. /**
  26645. * Returns a normalized vector (Vector3) orthogonal to the ground
  26646. * at the ground coordinates (x, z) expressed in the World system.
  26647. * @param x x coordinate
  26648. * @param z z coordinate
  26649. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26650. */
  26651. getNormalAtCoordinates(x: number, z: number): Vector3;
  26652. /**
  26653. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26654. * at the ground coordinates (x, z) expressed in the World system.
  26655. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26656. * @param x x coordinate
  26657. * @param z z coordinate
  26658. * @param ref vector to store the result
  26659. * @returns the GroundMesh.
  26660. */
  26661. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26662. /**
  26663. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26664. * if the ground has been updated.
  26665. * This can be used in the render loop.
  26666. * @returns the GroundMesh.
  26667. */
  26668. updateCoordinateHeights(): GroundMesh;
  26669. private _getFacetAt;
  26670. private _initHeightQuads;
  26671. private _computeHeightQuads;
  26672. /**
  26673. * Serializes this ground mesh
  26674. * @param serializationObject object to write serialization to
  26675. */
  26676. serialize(serializationObject: any): void;
  26677. /**
  26678. * Parses a serialized ground mesh
  26679. * @param parsedMesh the serialized mesh
  26680. * @param scene the scene to create the ground mesh in
  26681. * @returns the created ground mesh
  26682. */
  26683. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26684. }
  26685. }
  26686. declare module BABYLON {
  26687. /**
  26688. * Interface for Physics-Joint data
  26689. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26690. */
  26691. export interface PhysicsJointData {
  26692. /**
  26693. * The main pivot of the joint
  26694. */
  26695. mainPivot?: Vector3;
  26696. /**
  26697. * The connected pivot of the joint
  26698. */
  26699. connectedPivot?: Vector3;
  26700. /**
  26701. * The main axis of the joint
  26702. */
  26703. mainAxis?: Vector3;
  26704. /**
  26705. * The connected axis of the joint
  26706. */
  26707. connectedAxis?: Vector3;
  26708. /**
  26709. * The collision of the joint
  26710. */
  26711. collision?: boolean;
  26712. /**
  26713. * Native Oimo/Cannon/Energy data
  26714. */
  26715. nativeParams?: any;
  26716. }
  26717. /**
  26718. * This is a holder class for the physics joint created by the physics plugin
  26719. * It holds a set of functions to control the underlying joint
  26720. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26721. */
  26722. export class PhysicsJoint {
  26723. /**
  26724. * The type of the physics joint
  26725. */
  26726. type: number;
  26727. /**
  26728. * The data for the physics joint
  26729. */
  26730. jointData: PhysicsJointData;
  26731. private _physicsJoint;
  26732. protected _physicsPlugin: IPhysicsEnginePlugin;
  26733. /**
  26734. * Initializes the physics joint
  26735. * @param type The type of the physics joint
  26736. * @param jointData The data for the physics joint
  26737. */
  26738. constructor(
  26739. /**
  26740. * The type of the physics joint
  26741. */
  26742. type: number,
  26743. /**
  26744. * The data for the physics joint
  26745. */
  26746. jointData: PhysicsJointData);
  26747. /**
  26748. * Gets the physics joint
  26749. */
  26750. get physicsJoint(): any;
  26751. /**
  26752. * Sets the physics joint
  26753. */
  26754. set physicsJoint(newJoint: any);
  26755. /**
  26756. * Sets the physics plugin
  26757. */
  26758. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26759. /**
  26760. * Execute a function that is physics-plugin specific.
  26761. * @param {Function} func the function that will be executed.
  26762. * It accepts two parameters: the physics world and the physics joint
  26763. */
  26764. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26765. /**
  26766. * Distance-Joint type
  26767. */
  26768. static DistanceJoint: number;
  26769. /**
  26770. * Hinge-Joint type
  26771. */
  26772. static HingeJoint: number;
  26773. /**
  26774. * Ball-and-Socket joint type
  26775. */
  26776. static BallAndSocketJoint: number;
  26777. /**
  26778. * Wheel-Joint type
  26779. */
  26780. static WheelJoint: number;
  26781. /**
  26782. * Slider-Joint type
  26783. */
  26784. static SliderJoint: number;
  26785. /**
  26786. * Prismatic-Joint type
  26787. */
  26788. static PrismaticJoint: number;
  26789. /**
  26790. * Universal-Joint type
  26791. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  26792. */
  26793. static UniversalJoint: number;
  26794. /**
  26795. * Hinge-Joint 2 type
  26796. */
  26797. static Hinge2Joint: number;
  26798. /**
  26799. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  26800. */
  26801. static PointToPointJoint: number;
  26802. /**
  26803. * Spring-Joint type
  26804. */
  26805. static SpringJoint: number;
  26806. /**
  26807. * Lock-Joint type
  26808. */
  26809. static LockJoint: number;
  26810. }
  26811. /**
  26812. * A class representing a physics distance joint
  26813. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26814. */
  26815. export class DistanceJoint extends PhysicsJoint {
  26816. /**
  26817. *
  26818. * @param jointData The data for the Distance-Joint
  26819. */
  26820. constructor(jointData: DistanceJointData);
  26821. /**
  26822. * Update the predefined distance.
  26823. * @param maxDistance The maximum preferred distance
  26824. * @param minDistance The minimum preferred distance
  26825. */
  26826. updateDistance(maxDistance: number, minDistance?: number): void;
  26827. }
  26828. /**
  26829. * Represents a Motor-Enabled Joint
  26830. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26831. */
  26832. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  26833. /**
  26834. * Initializes the Motor-Enabled Joint
  26835. * @param type The type of the joint
  26836. * @param jointData The physica joint data for the joint
  26837. */
  26838. constructor(type: number, jointData: PhysicsJointData);
  26839. /**
  26840. * Set the motor values.
  26841. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26842. * @param force the force to apply
  26843. * @param maxForce max force for this motor.
  26844. */
  26845. setMotor(force?: number, maxForce?: number): void;
  26846. /**
  26847. * Set the motor's limits.
  26848. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26849. * @param upperLimit The upper limit of the motor
  26850. * @param lowerLimit The lower limit of the motor
  26851. */
  26852. setLimit(upperLimit: number, lowerLimit?: number): void;
  26853. }
  26854. /**
  26855. * This class represents a single physics Hinge-Joint
  26856. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26857. */
  26858. export class HingeJoint extends MotorEnabledJoint {
  26859. /**
  26860. * Initializes the Hinge-Joint
  26861. * @param jointData The joint data for the Hinge-Joint
  26862. */
  26863. constructor(jointData: PhysicsJointData);
  26864. /**
  26865. * Set the motor values.
  26866. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26867. * @param {number} force the force to apply
  26868. * @param {number} maxForce max force for this motor.
  26869. */
  26870. setMotor(force?: number, maxForce?: number): void;
  26871. /**
  26872. * Set the motor's limits.
  26873. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26874. * @param upperLimit The upper limit of the motor
  26875. * @param lowerLimit The lower limit of the motor
  26876. */
  26877. setLimit(upperLimit: number, lowerLimit?: number): void;
  26878. }
  26879. /**
  26880. * This class represents a dual hinge physics joint (same as wheel joint)
  26881. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26882. */
  26883. export class Hinge2Joint extends MotorEnabledJoint {
  26884. /**
  26885. * Initializes the Hinge2-Joint
  26886. * @param jointData The joint data for the Hinge2-Joint
  26887. */
  26888. constructor(jointData: PhysicsJointData);
  26889. /**
  26890. * Set the motor values.
  26891. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26892. * @param {number} targetSpeed the speed the motor is to reach
  26893. * @param {number} maxForce max force for this motor.
  26894. * @param {motorIndex} the motor's index, 0 or 1.
  26895. */
  26896. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  26897. /**
  26898. * Set the motor limits.
  26899. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26900. * @param {number} upperLimit the upper limit
  26901. * @param {number} lowerLimit lower limit
  26902. * @param {motorIndex} the motor's index, 0 or 1.
  26903. */
  26904. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26905. }
  26906. /**
  26907. * Interface for a motor enabled joint
  26908. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26909. */
  26910. export interface IMotorEnabledJoint {
  26911. /**
  26912. * Physics joint
  26913. */
  26914. physicsJoint: any;
  26915. /**
  26916. * Sets the motor of the motor-enabled joint
  26917. * @param force The force of the motor
  26918. * @param maxForce The maximum force of the motor
  26919. * @param motorIndex The index of the motor
  26920. */
  26921. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  26922. /**
  26923. * Sets the limit of the motor
  26924. * @param upperLimit The upper limit of the motor
  26925. * @param lowerLimit The lower limit of the motor
  26926. * @param motorIndex The index of the motor
  26927. */
  26928. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26929. }
  26930. /**
  26931. * Joint data for a Distance-Joint
  26932. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26933. */
  26934. export interface DistanceJointData extends PhysicsJointData {
  26935. /**
  26936. * Max distance the 2 joint objects can be apart
  26937. */
  26938. maxDistance: number;
  26939. }
  26940. /**
  26941. * Joint data from a spring joint
  26942. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26943. */
  26944. export interface SpringJointData extends PhysicsJointData {
  26945. /**
  26946. * Length of the spring
  26947. */
  26948. length: number;
  26949. /**
  26950. * Stiffness of the spring
  26951. */
  26952. stiffness: number;
  26953. /**
  26954. * Damping of the spring
  26955. */
  26956. damping: number;
  26957. /** this callback will be called when applying the force to the impostors. */
  26958. forceApplicationCallback: () => void;
  26959. }
  26960. }
  26961. declare module BABYLON {
  26962. /**
  26963. * Holds the data for the raycast result
  26964. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26965. */
  26966. export class PhysicsRaycastResult {
  26967. private _hasHit;
  26968. private _hitDistance;
  26969. private _hitNormalWorld;
  26970. private _hitPointWorld;
  26971. private _rayFromWorld;
  26972. private _rayToWorld;
  26973. /**
  26974. * Gets if there was a hit
  26975. */
  26976. get hasHit(): boolean;
  26977. /**
  26978. * Gets the distance from the hit
  26979. */
  26980. get hitDistance(): number;
  26981. /**
  26982. * Gets the hit normal/direction in the world
  26983. */
  26984. get hitNormalWorld(): Vector3;
  26985. /**
  26986. * Gets the hit point in the world
  26987. */
  26988. get hitPointWorld(): Vector3;
  26989. /**
  26990. * Gets the ray "start point" of the ray in the world
  26991. */
  26992. get rayFromWorld(): Vector3;
  26993. /**
  26994. * Gets the ray "end point" of the ray in the world
  26995. */
  26996. get rayToWorld(): Vector3;
  26997. /**
  26998. * Sets the hit data (normal & point in world space)
  26999. * @param hitNormalWorld defines the normal in world space
  27000. * @param hitPointWorld defines the point in world space
  27001. */
  27002. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  27003. /**
  27004. * Sets the distance from the start point to the hit point
  27005. * @param distance
  27006. */
  27007. setHitDistance(distance: number): void;
  27008. /**
  27009. * Calculates the distance manually
  27010. */
  27011. calculateHitDistance(): void;
  27012. /**
  27013. * Resets all the values to default
  27014. * @param from The from point on world space
  27015. * @param to The to point on world space
  27016. */
  27017. reset(from?: Vector3, to?: Vector3): void;
  27018. }
  27019. /**
  27020. * Interface for the size containing width and height
  27021. */
  27022. interface IXYZ {
  27023. /**
  27024. * X
  27025. */
  27026. x: number;
  27027. /**
  27028. * Y
  27029. */
  27030. y: number;
  27031. /**
  27032. * Z
  27033. */
  27034. z: number;
  27035. }
  27036. }
  27037. declare module BABYLON {
  27038. /**
  27039. * Interface used to describe a physics joint
  27040. */
  27041. export interface PhysicsImpostorJoint {
  27042. /** Defines the main impostor to which the joint is linked */
  27043. mainImpostor: PhysicsImpostor;
  27044. /** Defines the impostor that is connected to the main impostor using this joint */
  27045. connectedImpostor: PhysicsImpostor;
  27046. /** Defines the joint itself */
  27047. joint: PhysicsJoint;
  27048. }
  27049. /** @hidden */
  27050. export interface IPhysicsEnginePlugin {
  27051. world: any;
  27052. name: string;
  27053. setGravity(gravity: Vector3): void;
  27054. setTimeStep(timeStep: number): void;
  27055. getTimeStep(): number;
  27056. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27057. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27058. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27059. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27060. removePhysicsBody(impostor: PhysicsImpostor): void;
  27061. generateJoint(joint: PhysicsImpostorJoint): void;
  27062. removeJoint(joint: PhysicsImpostorJoint): void;
  27063. isSupported(): boolean;
  27064. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27065. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27066. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27067. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27068. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27069. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27070. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27071. getBodyMass(impostor: PhysicsImpostor): number;
  27072. getBodyFriction(impostor: PhysicsImpostor): number;
  27073. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27074. getBodyRestitution(impostor: PhysicsImpostor): number;
  27075. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27076. getBodyPressure?(impostor: PhysicsImpostor): number;
  27077. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  27078. getBodyStiffness?(impostor: PhysicsImpostor): number;
  27079. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  27080. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  27081. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  27082. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  27083. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  27084. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27085. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27086. sleepBody(impostor: PhysicsImpostor): void;
  27087. wakeUpBody(impostor: PhysicsImpostor): void;
  27088. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27089. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27090. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27091. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27092. getRadius(impostor: PhysicsImpostor): number;
  27093. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27094. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27095. dispose(): void;
  27096. }
  27097. /**
  27098. * Interface used to define a physics engine
  27099. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27100. */
  27101. export interface IPhysicsEngine {
  27102. /**
  27103. * Gets the gravity vector used by the simulation
  27104. */
  27105. gravity: Vector3;
  27106. /**
  27107. * Sets the gravity vector used by the simulation
  27108. * @param gravity defines the gravity vector to use
  27109. */
  27110. setGravity(gravity: Vector3): void;
  27111. /**
  27112. * Set the time step of the physics engine.
  27113. * Default is 1/60.
  27114. * To slow it down, enter 1/600 for example.
  27115. * To speed it up, 1/30
  27116. * @param newTimeStep the new timestep to apply to this world.
  27117. */
  27118. setTimeStep(newTimeStep: number): void;
  27119. /**
  27120. * Get the time step of the physics engine.
  27121. * @returns the current time step
  27122. */
  27123. getTimeStep(): number;
  27124. /**
  27125. * Set the sub time step of the physics engine.
  27126. * Default is 0 meaning there is no sub steps
  27127. * To increase physics resolution precision, set a small value (like 1 ms)
  27128. * @param subTimeStep defines the new sub timestep used for physics resolution.
  27129. */
  27130. setSubTimeStep(subTimeStep: number): void;
  27131. /**
  27132. * Get the sub time step of the physics engine.
  27133. * @returns the current sub time step
  27134. */
  27135. getSubTimeStep(): number;
  27136. /**
  27137. * Release all resources
  27138. */
  27139. dispose(): void;
  27140. /**
  27141. * Gets the name of the current physics plugin
  27142. * @returns the name of the plugin
  27143. */
  27144. getPhysicsPluginName(): string;
  27145. /**
  27146. * Adding a new impostor for the impostor tracking.
  27147. * This will be done by the impostor itself.
  27148. * @param impostor the impostor to add
  27149. */
  27150. addImpostor(impostor: PhysicsImpostor): void;
  27151. /**
  27152. * Remove an impostor from the engine.
  27153. * This impostor and its mesh will not longer be updated by the physics engine.
  27154. * @param impostor the impostor to remove
  27155. */
  27156. removeImpostor(impostor: PhysicsImpostor): void;
  27157. /**
  27158. * Add a joint to the physics engine
  27159. * @param mainImpostor defines the main impostor to which the joint is added.
  27160. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  27161. * @param joint defines the joint that will connect both impostors.
  27162. */
  27163. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27164. /**
  27165. * Removes a joint from the simulation
  27166. * @param mainImpostor defines the impostor used with the joint
  27167. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  27168. * @param joint defines the joint to remove
  27169. */
  27170. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27171. /**
  27172. * Gets the current plugin used to run the simulation
  27173. * @returns current plugin
  27174. */
  27175. getPhysicsPlugin(): IPhysicsEnginePlugin;
  27176. /**
  27177. * Gets the list of physic impostors
  27178. * @returns an array of PhysicsImpostor
  27179. */
  27180. getImpostors(): Array<PhysicsImpostor>;
  27181. /**
  27182. * Gets the impostor for a physics enabled object
  27183. * @param object defines the object impersonated by the impostor
  27184. * @returns the PhysicsImpostor or null if not found
  27185. */
  27186. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27187. /**
  27188. * Gets the impostor for a physics body object
  27189. * @param body defines physics body used by the impostor
  27190. * @returns the PhysicsImpostor or null if not found
  27191. */
  27192. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  27193. /**
  27194. * Does a raycast in the physics world
  27195. * @param from when should the ray start?
  27196. * @param to when should the ray end?
  27197. * @returns PhysicsRaycastResult
  27198. */
  27199. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27200. /**
  27201. * Called by the scene. No need to call it.
  27202. * @param delta defines the timespam between frames
  27203. */
  27204. _step(delta: number): void;
  27205. }
  27206. }
  27207. declare module BABYLON {
  27208. /**
  27209. * The interface for the physics imposter parameters
  27210. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27211. */
  27212. export interface PhysicsImpostorParameters {
  27213. /**
  27214. * The mass of the physics imposter
  27215. */
  27216. mass: number;
  27217. /**
  27218. * The friction of the physics imposter
  27219. */
  27220. friction?: number;
  27221. /**
  27222. * The coefficient of restitution of the physics imposter
  27223. */
  27224. restitution?: number;
  27225. /**
  27226. * The native options of the physics imposter
  27227. */
  27228. nativeOptions?: any;
  27229. /**
  27230. * Specifies if the parent should be ignored
  27231. */
  27232. ignoreParent?: boolean;
  27233. /**
  27234. * Specifies if bi-directional transformations should be disabled
  27235. */
  27236. disableBidirectionalTransformation?: boolean;
  27237. /**
  27238. * The pressure inside the physics imposter, soft object only
  27239. */
  27240. pressure?: number;
  27241. /**
  27242. * The stiffness the physics imposter, soft object only
  27243. */
  27244. stiffness?: number;
  27245. /**
  27246. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  27247. */
  27248. velocityIterations?: number;
  27249. /**
  27250. * The number of iterations used in maintaining consistent vertex positions, soft object only
  27251. */
  27252. positionIterations?: number;
  27253. /**
  27254. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  27255. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  27256. * Add to fix multiple points
  27257. */
  27258. fixedPoints?: number;
  27259. /**
  27260. * The collision margin around a soft object
  27261. */
  27262. margin?: number;
  27263. /**
  27264. * The collision margin around a soft object
  27265. */
  27266. damping?: number;
  27267. /**
  27268. * The path for a rope based on an extrusion
  27269. */
  27270. path?: any;
  27271. /**
  27272. * The shape of an extrusion used for a rope based on an extrusion
  27273. */
  27274. shape?: any;
  27275. }
  27276. /**
  27277. * Interface for a physics-enabled object
  27278. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27279. */
  27280. export interface IPhysicsEnabledObject {
  27281. /**
  27282. * The position of the physics-enabled object
  27283. */
  27284. position: Vector3;
  27285. /**
  27286. * The rotation of the physics-enabled object
  27287. */
  27288. rotationQuaternion: Nullable<Quaternion>;
  27289. /**
  27290. * The scale of the physics-enabled object
  27291. */
  27292. scaling: Vector3;
  27293. /**
  27294. * The rotation of the physics-enabled object
  27295. */
  27296. rotation?: Vector3;
  27297. /**
  27298. * The parent of the physics-enabled object
  27299. */
  27300. parent?: any;
  27301. /**
  27302. * The bounding info of the physics-enabled object
  27303. * @returns The bounding info of the physics-enabled object
  27304. */
  27305. getBoundingInfo(): BoundingInfo;
  27306. /**
  27307. * Computes the world matrix
  27308. * @param force Specifies if the world matrix should be computed by force
  27309. * @returns A world matrix
  27310. */
  27311. computeWorldMatrix(force: boolean): Matrix;
  27312. /**
  27313. * Gets the world matrix
  27314. * @returns A world matrix
  27315. */
  27316. getWorldMatrix?(): Matrix;
  27317. /**
  27318. * Gets the child meshes
  27319. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  27320. * @returns An array of abstract meshes
  27321. */
  27322. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27323. /**
  27324. * Gets the vertex data
  27325. * @param kind The type of vertex data
  27326. * @returns A nullable array of numbers, or a float32 array
  27327. */
  27328. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27329. /**
  27330. * Gets the indices from the mesh
  27331. * @returns A nullable array of index arrays
  27332. */
  27333. getIndices?(): Nullable<IndicesArray>;
  27334. /**
  27335. * Gets the scene from the mesh
  27336. * @returns the indices array or null
  27337. */
  27338. getScene?(): Scene;
  27339. /**
  27340. * Gets the absolute position from the mesh
  27341. * @returns the absolute position
  27342. */
  27343. getAbsolutePosition(): Vector3;
  27344. /**
  27345. * Gets the absolute pivot point from the mesh
  27346. * @returns the absolute pivot point
  27347. */
  27348. getAbsolutePivotPoint(): Vector3;
  27349. /**
  27350. * Rotates the mesh
  27351. * @param axis The axis of rotation
  27352. * @param amount The amount of rotation
  27353. * @param space The space of the rotation
  27354. * @returns The rotation transform node
  27355. */
  27356. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27357. /**
  27358. * Translates the mesh
  27359. * @param axis The axis of translation
  27360. * @param distance The distance of translation
  27361. * @param space The space of the translation
  27362. * @returns The transform node
  27363. */
  27364. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27365. /**
  27366. * Sets the absolute position of the mesh
  27367. * @param absolutePosition The absolute position of the mesh
  27368. * @returns The transform node
  27369. */
  27370. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27371. /**
  27372. * Gets the class name of the mesh
  27373. * @returns The class name
  27374. */
  27375. getClassName(): string;
  27376. }
  27377. /**
  27378. * Represents a physics imposter
  27379. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27380. */
  27381. export class PhysicsImpostor {
  27382. /**
  27383. * The physics-enabled object used as the physics imposter
  27384. */
  27385. object: IPhysicsEnabledObject;
  27386. /**
  27387. * The type of the physics imposter
  27388. */
  27389. type: number;
  27390. private _options;
  27391. private _scene?;
  27392. /**
  27393. * The default object size of the imposter
  27394. */
  27395. static DEFAULT_OBJECT_SIZE: Vector3;
  27396. /**
  27397. * The identity quaternion of the imposter
  27398. */
  27399. static IDENTITY_QUATERNION: Quaternion;
  27400. /** @hidden */
  27401. _pluginData: any;
  27402. private _physicsEngine;
  27403. private _physicsBody;
  27404. private _bodyUpdateRequired;
  27405. private _onBeforePhysicsStepCallbacks;
  27406. private _onAfterPhysicsStepCallbacks;
  27407. /** @hidden */
  27408. _onPhysicsCollideCallbacks: Array<{
  27409. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  27410. otherImpostors: Array<PhysicsImpostor>;
  27411. }>;
  27412. private _deltaPosition;
  27413. private _deltaRotation;
  27414. private _deltaRotationConjugated;
  27415. /** @hidden */
  27416. _isFromLine: boolean;
  27417. private _parent;
  27418. private _isDisposed;
  27419. private static _tmpVecs;
  27420. private static _tmpQuat;
  27421. /**
  27422. * Specifies if the physics imposter is disposed
  27423. */
  27424. get isDisposed(): boolean;
  27425. /**
  27426. * Gets the mass of the physics imposter
  27427. */
  27428. get mass(): number;
  27429. set mass(value: number);
  27430. /**
  27431. * Gets the coefficient of friction
  27432. */
  27433. get friction(): number;
  27434. /**
  27435. * Sets the coefficient of friction
  27436. */
  27437. set friction(value: number);
  27438. /**
  27439. * Gets the coefficient of restitution
  27440. */
  27441. get restitution(): number;
  27442. /**
  27443. * Sets the coefficient of restitution
  27444. */
  27445. set restitution(value: number);
  27446. /**
  27447. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  27448. */
  27449. get pressure(): number;
  27450. /**
  27451. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  27452. */
  27453. set pressure(value: number);
  27454. /**
  27455. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27456. */
  27457. get stiffness(): number;
  27458. /**
  27459. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27460. */
  27461. set stiffness(value: number);
  27462. /**
  27463. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27464. */
  27465. get velocityIterations(): number;
  27466. /**
  27467. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27468. */
  27469. set velocityIterations(value: number);
  27470. /**
  27471. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27472. */
  27473. get positionIterations(): number;
  27474. /**
  27475. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27476. */
  27477. set positionIterations(value: number);
  27478. /**
  27479. * The unique id of the physics imposter
  27480. * set by the physics engine when adding this impostor to the array
  27481. */
  27482. uniqueId: number;
  27483. /**
  27484. * @hidden
  27485. */
  27486. soft: boolean;
  27487. /**
  27488. * @hidden
  27489. */
  27490. segments: number;
  27491. private _joints;
  27492. /**
  27493. * Initializes the physics imposter
  27494. * @param object The physics-enabled object used as the physics imposter
  27495. * @param type The type of the physics imposter
  27496. * @param _options The options for the physics imposter
  27497. * @param _scene The Babylon scene
  27498. */
  27499. constructor(
  27500. /**
  27501. * The physics-enabled object used as the physics imposter
  27502. */
  27503. object: IPhysicsEnabledObject,
  27504. /**
  27505. * The type of the physics imposter
  27506. */
  27507. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27508. /**
  27509. * This function will completly initialize this impostor.
  27510. * It will create a new body - but only if this mesh has no parent.
  27511. * If it has, this impostor will not be used other than to define the impostor
  27512. * of the child mesh.
  27513. * @hidden
  27514. */
  27515. _init(): void;
  27516. private _getPhysicsParent;
  27517. /**
  27518. * Should a new body be generated.
  27519. * @returns boolean specifying if body initialization is required
  27520. */
  27521. isBodyInitRequired(): boolean;
  27522. /**
  27523. * Sets the updated scaling
  27524. * @param updated Specifies if the scaling is updated
  27525. */
  27526. setScalingUpdated(): void;
  27527. /**
  27528. * Force a regeneration of this or the parent's impostor's body.
  27529. * Use under cautious - This will remove all joints already implemented.
  27530. */
  27531. forceUpdate(): void;
  27532. /**
  27533. * Gets the body that holds this impostor. Either its own, or its parent.
  27534. */
  27535. get physicsBody(): any;
  27536. /**
  27537. * Get the parent of the physics imposter
  27538. * @returns Physics imposter or null
  27539. */
  27540. get parent(): Nullable<PhysicsImpostor>;
  27541. /**
  27542. * Sets the parent of the physics imposter
  27543. */
  27544. set parent(value: Nullable<PhysicsImpostor>);
  27545. /**
  27546. * Set the physics body. Used mainly by the physics engine/plugin
  27547. */
  27548. set physicsBody(physicsBody: any);
  27549. /**
  27550. * Resets the update flags
  27551. */
  27552. resetUpdateFlags(): void;
  27553. /**
  27554. * Gets the object extend size
  27555. * @returns the object extend size
  27556. */
  27557. getObjectExtendSize(): Vector3;
  27558. /**
  27559. * Gets the object center
  27560. * @returns The object center
  27561. */
  27562. getObjectCenter(): Vector3;
  27563. /**
  27564. * Get a specific parameter from the options parameters
  27565. * @param paramName The object parameter name
  27566. * @returns The object parameter
  27567. */
  27568. getParam(paramName: string): any;
  27569. /**
  27570. * Sets a specific parameter in the options given to the physics plugin
  27571. * @param paramName The parameter name
  27572. * @param value The value of the parameter
  27573. */
  27574. setParam(paramName: string, value: number): void;
  27575. /**
  27576. * Specifically change the body's mass option. Won't recreate the physics body object
  27577. * @param mass The mass of the physics imposter
  27578. */
  27579. setMass(mass: number): void;
  27580. /**
  27581. * Gets the linear velocity
  27582. * @returns linear velocity or null
  27583. */
  27584. getLinearVelocity(): Nullable<Vector3>;
  27585. /**
  27586. * Sets the linear velocity
  27587. * @param velocity linear velocity or null
  27588. */
  27589. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27590. /**
  27591. * Gets the angular velocity
  27592. * @returns angular velocity or null
  27593. */
  27594. getAngularVelocity(): Nullable<Vector3>;
  27595. /**
  27596. * Sets the angular velocity
  27597. * @param velocity The velocity or null
  27598. */
  27599. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27600. /**
  27601. * Execute a function with the physics plugin native code
  27602. * Provide a function the will have two variables - the world object and the physics body object
  27603. * @param func The function to execute with the physics plugin native code
  27604. */
  27605. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27606. /**
  27607. * Register a function that will be executed before the physics world is stepping forward
  27608. * @param func The function to execute before the physics world is stepped forward
  27609. */
  27610. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27611. /**
  27612. * Unregister a function that will be executed before the physics world is stepping forward
  27613. * @param func The function to execute before the physics world is stepped forward
  27614. */
  27615. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27616. /**
  27617. * Register a function that will be executed after the physics step
  27618. * @param func The function to execute after physics step
  27619. */
  27620. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27621. /**
  27622. * Unregisters a function that will be executed after the physics step
  27623. * @param func The function to execute after physics step
  27624. */
  27625. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27626. /**
  27627. * register a function that will be executed when this impostor collides against a different body
  27628. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  27629. * @param func Callback that is executed on collision
  27630. */
  27631. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  27632. /**
  27633. * Unregisters the physics imposter on contact
  27634. * @param collideAgainst The physics object to collide against
  27635. * @param func Callback to execute on collision
  27636. */
  27637. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27638. private _tmpQuat;
  27639. private _tmpQuat2;
  27640. /**
  27641. * Get the parent rotation
  27642. * @returns The parent rotation
  27643. */
  27644. getParentsRotation(): Quaternion;
  27645. /**
  27646. * this function is executed by the physics engine.
  27647. */
  27648. beforeStep: () => void;
  27649. /**
  27650. * this function is executed by the physics engine
  27651. */
  27652. afterStep: () => void;
  27653. /**
  27654. * Legacy collision detection event support
  27655. */
  27656. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27657. /**
  27658. * event and body object due to cannon's event-based architecture.
  27659. */
  27660. onCollide: (e: {
  27661. body: any;
  27662. }) => void;
  27663. /**
  27664. * Apply a force
  27665. * @param force The force to apply
  27666. * @param contactPoint The contact point for the force
  27667. * @returns The physics imposter
  27668. */
  27669. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27670. /**
  27671. * Apply an impulse
  27672. * @param force The impulse force
  27673. * @param contactPoint The contact point for the impulse force
  27674. * @returns The physics imposter
  27675. */
  27676. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27677. /**
  27678. * A help function to create a joint
  27679. * @param otherImpostor A physics imposter used to create a joint
  27680. * @param jointType The type of joint
  27681. * @param jointData The data for the joint
  27682. * @returns The physics imposter
  27683. */
  27684. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27685. /**
  27686. * Add a joint to this impostor with a different impostor
  27687. * @param otherImpostor A physics imposter used to add a joint
  27688. * @param joint The joint to add
  27689. * @returns The physics imposter
  27690. */
  27691. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27692. /**
  27693. * Add an anchor to a cloth impostor
  27694. * @param otherImpostor rigid impostor to anchor to
  27695. * @param width ratio across width from 0 to 1
  27696. * @param height ratio up height from 0 to 1
  27697. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27698. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27699. * @returns impostor the soft imposter
  27700. */
  27701. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27702. /**
  27703. * Add a hook to a rope impostor
  27704. * @param otherImpostor rigid impostor to anchor to
  27705. * @param length ratio across rope from 0 to 1
  27706. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27707. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27708. * @returns impostor the rope imposter
  27709. */
  27710. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27711. /**
  27712. * Will keep this body still, in a sleep mode.
  27713. * @returns the physics imposter
  27714. */
  27715. sleep(): PhysicsImpostor;
  27716. /**
  27717. * Wake the body up.
  27718. * @returns The physics imposter
  27719. */
  27720. wakeUp(): PhysicsImpostor;
  27721. /**
  27722. * Clones the physics imposter
  27723. * @param newObject The physics imposter clones to this physics-enabled object
  27724. * @returns A nullable physics imposter
  27725. */
  27726. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27727. /**
  27728. * Disposes the physics imposter
  27729. */
  27730. dispose(): void;
  27731. /**
  27732. * Sets the delta position
  27733. * @param position The delta position amount
  27734. */
  27735. setDeltaPosition(position: Vector3): void;
  27736. /**
  27737. * Sets the delta rotation
  27738. * @param rotation The delta rotation amount
  27739. */
  27740. setDeltaRotation(rotation: Quaternion): void;
  27741. /**
  27742. * Gets the box size of the physics imposter and stores the result in the input parameter
  27743. * @param result Stores the box size
  27744. * @returns The physics imposter
  27745. */
  27746. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27747. /**
  27748. * Gets the radius of the physics imposter
  27749. * @returns Radius of the physics imposter
  27750. */
  27751. getRadius(): number;
  27752. /**
  27753. * Sync a bone with this impostor
  27754. * @param bone The bone to sync to the impostor.
  27755. * @param boneMesh The mesh that the bone is influencing.
  27756. * @param jointPivot The pivot of the joint / bone in local space.
  27757. * @param distToJoint Optional distance from the impostor to the joint.
  27758. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27759. */
  27760. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27761. /**
  27762. * Sync impostor to a bone
  27763. * @param bone The bone that the impostor will be synced to.
  27764. * @param boneMesh The mesh that the bone is influencing.
  27765. * @param jointPivot The pivot of the joint / bone in local space.
  27766. * @param distToJoint Optional distance from the impostor to the joint.
  27767. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27768. * @param boneAxis Optional vector3 axis the bone is aligned with
  27769. */
  27770. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27771. /**
  27772. * No-Imposter type
  27773. */
  27774. static NoImpostor: number;
  27775. /**
  27776. * Sphere-Imposter type
  27777. */
  27778. static SphereImpostor: number;
  27779. /**
  27780. * Box-Imposter type
  27781. */
  27782. static BoxImpostor: number;
  27783. /**
  27784. * Plane-Imposter type
  27785. */
  27786. static PlaneImpostor: number;
  27787. /**
  27788. * Mesh-imposter type
  27789. */
  27790. static MeshImpostor: number;
  27791. /**
  27792. * Capsule-Impostor type (Ammo.js plugin only)
  27793. */
  27794. static CapsuleImpostor: number;
  27795. /**
  27796. * Cylinder-Imposter type
  27797. */
  27798. static CylinderImpostor: number;
  27799. /**
  27800. * Particle-Imposter type
  27801. */
  27802. static ParticleImpostor: number;
  27803. /**
  27804. * Heightmap-Imposter type
  27805. */
  27806. static HeightmapImpostor: number;
  27807. /**
  27808. * ConvexHull-Impostor type (Ammo.js plugin only)
  27809. */
  27810. static ConvexHullImpostor: number;
  27811. /**
  27812. * Custom-Imposter type (Ammo.js plugin only)
  27813. */
  27814. static CustomImpostor: number;
  27815. /**
  27816. * Rope-Imposter type
  27817. */
  27818. static RopeImpostor: number;
  27819. /**
  27820. * Cloth-Imposter type
  27821. */
  27822. static ClothImpostor: number;
  27823. /**
  27824. * Softbody-Imposter type
  27825. */
  27826. static SoftbodyImpostor: number;
  27827. }
  27828. }
  27829. declare module BABYLON {
  27830. /**
  27831. * @hidden
  27832. **/
  27833. export class _CreationDataStorage {
  27834. closePath?: boolean;
  27835. closeArray?: boolean;
  27836. idx: number[];
  27837. dashSize: number;
  27838. gapSize: number;
  27839. path3D: Path3D;
  27840. pathArray: Vector3[][];
  27841. arc: number;
  27842. radius: number;
  27843. cap: number;
  27844. tessellation: number;
  27845. }
  27846. /**
  27847. * @hidden
  27848. **/
  27849. class _InstanceDataStorage {
  27850. visibleInstances: any;
  27851. batchCache: _InstancesBatch;
  27852. instancesBufferSize: number;
  27853. instancesBuffer: Nullable<Buffer>;
  27854. instancesData: Float32Array;
  27855. overridenInstanceCount: number;
  27856. isFrozen: boolean;
  27857. previousBatch: Nullable<_InstancesBatch>;
  27858. hardwareInstancedRendering: boolean;
  27859. sideOrientation: number;
  27860. manualUpdate: boolean;
  27861. }
  27862. /**
  27863. * @hidden
  27864. **/
  27865. export class _InstancesBatch {
  27866. mustReturn: boolean;
  27867. visibleInstances: Nullable<InstancedMesh[]>[];
  27868. renderSelf: boolean[];
  27869. hardwareInstancedRendering: boolean[];
  27870. }
  27871. /**
  27872. * @hidden
  27873. **/
  27874. class _ThinInstanceDataStorage {
  27875. instancesCount: number;
  27876. matrixBuffer: Nullable<Buffer>;
  27877. matrixBufferSize: number;
  27878. matrixData: Nullable<Float32Array>;
  27879. boundingVectors: Array<Vector3>;
  27880. }
  27881. /**
  27882. * Class used to represent renderable models
  27883. */
  27884. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  27885. /**
  27886. * Mesh side orientation : usually the external or front surface
  27887. */
  27888. static readonly FRONTSIDE: number;
  27889. /**
  27890. * Mesh side orientation : usually the internal or back surface
  27891. */
  27892. static readonly BACKSIDE: number;
  27893. /**
  27894. * Mesh side orientation : both internal and external or front and back surfaces
  27895. */
  27896. static readonly DOUBLESIDE: number;
  27897. /**
  27898. * Mesh side orientation : by default, `FRONTSIDE`
  27899. */
  27900. static readonly DEFAULTSIDE: number;
  27901. /**
  27902. * Mesh cap setting : no cap
  27903. */
  27904. static readonly NO_CAP: number;
  27905. /**
  27906. * Mesh cap setting : one cap at the beginning of the mesh
  27907. */
  27908. static readonly CAP_START: number;
  27909. /**
  27910. * Mesh cap setting : one cap at the end of the mesh
  27911. */
  27912. static readonly CAP_END: number;
  27913. /**
  27914. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  27915. */
  27916. static readonly CAP_ALL: number;
  27917. /**
  27918. * Mesh pattern setting : no flip or rotate
  27919. */
  27920. static readonly NO_FLIP: number;
  27921. /**
  27922. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  27923. */
  27924. static readonly FLIP_TILE: number;
  27925. /**
  27926. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  27927. */
  27928. static readonly ROTATE_TILE: number;
  27929. /**
  27930. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  27931. */
  27932. static readonly FLIP_ROW: number;
  27933. /**
  27934. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  27935. */
  27936. static readonly ROTATE_ROW: number;
  27937. /**
  27938. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  27939. */
  27940. static readonly FLIP_N_ROTATE_TILE: number;
  27941. /**
  27942. * Mesh pattern setting : rotate pattern and rotate
  27943. */
  27944. static readonly FLIP_N_ROTATE_ROW: number;
  27945. /**
  27946. * Mesh tile positioning : part tiles same on left/right or top/bottom
  27947. */
  27948. static readonly CENTER: number;
  27949. /**
  27950. * Mesh tile positioning : part tiles on left
  27951. */
  27952. static readonly LEFT: number;
  27953. /**
  27954. * Mesh tile positioning : part tiles on right
  27955. */
  27956. static readonly RIGHT: number;
  27957. /**
  27958. * Mesh tile positioning : part tiles on top
  27959. */
  27960. static readonly TOP: number;
  27961. /**
  27962. * Mesh tile positioning : part tiles on bottom
  27963. */
  27964. static readonly BOTTOM: number;
  27965. /**
  27966. * Gets the default side orientation.
  27967. * @param orientation the orientation to value to attempt to get
  27968. * @returns the default orientation
  27969. * @hidden
  27970. */
  27971. static _GetDefaultSideOrientation(orientation?: number): number;
  27972. private _internalMeshDataInfo;
  27973. /**
  27974. * An event triggered before rendering the mesh
  27975. */
  27976. get onBeforeRenderObservable(): Observable<Mesh>;
  27977. /**
  27978. * An event triggered before binding the mesh
  27979. */
  27980. get onBeforeBindObservable(): Observable<Mesh>;
  27981. /**
  27982. * An event triggered after rendering the mesh
  27983. */
  27984. get onAfterRenderObservable(): Observable<Mesh>;
  27985. /**
  27986. * An event triggered before drawing the mesh
  27987. */
  27988. get onBeforeDrawObservable(): Observable<Mesh>;
  27989. private _onBeforeDrawObserver;
  27990. /**
  27991. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  27992. */
  27993. set onBeforeDraw(callback: () => void);
  27994. get hasInstances(): boolean;
  27995. get hasThinInstances(): boolean;
  27996. /**
  27997. * Gets the delay loading state of the mesh (when delay loading is turned on)
  27998. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  27999. */
  28000. delayLoadState: number;
  28001. /**
  28002. * Gets the list of instances created from this mesh
  28003. * it is not supposed to be modified manually.
  28004. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  28005. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28006. */
  28007. instances: InstancedMesh[];
  28008. /**
  28009. * Gets the file containing delay loading data for this mesh
  28010. */
  28011. delayLoadingFile: string;
  28012. /** @hidden */
  28013. _binaryInfo: any;
  28014. /**
  28015. * User defined function used to change how LOD level selection is done
  28016. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28017. */
  28018. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  28019. /**
  28020. * Gets or sets the morph target manager
  28021. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28022. */
  28023. get morphTargetManager(): Nullable<MorphTargetManager>;
  28024. set morphTargetManager(value: Nullable<MorphTargetManager>);
  28025. /** @hidden */
  28026. _creationDataStorage: Nullable<_CreationDataStorage>;
  28027. /** @hidden */
  28028. _geometry: Nullable<Geometry>;
  28029. /** @hidden */
  28030. _delayInfo: Array<string>;
  28031. /** @hidden */
  28032. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  28033. /** @hidden */
  28034. _instanceDataStorage: _InstanceDataStorage;
  28035. /** @hidden */
  28036. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  28037. private _effectiveMaterial;
  28038. /** @hidden */
  28039. _shouldGenerateFlatShading: boolean;
  28040. /** @hidden */
  28041. _originalBuilderSideOrientation: number;
  28042. /**
  28043. * Use this property to change the original side orientation defined at construction time
  28044. */
  28045. overrideMaterialSideOrientation: Nullable<number>;
  28046. /**
  28047. * Gets the source mesh (the one used to clone this one from)
  28048. */
  28049. get source(): Nullable<Mesh>;
  28050. /**
  28051. * Gets or sets a boolean indicating that this mesh does not use index buffer
  28052. */
  28053. get isUnIndexed(): boolean;
  28054. set isUnIndexed(value: boolean);
  28055. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  28056. get worldMatrixInstancedBuffer(): Float32Array;
  28057. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  28058. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  28059. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  28060. /**
  28061. * @constructor
  28062. * @param name The value used by scene.getMeshByName() to do a lookup.
  28063. * @param scene The scene to add this mesh to.
  28064. * @param parent The parent of this mesh, if it has one
  28065. * @param source An optional Mesh from which geometry is shared, cloned.
  28066. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28067. * When false, achieved by calling a clone(), also passing False.
  28068. * This will make creation of children, recursive.
  28069. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  28070. */
  28071. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  28072. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28073. doNotInstantiate: boolean;
  28074. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28075. /**
  28076. * Gets the class name
  28077. * @returns the string "Mesh".
  28078. */
  28079. getClassName(): string;
  28080. /** @hidden */
  28081. get _isMesh(): boolean;
  28082. /**
  28083. * Returns a description of this mesh
  28084. * @param fullDetails define if full details about this mesh must be used
  28085. * @returns a descriptive string representing this mesh
  28086. */
  28087. toString(fullDetails?: boolean): string;
  28088. /** @hidden */
  28089. _unBindEffect(): void;
  28090. /**
  28091. * Gets a boolean indicating if this mesh has LOD
  28092. */
  28093. get hasLODLevels(): boolean;
  28094. /**
  28095. * Gets the list of MeshLODLevel associated with the current mesh
  28096. * @returns an array of MeshLODLevel
  28097. */
  28098. getLODLevels(): MeshLODLevel[];
  28099. private _sortLODLevels;
  28100. /**
  28101. * Add a mesh as LOD level triggered at the given distance.
  28102. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28103. * @param distance The distance from the center of the object to show this level
  28104. * @param mesh The mesh to be added as LOD level (can be null)
  28105. * @return This mesh (for chaining)
  28106. */
  28107. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  28108. /**
  28109. * Returns the LOD level mesh at the passed distance or null if not found.
  28110. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28111. * @param distance The distance from the center of the object to show this level
  28112. * @returns a Mesh or `null`
  28113. */
  28114. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  28115. /**
  28116. * Remove a mesh from the LOD array
  28117. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28118. * @param mesh defines the mesh to be removed
  28119. * @return This mesh (for chaining)
  28120. */
  28121. removeLODLevel(mesh: Mesh): Mesh;
  28122. /**
  28123. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  28124. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28125. * @param camera defines the camera to use to compute distance
  28126. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  28127. * @return This mesh (for chaining)
  28128. */
  28129. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  28130. /**
  28131. * Gets the mesh internal Geometry object
  28132. */
  28133. get geometry(): Nullable<Geometry>;
  28134. /**
  28135. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  28136. * @returns the total number of vertices
  28137. */
  28138. getTotalVertices(): number;
  28139. /**
  28140. * Returns the content of an associated vertex buffer
  28141. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28142. * - VertexBuffer.PositionKind
  28143. * - VertexBuffer.UVKind
  28144. * - VertexBuffer.UV2Kind
  28145. * - VertexBuffer.UV3Kind
  28146. * - VertexBuffer.UV4Kind
  28147. * - VertexBuffer.UV5Kind
  28148. * - VertexBuffer.UV6Kind
  28149. * - VertexBuffer.ColorKind
  28150. * - VertexBuffer.MatricesIndicesKind
  28151. * - VertexBuffer.MatricesIndicesExtraKind
  28152. * - VertexBuffer.MatricesWeightsKind
  28153. * - VertexBuffer.MatricesWeightsExtraKind
  28154. * @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
  28155. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  28156. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  28157. */
  28158. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28159. /**
  28160. * Returns the mesh VertexBuffer object from the requested `kind`
  28161. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28162. * - VertexBuffer.PositionKind
  28163. * - VertexBuffer.NormalKind
  28164. * - VertexBuffer.UVKind
  28165. * - VertexBuffer.UV2Kind
  28166. * - VertexBuffer.UV3Kind
  28167. * - VertexBuffer.UV4Kind
  28168. * - VertexBuffer.UV5Kind
  28169. * - VertexBuffer.UV6Kind
  28170. * - VertexBuffer.ColorKind
  28171. * - VertexBuffer.MatricesIndicesKind
  28172. * - VertexBuffer.MatricesIndicesExtraKind
  28173. * - VertexBuffer.MatricesWeightsKind
  28174. * - VertexBuffer.MatricesWeightsExtraKind
  28175. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  28176. */
  28177. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  28178. /**
  28179. * Tests if a specific vertex buffer is associated with this mesh
  28180. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28181. * - VertexBuffer.PositionKind
  28182. * - VertexBuffer.NormalKind
  28183. * - VertexBuffer.UVKind
  28184. * - VertexBuffer.UV2Kind
  28185. * - VertexBuffer.UV3Kind
  28186. * - VertexBuffer.UV4Kind
  28187. * - VertexBuffer.UV5Kind
  28188. * - VertexBuffer.UV6Kind
  28189. * - VertexBuffer.ColorKind
  28190. * - VertexBuffer.MatricesIndicesKind
  28191. * - VertexBuffer.MatricesIndicesExtraKind
  28192. * - VertexBuffer.MatricesWeightsKind
  28193. * - VertexBuffer.MatricesWeightsExtraKind
  28194. * @returns a boolean
  28195. */
  28196. isVerticesDataPresent(kind: string): boolean;
  28197. /**
  28198. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  28199. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28200. * - VertexBuffer.PositionKind
  28201. * - VertexBuffer.UVKind
  28202. * - VertexBuffer.UV2Kind
  28203. * - VertexBuffer.UV3Kind
  28204. * - VertexBuffer.UV4Kind
  28205. * - VertexBuffer.UV5Kind
  28206. * - VertexBuffer.UV6Kind
  28207. * - VertexBuffer.ColorKind
  28208. * - VertexBuffer.MatricesIndicesKind
  28209. * - VertexBuffer.MatricesIndicesExtraKind
  28210. * - VertexBuffer.MatricesWeightsKind
  28211. * - VertexBuffer.MatricesWeightsExtraKind
  28212. * @returns a boolean
  28213. */
  28214. isVertexBufferUpdatable(kind: string): boolean;
  28215. /**
  28216. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  28217. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28218. * - VertexBuffer.PositionKind
  28219. * - VertexBuffer.NormalKind
  28220. * - VertexBuffer.UVKind
  28221. * - VertexBuffer.UV2Kind
  28222. * - VertexBuffer.UV3Kind
  28223. * - VertexBuffer.UV4Kind
  28224. * - VertexBuffer.UV5Kind
  28225. * - VertexBuffer.UV6Kind
  28226. * - VertexBuffer.ColorKind
  28227. * - VertexBuffer.MatricesIndicesKind
  28228. * - VertexBuffer.MatricesIndicesExtraKind
  28229. * - VertexBuffer.MatricesWeightsKind
  28230. * - VertexBuffer.MatricesWeightsExtraKind
  28231. * @returns an array of strings
  28232. */
  28233. getVerticesDataKinds(): string[];
  28234. /**
  28235. * Returns a positive integer : the total number of indices in this mesh geometry.
  28236. * @returns the numner of indices or zero if the mesh has no geometry.
  28237. */
  28238. getTotalIndices(): number;
  28239. /**
  28240. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28241. * @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.
  28242. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  28243. * @returns the indices array or an empty array if the mesh has no geometry
  28244. */
  28245. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  28246. get isBlocked(): boolean;
  28247. /**
  28248. * Determine if the current mesh is ready to be rendered
  28249. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28250. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  28251. * @returns true if all associated assets are ready (material, textures, shaders)
  28252. */
  28253. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  28254. /**
  28255. * 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.
  28256. */
  28257. get areNormalsFrozen(): boolean;
  28258. /**
  28259. * 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.
  28260. * @returns the current mesh
  28261. */
  28262. freezeNormals(): Mesh;
  28263. /**
  28264. * 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
  28265. * @returns the current mesh
  28266. */
  28267. unfreezeNormals(): Mesh;
  28268. /**
  28269. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  28270. */
  28271. set overridenInstanceCount(count: number);
  28272. /** @hidden */
  28273. _preActivate(): Mesh;
  28274. /** @hidden */
  28275. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28276. /** @hidden */
  28277. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  28278. protected _afterComputeWorldMatrix(): void;
  28279. /** @hidden */
  28280. _postActivate(): void;
  28281. /**
  28282. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28283. * This means the mesh underlying bounding box and sphere are recomputed.
  28284. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28285. * @returns the current mesh
  28286. */
  28287. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  28288. /** @hidden */
  28289. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  28290. /**
  28291. * This function will subdivide the mesh into multiple submeshes
  28292. * @param count defines the expected number of submeshes
  28293. */
  28294. subdivide(count: number): void;
  28295. /**
  28296. * Copy a FloatArray into a specific associated vertex buffer
  28297. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28298. * - VertexBuffer.PositionKind
  28299. * - VertexBuffer.UVKind
  28300. * - VertexBuffer.UV2Kind
  28301. * - VertexBuffer.UV3Kind
  28302. * - VertexBuffer.UV4Kind
  28303. * - VertexBuffer.UV5Kind
  28304. * - VertexBuffer.UV6Kind
  28305. * - VertexBuffer.ColorKind
  28306. * - VertexBuffer.MatricesIndicesKind
  28307. * - VertexBuffer.MatricesIndicesExtraKind
  28308. * - VertexBuffer.MatricesWeightsKind
  28309. * - VertexBuffer.MatricesWeightsExtraKind
  28310. * @param data defines the data source
  28311. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28312. * @param stride defines the data stride size (can be null)
  28313. * @returns the current mesh
  28314. */
  28315. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28316. /**
  28317. * Delete a vertex buffer associated with this mesh
  28318. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  28319. * - VertexBuffer.PositionKind
  28320. * - VertexBuffer.UVKind
  28321. * - VertexBuffer.UV2Kind
  28322. * - VertexBuffer.UV3Kind
  28323. * - VertexBuffer.UV4Kind
  28324. * - VertexBuffer.UV5Kind
  28325. * - VertexBuffer.UV6Kind
  28326. * - VertexBuffer.ColorKind
  28327. * - VertexBuffer.MatricesIndicesKind
  28328. * - VertexBuffer.MatricesIndicesExtraKind
  28329. * - VertexBuffer.MatricesWeightsKind
  28330. * - VertexBuffer.MatricesWeightsExtraKind
  28331. */
  28332. removeVerticesData(kind: string): void;
  28333. /**
  28334. * Flags an associated vertex buffer as updatable
  28335. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  28336. * - VertexBuffer.PositionKind
  28337. * - VertexBuffer.UVKind
  28338. * - VertexBuffer.UV2Kind
  28339. * - VertexBuffer.UV3Kind
  28340. * - VertexBuffer.UV4Kind
  28341. * - VertexBuffer.UV5Kind
  28342. * - VertexBuffer.UV6Kind
  28343. * - VertexBuffer.ColorKind
  28344. * - VertexBuffer.MatricesIndicesKind
  28345. * - VertexBuffer.MatricesIndicesExtraKind
  28346. * - VertexBuffer.MatricesWeightsKind
  28347. * - VertexBuffer.MatricesWeightsExtraKind
  28348. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28349. */
  28350. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  28351. /**
  28352. * Sets the mesh global Vertex Buffer
  28353. * @param buffer defines the buffer to use
  28354. * @returns the current mesh
  28355. */
  28356. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  28357. /**
  28358. * Update a specific associated vertex buffer
  28359. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28360. * - VertexBuffer.PositionKind
  28361. * - VertexBuffer.UVKind
  28362. * - VertexBuffer.UV2Kind
  28363. * - VertexBuffer.UV3Kind
  28364. * - VertexBuffer.UV4Kind
  28365. * - VertexBuffer.UV5Kind
  28366. * - VertexBuffer.UV6Kind
  28367. * - VertexBuffer.ColorKind
  28368. * - VertexBuffer.MatricesIndicesKind
  28369. * - VertexBuffer.MatricesIndicesExtraKind
  28370. * - VertexBuffer.MatricesWeightsKind
  28371. * - VertexBuffer.MatricesWeightsExtraKind
  28372. * @param data defines the data source
  28373. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  28374. * @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)
  28375. * @returns the current mesh
  28376. */
  28377. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28378. /**
  28379. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  28380. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  28381. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  28382. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  28383. * @returns the current mesh
  28384. */
  28385. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  28386. /**
  28387. * Creates a un-shared specific occurence of the geometry for the mesh.
  28388. * @returns the current mesh
  28389. */
  28390. makeGeometryUnique(): Mesh;
  28391. /**
  28392. * Set the index buffer of this mesh
  28393. * @param indices defines the source data
  28394. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  28395. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  28396. * @returns the current mesh
  28397. */
  28398. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  28399. /**
  28400. * Update the current index buffer
  28401. * @param indices defines the source data
  28402. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28403. * @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)
  28404. * @returns the current mesh
  28405. */
  28406. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28407. /**
  28408. * Invert the geometry to move from a right handed system to a left handed one.
  28409. * @returns the current mesh
  28410. */
  28411. toLeftHanded(): Mesh;
  28412. /** @hidden */
  28413. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28414. /** @hidden */
  28415. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28416. /**
  28417. * Registers for this mesh a javascript function called just before the rendering process
  28418. * @param func defines the function to call before rendering this mesh
  28419. * @returns the current mesh
  28420. */
  28421. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28422. /**
  28423. * Disposes a previously registered javascript function called before the rendering
  28424. * @param func defines the function to remove
  28425. * @returns the current mesh
  28426. */
  28427. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28428. /**
  28429. * Registers for this mesh a javascript function called just after the rendering is complete
  28430. * @param func defines the function to call after rendering this mesh
  28431. * @returns the current mesh
  28432. */
  28433. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28434. /**
  28435. * Disposes a previously registered javascript function called after the rendering.
  28436. * @param func defines the function to remove
  28437. * @returns the current mesh
  28438. */
  28439. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28440. /** @hidden */
  28441. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  28442. /** @hidden */
  28443. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  28444. /** @hidden */
  28445. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  28446. /** @hidden */
  28447. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  28448. /** @hidden */
  28449. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  28450. /** @hidden */
  28451. _rebuild(): void;
  28452. /** @hidden */
  28453. _freeze(): void;
  28454. /** @hidden */
  28455. _unFreeze(): void;
  28456. /**
  28457. * 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
  28458. * @param subMesh defines the subMesh to render
  28459. * @param enableAlphaMode defines if alpha mode can be changed
  28460. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  28461. * @returns the current mesh
  28462. */
  28463. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  28464. private _onBeforeDraw;
  28465. /**
  28466. * Renormalize the mesh and patch it up if there are no weights
  28467. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  28468. * However in the case of zero weights then we set just a single influence to 1.
  28469. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  28470. */
  28471. cleanMatrixWeights(): void;
  28472. private normalizeSkinFourWeights;
  28473. private normalizeSkinWeightsAndExtra;
  28474. /**
  28475. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  28476. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  28477. * the user know there was an issue with importing the mesh
  28478. * @returns a validation object with skinned, valid and report string
  28479. */
  28480. validateSkinning(): {
  28481. skinned: boolean;
  28482. valid: boolean;
  28483. report: string;
  28484. };
  28485. /** @hidden */
  28486. _checkDelayState(): Mesh;
  28487. private _queueLoad;
  28488. /**
  28489. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28490. * A mesh is in the frustum if its bounding box intersects the frustum
  28491. * @param frustumPlanes defines the frustum to test
  28492. * @returns true if the mesh is in the frustum planes
  28493. */
  28494. isInFrustum(frustumPlanes: Plane[]): boolean;
  28495. /**
  28496. * Sets the mesh material by the material or multiMaterial `id` property
  28497. * @param id is a string identifying the material or the multiMaterial
  28498. * @returns the current mesh
  28499. */
  28500. setMaterialByID(id: string): Mesh;
  28501. /**
  28502. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  28503. * @returns an array of IAnimatable
  28504. */
  28505. getAnimatables(): IAnimatable[];
  28506. /**
  28507. * Modifies the mesh geometry according to the passed transformation matrix.
  28508. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  28509. * The mesh normals are modified using the same transformation.
  28510. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28511. * @param transform defines the transform matrix to use
  28512. * @see https://doc.babylonjs.com/resources/baking_transformations
  28513. * @returns the current mesh
  28514. */
  28515. bakeTransformIntoVertices(transform: Matrix): Mesh;
  28516. /**
  28517. * Modifies the mesh geometry according to its own current World Matrix.
  28518. * The mesh World Matrix is then reset.
  28519. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  28520. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28521. * @see https://doc.babylonjs.com/resources/baking_transformations
  28522. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  28523. * @returns the current mesh
  28524. */
  28525. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  28526. /** @hidden */
  28527. get _positions(): Nullable<Vector3[]>;
  28528. /** @hidden */
  28529. _resetPointsArrayCache(): Mesh;
  28530. /** @hidden */
  28531. _generatePointsArray(): boolean;
  28532. /**
  28533. * Returns a new Mesh object generated from the current mesh properties.
  28534. * This method must not get confused with createInstance()
  28535. * @param name is a string, the name given to the new mesh
  28536. * @param newParent can be any Node object (default `null`)
  28537. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  28538. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  28539. * @returns a new mesh
  28540. */
  28541. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  28542. /**
  28543. * Releases resources associated with this mesh.
  28544. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28545. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28546. */
  28547. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28548. /** @hidden */
  28549. _disposeInstanceSpecificData(): void;
  28550. /** @hidden */
  28551. _disposeThinInstanceSpecificData(): void;
  28552. /**
  28553. * Modifies the mesh geometry according to a displacement map.
  28554. * 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.
  28555. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28556. * @param url is a string, the URL from the image file is to be downloaded.
  28557. * @param minHeight is the lower limit of the displacement.
  28558. * @param maxHeight is the upper limit of the displacement.
  28559. * @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.
  28560. * @param uvOffset is an optional vector2 used to offset UV.
  28561. * @param uvScale is an optional vector2 used to scale UV.
  28562. * @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.
  28563. * @returns the Mesh.
  28564. */
  28565. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28566. /**
  28567. * Modifies the mesh geometry according to a displacementMap buffer.
  28568. * 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.
  28569. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28570. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  28571. * @param heightMapWidth is the width of the buffer image.
  28572. * @param heightMapHeight is the height of the buffer image.
  28573. * @param minHeight is the lower limit of the displacement.
  28574. * @param maxHeight is the upper limit of the displacement.
  28575. * @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.
  28576. * @param uvOffset is an optional vector2 used to offset UV.
  28577. * @param uvScale is an optional vector2 used to scale UV.
  28578. * @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.
  28579. * @returns the Mesh.
  28580. */
  28581. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28582. /**
  28583. * Modify the mesh to get a flat shading rendering.
  28584. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  28585. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  28586. * @returns current mesh
  28587. */
  28588. convertToFlatShadedMesh(): Mesh;
  28589. /**
  28590. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  28591. * In other words, more vertices, no more indices and a single bigger VBO.
  28592. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  28593. * @returns current mesh
  28594. */
  28595. convertToUnIndexedMesh(): Mesh;
  28596. /**
  28597. * Inverses facet orientations.
  28598. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28599. * @param flipNormals will also inverts the normals
  28600. * @returns current mesh
  28601. */
  28602. flipFaces(flipNormals?: boolean): Mesh;
  28603. /**
  28604. * Increase the number of facets and hence vertices in a mesh
  28605. * Vertex normals are interpolated from existing vertex normals
  28606. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28607. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  28608. */
  28609. increaseVertices(numberPerEdge: number): void;
  28610. /**
  28611. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  28612. * This will undo any application of covertToFlatShadedMesh
  28613. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28614. */
  28615. forceSharedVertices(): void;
  28616. /** @hidden */
  28617. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  28618. /** @hidden */
  28619. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  28620. /**
  28621. * Creates a new InstancedMesh object from the mesh model.
  28622. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28623. * @param name defines the name of the new instance
  28624. * @returns a new InstancedMesh
  28625. */
  28626. createInstance(name: string): InstancedMesh;
  28627. /**
  28628. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  28629. * After this call, all the mesh instances have the same submeshes than the current mesh.
  28630. * @returns the current mesh
  28631. */
  28632. synchronizeInstances(): Mesh;
  28633. /**
  28634. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28635. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28636. * This should be used together with the simplification to avoid disappearing triangles.
  28637. * @param successCallback an optional success callback to be called after the optimization finished.
  28638. * @returns the current mesh
  28639. */
  28640. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28641. /**
  28642. * Serialize current mesh
  28643. * @param serializationObject defines the object which will receive the serialization data
  28644. */
  28645. serialize(serializationObject: any): void;
  28646. /** @hidden */
  28647. _syncGeometryWithMorphTargetManager(): void;
  28648. /** @hidden */
  28649. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28650. /**
  28651. * Returns a new Mesh object parsed from the source provided.
  28652. * @param parsedMesh is the source
  28653. * @param scene defines the hosting scene
  28654. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28655. * @returns a new Mesh
  28656. */
  28657. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28658. /**
  28659. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28660. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28661. * @param name defines the name of the mesh to create
  28662. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28663. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28664. * @param closePath creates a seam between the first and the last points of each path of the path array
  28665. * @param offset is taken in account only if the `pathArray` is containing a single path
  28666. * @param scene defines the hosting scene
  28667. * @param updatable defines if the mesh must be flagged as updatable
  28668. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28669. * @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)
  28670. * @returns a new Mesh
  28671. */
  28672. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28673. /**
  28674. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28675. * @param name defines the name of the mesh to create
  28676. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28677. * @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
  28678. * @param scene defines the hosting scene
  28679. * @param updatable defines if the mesh must be flagged as updatable
  28680. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28681. * @returns a new Mesh
  28682. */
  28683. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28684. /**
  28685. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  28686. * @param name defines the name of the mesh to create
  28687. * @param size sets the size (float) of each box side (default 1)
  28688. * @param scene defines the hosting scene
  28689. * @param updatable defines if the mesh must be flagged as updatable
  28690. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28691. * @returns a new Mesh
  28692. */
  28693. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28694. /**
  28695. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  28696. * @param name defines the name of the mesh to create
  28697. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28698. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28699. * @param scene defines the hosting scene
  28700. * @param updatable defines if the mesh must be flagged as updatable
  28701. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28702. * @returns a new Mesh
  28703. */
  28704. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28705. /**
  28706. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  28707. * @param name defines the name of the mesh to create
  28708. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28709. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28710. * @param scene defines the hosting scene
  28711. * @returns a new Mesh
  28712. */
  28713. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  28714. /**
  28715. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  28716. * @param name defines the name of the mesh to create
  28717. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  28718. * @param diameterTop set the top cap diameter (floats, default 1)
  28719. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  28720. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  28721. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  28722. * @param scene defines the hosting scene
  28723. * @param updatable defines if the mesh must be flagged as updatable
  28724. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28725. * @returns a new Mesh
  28726. */
  28727. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28728. /**
  28729. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28730. * @param name defines the name of the mesh to create
  28731. * @param diameter sets the diameter size (float) of the torus (default 1)
  28732. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28733. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28734. * @param scene defines the hosting scene
  28735. * @param updatable defines if the mesh must be flagged as updatable
  28736. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28737. * @returns a new Mesh
  28738. */
  28739. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28740. /**
  28741. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28742. * @param name defines the name of the mesh to create
  28743. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28744. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28745. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28746. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28747. * @param p the number of windings on X axis (positive integers, default 2)
  28748. * @param q the number of windings on Y axis (positive integers, default 3)
  28749. * @param scene defines the hosting scene
  28750. * @param updatable defines if the mesh must be flagged as updatable
  28751. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28752. * @returns a new Mesh
  28753. */
  28754. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28755. /**
  28756. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  28757. * @param name defines the name of the mesh to create
  28758. * @param points is an array successive Vector3
  28759. * @param scene defines the hosting scene
  28760. * @param updatable defines if the mesh must be flagged as updatable
  28761. * @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).
  28762. * @returns a new Mesh
  28763. */
  28764. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  28765. /**
  28766. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  28767. * @param name defines the name of the mesh to create
  28768. * @param points is an array successive Vector3
  28769. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  28770. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28771. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  28772. * @param scene defines the hosting scene
  28773. * @param updatable defines if the mesh must be flagged as updatable
  28774. * @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)
  28775. * @returns a new Mesh
  28776. */
  28777. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  28778. /**
  28779. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  28780. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  28781. * 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.
  28782. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28783. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28784. * Remember you can only change the shape positions, not their number when updating a polygon.
  28785. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28786. * @param name defines the name of the mesh to create
  28787. * @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
  28788. * @param scene defines the hosting scene
  28789. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28790. * @param updatable defines if the mesh must be flagged as updatable
  28791. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28792. * @param earcutInjection can be used to inject your own earcut reference
  28793. * @returns a new Mesh
  28794. */
  28795. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28796. /**
  28797. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  28798. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  28799. * @param name defines the name of the mesh to create
  28800. * @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
  28801. * @param depth defines the height of extrusion
  28802. * @param scene defines the hosting scene
  28803. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28804. * @param updatable defines if the mesh must be flagged as updatable
  28805. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28806. * @param earcutInjection can be used to inject your own earcut reference
  28807. * @returns a new Mesh
  28808. */
  28809. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28810. /**
  28811. * Creates an extruded shape mesh.
  28812. * 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
  28813. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28814. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28815. * @param name defines the name of the mesh to create
  28816. * @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
  28817. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28818. * @param scale is the value to scale the shape
  28819. * @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
  28820. * @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
  28821. * @param scene defines the hosting scene
  28822. * @param updatable defines if the mesh must be flagged as updatable
  28823. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28824. * @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)
  28825. * @returns a new Mesh
  28826. */
  28827. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28828. /**
  28829. * Creates an custom extruded shape mesh.
  28830. * The custom extrusion is a parametric shape.
  28831. * It has no predefined shape. Its final shape will depend on the input parameters.
  28832. * Please consider using the same method from the MeshBuilder class instead
  28833. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28834. * @param name defines the name of the mesh to create
  28835. * @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
  28836. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28837. * @param scaleFunction is a custom Javascript function called on each path point
  28838. * @param rotationFunction is a custom Javascript function called on each path point
  28839. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28840. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  28841. * @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
  28842. * @param scene defines the hosting scene
  28843. * @param updatable defines if the mesh must be flagged as updatable
  28844. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28845. * @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)
  28846. * @returns a new Mesh
  28847. */
  28848. 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;
  28849. /**
  28850. * Creates lathe mesh.
  28851. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  28852. * Please consider using the same method from the MeshBuilder class instead
  28853. * @param name defines the name of the mesh to create
  28854. * @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
  28855. * @param radius is the radius value of the lathe
  28856. * @param tessellation is the side number of the lathe.
  28857. * @param scene defines the hosting scene
  28858. * @param updatable defines if the mesh must be flagged as updatable
  28859. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28860. * @returns a new Mesh
  28861. */
  28862. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28863. /**
  28864. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  28865. * @param name defines the name of the mesh to create
  28866. * @param size sets the size (float) of both sides of the plane at once (default 1)
  28867. * @param scene defines the hosting scene
  28868. * @param updatable defines if the mesh must be flagged as updatable
  28869. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28870. * @returns a new Mesh
  28871. */
  28872. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28873. /**
  28874. * Creates a ground mesh.
  28875. * Please consider using the same method from the MeshBuilder class instead
  28876. * @param name defines the name of the mesh to create
  28877. * @param width set the width of the ground
  28878. * @param height set the height of the ground
  28879. * @param subdivisions sets the number of subdivisions per side
  28880. * @param scene defines the hosting scene
  28881. * @param updatable defines if the mesh must be flagged as updatable
  28882. * @returns a new Mesh
  28883. */
  28884. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  28885. /**
  28886. * Creates a tiled ground mesh.
  28887. * Please consider using the same method from the MeshBuilder class instead
  28888. * @param name defines the name of the mesh to create
  28889. * @param xmin set the ground minimum X coordinate
  28890. * @param zmin set the ground minimum Y coordinate
  28891. * @param xmax set the ground maximum X coordinate
  28892. * @param zmax set the ground maximum Z coordinate
  28893. * @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
  28894. * @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
  28895. * @param scene defines the hosting scene
  28896. * @param updatable defines if the mesh must be flagged as updatable
  28897. * @returns a new Mesh
  28898. */
  28899. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  28900. w: number;
  28901. h: number;
  28902. }, precision: {
  28903. w: number;
  28904. h: number;
  28905. }, scene: Scene, updatable?: boolean): Mesh;
  28906. /**
  28907. * Creates a ground mesh from a height map.
  28908. * Please consider using the same method from the MeshBuilder class instead
  28909. * @see https://doc.babylonjs.com/babylon101/height_map
  28910. * @param name defines the name of the mesh to create
  28911. * @param url sets the URL of the height map image resource
  28912. * @param width set the ground width size
  28913. * @param height set the ground height size
  28914. * @param subdivisions sets the number of subdivision per side
  28915. * @param minHeight is the minimum altitude on the ground
  28916. * @param maxHeight is the maximum altitude on the ground
  28917. * @param scene defines the hosting scene
  28918. * @param updatable defines if the mesh must be flagged as updatable
  28919. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  28920. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28921. * @returns a new Mesh
  28922. */
  28923. 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;
  28924. /**
  28925. * Creates a tube mesh.
  28926. * The tube is a parametric shape.
  28927. * It has no predefined shape. Its final shape will depend on the input parameters.
  28928. * Please consider using the same method from the MeshBuilder class instead
  28929. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28930. * @param name defines the name of the mesh to create
  28931. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  28932. * @param radius sets the tube radius size
  28933. * @param tessellation is the number of sides on the tubular surface
  28934. * @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
  28935. * @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
  28936. * @param scene defines the hosting scene
  28937. * @param updatable defines if the mesh must be flagged as updatable
  28938. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28939. * @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)
  28940. * @returns a new Mesh
  28941. */
  28942. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  28943. (i: number, distance: number): number;
  28944. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28945. /**
  28946. * Creates a polyhedron mesh.
  28947. * Please consider using the same method from the MeshBuilder class instead.
  28948. * * 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
  28949. * * The parameter `size` (positive float, default 1) sets the polygon size
  28950. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28951. * * 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`
  28952. * * 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
  28953. * * 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)`)
  28954. * * 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
  28955. * * 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
  28956. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28957. * * 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
  28958. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28959. * @param name defines the name of the mesh to create
  28960. * @param options defines the options used to create the mesh
  28961. * @param scene defines the hosting scene
  28962. * @returns a new Mesh
  28963. */
  28964. static CreatePolyhedron(name: string, options: {
  28965. type?: number;
  28966. size?: number;
  28967. sizeX?: number;
  28968. sizeY?: number;
  28969. sizeZ?: number;
  28970. custom?: any;
  28971. faceUV?: Vector4[];
  28972. faceColors?: Color4[];
  28973. updatable?: boolean;
  28974. sideOrientation?: number;
  28975. }, scene: Scene): Mesh;
  28976. /**
  28977. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28978. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28979. * * 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`)
  28980. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28981. * * 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
  28982. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28983. * * 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
  28984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28985. * @param name defines the name of the mesh
  28986. * @param options defines the options used to create the mesh
  28987. * @param scene defines the hosting scene
  28988. * @returns a new Mesh
  28989. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28990. */
  28991. static CreateIcoSphere(name: string, options: {
  28992. radius?: number;
  28993. flat?: boolean;
  28994. subdivisions?: number;
  28995. sideOrientation?: number;
  28996. updatable?: boolean;
  28997. }, scene: Scene): Mesh;
  28998. /**
  28999. * Creates a decal mesh.
  29000. * Please consider using the same method from the MeshBuilder class instead.
  29001. * A decal is a mesh usually applied as a model onto the surface of another mesh
  29002. * @param name defines the name of the mesh
  29003. * @param sourceMesh defines the mesh receiving the decal
  29004. * @param position sets the position of the decal in world coordinates
  29005. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  29006. * @param size sets the decal scaling
  29007. * @param angle sets the angle to rotate the decal
  29008. * @returns a new Mesh
  29009. */
  29010. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  29011. /**
  29012. * Prepare internal position array for software CPU skinning
  29013. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  29014. */
  29015. setPositionsForCPUSkinning(): Float32Array;
  29016. /**
  29017. * Prepare internal normal array for software CPU skinning
  29018. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  29019. */
  29020. setNormalsForCPUSkinning(): Float32Array;
  29021. /**
  29022. * Updates the vertex buffer by applying transformation from the bones
  29023. * @param skeleton defines the skeleton to apply to current mesh
  29024. * @returns the current mesh
  29025. */
  29026. applySkeleton(skeleton: Skeleton): Mesh;
  29027. /**
  29028. * 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
  29029. * @param meshes defines the list of meshes to scan
  29030. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  29031. */
  29032. static MinMax(meshes: AbstractMesh[]): {
  29033. min: Vector3;
  29034. max: Vector3;
  29035. };
  29036. /**
  29037. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  29038. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  29039. * @returns a vector3
  29040. */
  29041. static Center(meshesOrMinMaxVector: {
  29042. min: Vector3;
  29043. max: Vector3;
  29044. } | AbstractMesh[]): Vector3;
  29045. /**
  29046. * Merge the array of meshes into a single mesh for performance reasons.
  29047. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  29048. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  29049. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  29050. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  29051. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  29052. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  29053. * @returns a new mesh
  29054. */
  29055. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  29056. /** @hidden */
  29057. addInstance(instance: InstancedMesh): void;
  29058. /** @hidden */
  29059. removeInstance(instance: InstancedMesh): void;
  29060. }
  29061. }
  29062. declare module BABYLON {
  29063. /**
  29064. * This is the base class of all the camera used in the application.
  29065. * @see https://doc.babylonjs.com/features/cameras
  29066. */
  29067. export class Camera extends Node {
  29068. /** @hidden */
  29069. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29070. /**
  29071. * This is the default projection mode used by the cameras.
  29072. * It helps recreating a feeling of perspective and better appreciate depth.
  29073. * This is the best way to simulate real life cameras.
  29074. */
  29075. static readonly PERSPECTIVE_CAMERA: number;
  29076. /**
  29077. * This helps creating camera with an orthographic mode.
  29078. * 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.
  29079. */
  29080. static readonly ORTHOGRAPHIC_CAMERA: number;
  29081. /**
  29082. * This is the default FOV mode for perspective cameras.
  29083. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29084. */
  29085. static readonly FOVMODE_VERTICAL_FIXED: number;
  29086. /**
  29087. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29088. */
  29089. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29090. /**
  29091. * This specifies ther is no need for a camera rig.
  29092. * Basically only one eye is rendered corresponding to the camera.
  29093. */
  29094. static readonly RIG_MODE_NONE: number;
  29095. /**
  29096. * Simulates a camera Rig with one blue eye and one red eye.
  29097. * This can be use with 3d blue and red glasses.
  29098. */
  29099. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29100. /**
  29101. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29102. */
  29103. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29104. /**
  29105. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29106. */
  29107. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29108. /**
  29109. * Defines that both eyes of the camera will be rendered over under each other.
  29110. */
  29111. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29112. /**
  29113. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  29114. */
  29115. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  29116. /**
  29117. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29118. */
  29119. static readonly RIG_MODE_VR: number;
  29120. /**
  29121. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29122. */
  29123. static readonly RIG_MODE_WEBVR: number;
  29124. /**
  29125. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29126. */
  29127. static readonly RIG_MODE_CUSTOM: number;
  29128. /**
  29129. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29130. */
  29131. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29132. /**
  29133. * Define the input manager associated with the camera.
  29134. */
  29135. inputs: CameraInputsManager<Camera>;
  29136. /** @hidden */
  29137. _position: Vector3;
  29138. /**
  29139. * Define the current local position of the camera in the scene
  29140. */
  29141. get position(): Vector3;
  29142. set position(newPosition: Vector3);
  29143. /**
  29144. * The vector the camera should consider as up.
  29145. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29146. */
  29147. upVector: Vector3;
  29148. /**
  29149. * Define the current limit on the left side for an orthographic camera
  29150. * In scene unit
  29151. */
  29152. orthoLeft: Nullable<number>;
  29153. /**
  29154. * Define the current limit on the right side for an orthographic camera
  29155. * In scene unit
  29156. */
  29157. orthoRight: Nullable<number>;
  29158. /**
  29159. * Define the current limit on the bottom side for an orthographic camera
  29160. * In scene unit
  29161. */
  29162. orthoBottom: Nullable<number>;
  29163. /**
  29164. * Define the current limit on the top side for an orthographic camera
  29165. * In scene unit
  29166. */
  29167. orthoTop: Nullable<number>;
  29168. /**
  29169. * Field Of View is set in Radians. (default is 0.8)
  29170. */
  29171. fov: number;
  29172. /**
  29173. * Define the minimum distance the camera can see from.
  29174. * This is important to note that the depth buffer are not infinite and the closer it starts
  29175. * the more your scene might encounter depth fighting issue.
  29176. */
  29177. minZ: number;
  29178. /**
  29179. * Define the maximum distance the camera can see to.
  29180. * This is important to note that the depth buffer are not infinite and the further it end
  29181. * the more your scene might encounter depth fighting issue.
  29182. */
  29183. maxZ: number;
  29184. /**
  29185. * Define the default inertia of the camera.
  29186. * This helps giving a smooth feeling to the camera movement.
  29187. */
  29188. inertia: number;
  29189. /**
  29190. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  29191. */
  29192. mode: number;
  29193. /**
  29194. * Define whether the camera is intermediate.
  29195. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29196. */
  29197. isIntermediate: boolean;
  29198. /**
  29199. * Define the viewport of the camera.
  29200. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29201. */
  29202. viewport: Viewport;
  29203. /**
  29204. * Restricts the camera to viewing objects with the same layerMask.
  29205. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29206. */
  29207. layerMask: number;
  29208. /**
  29209. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29210. */
  29211. fovMode: number;
  29212. /**
  29213. * Rig mode of the camera.
  29214. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29215. * This is normally controlled byt the camera themselves as internal use.
  29216. */
  29217. cameraRigMode: number;
  29218. /**
  29219. * Defines the distance between both "eyes" in case of a RIG
  29220. */
  29221. interaxialDistance: number;
  29222. /**
  29223. * Defines if stereoscopic rendering is done side by side or over under.
  29224. */
  29225. isStereoscopicSideBySide: boolean;
  29226. /**
  29227. * 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
  29228. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29229. * else in the scene. (Eg. security camera)
  29230. *
  29231. * 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)
  29232. */
  29233. customRenderTargets: RenderTargetTexture[];
  29234. /**
  29235. * When set, the camera will render to this render target instead of the default canvas
  29236. *
  29237. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  29238. */
  29239. outputRenderTarget: Nullable<RenderTargetTexture>;
  29240. /**
  29241. * Observable triggered when the camera view matrix has changed.
  29242. */
  29243. onViewMatrixChangedObservable: Observable<Camera>;
  29244. /**
  29245. * Observable triggered when the camera Projection matrix has changed.
  29246. */
  29247. onProjectionMatrixChangedObservable: Observable<Camera>;
  29248. /**
  29249. * Observable triggered when the inputs have been processed.
  29250. */
  29251. onAfterCheckInputsObservable: Observable<Camera>;
  29252. /**
  29253. * Observable triggered when reset has been called and applied to the camera.
  29254. */
  29255. onRestoreStateObservable: Observable<Camera>;
  29256. /**
  29257. * Is this camera a part of a rig system?
  29258. */
  29259. isRigCamera: boolean;
  29260. /**
  29261. * If isRigCamera set to true this will be set with the parent camera.
  29262. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  29263. */
  29264. rigParent?: Camera;
  29265. /** @hidden */
  29266. _cameraRigParams: any;
  29267. /** @hidden */
  29268. _rigCameras: Camera[];
  29269. /** @hidden */
  29270. _rigPostProcess: Nullable<PostProcess>;
  29271. protected _webvrViewMatrix: Matrix;
  29272. /** @hidden */
  29273. _skipRendering: boolean;
  29274. /** @hidden */
  29275. _projectionMatrix: Matrix;
  29276. /** @hidden */
  29277. _postProcesses: Nullable<PostProcess>[];
  29278. /** @hidden */
  29279. _activeMeshes: SmartArray<AbstractMesh>;
  29280. protected _globalPosition: Vector3;
  29281. /** @hidden */
  29282. _computedViewMatrix: Matrix;
  29283. private _doNotComputeProjectionMatrix;
  29284. private _transformMatrix;
  29285. private _frustumPlanes;
  29286. private _refreshFrustumPlanes;
  29287. private _storedFov;
  29288. private _stateStored;
  29289. /**
  29290. * Instantiates a new camera object.
  29291. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29292. * @see https://doc.babylonjs.com/features/cameras
  29293. * @param name Defines the name of the camera in the scene
  29294. * @param position Defines the position of the camera
  29295. * @param scene Defines the scene the camera belongs too
  29296. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29297. */
  29298. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29299. /**
  29300. * Store current camera state (fov, position, etc..)
  29301. * @returns the camera
  29302. */
  29303. storeState(): Camera;
  29304. /**
  29305. * Restores the camera state values if it has been stored. You must call storeState() first
  29306. */
  29307. protected _restoreStateValues(): boolean;
  29308. /**
  29309. * Restored camera state. You must call storeState() first.
  29310. * @returns true if restored and false otherwise
  29311. */
  29312. restoreState(): boolean;
  29313. /**
  29314. * Gets the class name of the camera.
  29315. * @returns the class name
  29316. */
  29317. getClassName(): string;
  29318. /** @hidden */
  29319. readonly _isCamera: boolean;
  29320. /**
  29321. * Gets a string representation of the camera useful for debug purpose.
  29322. * @param fullDetails Defines that a more verboe level of logging is required
  29323. * @returns the string representation
  29324. */
  29325. toString(fullDetails?: boolean): string;
  29326. /**
  29327. * Gets the current world space position of the camera.
  29328. */
  29329. get globalPosition(): Vector3;
  29330. /**
  29331. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29332. * @returns the active meshe list
  29333. */
  29334. getActiveMeshes(): SmartArray<AbstractMesh>;
  29335. /**
  29336. * Check whether a mesh is part of the current active mesh list of the camera
  29337. * @param mesh Defines the mesh to check
  29338. * @returns true if active, false otherwise
  29339. */
  29340. isActiveMesh(mesh: Mesh): boolean;
  29341. /**
  29342. * Is this camera ready to be used/rendered
  29343. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29344. * @return true if the camera is ready
  29345. */
  29346. isReady(completeCheck?: boolean): boolean;
  29347. /** @hidden */
  29348. _initCache(): void;
  29349. /** @hidden */
  29350. _updateCache(ignoreParentClass?: boolean): void;
  29351. /** @hidden */
  29352. _isSynchronized(): boolean;
  29353. /** @hidden */
  29354. _isSynchronizedViewMatrix(): boolean;
  29355. /** @hidden */
  29356. _isSynchronizedProjectionMatrix(): boolean;
  29357. /**
  29358. * Attach the input controls to a specific dom element to get the input from.
  29359. * @param element Defines the element the controls should be listened from
  29360. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29361. */
  29362. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29363. /**
  29364. * Detach the current controls from the specified dom element.
  29365. * @param element Defines the element to stop listening the inputs from
  29366. */
  29367. detachControl(element: HTMLElement): void;
  29368. /**
  29369. * Update the camera state according to the different inputs gathered during the frame.
  29370. */
  29371. update(): void;
  29372. /** @hidden */
  29373. _checkInputs(): void;
  29374. /** @hidden */
  29375. get rigCameras(): Camera[];
  29376. /**
  29377. * Gets the post process used by the rig cameras
  29378. */
  29379. get rigPostProcess(): Nullable<PostProcess>;
  29380. /**
  29381. * Internal, gets the first post proces.
  29382. * @returns the first post process to be run on this camera.
  29383. */
  29384. _getFirstPostProcess(): Nullable<PostProcess>;
  29385. private _cascadePostProcessesToRigCams;
  29386. /**
  29387. * Attach a post process to the camera.
  29388. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29389. * @param postProcess The post process to attach to the camera
  29390. * @param insertAt The position of the post process in case several of them are in use in the scene
  29391. * @returns the position the post process has been inserted at
  29392. */
  29393. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29394. /**
  29395. * Detach a post process to the camera.
  29396. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29397. * @param postProcess The post process to detach from the camera
  29398. */
  29399. detachPostProcess(postProcess: PostProcess): void;
  29400. /**
  29401. * Gets the current world matrix of the camera
  29402. */
  29403. getWorldMatrix(): Matrix;
  29404. /** @hidden */
  29405. _getViewMatrix(): Matrix;
  29406. /**
  29407. * Gets the current view matrix of the camera.
  29408. * @param force forces the camera to recompute the matrix without looking at the cached state
  29409. * @returns the view matrix
  29410. */
  29411. getViewMatrix(force?: boolean): Matrix;
  29412. /**
  29413. * Freeze the projection matrix.
  29414. * It will prevent the cache check of the camera projection compute and can speed up perf
  29415. * if no parameter of the camera are meant to change
  29416. * @param projection Defines manually a projection if necessary
  29417. */
  29418. freezeProjectionMatrix(projection?: Matrix): void;
  29419. /**
  29420. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29421. */
  29422. unfreezeProjectionMatrix(): void;
  29423. /**
  29424. * Gets the current projection matrix of the camera.
  29425. * @param force forces the camera to recompute the matrix without looking at the cached state
  29426. * @returns the projection matrix
  29427. */
  29428. getProjectionMatrix(force?: boolean): Matrix;
  29429. /**
  29430. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29431. * @returns a Matrix
  29432. */
  29433. getTransformationMatrix(): Matrix;
  29434. private _updateFrustumPlanes;
  29435. /**
  29436. * Checks if a cullable object (mesh...) is in the camera frustum
  29437. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29438. * @param target The object to check
  29439. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29440. * @returns true if the object is in frustum otherwise false
  29441. */
  29442. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29443. /**
  29444. * Checks if a cullable object (mesh...) is in the camera frustum
  29445. * Unlike isInFrustum this cheks the full bounding box
  29446. * @param target The object to check
  29447. * @returns true if the object is in frustum otherwise false
  29448. */
  29449. isCompletelyInFrustum(target: ICullable): boolean;
  29450. /**
  29451. * Gets a ray in the forward direction from the camera.
  29452. * @param length Defines the length of the ray to create
  29453. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29454. * @param origin Defines the start point of the ray which defaults to the camera position
  29455. * @returns the forward ray
  29456. */
  29457. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29458. /**
  29459. * Releases resources associated with this node.
  29460. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29461. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29462. */
  29463. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29464. /** @hidden */
  29465. _isLeftCamera: boolean;
  29466. /**
  29467. * Gets the left camera of a rig setup in case of Rigged Camera
  29468. */
  29469. get isLeftCamera(): boolean;
  29470. /** @hidden */
  29471. _isRightCamera: boolean;
  29472. /**
  29473. * Gets the right camera of a rig setup in case of Rigged Camera
  29474. */
  29475. get isRightCamera(): boolean;
  29476. /**
  29477. * Gets the left camera of a rig setup in case of Rigged Camera
  29478. */
  29479. get leftCamera(): Nullable<FreeCamera>;
  29480. /**
  29481. * Gets the right camera of a rig setup in case of Rigged Camera
  29482. */
  29483. get rightCamera(): Nullable<FreeCamera>;
  29484. /**
  29485. * Gets the left camera target of a rig setup in case of Rigged Camera
  29486. * @returns the target position
  29487. */
  29488. getLeftTarget(): Nullable<Vector3>;
  29489. /**
  29490. * Gets the right camera target of a rig setup in case of Rigged Camera
  29491. * @returns the target position
  29492. */
  29493. getRightTarget(): Nullable<Vector3>;
  29494. /**
  29495. * @hidden
  29496. */
  29497. setCameraRigMode(mode: number, rigParams: any): void;
  29498. /** @hidden */
  29499. static _setStereoscopicRigMode(camera: Camera): void;
  29500. /** @hidden */
  29501. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29502. /** @hidden */
  29503. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29504. /** @hidden */
  29505. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29506. /** @hidden */
  29507. _getVRProjectionMatrix(): Matrix;
  29508. protected _updateCameraRotationMatrix(): void;
  29509. protected _updateWebVRCameraRotationMatrix(): void;
  29510. /**
  29511. * This function MUST be overwritten by the different WebVR cameras available.
  29512. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29513. * @hidden
  29514. */
  29515. _getWebVRProjectionMatrix(): Matrix;
  29516. /**
  29517. * This function MUST be overwritten by the different WebVR cameras available.
  29518. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29519. * @hidden
  29520. */
  29521. _getWebVRViewMatrix(): Matrix;
  29522. /** @hidden */
  29523. setCameraRigParameter(name: string, value: any): void;
  29524. /**
  29525. * needs to be overridden by children so sub has required properties to be copied
  29526. * @hidden
  29527. */
  29528. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29529. /**
  29530. * May need to be overridden by children
  29531. * @hidden
  29532. */
  29533. _updateRigCameras(): void;
  29534. /** @hidden */
  29535. _setupInputs(): void;
  29536. /**
  29537. * Serialiaze the camera setup to a json represention
  29538. * @returns the JSON representation
  29539. */
  29540. serialize(): any;
  29541. /**
  29542. * Clones the current camera.
  29543. * @param name The cloned camera name
  29544. * @returns the cloned camera
  29545. */
  29546. clone(name: string): Camera;
  29547. /**
  29548. * Gets the direction of the camera relative to a given local axis.
  29549. * @param localAxis Defines the reference axis to provide a relative direction.
  29550. * @return the direction
  29551. */
  29552. getDirection(localAxis: Vector3): Vector3;
  29553. /**
  29554. * Returns the current camera absolute rotation
  29555. */
  29556. get absoluteRotation(): Quaternion;
  29557. /**
  29558. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29559. * @param localAxis Defines the reference axis to provide a relative direction.
  29560. * @param result Defines the vector to store the result in
  29561. */
  29562. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29563. /**
  29564. * Gets a camera constructor for a given camera type
  29565. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29566. * @param name The name of the camera the result will be able to instantiate
  29567. * @param scene The scene the result will construct the camera in
  29568. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29569. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29570. * @returns a factory method to construc the camera
  29571. */
  29572. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29573. /**
  29574. * Compute the world matrix of the camera.
  29575. * @returns the camera world matrix
  29576. */
  29577. computeWorldMatrix(): Matrix;
  29578. /**
  29579. * Parse a JSON and creates the camera from the parsed information
  29580. * @param parsedCamera The JSON to parse
  29581. * @param scene The scene to instantiate the camera in
  29582. * @returns the newly constructed camera
  29583. */
  29584. static Parse(parsedCamera: any, scene: Scene): Camera;
  29585. }
  29586. }
  29587. declare module BABYLON {
  29588. /**
  29589. * Class containing static functions to help procedurally build meshes
  29590. */
  29591. export class DiscBuilder {
  29592. /**
  29593. * Creates a plane polygonal mesh. By default, this is a disc
  29594. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  29595. * * 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
  29596. * * 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
  29597. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29598. * * 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
  29599. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29600. * @param name defines the name of the mesh
  29601. * @param options defines the options used to create the mesh
  29602. * @param scene defines the hosting scene
  29603. * @returns the plane polygonal mesh
  29604. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  29605. */
  29606. static CreateDisc(name: string, options: {
  29607. radius?: number;
  29608. tessellation?: number;
  29609. arc?: number;
  29610. updatable?: boolean;
  29611. sideOrientation?: number;
  29612. frontUVs?: Vector4;
  29613. backUVs?: Vector4;
  29614. }, scene?: Nullable<Scene>): Mesh;
  29615. }
  29616. }
  29617. declare module BABYLON {
  29618. /**
  29619. * Options to be used when creating a FresnelParameters.
  29620. */
  29621. export type IFresnelParametersCreationOptions = {
  29622. /**
  29623. * Define the color used on edges (grazing angle)
  29624. */
  29625. leftColor?: Color3;
  29626. /**
  29627. * Define the color used on center
  29628. */
  29629. rightColor?: Color3;
  29630. /**
  29631. * Define bias applied to computed fresnel term
  29632. */
  29633. bias?: number;
  29634. /**
  29635. * Defined the power exponent applied to fresnel term
  29636. */
  29637. power?: number;
  29638. /**
  29639. * Define if the fresnel effect is enable or not.
  29640. */
  29641. isEnabled?: boolean;
  29642. };
  29643. /**
  29644. * Serialized format for FresnelParameters.
  29645. */
  29646. export type IFresnelParametersSerialized = {
  29647. /**
  29648. * Define the color used on edges (grazing angle) [as an array]
  29649. */
  29650. leftColor: number[];
  29651. /**
  29652. * Define the color used on center [as an array]
  29653. */
  29654. rightColor: number[];
  29655. /**
  29656. * Define bias applied to computed fresnel term
  29657. */
  29658. bias: number;
  29659. /**
  29660. * Defined the power exponent applied to fresnel term
  29661. */
  29662. power?: number;
  29663. /**
  29664. * Define if the fresnel effect is enable or not.
  29665. */
  29666. isEnabled: boolean;
  29667. };
  29668. /**
  29669. * This represents all the required information to add a fresnel effect on a material:
  29670. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29671. */
  29672. export class FresnelParameters {
  29673. private _isEnabled;
  29674. /**
  29675. * Define if the fresnel effect is enable or not.
  29676. */
  29677. get isEnabled(): boolean;
  29678. set isEnabled(value: boolean);
  29679. /**
  29680. * Define the color used on edges (grazing angle)
  29681. */
  29682. leftColor: Color3;
  29683. /**
  29684. * Define the color used on center
  29685. */
  29686. rightColor: Color3;
  29687. /**
  29688. * Define bias applied to computed fresnel term
  29689. */
  29690. bias: number;
  29691. /**
  29692. * Defined the power exponent applied to fresnel term
  29693. */
  29694. power: number;
  29695. /**
  29696. * Creates a new FresnelParameters object.
  29697. *
  29698. * @param options provide your own settings to optionally to override defaults
  29699. */
  29700. constructor(options?: IFresnelParametersCreationOptions);
  29701. /**
  29702. * Clones the current fresnel and its valuues
  29703. * @returns a clone fresnel configuration
  29704. */
  29705. clone(): FresnelParameters;
  29706. /**
  29707. * Determines equality between FresnelParameters objects
  29708. * @param otherFresnelParameters defines the second operand
  29709. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  29710. */
  29711. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  29712. /**
  29713. * Serializes the current fresnel parameters to a JSON representation.
  29714. * @return the JSON serialization
  29715. */
  29716. serialize(): IFresnelParametersSerialized;
  29717. /**
  29718. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29719. * @param parsedFresnelParameters Define the JSON representation
  29720. * @returns the parsed parameters
  29721. */
  29722. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  29723. }
  29724. }
  29725. declare module BABYLON {
  29726. /**
  29727. * This groups all the flags used to control the materials channel.
  29728. */
  29729. export class MaterialFlags {
  29730. private static _DiffuseTextureEnabled;
  29731. /**
  29732. * Are diffuse textures enabled in the application.
  29733. */
  29734. static get DiffuseTextureEnabled(): boolean;
  29735. static set DiffuseTextureEnabled(value: boolean);
  29736. private static _DetailTextureEnabled;
  29737. /**
  29738. * Are detail textures enabled in the application.
  29739. */
  29740. static get DetailTextureEnabled(): boolean;
  29741. static set DetailTextureEnabled(value: boolean);
  29742. private static _AmbientTextureEnabled;
  29743. /**
  29744. * Are ambient textures enabled in the application.
  29745. */
  29746. static get AmbientTextureEnabled(): boolean;
  29747. static set AmbientTextureEnabled(value: boolean);
  29748. private static _OpacityTextureEnabled;
  29749. /**
  29750. * Are opacity textures enabled in the application.
  29751. */
  29752. static get OpacityTextureEnabled(): boolean;
  29753. static set OpacityTextureEnabled(value: boolean);
  29754. private static _ReflectionTextureEnabled;
  29755. /**
  29756. * Are reflection textures enabled in the application.
  29757. */
  29758. static get ReflectionTextureEnabled(): boolean;
  29759. static set ReflectionTextureEnabled(value: boolean);
  29760. private static _EmissiveTextureEnabled;
  29761. /**
  29762. * Are emissive textures enabled in the application.
  29763. */
  29764. static get EmissiveTextureEnabled(): boolean;
  29765. static set EmissiveTextureEnabled(value: boolean);
  29766. private static _SpecularTextureEnabled;
  29767. /**
  29768. * Are specular textures enabled in the application.
  29769. */
  29770. static get SpecularTextureEnabled(): boolean;
  29771. static set SpecularTextureEnabled(value: boolean);
  29772. private static _BumpTextureEnabled;
  29773. /**
  29774. * Are bump textures enabled in the application.
  29775. */
  29776. static get BumpTextureEnabled(): boolean;
  29777. static set BumpTextureEnabled(value: boolean);
  29778. private static _LightmapTextureEnabled;
  29779. /**
  29780. * Are lightmap textures enabled in the application.
  29781. */
  29782. static get LightmapTextureEnabled(): boolean;
  29783. static set LightmapTextureEnabled(value: boolean);
  29784. private static _RefractionTextureEnabled;
  29785. /**
  29786. * Are refraction textures enabled in the application.
  29787. */
  29788. static get RefractionTextureEnabled(): boolean;
  29789. static set RefractionTextureEnabled(value: boolean);
  29790. private static _ColorGradingTextureEnabled;
  29791. /**
  29792. * Are color grading textures enabled in the application.
  29793. */
  29794. static get ColorGradingTextureEnabled(): boolean;
  29795. static set ColorGradingTextureEnabled(value: boolean);
  29796. private static _FresnelEnabled;
  29797. /**
  29798. * Are fresnels enabled in the application.
  29799. */
  29800. static get FresnelEnabled(): boolean;
  29801. static set FresnelEnabled(value: boolean);
  29802. private static _ClearCoatTextureEnabled;
  29803. /**
  29804. * Are clear coat textures enabled in the application.
  29805. */
  29806. static get ClearCoatTextureEnabled(): boolean;
  29807. static set ClearCoatTextureEnabled(value: boolean);
  29808. private static _ClearCoatBumpTextureEnabled;
  29809. /**
  29810. * Are clear coat bump textures enabled in the application.
  29811. */
  29812. static get ClearCoatBumpTextureEnabled(): boolean;
  29813. static set ClearCoatBumpTextureEnabled(value: boolean);
  29814. private static _ClearCoatTintTextureEnabled;
  29815. /**
  29816. * Are clear coat tint textures enabled in the application.
  29817. */
  29818. static get ClearCoatTintTextureEnabled(): boolean;
  29819. static set ClearCoatTintTextureEnabled(value: boolean);
  29820. private static _SheenTextureEnabled;
  29821. /**
  29822. * Are sheen textures enabled in the application.
  29823. */
  29824. static get SheenTextureEnabled(): boolean;
  29825. static set SheenTextureEnabled(value: boolean);
  29826. private static _AnisotropicTextureEnabled;
  29827. /**
  29828. * Are anisotropic textures enabled in the application.
  29829. */
  29830. static get AnisotropicTextureEnabled(): boolean;
  29831. static set AnisotropicTextureEnabled(value: boolean);
  29832. private static _ThicknessTextureEnabled;
  29833. /**
  29834. * Are thickness textures enabled in the application.
  29835. */
  29836. static get ThicknessTextureEnabled(): boolean;
  29837. static set ThicknessTextureEnabled(value: boolean);
  29838. }
  29839. }
  29840. declare module BABYLON {
  29841. /** @hidden */
  29842. export var defaultFragmentDeclaration: {
  29843. name: string;
  29844. shader: string;
  29845. };
  29846. }
  29847. declare module BABYLON {
  29848. /** @hidden */
  29849. export var defaultUboDeclaration: {
  29850. name: string;
  29851. shader: string;
  29852. };
  29853. }
  29854. declare module BABYLON {
  29855. /** @hidden */
  29856. export var prePassDeclaration: {
  29857. name: string;
  29858. shader: string;
  29859. };
  29860. }
  29861. declare module BABYLON {
  29862. /** @hidden */
  29863. export var lightFragmentDeclaration: {
  29864. name: string;
  29865. shader: string;
  29866. };
  29867. }
  29868. declare module BABYLON {
  29869. /** @hidden */
  29870. export var lightUboDeclaration: {
  29871. name: string;
  29872. shader: string;
  29873. };
  29874. }
  29875. declare module BABYLON {
  29876. /** @hidden */
  29877. export var lightsFragmentFunctions: {
  29878. name: string;
  29879. shader: string;
  29880. };
  29881. }
  29882. declare module BABYLON {
  29883. /** @hidden */
  29884. export var shadowsFragmentFunctions: {
  29885. name: string;
  29886. shader: string;
  29887. };
  29888. }
  29889. declare module BABYLON {
  29890. /** @hidden */
  29891. export var fresnelFunction: {
  29892. name: string;
  29893. shader: string;
  29894. };
  29895. }
  29896. declare module BABYLON {
  29897. /** @hidden */
  29898. export var bumpFragmentMainFunctions: {
  29899. name: string;
  29900. shader: string;
  29901. };
  29902. }
  29903. declare module BABYLON {
  29904. /** @hidden */
  29905. export var bumpFragmentFunctions: {
  29906. name: string;
  29907. shader: string;
  29908. };
  29909. }
  29910. declare module BABYLON {
  29911. /** @hidden */
  29912. export var logDepthDeclaration: {
  29913. name: string;
  29914. shader: string;
  29915. };
  29916. }
  29917. declare module BABYLON {
  29918. /** @hidden */
  29919. export var bumpFragment: {
  29920. name: string;
  29921. shader: string;
  29922. };
  29923. }
  29924. declare module BABYLON {
  29925. /** @hidden */
  29926. export var depthPrePass: {
  29927. name: string;
  29928. shader: string;
  29929. };
  29930. }
  29931. declare module BABYLON {
  29932. /** @hidden */
  29933. export var lightFragment: {
  29934. name: string;
  29935. shader: string;
  29936. };
  29937. }
  29938. declare module BABYLON {
  29939. /** @hidden */
  29940. export var logDepthFragment: {
  29941. name: string;
  29942. shader: string;
  29943. };
  29944. }
  29945. declare module BABYLON {
  29946. /** @hidden */
  29947. export var defaultPixelShader: {
  29948. name: string;
  29949. shader: string;
  29950. };
  29951. }
  29952. declare module BABYLON {
  29953. /** @hidden */
  29954. export var defaultVertexDeclaration: {
  29955. name: string;
  29956. shader: string;
  29957. };
  29958. }
  29959. declare module BABYLON {
  29960. /** @hidden */
  29961. export var bumpVertexDeclaration: {
  29962. name: string;
  29963. shader: string;
  29964. };
  29965. }
  29966. declare module BABYLON {
  29967. /** @hidden */
  29968. export var bumpVertex: {
  29969. name: string;
  29970. shader: string;
  29971. };
  29972. }
  29973. declare module BABYLON {
  29974. /** @hidden */
  29975. export var fogVertex: {
  29976. name: string;
  29977. shader: string;
  29978. };
  29979. }
  29980. declare module BABYLON {
  29981. /** @hidden */
  29982. export var shadowsVertex: {
  29983. name: string;
  29984. shader: string;
  29985. };
  29986. }
  29987. declare module BABYLON {
  29988. /** @hidden */
  29989. export var pointCloudVertex: {
  29990. name: string;
  29991. shader: string;
  29992. };
  29993. }
  29994. declare module BABYLON {
  29995. /** @hidden */
  29996. export var logDepthVertex: {
  29997. name: string;
  29998. shader: string;
  29999. };
  30000. }
  30001. declare module BABYLON {
  30002. /** @hidden */
  30003. export var defaultVertexShader: {
  30004. name: string;
  30005. shader: string;
  30006. };
  30007. }
  30008. declare module BABYLON {
  30009. /**
  30010. * @hidden
  30011. */
  30012. export interface IMaterialDetailMapDefines {
  30013. DETAIL: boolean;
  30014. DETAILDIRECTUV: number;
  30015. DETAIL_NORMALBLENDMETHOD: number;
  30016. /** @hidden */
  30017. _areTexturesDirty: boolean;
  30018. }
  30019. /**
  30020. * Define the code related to the detail map parameters of a material
  30021. *
  30022. * Inspired from:
  30023. * 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
  30024. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  30025. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  30026. */
  30027. export class DetailMapConfiguration {
  30028. private _texture;
  30029. /**
  30030. * The detail texture of the material.
  30031. */
  30032. texture: Nullable<BaseTexture>;
  30033. /**
  30034. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  30035. * Bigger values mean stronger blending
  30036. */
  30037. diffuseBlendLevel: number;
  30038. /**
  30039. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  30040. * Bigger values mean stronger blending. Only used with PBR materials
  30041. */
  30042. roughnessBlendLevel: number;
  30043. /**
  30044. * Defines how strong the bump effect from the detail map is
  30045. * Bigger values mean stronger effect
  30046. */
  30047. bumpLevel: number;
  30048. private _normalBlendMethod;
  30049. /**
  30050. * The method used to blend the bump and detail normals together
  30051. */
  30052. normalBlendMethod: number;
  30053. private _isEnabled;
  30054. /**
  30055. * Enable or disable the detail map on this material
  30056. */
  30057. isEnabled: boolean;
  30058. /** @hidden */
  30059. private _internalMarkAllSubMeshesAsTexturesDirty;
  30060. /** @hidden */
  30061. _markAllSubMeshesAsTexturesDirty(): void;
  30062. /**
  30063. * Instantiate a new detail map
  30064. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  30065. */
  30066. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  30067. /**
  30068. * Gets whether the submesh is ready to be used or not.
  30069. * @param defines the list of "defines" to update.
  30070. * @param scene defines the scene the material belongs to.
  30071. * @returns - boolean indicating that the submesh is ready or not.
  30072. */
  30073. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  30074. /**
  30075. * Update the defines for detail map usage
  30076. * @param defines the list of "defines" to update.
  30077. * @param scene defines the scene the material belongs to.
  30078. */
  30079. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  30080. /**
  30081. * Binds the material data.
  30082. * @param uniformBuffer defines the Uniform buffer to fill in.
  30083. * @param scene defines the scene the material belongs to.
  30084. * @param isFrozen defines whether the material is frozen or not.
  30085. */
  30086. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  30087. /**
  30088. * Checks to see if a texture is used in the material.
  30089. * @param texture - Base texture to use.
  30090. * @returns - Boolean specifying if a texture is used in the material.
  30091. */
  30092. hasTexture(texture: BaseTexture): boolean;
  30093. /**
  30094. * Returns an array of the actively used textures.
  30095. * @param activeTextures Array of BaseTextures
  30096. */
  30097. getActiveTextures(activeTextures: BaseTexture[]): void;
  30098. /**
  30099. * Returns the animatable textures.
  30100. * @param animatables Array of animatable textures.
  30101. */
  30102. getAnimatables(animatables: IAnimatable[]): void;
  30103. /**
  30104. * Disposes the resources of the material.
  30105. * @param forceDisposeTextures - Forces the disposal of all textures.
  30106. */
  30107. dispose(forceDisposeTextures?: boolean): void;
  30108. /**
  30109. * Get the current class name useful for serialization or dynamic coding.
  30110. * @returns "DetailMap"
  30111. */
  30112. getClassName(): string;
  30113. /**
  30114. * Add the required uniforms to the current list.
  30115. * @param uniforms defines the current uniform list.
  30116. */
  30117. static AddUniforms(uniforms: string[]): void;
  30118. /**
  30119. * Add the required samplers to the current list.
  30120. * @param samplers defines the current sampler list.
  30121. */
  30122. static AddSamplers(samplers: string[]): void;
  30123. /**
  30124. * Add the required uniforms to the current buffer.
  30125. * @param uniformBuffer defines the current uniform buffer.
  30126. */
  30127. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  30128. /**
  30129. * Makes a duplicate of the current instance into another one.
  30130. * @param detailMap define the instance where to copy the info
  30131. */
  30132. copyTo(detailMap: DetailMapConfiguration): void;
  30133. /**
  30134. * Serializes this detail map instance
  30135. * @returns - An object with the serialized instance.
  30136. */
  30137. serialize(): any;
  30138. /**
  30139. * Parses a detail map setting from a serialized object.
  30140. * @param source - Serialized object.
  30141. * @param scene Defines the scene we are parsing for
  30142. * @param rootUrl Defines the rootUrl to load from
  30143. */
  30144. parse(source: any, scene: Scene, rootUrl: string): void;
  30145. }
  30146. }
  30147. declare module BABYLON {
  30148. /** @hidden */
  30149. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  30150. MAINUV1: boolean;
  30151. MAINUV2: boolean;
  30152. DIFFUSE: boolean;
  30153. DIFFUSEDIRECTUV: number;
  30154. DETAIL: boolean;
  30155. DETAILDIRECTUV: number;
  30156. DETAIL_NORMALBLENDMETHOD: number;
  30157. AMBIENT: boolean;
  30158. AMBIENTDIRECTUV: number;
  30159. OPACITY: boolean;
  30160. OPACITYDIRECTUV: number;
  30161. OPACITYRGB: boolean;
  30162. REFLECTION: boolean;
  30163. EMISSIVE: boolean;
  30164. EMISSIVEDIRECTUV: number;
  30165. SPECULAR: boolean;
  30166. SPECULARDIRECTUV: number;
  30167. BUMP: boolean;
  30168. BUMPDIRECTUV: number;
  30169. PARALLAX: boolean;
  30170. PARALLAXOCCLUSION: boolean;
  30171. SPECULAROVERALPHA: boolean;
  30172. CLIPPLANE: boolean;
  30173. CLIPPLANE2: boolean;
  30174. CLIPPLANE3: boolean;
  30175. CLIPPLANE4: boolean;
  30176. CLIPPLANE5: boolean;
  30177. CLIPPLANE6: boolean;
  30178. ALPHATEST: boolean;
  30179. DEPTHPREPASS: boolean;
  30180. ALPHAFROMDIFFUSE: boolean;
  30181. POINTSIZE: boolean;
  30182. FOG: boolean;
  30183. SPECULARTERM: boolean;
  30184. DIFFUSEFRESNEL: boolean;
  30185. OPACITYFRESNEL: boolean;
  30186. REFLECTIONFRESNEL: boolean;
  30187. REFRACTIONFRESNEL: boolean;
  30188. EMISSIVEFRESNEL: boolean;
  30189. FRESNEL: boolean;
  30190. NORMAL: boolean;
  30191. UV1: boolean;
  30192. UV2: boolean;
  30193. VERTEXCOLOR: boolean;
  30194. VERTEXALPHA: boolean;
  30195. NUM_BONE_INFLUENCERS: number;
  30196. BonesPerMesh: number;
  30197. BONETEXTURE: boolean;
  30198. INSTANCES: boolean;
  30199. THIN_INSTANCES: boolean;
  30200. GLOSSINESS: boolean;
  30201. ROUGHNESS: boolean;
  30202. EMISSIVEASILLUMINATION: boolean;
  30203. LINKEMISSIVEWITHDIFFUSE: boolean;
  30204. REFLECTIONFRESNELFROMSPECULAR: boolean;
  30205. LIGHTMAP: boolean;
  30206. LIGHTMAPDIRECTUV: number;
  30207. OBJECTSPACE_NORMALMAP: boolean;
  30208. USELIGHTMAPASSHADOWMAP: boolean;
  30209. REFLECTIONMAP_3D: boolean;
  30210. REFLECTIONMAP_SPHERICAL: boolean;
  30211. REFLECTIONMAP_PLANAR: boolean;
  30212. REFLECTIONMAP_CUBIC: boolean;
  30213. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  30214. REFLECTIONMAP_PROJECTION: boolean;
  30215. REFLECTIONMAP_SKYBOX: boolean;
  30216. REFLECTIONMAP_EXPLICIT: boolean;
  30217. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  30218. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  30219. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  30220. INVERTCUBICMAP: boolean;
  30221. LOGARITHMICDEPTH: boolean;
  30222. REFRACTION: boolean;
  30223. REFRACTIONMAP_3D: boolean;
  30224. REFLECTIONOVERALPHA: boolean;
  30225. TWOSIDEDLIGHTING: boolean;
  30226. SHADOWFLOAT: boolean;
  30227. MORPHTARGETS: boolean;
  30228. MORPHTARGETS_NORMAL: boolean;
  30229. MORPHTARGETS_TANGENT: boolean;
  30230. MORPHTARGETS_UV: boolean;
  30231. NUM_MORPH_INFLUENCERS: number;
  30232. NONUNIFORMSCALING: boolean;
  30233. PREMULTIPLYALPHA: boolean;
  30234. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  30235. ALPHABLEND: boolean;
  30236. PREPASS: boolean;
  30237. SCENE_MRT_COUNT: number;
  30238. RGBDLIGHTMAP: boolean;
  30239. RGBDREFLECTION: boolean;
  30240. RGBDREFRACTION: boolean;
  30241. IMAGEPROCESSING: boolean;
  30242. VIGNETTE: boolean;
  30243. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30244. VIGNETTEBLENDMODEOPAQUE: boolean;
  30245. TONEMAPPING: boolean;
  30246. TONEMAPPING_ACES: boolean;
  30247. CONTRAST: boolean;
  30248. COLORCURVES: boolean;
  30249. COLORGRADING: boolean;
  30250. COLORGRADING3D: boolean;
  30251. SAMPLER3DGREENDEPTH: boolean;
  30252. SAMPLER3DBGRMAP: boolean;
  30253. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30254. MULTIVIEW: boolean;
  30255. /**
  30256. * If the reflection texture on this material is in linear color space
  30257. * @hidden
  30258. */
  30259. IS_REFLECTION_LINEAR: boolean;
  30260. /**
  30261. * If the refraction texture on this material is in linear color space
  30262. * @hidden
  30263. */
  30264. IS_REFRACTION_LINEAR: boolean;
  30265. EXPOSURE: boolean;
  30266. constructor();
  30267. setReflectionMode(modeToEnable: string): void;
  30268. }
  30269. /**
  30270. * This is the default material used in Babylon. It is the best trade off between quality
  30271. * and performances.
  30272. * @see https://doc.babylonjs.com/babylon101/materials
  30273. */
  30274. export class StandardMaterial extends PushMaterial {
  30275. private _diffuseTexture;
  30276. /**
  30277. * The basic texture of the material as viewed under a light.
  30278. */
  30279. diffuseTexture: Nullable<BaseTexture>;
  30280. private _ambientTexture;
  30281. /**
  30282. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  30283. */
  30284. ambientTexture: Nullable<BaseTexture>;
  30285. private _opacityTexture;
  30286. /**
  30287. * Define the transparency of the material from a texture.
  30288. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  30289. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  30290. */
  30291. opacityTexture: Nullable<BaseTexture>;
  30292. private _reflectionTexture;
  30293. /**
  30294. * Define the texture used to display the reflection.
  30295. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30296. */
  30297. reflectionTexture: Nullable<BaseTexture>;
  30298. private _emissiveTexture;
  30299. /**
  30300. * Define texture of the material as if self lit.
  30301. * This will be mixed in the final result even in the absence of light.
  30302. */
  30303. emissiveTexture: Nullable<BaseTexture>;
  30304. private _specularTexture;
  30305. /**
  30306. * Define how the color and intensity of the highlight given by the light in the material.
  30307. */
  30308. specularTexture: Nullable<BaseTexture>;
  30309. private _bumpTexture;
  30310. /**
  30311. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  30312. * 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.
  30313. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  30314. */
  30315. bumpTexture: Nullable<BaseTexture>;
  30316. private _lightmapTexture;
  30317. /**
  30318. * Complex lighting can be computationally expensive to compute at runtime.
  30319. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  30320. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  30321. */
  30322. lightmapTexture: Nullable<BaseTexture>;
  30323. private _refractionTexture;
  30324. /**
  30325. * Define the texture used to display the refraction.
  30326. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30327. */
  30328. refractionTexture: Nullable<BaseTexture>;
  30329. /**
  30330. * The color of the material lit by the environmental background lighting.
  30331. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  30332. */
  30333. ambientColor: Color3;
  30334. /**
  30335. * The basic color of the material as viewed under a light.
  30336. */
  30337. diffuseColor: Color3;
  30338. /**
  30339. * Define how the color and intensity of the highlight given by the light in the material.
  30340. */
  30341. specularColor: Color3;
  30342. /**
  30343. * Define the color of the material as if self lit.
  30344. * This will be mixed in the final result even in the absence of light.
  30345. */
  30346. emissiveColor: Color3;
  30347. /**
  30348. * Defines how sharp are the highlights in the material.
  30349. * The bigger the value the sharper giving a more glossy feeling to the result.
  30350. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  30351. */
  30352. specularPower: number;
  30353. private _useAlphaFromDiffuseTexture;
  30354. /**
  30355. * Does the transparency come from the diffuse texture alpha channel.
  30356. */
  30357. useAlphaFromDiffuseTexture: boolean;
  30358. private _useEmissiveAsIllumination;
  30359. /**
  30360. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  30361. */
  30362. useEmissiveAsIllumination: boolean;
  30363. private _linkEmissiveWithDiffuse;
  30364. /**
  30365. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  30366. * the emissive level when the final color is close to one.
  30367. */
  30368. linkEmissiveWithDiffuse: boolean;
  30369. private _useSpecularOverAlpha;
  30370. /**
  30371. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  30372. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30373. */
  30374. useSpecularOverAlpha: boolean;
  30375. private _useReflectionOverAlpha;
  30376. /**
  30377. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30378. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30379. */
  30380. useReflectionOverAlpha: boolean;
  30381. private _disableLighting;
  30382. /**
  30383. * Does lights from the scene impacts this material.
  30384. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  30385. */
  30386. disableLighting: boolean;
  30387. private _useObjectSpaceNormalMap;
  30388. /**
  30389. * Allows using an object space normal map (instead of tangent space).
  30390. */
  30391. useObjectSpaceNormalMap: boolean;
  30392. private _useParallax;
  30393. /**
  30394. * Is parallax enabled or not.
  30395. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30396. */
  30397. useParallax: boolean;
  30398. private _useParallaxOcclusion;
  30399. /**
  30400. * Is parallax occlusion enabled or not.
  30401. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  30402. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30403. */
  30404. useParallaxOcclusion: boolean;
  30405. /**
  30406. * 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.
  30407. */
  30408. parallaxScaleBias: number;
  30409. private _roughness;
  30410. /**
  30411. * Helps to define how blurry the reflections should appears in the material.
  30412. */
  30413. roughness: number;
  30414. /**
  30415. * In case of refraction, define the value of the index of refraction.
  30416. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30417. */
  30418. indexOfRefraction: number;
  30419. /**
  30420. * Invert the refraction texture alongside the y axis.
  30421. * It can be useful with procedural textures or probe for instance.
  30422. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30423. */
  30424. invertRefractionY: boolean;
  30425. /**
  30426. * Defines the alpha limits in alpha test mode.
  30427. */
  30428. alphaCutOff: number;
  30429. private _useLightmapAsShadowmap;
  30430. /**
  30431. * In case of light mapping, define whether the map contains light or shadow informations.
  30432. */
  30433. useLightmapAsShadowmap: boolean;
  30434. private _diffuseFresnelParameters;
  30435. /**
  30436. * Define the diffuse fresnel parameters of the material.
  30437. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30438. */
  30439. diffuseFresnelParameters: FresnelParameters;
  30440. private _opacityFresnelParameters;
  30441. /**
  30442. * Define the opacity fresnel parameters of the material.
  30443. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30444. */
  30445. opacityFresnelParameters: FresnelParameters;
  30446. private _reflectionFresnelParameters;
  30447. /**
  30448. * Define the reflection fresnel parameters of the material.
  30449. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30450. */
  30451. reflectionFresnelParameters: FresnelParameters;
  30452. private _refractionFresnelParameters;
  30453. /**
  30454. * Define the refraction fresnel parameters of the material.
  30455. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30456. */
  30457. refractionFresnelParameters: FresnelParameters;
  30458. private _emissiveFresnelParameters;
  30459. /**
  30460. * Define the emissive fresnel parameters of the material.
  30461. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30462. */
  30463. emissiveFresnelParameters: FresnelParameters;
  30464. private _useReflectionFresnelFromSpecular;
  30465. /**
  30466. * If true automatically deducts the fresnels values from the material specularity.
  30467. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30468. */
  30469. useReflectionFresnelFromSpecular: boolean;
  30470. private _useGlossinessFromSpecularMapAlpha;
  30471. /**
  30472. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  30473. */
  30474. useGlossinessFromSpecularMapAlpha: boolean;
  30475. private _maxSimultaneousLights;
  30476. /**
  30477. * Defines the maximum number of lights that can be used in the material
  30478. */
  30479. maxSimultaneousLights: number;
  30480. private _invertNormalMapX;
  30481. /**
  30482. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30483. */
  30484. invertNormalMapX: boolean;
  30485. private _invertNormalMapY;
  30486. /**
  30487. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30488. */
  30489. invertNormalMapY: boolean;
  30490. private _twoSidedLighting;
  30491. /**
  30492. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30493. */
  30494. twoSidedLighting: boolean;
  30495. /**
  30496. * Default configuration related to image processing available in the standard Material.
  30497. */
  30498. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30499. /**
  30500. * Gets the image processing configuration used either in this material.
  30501. */
  30502. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  30503. /**
  30504. * Sets the Default image processing configuration used either in the this material.
  30505. *
  30506. * If sets to null, the scene one is in use.
  30507. */
  30508. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  30509. /**
  30510. * Keep track of the image processing observer to allow dispose and replace.
  30511. */
  30512. private _imageProcessingObserver;
  30513. /**
  30514. * Attaches a new image processing configuration to the Standard Material.
  30515. * @param configuration
  30516. */
  30517. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30518. /**
  30519. * Gets wether the color curves effect is enabled.
  30520. */
  30521. get cameraColorCurvesEnabled(): boolean;
  30522. /**
  30523. * Sets wether the color curves effect is enabled.
  30524. */
  30525. set cameraColorCurvesEnabled(value: boolean);
  30526. /**
  30527. * Gets wether the color grading effect is enabled.
  30528. */
  30529. get cameraColorGradingEnabled(): boolean;
  30530. /**
  30531. * Gets wether the color grading effect is enabled.
  30532. */
  30533. set cameraColorGradingEnabled(value: boolean);
  30534. /**
  30535. * Gets wether tonemapping is enabled or not.
  30536. */
  30537. get cameraToneMappingEnabled(): boolean;
  30538. /**
  30539. * Sets wether tonemapping is enabled or not
  30540. */
  30541. set cameraToneMappingEnabled(value: boolean);
  30542. /**
  30543. * The camera exposure used on this material.
  30544. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30545. * This corresponds to a photographic exposure.
  30546. */
  30547. get cameraExposure(): number;
  30548. /**
  30549. * The camera exposure used on this material.
  30550. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30551. * This corresponds to a photographic exposure.
  30552. */
  30553. set cameraExposure(value: number);
  30554. /**
  30555. * Gets The camera contrast used on this material.
  30556. */
  30557. get cameraContrast(): number;
  30558. /**
  30559. * Sets The camera contrast used on this material.
  30560. */
  30561. set cameraContrast(value: number);
  30562. /**
  30563. * Gets the Color Grading 2D Lookup Texture.
  30564. */
  30565. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  30566. /**
  30567. * Sets the Color Grading 2D Lookup Texture.
  30568. */
  30569. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  30570. /**
  30571. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30572. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30573. * 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;
  30574. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30575. */
  30576. get cameraColorCurves(): Nullable<ColorCurves>;
  30577. /**
  30578. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30579. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30580. * 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;
  30581. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30582. */
  30583. set cameraColorCurves(value: Nullable<ColorCurves>);
  30584. /**
  30585. * Can this material render to several textures at once
  30586. */
  30587. get canRenderToMRT(): boolean;
  30588. /**
  30589. * Defines the detail map parameters for the material.
  30590. */
  30591. readonly detailMap: DetailMapConfiguration;
  30592. protected _renderTargets: SmartArray<RenderTargetTexture>;
  30593. protected _worldViewProjectionMatrix: Matrix;
  30594. protected _globalAmbientColor: Color3;
  30595. protected _useLogarithmicDepth: boolean;
  30596. protected _rebuildInParallel: boolean;
  30597. /**
  30598. * Instantiates a new standard material.
  30599. * This is the default material used in Babylon. It is the best trade off between quality
  30600. * and performances.
  30601. * @see https://doc.babylonjs.com/babylon101/materials
  30602. * @param name Define the name of the material in the scene
  30603. * @param scene Define the scene the material belong to
  30604. */
  30605. constructor(name: string, scene: Scene);
  30606. /**
  30607. * Gets a boolean indicating that current material needs to register RTT
  30608. */
  30609. get hasRenderTargetTextures(): boolean;
  30610. /**
  30611. * Gets the current class name of the material e.g. "StandardMaterial"
  30612. * Mainly use in serialization.
  30613. * @returns the class name
  30614. */
  30615. getClassName(): string;
  30616. /**
  30617. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  30618. * You can try switching to logarithmic depth.
  30619. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  30620. */
  30621. get useLogarithmicDepth(): boolean;
  30622. set useLogarithmicDepth(value: boolean);
  30623. /**
  30624. * Specifies if the material will require alpha blending
  30625. * @returns a boolean specifying if alpha blending is needed
  30626. */
  30627. needAlphaBlending(): boolean;
  30628. /**
  30629. * Specifies if this material should be rendered in alpha test mode
  30630. * @returns a boolean specifying if an alpha test is needed.
  30631. */
  30632. needAlphaTesting(): boolean;
  30633. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  30634. /**
  30635. * Get the texture used for alpha test purpose.
  30636. * @returns the diffuse texture in case of the standard material.
  30637. */
  30638. getAlphaTestTexture(): Nullable<BaseTexture>;
  30639. /**
  30640. * Get if the submesh is ready to be used and all its information available.
  30641. * Child classes can use it to update shaders
  30642. * @param mesh defines the mesh to check
  30643. * @param subMesh defines which submesh to check
  30644. * @param useInstances specifies that instances should be used
  30645. * @returns a boolean indicating that the submesh is ready or not
  30646. */
  30647. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30648. /**
  30649. * Builds the material UBO layouts.
  30650. * Used internally during the effect preparation.
  30651. */
  30652. buildUniformLayout(): void;
  30653. /**
  30654. * Unbinds the material from the mesh
  30655. */
  30656. unbind(): void;
  30657. /**
  30658. * Binds the submesh to this material by preparing the effect and shader to draw
  30659. * @param world defines the world transformation matrix
  30660. * @param mesh defines the mesh containing the submesh
  30661. * @param subMesh defines the submesh to bind the material to
  30662. */
  30663. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30664. /**
  30665. * Get the list of animatables in the material.
  30666. * @returns the list of animatables object used in the material
  30667. */
  30668. getAnimatables(): IAnimatable[];
  30669. /**
  30670. * Gets the active textures from the material
  30671. * @returns an array of textures
  30672. */
  30673. getActiveTextures(): BaseTexture[];
  30674. /**
  30675. * Specifies if the material uses a texture
  30676. * @param texture defines the texture to check against the material
  30677. * @returns a boolean specifying if the material uses the texture
  30678. */
  30679. hasTexture(texture: BaseTexture): boolean;
  30680. /**
  30681. * Disposes the material
  30682. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30683. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30684. */
  30685. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  30686. /**
  30687. * Makes a duplicate of the material, and gives it a new name
  30688. * @param name defines the new name for the duplicated material
  30689. * @returns the cloned material
  30690. */
  30691. clone(name: string): StandardMaterial;
  30692. /**
  30693. * Serializes this material in a JSON representation
  30694. * @returns the serialized material object
  30695. */
  30696. serialize(): any;
  30697. /**
  30698. * Creates a standard material from parsed material data
  30699. * @param source defines the JSON representation of the material
  30700. * @param scene defines the hosting scene
  30701. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  30702. * @returns a new standard material
  30703. */
  30704. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  30705. /**
  30706. * Are diffuse textures enabled in the application.
  30707. */
  30708. static get DiffuseTextureEnabled(): boolean;
  30709. static set DiffuseTextureEnabled(value: boolean);
  30710. /**
  30711. * Are detail textures enabled in the application.
  30712. */
  30713. static get DetailTextureEnabled(): boolean;
  30714. static set DetailTextureEnabled(value: boolean);
  30715. /**
  30716. * Are ambient textures enabled in the application.
  30717. */
  30718. static get AmbientTextureEnabled(): boolean;
  30719. static set AmbientTextureEnabled(value: boolean);
  30720. /**
  30721. * Are opacity textures enabled in the application.
  30722. */
  30723. static get OpacityTextureEnabled(): boolean;
  30724. static set OpacityTextureEnabled(value: boolean);
  30725. /**
  30726. * Are reflection textures enabled in the application.
  30727. */
  30728. static get ReflectionTextureEnabled(): boolean;
  30729. static set ReflectionTextureEnabled(value: boolean);
  30730. /**
  30731. * Are emissive textures enabled in the application.
  30732. */
  30733. static get EmissiveTextureEnabled(): boolean;
  30734. static set EmissiveTextureEnabled(value: boolean);
  30735. /**
  30736. * Are specular textures enabled in the application.
  30737. */
  30738. static get SpecularTextureEnabled(): boolean;
  30739. static set SpecularTextureEnabled(value: boolean);
  30740. /**
  30741. * Are bump textures enabled in the application.
  30742. */
  30743. static get BumpTextureEnabled(): boolean;
  30744. static set BumpTextureEnabled(value: boolean);
  30745. /**
  30746. * Are lightmap textures enabled in the application.
  30747. */
  30748. static get LightmapTextureEnabled(): boolean;
  30749. static set LightmapTextureEnabled(value: boolean);
  30750. /**
  30751. * Are refraction textures enabled in the application.
  30752. */
  30753. static get RefractionTextureEnabled(): boolean;
  30754. static set RefractionTextureEnabled(value: boolean);
  30755. /**
  30756. * Are color grading textures enabled in the application.
  30757. */
  30758. static get ColorGradingTextureEnabled(): boolean;
  30759. static set ColorGradingTextureEnabled(value: boolean);
  30760. /**
  30761. * Are fresnels enabled in the application.
  30762. */
  30763. static get FresnelEnabled(): boolean;
  30764. static set FresnelEnabled(value: boolean);
  30765. }
  30766. }
  30767. declare module BABYLON {
  30768. /**
  30769. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  30770. *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.
  30771. * The SPS is also a particle system. It provides some methods to manage the particles.
  30772. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  30773. *
  30774. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  30775. */
  30776. export class SolidParticleSystem implements IDisposable {
  30777. /**
  30778. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  30779. * Example : var p = SPS.particles[i];
  30780. */
  30781. particles: SolidParticle[];
  30782. /**
  30783. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  30784. */
  30785. nbParticles: number;
  30786. /**
  30787. * If the particles must ever face the camera (default false). Useful for planar particles.
  30788. */
  30789. billboard: boolean;
  30790. /**
  30791. * Recompute normals when adding a shape
  30792. */
  30793. recomputeNormals: boolean;
  30794. /**
  30795. * This a counter ofr your own usage. It's not set by any SPS functions.
  30796. */
  30797. counter: number;
  30798. /**
  30799. * The SPS name. This name is also given to the underlying mesh.
  30800. */
  30801. name: string;
  30802. /**
  30803. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  30804. */
  30805. mesh: Mesh;
  30806. /**
  30807. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  30808. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  30809. */
  30810. vars: any;
  30811. /**
  30812. * This array is populated when the SPS is set as 'pickable'.
  30813. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  30814. * Each element of this array is an object `{idx: int, faceId: int}`.
  30815. * `idx` is the picked particle index in the `SPS.particles` array
  30816. * `faceId` is the picked face index counted within this particle.
  30817. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  30818. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  30819. * Use the method SPS.pickedParticle(pickingInfo) instead.
  30820. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30821. */
  30822. pickedParticles: {
  30823. idx: number;
  30824. faceId: number;
  30825. }[];
  30826. /**
  30827. * This array is populated when the SPS is set as 'pickable'
  30828. * Each key of this array is a submesh index.
  30829. * Each element of this array is a second array defined like this :
  30830. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  30831. * Each element of this second array is an object `{idx: int, faceId: int}`.
  30832. * `idx` is the picked particle index in the `SPS.particles` array
  30833. * `faceId` is the picked face index counted within this particle.
  30834. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  30835. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30836. */
  30837. pickedBySubMesh: {
  30838. idx: number;
  30839. faceId: number;
  30840. }[][];
  30841. /**
  30842. * This array is populated when `enableDepthSort` is set to true.
  30843. * Each element of this array is an instance of the class DepthSortedParticle.
  30844. */
  30845. depthSortedParticles: DepthSortedParticle[];
  30846. /**
  30847. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  30848. * @hidden
  30849. */
  30850. _bSphereOnly: boolean;
  30851. /**
  30852. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  30853. * @hidden
  30854. */
  30855. _bSphereRadiusFactor: number;
  30856. private _scene;
  30857. private _positions;
  30858. private _indices;
  30859. private _normals;
  30860. private _colors;
  30861. private _uvs;
  30862. private _indices32;
  30863. private _positions32;
  30864. private _normals32;
  30865. private _fixedNormal32;
  30866. private _colors32;
  30867. private _uvs32;
  30868. private _index;
  30869. private _updatable;
  30870. private _pickable;
  30871. private _isVisibilityBoxLocked;
  30872. private _alwaysVisible;
  30873. private _depthSort;
  30874. private _expandable;
  30875. private _shapeCounter;
  30876. private _copy;
  30877. private _color;
  30878. private _computeParticleColor;
  30879. private _computeParticleTexture;
  30880. private _computeParticleRotation;
  30881. private _computeParticleVertex;
  30882. private _computeBoundingBox;
  30883. private _depthSortParticles;
  30884. private _camera;
  30885. private _mustUnrotateFixedNormals;
  30886. private _particlesIntersect;
  30887. private _needs32Bits;
  30888. private _isNotBuilt;
  30889. private _lastParticleId;
  30890. private _idxOfId;
  30891. private _multimaterialEnabled;
  30892. private _useModelMaterial;
  30893. private _indicesByMaterial;
  30894. private _materialIndexes;
  30895. private _depthSortFunction;
  30896. private _materialSortFunction;
  30897. private _materials;
  30898. private _multimaterial;
  30899. private _materialIndexesById;
  30900. private _defaultMaterial;
  30901. private _autoUpdateSubMeshes;
  30902. private _tmpVertex;
  30903. /**
  30904. * Creates a SPS (Solid Particle System) object.
  30905. * @param name (String) is the SPS name, this will be the underlying mesh name.
  30906. * @param scene (Scene) is the scene in which the SPS is added.
  30907. * @param options defines the options of the sps e.g.
  30908. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  30909. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  30910. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  30911. * * 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.
  30912. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  30913. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  30914. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  30915. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  30916. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  30917. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  30918. */
  30919. constructor(name: string, scene: Scene, options?: {
  30920. updatable?: boolean;
  30921. isPickable?: boolean;
  30922. enableDepthSort?: boolean;
  30923. particleIntersection?: boolean;
  30924. boundingSphereOnly?: boolean;
  30925. bSphereRadiusFactor?: number;
  30926. expandable?: boolean;
  30927. useModelMaterial?: boolean;
  30928. enableMultiMaterial?: boolean;
  30929. });
  30930. /**
  30931. * Builds the SPS underlying mesh. Returns a standard Mesh.
  30932. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  30933. * @returns the created mesh
  30934. */
  30935. buildMesh(): Mesh;
  30936. /**
  30937. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  30938. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  30939. * Thus the particles generated from `digest()` have their property `position` set yet.
  30940. * @param mesh ( Mesh ) is the mesh to be digested
  30941. * @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
  30942. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  30943. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  30944. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30945. * @returns the current SPS
  30946. */
  30947. digest(mesh: Mesh, options?: {
  30948. facetNb?: number;
  30949. number?: number;
  30950. delta?: number;
  30951. storage?: [];
  30952. }): SolidParticleSystem;
  30953. /**
  30954. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  30955. * @hidden
  30956. */
  30957. private _unrotateFixedNormals;
  30958. /**
  30959. * Resets the temporary working copy particle
  30960. * @hidden
  30961. */
  30962. private _resetCopy;
  30963. /**
  30964. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  30965. * @param p the current index in the positions array to be updated
  30966. * @param ind the current index in the indices array
  30967. * @param shape a Vector3 array, the shape geometry
  30968. * @param positions the positions array to be updated
  30969. * @param meshInd the shape indices array
  30970. * @param indices the indices array to be updated
  30971. * @param meshUV the shape uv array
  30972. * @param uvs the uv array to be updated
  30973. * @param meshCol the shape color array
  30974. * @param colors the color array to be updated
  30975. * @param meshNor the shape normals array
  30976. * @param normals the normals array to be updated
  30977. * @param idx the particle index
  30978. * @param idxInShape the particle index in its shape
  30979. * @param options the addShape() method passed options
  30980. * @model the particle model
  30981. * @hidden
  30982. */
  30983. private _meshBuilder;
  30984. /**
  30985. * Returns a shape Vector3 array from positions float array
  30986. * @param positions float array
  30987. * @returns a vector3 array
  30988. * @hidden
  30989. */
  30990. private _posToShape;
  30991. /**
  30992. * Returns a shapeUV array from a float uvs (array deep copy)
  30993. * @param uvs as a float array
  30994. * @returns a shapeUV array
  30995. * @hidden
  30996. */
  30997. private _uvsToShapeUV;
  30998. /**
  30999. * Adds a new particle object in the particles array
  31000. * @param idx particle index in particles array
  31001. * @param id particle id
  31002. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  31003. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  31004. * @param model particle ModelShape object
  31005. * @param shapeId model shape identifier
  31006. * @param idxInShape index of the particle in the current model
  31007. * @param bInfo model bounding info object
  31008. * @param storage target storage array, if any
  31009. * @hidden
  31010. */
  31011. private _addParticle;
  31012. /**
  31013. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31014. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  31015. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31016. * @param nb (positive integer) the number of particles to be created from this model
  31017. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31018. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31019. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31020. * @returns the number of shapes in the system
  31021. */
  31022. addShape(mesh: Mesh, nb: number, options?: {
  31023. positionFunction?: any;
  31024. vertexFunction?: any;
  31025. storage?: [];
  31026. }): number;
  31027. /**
  31028. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  31029. * @hidden
  31030. */
  31031. private _rebuildParticle;
  31032. /**
  31033. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31034. * @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.
  31035. * @returns the SPS.
  31036. */
  31037. rebuildMesh(reset?: boolean): SolidParticleSystem;
  31038. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  31039. * Returns an array with the removed particles.
  31040. * 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.
  31041. * The SPS can't be empty so at least one particle needs to remain in place.
  31042. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  31043. * @param start index of the first particle to remove
  31044. * @param end index of the last particle to remove (included)
  31045. * @returns an array populated with the removed particles
  31046. */
  31047. removeParticles(start: number, end: number): SolidParticle[];
  31048. /**
  31049. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  31050. * @param solidParticleArray an array populated with Solid Particles objects
  31051. * @returns the SPS
  31052. */
  31053. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  31054. /**
  31055. * Creates a new particle and modifies the SPS mesh geometry :
  31056. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  31057. * - calls _addParticle() to populate the particle array
  31058. * factorized code from addShape() and insertParticlesFromArray()
  31059. * @param idx particle index in the particles array
  31060. * @param i particle index in its shape
  31061. * @param modelShape particle ModelShape object
  31062. * @param shape shape vertex array
  31063. * @param meshInd shape indices array
  31064. * @param meshUV shape uv array
  31065. * @param meshCol shape color array
  31066. * @param meshNor shape normals array
  31067. * @param bbInfo shape bounding info
  31068. * @param storage target particle storage
  31069. * @options addShape() passed options
  31070. * @hidden
  31071. */
  31072. private _insertNewParticle;
  31073. /**
  31074. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31075. * This method calls `updateParticle()` for each particle of the SPS.
  31076. * For an animated SPS, it is usually called within the render loop.
  31077. * 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.
  31078. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31079. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31080. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31081. * @returns the SPS.
  31082. */
  31083. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31084. /**
  31085. * Disposes the SPS.
  31086. */
  31087. dispose(): void;
  31088. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  31089. * idx is the particle index in the SPS
  31090. * faceId is the picked face index counted within this particle.
  31091. * Returns null if the pickInfo can't identify a picked particle.
  31092. * @param pickingInfo (PickingInfo object)
  31093. * @returns {idx: number, faceId: number} or null
  31094. */
  31095. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  31096. idx: number;
  31097. faceId: number;
  31098. }>;
  31099. /**
  31100. * Returns a SolidParticle object from its identifier : particle.id
  31101. * @param id (integer) the particle Id
  31102. * @returns the searched particle or null if not found in the SPS.
  31103. */
  31104. getParticleById(id: number): Nullable<SolidParticle>;
  31105. /**
  31106. * Returns a new array populated with the particles having the passed shapeId.
  31107. * @param shapeId (integer) the shape identifier
  31108. * @returns a new solid particle array
  31109. */
  31110. getParticlesByShapeId(shapeId: number): SolidParticle[];
  31111. /**
  31112. * Populates the passed array "ref" with the particles having the passed shapeId.
  31113. * @param shapeId the shape identifier
  31114. * @returns the SPS
  31115. * @param ref
  31116. */
  31117. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  31118. /**
  31119. * Computes the required SubMeshes according the materials assigned to the particles.
  31120. * @returns the solid particle system.
  31121. * Does nothing if called before the SPS mesh is built.
  31122. */
  31123. computeSubMeshes(): SolidParticleSystem;
  31124. /**
  31125. * Sorts the solid particles by material when MultiMaterial is enabled.
  31126. * Updates the indices32 array.
  31127. * Updates the indicesByMaterial array.
  31128. * Updates the mesh indices array.
  31129. * @returns the SPS
  31130. * @hidden
  31131. */
  31132. private _sortParticlesByMaterial;
  31133. /**
  31134. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  31135. * @hidden
  31136. */
  31137. private _setMaterialIndexesById;
  31138. /**
  31139. * Returns an array with unique values of Materials from the passed array
  31140. * @param array the material array to be checked and filtered
  31141. * @hidden
  31142. */
  31143. private _filterUniqueMaterialId;
  31144. /**
  31145. * Sets a new Standard Material as _defaultMaterial if not already set.
  31146. * @hidden
  31147. */
  31148. private _setDefaultMaterial;
  31149. /**
  31150. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31151. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31152. * @returns the SPS.
  31153. */
  31154. refreshVisibleSize(): SolidParticleSystem;
  31155. /**
  31156. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31157. * @param size the size (float) of the visibility box
  31158. * note : this doesn't lock the SPS mesh bounding box.
  31159. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31160. */
  31161. setVisibilityBox(size: number): void;
  31162. /**
  31163. * Gets whether the SPS as always visible or not
  31164. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31165. */
  31166. get isAlwaysVisible(): boolean;
  31167. /**
  31168. * Sets the SPS as always visible or not
  31169. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31170. */
  31171. set isAlwaysVisible(val: boolean);
  31172. /**
  31173. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31174. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31175. */
  31176. set isVisibilityBoxLocked(val: boolean);
  31177. /**
  31178. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31179. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31180. */
  31181. get isVisibilityBoxLocked(): boolean;
  31182. /**
  31183. * Tells to `setParticles()` to compute the particle rotations or not.
  31184. * Default value : true. The SPS is faster when it's set to false.
  31185. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31186. */
  31187. set computeParticleRotation(val: boolean);
  31188. /**
  31189. * Tells to `setParticles()` to compute the particle colors or not.
  31190. * Default value : true. The SPS is faster when it's set to false.
  31191. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31192. */
  31193. set computeParticleColor(val: boolean);
  31194. set computeParticleTexture(val: boolean);
  31195. /**
  31196. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31197. * Default value : false. The SPS is faster when it's set to false.
  31198. * Note : the particle custom vertex positions aren't stored values.
  31199. */
  31200. set computeParticleVertex(val: boolean);
  31201. /**
  31202. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31203. */
  31204. set computeBoundingBox(val: boolean);
  31205. /**
  31206. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31207. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31208. * Default : `true`
  31209. */
  31210. set depthSortParticles(val: boolean);
  31211. /**
  31212. * Gets if `setParticles()` computes the particle rotations or not.
  31213. * Default value : true. The SPS is faster when it's set to false.
  31214. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31215. */
  31216. get computeParticleRotation(): boolean;
  31217. /**
  31218. * Gets if `setParticles()` computes the particle colors or not.
  31219. * Default value : true. The SPS is faster when it's set to false.
  31220. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31221. */
  31222. get computeParticleColor(): boolean;
  31223. /**
  31224. * Gets if `setParticles()` computes the particle textures or not.
  31225. * Default value : true. The SPS is faster when it's set to false.
  31226. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31227. */
  31228. get computeParticleTexture(): boolean;
  31229. /**
  31230. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31231. * Default value : false. The SPS is faster when it's set to false.
  31232. * Note : the particle custom vertex positions aren't stored values.
  31233. */
  31234. get computeParticleVertex(): boolean;
  31235. /**
  31236. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31237. */
  31238. get computeBoundingBox(): boolean;
  31239. /**
  31240. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31241. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31242. * Default : `true`
  31243. */
  31244. get depthSortParticles(): boolean;
  31245. /**
  31246. * Gets if the SPS is created as expandable at construction time.
  31247. * Default : `false`
  31248. */
  31249. get expandable(): boolean;
  31250. /**
  31251. * Gets if the SPS supports the Multi Materials
  31252. */
  31253. get multimaterialEnabled(): boolean;
  31254. /**
  31255. * Gets if the SPS uses the model materials for its own multimaterial.
  31256. */
  31257. get useModelMaterial(): boolean;
  31258. /**
  31259. * The SPS used material array.
  31260. */
  31261. get materials(): Material[];
  31262. /**
  31263. * Sets the SPS MultiMaterial from the passed materials.
  31264. * Note : the passed array is internally copied and not used then by reference.
  31265. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  31266. */
  31267. setMultiMaterial(materials: Material[]): void;
  31268. /**
  31269. * The SPS computed multimaterial object
  31270. */
  31271. get multimaterial(): MultiMaterial;
  31272. set multimaterial(mm: MultiMaterial);
  31273. /**
  31274. * If the subMeshes must be updated on the next call to setParticles()
  31275. */
  31276. get autoUpdateSubMeshes(): boolean;
  31277. set autoUpdateSubMeshes(val: boolean);
  31278. /**
  31279. * This function does nothing. It may be overwritten to set all the particle first values.
  31280. * The SPS doesn't call this function, you may have to call it by your own.
  31281. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31282. */
  31283. initParticles(): void;
  31284. /**
  31285. * This function does nothing. It may be overwritten to recycle a particle.
  31286. * The SPS doesn't call this function, you may have to call it by your own.
  31287. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31288. * @param particle The particle to recycle
  31289. * @returns the recycled particle
  31290. */
  31291. recycleParticle(particle: SolidParticle): SolidParticle;
  31292. /**
  31293. * Updates a particle : this function should be overwritten by the user.
  31294. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31295. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31296. * @example : just set a particle position or velocity and recycle conditions
  31297. * @param particle The particle to update
  31298. * @returns the updated particle
  31299. */
  31300. updateParticle(particle: SolidParticle): SolidParticle;
  31301. /**
  31302. * Updates a vertex of a particle : it can be overwritten by the user.
  31303. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31304. * @param particle the current particle
  31305. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  31306. * @param pt the index of the current vertex in the particle shape
  31307. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  31308. * @example : just set a vertex particle position or color
  31309. * @returns the sps
  31310. */
  31311. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  31312. /**
  31313. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31314. * This does nothing and may be overwritten by the user.
  31315. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31316. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31317. * @param update the boolean update value actually passed to setParticles()
  31318. */
  31319. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31320. /**
  31321. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31322. * This will be passed three parameters.
  31323. * This does nothing and may be overwritten by the user.
  31324. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31325. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31326. * @param update the boolean update value actually passed to setParticles()
  31327. */
  31328. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31329. }
  31330. }
  31331. declare module BABYLON {
  31332. /**
  31333. * Represents one particle of a solid particle system.
  31334. */
  31335. export class SolidParticle {
  31336. /**
  31337. * particle global index
  31338. */
  31339. idx: number;
  31340. /**
  31341. * particle identifier
  31342. */
  31343. id: number;
  31344. /**
  31345. * The color of the particle
  31346. */
  31347. color: Nullable<Color4>;
  31348. /**
  31349. * The world space position of the particle.
  31350. */
  31351. position: Vector3;
  31352. /**
  31353. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31354. */
  31355. rotation: Vector3;
  31356. /**
  31357. * The world space rotation quaternion of the particle.
  31358. */
  31359. rotationQuaternion: Nullable<Quaternion>;
  31360. /**
  31361. * The scaling of the particle.
  31362. */
  31363. scaling: Vector3;
  31364. /**
  31365. * The uvs of the particle.
  31366. */
  31367. uvs: Vector4;
  31368. /**
  31369. * The current speed of the particle.
  31370. */
  31371. velocity: Vector3;
  31372. /**
  31373. * The pivot point in the particle local space.
  31374. */
  31375. pivot: Vector3;
  31376. /**
  31377. * Must the particle be translated from its pivot point in its local space ?
  31378. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31379. * Default : false
  31380. */
  31381. translateFromPivot: boolean;
  31382. /**
  31383. * Is the particle active or not ?
  31384. */
  31385. alive: boolean;
  31386. /**
  31387. * Is the particle visible or not ?
  31388. */
  31389. isVisible: boolean;
  31390. /**
  31391. * Index of this particle in the global "positions" array (Internal use)
  31392. * @hidden
  31393. */
  31394. _pos: number;
  31395. /**
  31396. * @hidden Index of this particle in the global "indices" array (Internal use)
  31397. */
  31398. _ind: number;
  31399. /**
  31400. * @hidden ModelShape of this particle (Internal use)
  31401. */
  31402. _model: ModelShape;
  31403. /**
  31404. * ModelShape id of this particle
  31405. */
  31406. shapeId: number;
  31407. /**
  31408. * Index of the particle in its shape id
  31409. */
  31410. idxInShape: number;
  31411. /**
  31412. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31413. */
  31414. _modelBoundingInfo: BoundingInfo;
  31415. /**
  31416. * @hidden Particle BoundingInfo object (Internal use)
  31417. */
  31418. _boundingInfo: BoundingInfo;
  31419. /**
  31420. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31421. */
  31422. _sps: SolidParticleSystem;
  31423. /**
  31424. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31425. */
  31426. _stillInvisible: boolean;
  31427. /**
  31428. * @hidden Last computed particle rotation matrix
  31429. */
  31430. _rotationMatrix: number[];
  31431. /**
  31432. * Parent particle Id, if any.
  31433. * Default null.
  31434. */
  31435. parentId: Nullable<number>;
  31436. /**
  31437. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  31438. */
  31439. materialIndex: Nullable<number>;
  31440. /**
  31441. * Custom object or properties.
  31442. */
  31443. props: Nullable<any>;
  31444. /**
  31445. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  31446. * The possible values are :
  31447. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31448. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31449. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31450. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31451. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31452. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  31453. * */
  31454. cullingStrategy: number;
  31455. /**
  31456. * @hidden Internal global position in the SPS.
  31457. */
  31458. _globalPosition: Vector3;
  31459. /**
  31460. * Creates a Solid Particle object.
  31461. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31462. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  31463. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  31464. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31465. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31466. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31467. * @param shapeId (integer) is the model shape identifier in the SPS.
  31468. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31469. * @param sps defines the sps it is associated to
  31470. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31471. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  31472. */
  31473. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  31474. /**
  31475. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  31476. * @param target the particle target
  31477. * @returns the current particle
  31478. */
  31479. copyToRef(target: SolidParticle): SolidParticle;
  31480. /**
  31481. * Legacy support, changed scale to scaling
  31482. */
  31483. get scale(): Vector3;
  31484. /**
  31485. * Legacy support, changed scale to scaling
  31486. */
  31487. set scale(scale: Vector3);
  31488. /**
  31489. * Legacy support, changed quaternion to rotationQuaternion
  31490. */
  31491. get quaternion(): Nullable<Quaternion>;
  31492. /**
  31493. * Legacy support, changed quaternion to rotationQuaternion
  31494. */
  31495. set quaternion(q: Nullable<Quaternion>);
  31496. /**
  31497. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31498. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31499. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31500. * @returns true if it intersects
  31501. */
  31502. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31503. /**
  31504. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  31505. * A particle is in the frustum if its bounding box intersects the frustum
  31506. * @param frustumPlanes defines the frustum to test
  31507. * @returns true if the particle is in the frustum planes
  31508. */
  31509. isInFrustum(frustumPlanes: Plane[]): boolean;
  31510. /**
  31511. * get the rotation matrix of the particle
  31512. * @hidden
  31513. */
  31514. getRotationMatrix(m: Matrix): void;
  31515. }
  31516. /**
  31517. * Represents the shape of the model used by one particle of a solid particle system.
  31518. * SPS internal tool, don't use it manually.
  31519. */
  31520. export class ModelShape {
  31521. /**
  31522. * The shape id
  31523. * @hidden
  31524. */
  31525. shapeID: number;
  31526. /**
  31527. * flat array of model positions (internal use)
  31528. * @hidden
  31529. */
  31530. _shape: Vector3[];
  31531. /**
  31532. * flat array of model UVs (internal use)
  31533. * @hidden
  31534. */
  31535. _shapeUV: number[];
  31536. /**
  31537. * color array of the model
  31538. * @hidden
  31539. */
  31540. _shapeColors: number[];
  31541. /**
  31542. * indices array of the model
  31543. * @hidden
  31544. */
  31545. _indices: number[];
  31546. /**
  31547. * normals array of the model
  31548. * @hidden
  31549. */
  31550. _normals: number[];
  31551. /**
  31552. * length of the shape in the model indices array (internal use)
  31553. * @hidden
  31554. */
  31555. _indicesLength: number;
  31556. /**
  31557. * Custom position function (internal use)
  31558. * @hidden
  31559. */
  31560. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31561. /**
  31562. * Custom vertex function (internal use)
  31563. * @hidden
  31564. */
  31565. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31566. /**
  31567. * Model material (internal use)
  31568. * @hidden
  31569. */
  31570. _material: Nullable<Material>;
  31571. /**
  31572. * 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.
  31573. * SPS internal tool, don't use it manually.
  31574. * @hidden
  31575. */
  31576. 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>);
  31577. }
  31578. /**
  31579. * Represents a Depth Sorted Particle in the solid particle system.
  31580. * @hidden
  31581. */
  31582. export class DepthSortedParticle {
  31583. /**
  31584. * Particle index
  31585. */
  31586. idx: number;
  31587. /**
  31588. * Index of the particle in the "indices" array
  31589. */
  31590. ind: number;
  31591. /**
  31592. * Length of the particle shape in the "indices" array
  31593. */
  31594. indicesLength: number;
  31595. /**
  31596. * Squared distance from the particle to the camera
  31597. */
  31598. sqDistance: number;
  31599. /**
  31600. * Material index when used with MultiMaterials
  31601. */
  31602. materialIndex: number;
  31603. /**
  31604. * Creates a new sorted particle
  31605. * @param materialIndex
  31606. */
  31607. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  31608. }
  31609. /**
  31610. * Represents a solid particle vertex
  31611. */
  31612. export class SolidParticleVertex {
  31613. /**
  31614. * Vertex position
  31615. */
  31616. position: Vector3;
  31617. /**
  31618. * Vertex color
  31619. */
  31620. color: Color4;
  31621. /**
  31622. * Vertex UV
  31623. */
  31624. uv: Vector2;
  31625. /**
  31626. * Creates a new solid particle vertex
  31627. */
  31628. constructor();
  31629. /** Vertex x coordinate */
  31630. get x(): number;
  31631. set x(val: number);
  31632. /** Vertex y coordinate */
  31633. get y(): number;
  31634. set y(val: number);
  31635. /** Vertex z coordinate */
  31636. get z(): number;
  31637. set z(val: number);
  31638. }
  31639. }
  31640. declare module BABYLON {
  31641. /**
  31642. * @hidden
  31643. */
  31644. export class _MeshCollisionData {
  31645. _checkCollisions: boolean;
  31646. _collisionMask: number;
  31647. _collisionGroup: number;
  31648. _surroundingMeshes: Nullable<AbstractMesh[]>;
  31649. _collider: Nullable<Collider>;
  31650. _oldPositionForCollisions: Vector3;
  31651. _diffPositionForCollisions: Vector3;
  31652. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  31653. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  31654. }
  31655. }
  31656. declare module BABYLON {
  31657. /** @hidden */
  31658. class _FacetDataStorage {
  31659. facetPositions: Vector3[];
  31660. facetNormals: Vector3[];
  31661. facetPartitioning: number[][];
  31662. facetNb: number;
  31663. partitioningSubdivisions: number;
  31664. partitioningBBoxRatio: number;
  31665. facetDataEnabled: boolean;
  31666. facetParameters: any;
  31667. bbSize: Vector3;
  31668. subDiv: {
  31669. max: number;
  31670. X: number;
  31671. Y: number;
  31672. Z: number;
  31673. };
  31674. facetDepthSort: boolean;
  31675. facetDepthSortEnabled: boolean;
  31676. depthSortedIndices: IndicesArray;
  31677. depthSortedFacets: {
  31678. ind: number;
  31679. sqDistance: number;
  31680. }[];
  31681. facetDepthSortFunction: (f1: {
  31682. ind: number;
  31683. sqDistance: number;
  31684. }, f2: {
  31685. ind: number;
  31686. sqDistance: number;
  31687. }) => number;
  31688. facetDepthSortFrom: Vector3;
  31689. facetDepthSortOrigin: Vector3;
  31690. invertedMatrix: Matrix;
  31691. }
  31692. /**
  31693. * @hidden
  31694. **/
  31695. class _InternalAbstractMeshDataInfo {
  31696. _hasVertexAlpha: boolean;
  31697. _useVertexColors: boolean;
  31698. _numBoneInfluencers: number;
  31699. _applyFog: boolean;
  31700. _receiveShadows: boolean;
  31701. _facetData: _FacetDataStorage;
  31702. _visibility: number;
  31703. _skeleton: Nullable<Skeleton>;
  31704. _layerMask: number;
  31705. _computeBonesUsingShaders: boolean;
  31706. _isActive: boolean;
  31707. _onlyForInstances: boolean;
  31708. _isActiveIntermediate: boolean;
  31709. _onlyForInstancesIntermediate: boolean;
  31710. _actAsRegularMesh: boolean;
  31711. }
  31712. /**
  31713. * Class used to store all common mesh properties
  31714. */
  31715. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  31716. /** No occlusion */
  31717. static OCCLUSION_TYPE_NONE: number;
  31718. /** Occlusion set to optimisitic */
  31719. static OCCLUSION_TYPE_OPTIMISTIC: number;
  31720. /** Occlusion set to strict */
  31721. static OCCLUSION_TYPE_STRICT: number;
  31722. /** Use an accurante occlusion algorithm */
  31723. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  31724. /** Use a conservative occlusion algorithm */
  31725. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  31726. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  31727. * Test order :
  31728. * Is the bounding sphere outside the frustum ?
  31729. * If not, are the bounding box vertices outside the frustum ?
  31730. * It not, then the cullable object is in the frustum.
  31731. */
  31732. static readonly CULLINGSTRATEGY_STANDARD: number;
  31733. /** Culling strategy : Bounding Sphere Only.
  31734. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  31735. * It's also less accurate than the standard because some not visible objects can still be selected.
  31736. * Test : is the bounding sphere outside the frustum ?
  31737. * If not, then the cullable object is in the frustum.
  31738. */
  31739. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  31740. /** Culling strategy : Optimistic Inclusion.
  31741. * This in an inclusion test first, then the standard exclusion test.
  31742. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  31743. * 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.
  31744. * Anyway, it's as accurate as the standard strategy.
  31745. * Test :
  31746. * Is the cullable object bounding sphere center in the frustum ?
  31747. * If not, apply the default culling strategy.
  31748. */
  31749. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  31750. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  31751. * This in an inclusion test first, then the bounding sphere only exclusion test.
  31752. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  31753. * 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.
  31754. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  31755. * Test :
  31756. * Is the cullable object bounding sphere center in the frustum ?
  31757. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  31758. */
  31759. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  31760. /**
  31761. * No billboard
  31762. */
  31763. static get BILLBOARDMODE_NONE(): number;
  31764. /** Billboard on X axis */
  31765. static get BILLBOARDMODE_X(): number;
  31766. /** Billboard on Y axis */
  31767. static get BILLBOARDMODE_Y(): number;
  31768. /** Billboard on Z axis */
  31769. static get BILLBOARDMODE_Z(): number;
  31770. /** Billboard on all axes */
  31771. static get BILLBOARDMODE_ALL(): number;
  31772. /** Billboard on using position instead of orientation */
  31773. static get BILLBOARDMODE_USE_POSITION(): number;
  31774. /** @hidden */
  31775. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  31776. /**
  31777. * The culling strategy to use to check whether the mesh must be rendered or not.
  31778. * This value can be changed at any time and will be used on the next render mesh selection.
  31779. * The possible values are :
  31780. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31781. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31782. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31783. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31784. * Please read each static variable documentation to get details about the culling process.
  31785. * */
  31786. cullingStrategy: number;
  31787. /**
  31788. * Gets the number of facets in the mesh
  31789. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31790. */
  31791. get facetNb(): number;
  31792. /**
  31793. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  31794. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  31795. */
  31796. get partitioningSubdivisions(): number;
  31797. set partitioningSubdivisions(nb: number);
  31798. /**
  31799. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  31800. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  31801. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  31802. */
  31803. get partitioningBBoxRatio(): number;
  31804. set partitioningBBoxRatio(ratio: number);
  31805. /**
  31806. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  31807. * Works only for updatable meshes.
  31808. * Doesn't work with multi-materials
  31809. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  31810. */
  31811. get mustDepthSortFacets(): boolean;
  31812. set mustDepthSortFacets(sort: boolean);
  31813. /**
  31814. * The location (Vector3) where the facet depth sort must be computed from.
  31815. * By default, the active camera position.
  31816. * Used only when facet depth sort is enabled
  31817. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  31818. */
  31819. get facetDepthSortFrom(): Vector3;
  31820. set facetDepthSortFrom(location: Vector3);
  31821. /**
  31822. * gets a boolean indicating if facetData is enabled
  31823. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31824. */
  31825. get isFacetDataEnabled(): boolean;
  31826. /** @hidden */
  31827. _updateNonUniformScalingState(value: boolean): boolean;
  31828. /**
  31829. * An event triggered when this mesh collides with another one
  31830. */
  31831. onCollideObservable: Observable<AbstractMesh>;
  31832. /** Set a function to call when this mesh collides with another one */
  31833. set onCollide(callback: () => void);
  31834. /**
  31835. * An event triggered when the collision's position changes
  31836. */
  31837. onCollisionPositionChangeObservable: Observable<Vector3>;
  31838. /** Set a function to call when the collision's position changes */
  31839. set onCollisionPositionChange(callback: () => void);
  31840. /**
  31841. * An event triggered when material is changed
  31842. */
  31843. onMaterialChangedObservable: Observable<AbstractMesh>;
  31844. /**
  31845. * Gets or sets the orientation for POV movement & rotation
  31846. */
  31847. definedFacingForward: boolean;
  31848. /** @hidden */
  31849. _occlusionQuery: Nullable<WebGLQuery>;
  31850. /** @hidden */
  31851. _renderingGroup: Nullable<RenderingGroup>;
  31852. /**
  31853. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  31854. */
  31855. get visibility(): number;
  31856. /**
  31857. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  31858. */
  31859. set visibility(value: number);
  31860. /** Gets or sets the alpha index used to sort transparent meshes
  31861. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  31862. */
  31863. alphaIndex: number;
  31864. /**
  31865. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  31866. */
  31867. isVisible: boolean;
  31868. /**
  31869. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  31870. */
  31871. isPickable: boolean;
  31872. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  31873. showSubMeshesBoundingBox: boolean;
  31874. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  31875. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  31876. */
  31877. isBlocker: boolean;
  31878. /**
  31879. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  31880. */
  31881. enablePointerMoveEvents: boolean;
  31882. /**
  31883. * Specifies the rendering group id for this mesh (0 by default)
  31884. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  31885. */
  31886. renderingGroupId: number;
  31887. private _material;
  31888. /** Gets or sets current material */
  31889. get material(): Nullable<Material>;
  31890. set material(value: Nullable<Material>);
  31891. /**
  31892. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  31893. * @see https://doc.babylonjs.com/babylon101/shadows
  31894. */
  31895. get receiveShadows(): boolean;
  31896. set receiveShadows(value: boolean);
  31897. /** Defines color to use when rendering outline */
  31898. outlineColor: Color3;
  31899. /** Define width to use when rendering outline */
  31900. outlineWidth: number;
  31901. /** Defines color to use when rendering overlay */
  31902. overlayColor: Color3;
  31903. /** Defines alpha to use when rendering overlay */
  31904. overlayAlpha: number;
  31905. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  31906. get hasVertexAlpha(): boolean;
  31907. set hasVertexAlpha(value: boolean);
  31908. /** 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) */
  31909. get useVertexColors(): boolean;
  31910. set useVertexColors(value: boolean);
  31911. /**
  31912. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  31913. */
  31914. get computeBonesUsingShaders(): boolean;
  31915. set computeBonesUsingShaders(value: boolean);
  31916. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  31917. get numBoneInfluencers(): number;
  31918. set numBoneInfluencers(value: number);
  31919. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  31920. get applyFog(): boolean;
  31921. set applyFog(value: boolean);
  31922. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  31923. useOctreeForRenderingSelection: boolean;
  31924. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  31925. useOctreeForPicking: boolean;
  31926. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  31927. useOctreeForCollisions: boolean;
  31928. /**
  31929. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  31930. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  31931. */
  31932. get layerMask(): number;
  31933. set layerMask(value: number);
  31934. /**
  31935. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  31936. */
  31937. alwaysSelectAsActiveMesh: boolean;
  31938. /**
  31939. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  31940. */
  31941. doNotSyncBoundingInfo: boolean;
  31942. /**
  31943. * Gets or sets the current action manager
  31944. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  31945. */
  31946. actionManager: Nullable<AbstractActionManager>;
  31947. private _meshCollisionData;
  31948. /**
  31949. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  31950. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31951. */
  31952. ellipsoid: Vector3;
  31953. /**
  31954. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  31955. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31956. */
  31957. ellipsoidOffset: Vector3;
  31958. /**
  31959. * Gets or sets a collision mask used to mask collisions (default is -1).
  31960. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31961. */
  31962. get collisionMask(): number;
  31963. set collisionMask(mask: number);
  31964. /**
  31965. * Gets or sets the current collision group mask (-1 by default).
  31966. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31967. */
  31968. get collisionGroup(): number;
  31969. set collisionGroup(mask: number);
  31970. /**
  31971. * Gets or sets current surrounding meshes (null by default).
  31972. *
  31973. * By default collision detection is tested against every mesh in the scene.
  31974. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  31975. * meshes will be tested for the collision.
  31976. *
  31977. * Note: if set to an empty array no collision will happen when this mesh is moved.
  31978. */
  31979. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  31980. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  31981. /**
  31982. * Defines edge width used when edgesRenderer is enabled
  31983. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31984. */
  31985. edgesWidth: number;
  31986. /**
  31987. * Defines edge color used when edgesRenderer is enabled
  31988. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31989. */
  31990. edgesColor: Color4;
  31991. /** @hidden */
  31992. _edgesRenderer: Nullable<IEdgesRenderer>;
  31993. /** @hidden */
  31994. _masterMesh: Nullable<AbstractMesh>;
  31995. /** @hidden */
  31996. _boundingInfo: Nullable<BoundingInfo>;
  31997. /** @hidden */
  31998. _renderId: number;
  31999. /**
  32000. * Gets or sets the list of subMeshes
  32001. * @see https://doc.babylonjs.com/how_to/multi_materials
  32002. */
  32003. subMeshes: SubMesh[];
  32004. /** @hidden */
  32005. _intersectionsInProgress: AbstractMesh[];
  32006. /** @hidden */
  32007. _unIndexed: boolean;
  32008. /** @hidden */
  32009. _lightSources: Light[];
  32010. /** Gets the list of lights affecting that mesh */
  32011. get lightSources(): Light[];
  32012. /** @hidden */
  32013. get _positions(): Nullable<Vector3[]>;
  32014. /** @hidden */
  32015. _waitingData: {
  32016. lods: Nullable<any>;
  32017. actions: Nullable<any>;
  32018. freezeWorldMatrix: Nullable<boolean>;
  32019. };
  32020. /** @hidden */
  32021. _bonesTransformMatrices: Nullable<Float32Array>;
  32022. /** @hidden */
  32023. _transformMatrixTexture: Nullable<RawTexture>;
  32024. /**
  32025. * Gets or sets a skeleton to apply skining transformations
  32026. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32027. */
  32028. set skeleton(value: Nullable<Skeleton>);
  32029. get skeleton(): Nullable<Skeleton>;
  32030. /**
  32031. * An event triggered when the mesh is rebuilt.
  32032. */
  32033. onRebuildObservable: Observable<AbstractMesh>;
  32034. /**
  32035. * Creates a new AbstractMesh
  32036. * @param name defines the name of the mesh
  32037. * @param scene defines the hosting scene
  32038. */
  32039. constructor(name: string, scene?: Nullable<Scene>);
  32040. /**
  32041. * Returns the string "AbstractMesh"
  32042. * @returns "AbstractMesh"
  32043. */
  32044. getClassName(): string;
  32045. /**
  32046. * Gets a string representation of the current mesh
  32047. * @param fullDetails defines a boolean indicating if full details must be included
  32048. * @returns a string representation of the current mesh
  32049. */
  32050. toString(fullDetails?: boolean): string;
  32051. /**
  32052. * @hidden
  32053. */
  32054. protected _getEffectiveParent(): Nullable<Node>;
  32055. /** @hidden */
  32056. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32057. /** @hidden */
  32058. _rebuild(): void;
  32059. /** @hidden */
  32060. _resyncLightSources(): void;
  32061. /** @hidden */
  32062. _resyncLightSource(light: Light): void;
  32063. /** @hidden */
  32064. _unBindEffect(): void;
  32065. /** @hidden */
  32066. _removeLightSource(light: Light, dispose: boolean): void;
  32067. private _markSubMeshesAsDirty;
  32068. /** @hidden */
  32069. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  32070. /** @hidden */
  32071. _markSubMeshesAsAttributesDirty(): void;
  32072. /** @hidden */
  32073. _markSubMeshesAsMiscDirty(): void;
  32074. /**
  32075. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  32076. */
  32077. get scaling(): Vector3;
  32078. set scaling(newScaling: Vector3);
  32079. /**
  32080. * Returns true if the mesh is blocked. Implemented by child classes
  32081. */
  32082. get isBlocked(): boolean;
  32083. /**
  32084. * Returns the mesh itself by default. Implemented by child classes
  32085. * @param camera defines the camera to use to pick the right LOD level
  32086. * @returns the currentAbstractMesh
  32087. */
  32088. getLOD(camera: Camera): Nullable<AbstractMesh>;
  32089. /**
  32090. * Returns 0 by default. Implemented by child classes
  32091. * @returns an integer
  32092. */
  32093. getTotalVertices(): number;
  32094. /**
  32095. * Returns a positive integer : the total number of indices in this mesh geometry.
  32096. * @returns the numner of indices or zero if the mesh has no geometry.
  32097. */
  32098. getTotalIndices(): number;
  32099. /**
  32100. * Returns null by default. Implemented by child classes
  32101. * @returns null
  32102. */
  32103. getIndices(): Nullable<IndicesArray>;
  32104. /**
  32105. * Returns the array of the requested vertex data kind. Implemented by child classes
  32106. * @param kind defines the vertex data kind to use
  32107. * @returns null
  32108. */
  32109. getVerticesData(kind: string): Nullable<FloatArray>;
  32110. /**
  32111. * Sets the vertex data of the mesh geometry for the requested `kind`.
  32112. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  32113. * Note that a new underlying VertexBuffer object is created each call.
  32114. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  32115. * @param kind defines vertex data kind:
  32116. * * VertexBuffer.PositionKind
  32117. * * VertexBuffer.UVKind
  32118. * * VertexBuffer.UV2Kind
  32119. * * VertexBuffer.UV3Kind
  32120. * * VertexBuffer.UV4Kind
  32121. * * VertexBuffer.UV5Kind
  32122. * * VertexBuffer.UV6Kind
  32123. * * VertexBuffer.ColorKind
  32124. * * VertexBuffer.MatricesIndicesKind
  32125. * * VertexBuffer.MatricesIndicesExtraKind
  32126. * * VertexBuffer.MatricesWeightsKind
  32127. * * VertexBuffer.MatricesWeightsExtraKind
  32128. * @param data defines the data source
  32129. * @param updatable defines if the data must be flagged as updatable (or static)
  32130. * @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
  32131. * @returns the current mesh
  32132. */
  32133. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32134. /**
  32135. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  32136. * If the mesh has no geometry, it is simply returned as it is.
  32137. * @param kind defines vertex data kind:
  32138. * * VertexBuffer.PositionKind
  32139. * * VertexBuffer.UVKind
  32140. * * VertexBuffer.UV2Kind
  32141. * * VertexBuffer.UV3Kind
  32142. * * VertexBuffer.UV4Kind
  32143. * * VertexBuffer.UV5Kind
  32144. * * VertexBuffer.UV6Kind
  32145. * * VertexBuffer.ColorKind
  32146. * * VertexBuffer.MatricesIndicesKind
  32147. * * VertexBuffer.MatricesIndicesExtraKind
  32148. * * VertexBuffer.MatricesWeightsKind
  32149. * * VertexBuffer.MatricesWeightsExtraKind
  32150. * @param data defines the data source
  32151. * @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
  32152. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  32153. * @returns the current mesh
  32154. */
  32155. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32156. /**
  32157. * Sets the mesh indices,
  32158. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  32159. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  32160. * @param totalVertices Defines the total number of vertices
  32161. * @returns the current mesh
  32162. */
  32163. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  32164. /**
  32165. * Gets a boolean indicating if specific vertex data is present
  32166. * @param kind defines the vertex data kind to use
  32167. * @returns true is data kind is present
  32168. */
  32169. isVerticesDataPresent(kind: string): boolean;
  32170. /**
  32171. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  32172. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  32173. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  32174. * @returns a BoundingInfo
  32175. */
  32176. getBoundingInfo(): BoundingInfo;
  32177. /**
  32178. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  32179. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  32180. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  32181. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  32182. * @returns the current mesh
  32183. */
  32184. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  32185. /**
  32186. * Overwrite the current bounding info
  32187. * @param boundingInfo defines the new bounding info
  32188. * @returns the current mesh
  32189. */
  32190. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  32191. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  32192. get useBones(): boolean;
  32193. /** @hidden */
  32194. _preActivate(): void;
  32195. /** @hidden */
  32196. _preActivateForIntermediateRendering(renderId: number): void;
  32197. /** @hidden */
  32198. _activate(renderId: number, intermediateRendering: boolean): boolean;
  32199. /** @hidden */
  32200. _postActivate(): void;
  32201. /** @hidden */
  32202. _freeze(): void;
  32203. /** @hidden */
  32204. _unFreeze(): void;
  32205. /**
  32206. * Gets the current world matrix
  32207. * @returns a Matrix
  32208. */
  32209. getWorldMatrix(): Matrix;
  32210. /** @hidden */
  32211. _getWorldMatrixDeterminant(): number;
  32212. /**
  32213. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  32214. */
  32215. get isAnInstance(): boolean;
  32216. /**
  32217. * Gets a boolean indicating if this mesh has instances
  32218. */
  32219. get hasInstances(): boolean;
  32220. /**
  32221. * Gets a boolean indicating if this mesh has thin instances
  32222. */
  32223. get hasThinInstances(): boolean;
  32224. /**
  32225. * Perform relative position change from the point of view of behind the front of the mesh.
  32226. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32227. * Supports definition of mesh facing forward or backward
  32228. * @param amountRight defines the distance on the right axis
  32229. * @param amountUp defines the distance on the up axis
  32230. * @param amountForward defines the distance on the forward axis
  32231. * @returns the current mesh
  32232. */
  32233. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  32234. /**
  32235. * Calculate relative position change from the point of view of behind the front of the mesh.
  32236. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32237. * Supports definition of mesh facing forward or backward
  32238. * @param amountRight defines the distance on the right axis
  32239. * @param amountUp defines the distance on the up axis
  32240. * @param amountForward defines the distance on the forward axis
  32241. * @returns the new displacement vector
  32242. */
  32243. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  32244. /**
  32245. * Perform relative rotation change from the point of view of behind the front of the mesh.
  32246. * Supports definition of mesh facing forward or backward
  32247. * @param flipBack defines the flip
  32248. * @param twirlClockwise defines the twirl
  32249. * @param tiltRight defines the tilt
  32250. * @returns the current mesh
  32251. */
  32252. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  32253. /**
  32254. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  32255. * Supports definition of mesh facing forward or backward.
  32256. * @param flipBack defines the flip
  32257. * @param twirlClockwise defines the twirl
  32258. * @param tiltRight defines the tilt
  32259. * @returns the new rotation vector
  32260. */
  32261. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  32262. /**
  32263. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32264. * This means the mesh underlying bounding box and sphere are recomputed.
  32265. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32266. * @returns the current mesh
  32267. */
  32268. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  32269. /** @hidden */
  32270. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  32271. /** @hidden */
  32272. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  32273. /** @hidden */
  32274. _updateBoundingInfo(): AbstractMesh;
  32275. /** @hidden */
  32276. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  32277. /** @hidden */
  32278. protected _afterComputeWorldMatrix(): void;
  32279. /** @hidden */
  32280. get _effectiveMesh(): AbstractMesh;
  32281. /**
  32282. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32283. * A mesh is in the frustum if its bounding box intersects the frustum
  32284. * @param frustumPlanes defines the frustum to test
  32285. * @returns true if the mesh is in the frustum planes
  32286. */
  32287. isInFrustum(frustumPlanes: Plane[]): boolean;
  32288. /**
  32289. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  32290. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  32291. * @param frustumPlanes defines the frustum to test
  32292. * @returns true if the mesh is completely in the frustum planes
  32293. */
  32294. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32295. /**
  32296. * True if the mesh intersects another mesh or a SolidParticle object
  32297. * @param mesh defines a target mesh or SolidParticle to test
  32298. * @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)
  32299. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  32300. * @returns true if there is an intersection
  32301. */
  32302. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  32303. /**
  32304. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  32305. * @param point defines the point to test
  32306. * @returns true if there is an intersection
  32307. */
  32308. intersectsPoint(point: Vector3): boolean;
  32309. /**
  32310. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  32311. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32312. */
  32313. get checkCollisions(): boolean;
  32314. set checkCollisions(collisionEnabled: boolean);
  32315. /**
  32316. * Gets Collider object used to compute collisions (not physics)
  32317. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32318. */
  32319. get collider(): Nullable<Collider>;
  32320. /**
  32321. * Move the mesh using collision engine
  32322. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32323. * @param displacement defines the requested displacement vector
  32324. * @returns the current mesh
  32325. */
  32326. moveWithCollisions(displacement: Vector3): AbstractMesh;
  32327. private _onCollisionPositionChange;
  32328. /** @hidden */
  32329. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  32330. /** @hidden */
  32331. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  32332. /** @hidden */
  32333. _checkCollision(collider: Collider): AbstractMesh;
  32334. /** @hidden */
  32335. _generatePointsArray(): boolean;
  32336. /**
  32337. * Checks if the passed Ray intersects with the mesh
  32338. * @param ray defines the ray to use
  32339. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  32340. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32341. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  32342. * @returns the picking info
  32343. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  32344. */
  32345. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  32346. /**
  32347. * Clones the current mesh
  32348. * @param name defines the mesh name
  32349. * @param newParent defines the new mesh parent
  32350. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  32351. * @returns the new mesh
  32352. */
  32353. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  32354. /**
  32355. * Disposes all the submeshes of the current meshnp
  32356. * @returns the current mesh
  32357. */
  32358. releaseSubMeshes(): AbstractMesh;
  32359. /**
  32360. * Releases resources associated with this abstract mesh.
  32361. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32362. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32363. */
  32364. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32365. /**
  32366. * Adds the passed mesh as a child to the current mesh
  32367. * @param mesh defines the child mesh
  32368. * @returns the current mesh
  32369. */
  32370. addChild(mesh: AbstractMesh): AbstractMesh;
  32371. /**
  32372. * Removes the passed mesh from the current mesh children list
  32373. * @param mesh defines the child mesh
  32374. * @returns the current mesh
  32375. */
  32376. removeChild(mesh: AbstractMesh): AbstractMesh;
  32377. /** @hidden */
  32378. private _initFacetData;
  32379. /**
  32380. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  32381. * This method can be called within the render loop.
  32382. * 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
  32383. * @returns the current mesh
  32384. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32385. */
  32386. updateFacetData(): AbstractMesh;
  32387. /**
  32388. * Returns the facetLocalNormals array.
  32389. * The normals are expressed in the mesh local spac
  32390. * @returns an array of Vector3
  32391. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32392. */
  32393. getFacetLocalNormals(): Vector3[];
  32394. /**
  32395. * Returns the facetLocalPositions array.
  32396. * The facet positions are expressed in the mesh local space
  32397. * @returns an array of Vector3
  32398. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32399. */
  32400. getFacetLocalPositions(): Vector3[];
  32401. /**
  32402. * Returns the facetLocalPartioning array
  32403. * @returns an array of array of numbers
  32404. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32405. */
  32406. getFacetLocalPartitioning(): number[][];
  32407. /**
  32408. * Returns the i-th facet position in the world system.
  32409. * This method allocates a new Vector3 per call
  32410. * @param i defines the facet index
  32411. * @returns a new Vector3
  32412. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32413. */
  32414. getFacetPosition(i: number): Vector3;
  32415. /**
  32416. * Sets the reference Vector3 with the i-th facet position in the world system
  32417. * @param i defines the facet index
  32418. * @param ref defines the target vector
  32419. * @returns the current mesh
  32420. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32421. */
  32422. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  32423. /**
  32424. * Returns the i-th facet normal in the world system.
  32425. * This method allocates a new Vector3 per call
  32426. * @param i defines the facet index
  32427. * @returns a new Vector3
  32428. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32429. */
  32430. getFacetNormal(i: number): Vector3;
  32431. /**
  32432. * Sets the reference Vector3 with the i-th facet normal in the world system
  32433. * @param i defines the facet index
  32434. * @param ref defines the target vector
  32435. * @returns the current mesh
  32436. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32437. */
  32438. getFacetNormalToRef(i: number, ref: Vector3): this;
  32439. /**
  32440. * 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)
  32441. * @param x defines x coordinate
  32442. * @param y defines y coordinate
  32443. * @param z defines z coordinate
  32444. * @returns the array of facet indexes
  32445. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32446. */
  32447. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  32448. /**
  32449. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  32450. * @param projected sets as the (x,y,z) world projection on the facet
  32451. * @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
  32452. * @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
  32453. * @param x defines x coordinate
  32454. * @param y defines y coordinate
  32455. * @param z defines z coordinate
  32456. * @returns the face index if found (or null instead)
  32457. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32458. */
  32459. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32460. /**
  32461. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  32462. * @param projected sets as the (x,y,z) local projection on the facet
  32463. * @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
  32464. * @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
  32465. * @param x defines x coordinate
  32466. * @param y defines y coordinate
  32467. * @param z defines z coordinate
  32468. * @returns the face index if found (or null instead)
  32469. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32470. */
  32471. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32472. /**
  32473. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  32474. * @returns the parameters
  32475. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32476. */
  32477. getFacetDataParameters(): any;
  32478. /**
  32479. * Disables the feature FacetData and frees the related memory
  32480. * @returns the current mesh
  32481. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32482. */
  32483. disableFacetData(): AbstractMesh;
  32484. /**
  32485. * Updates the AbstractMesh indices array
  32486. * @param indices defines the data source
  32487. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32488. * @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)
  32489. * @returns the current mesh
  32490. */
  32491. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32492. /**
  32493. * Creates new normals data for the mesh
  32494. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  32495. * @returns the current mesh
  32496. */
  32497. createNormals(updatable: boolean): AbstractMesh;
  32498. /**
  32499. * Align the mesh with a normal
  32500. * @param normal defines the normal to use
  32501. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  32502. * @returns the current mesh
  32503. */
  32504. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  32505. /** @hidden */
  32506. _checkOcclusionQuery(): boolean;
  32507. /**
  32508. * Disables the mesh edge rendering mode
  32509. * @returns the currentAbstractMesh
  32510. */
  32511. disableEdgesRendering(): AbstractMesh;
  32512. /**
  32513. * Enables the edge rendering mode on the mesh.
  32514. * This mode makes the mesh edges visible
  32515. * @param epsilon defines the maximal distance between two angles to detect a face
  32516. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32517. * @returns the currentAbstractMesh
  32518. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32519. */
  32520. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32521. /**
  32522. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  32523. * @returns an array of particle systems in the scene that use the mesh as an emitter
  32524. */
  32525. getConnectedParticleSystems(): IParticleSystem[];
  32526. }
  32527. }
  32528. declare module BABYLON {
  32529. /**
  32530. * Interface used to define ActionEvent
  32531. */
  32532. export interface IActionEvent {
  32533. /** The mesh or sprite that triggered the action */
  32534. source: any;
  32535. /** The X mouse cursor position at the time of the event */
  32536. pointerX: number;
  32537. /** The Y mouse cursor position at the time of the event */
  32538. pointerY: number;
  32539. /** The mesh that is currently pointed at (can be null) */
  32540. meshUnderPointer: Nullable<AbstractMesh>;
  32541. /** the original (browser) event that triggered the ActionEvent */
  32542. sourceEvent?: any;
  32543. /** additional data for the event */
  32544. additionalData?: any;
  32545. }
  32546. /**
  32547. * ActionEvent is the event being sent when an action is triggered.
  32548. */
  32549. export class ActionEvent implements IActionEvent {
  32550. /** The mesh or sprite that triggered the action */
  32551. source: any;
  32552. /** The X mouse cursor position at the time of the event */
  32553. pointerX: number;
  32554. /** The Y mouse cursor position at the time of the event */
  32555. pointerY: number;
  32556. /** The mesh that is currently pointed at (can be null) */
  32557. meshUnderPointer: Nullable<AbstractMesh>;
  32558. /** the original (browser) event that triggered the ActionEvent */
  32559. sourceEvent?: any;
  32560. /** additional data for the event */
  32561. additionalData?: any;
  32562. /**
  32563. * Creates a new ActionEvent
  32564. * @param source The mesh or sprite that triggered the action
  32565. * @param pointerX The X mouse cursor position at the time of the event
  32566. * @param pointerY The Y mouse cursor position at the time of the event
  32567. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  32568. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  32569. * @param additionalData additional data for the event
  32570. */
  32571. constructor(
  32572. /** The mesh or sprite that triggered the action */
  32573. source: any,
  32574. /** The X mouse cursor position at the time of the event */
  32575. pointerX: number,
  32576. /** The Y mouse cursor position at the time of the event */
  32577. pointerY: number,
  32578. /** The mesh that is currently pointed at (can be null) */
  32579. meshUnderPointer: Nullable<AbstractMesh>,
  32580. /** the original (browser) event that triggered the ActionEvent */
  32581. sourceEvent?: any,
  32582. /** additional data for the event */
  32583. additionalData?: any);
  32584. /**
  32585. * Helper function to auto-create an ActionEvent from a source mesh.
  32586. * @param source The source mesh that triggered the event
  32587. * @param evt The original (browser) event
  32588. * @param additionalData additional data for the event
  32589. * @returns the new ActionEvent
  32590. */
  32591. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  32592. /**
  32593. * Helper function to auto-create an ActionEvent from a source sprite
  32594. * @param source The source sprite that triggered the event
  32595. * @param scene Scene associated with the sprite
  32596. * @param evt The original (browser) event
  32597. * @param additionalData additional data for the event
  32598. * @returns the new ActionEvent
  32599. */
  32600. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  32601. /**
  32602. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  32603. * @param scene the scene where the event occurred
  32604. * @param evt The original (browser) event
  32605. * @returns the new ActionEvent
  32606. */
  32607. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  32608. /**
  32609. * Helper function to auto-create an ActionEvent from a primitive
  32610. * @param prim defines the target primitive
  32611. * @param pointerPos defines the pointer position
  32612. * @param evt The original (browser) event
  32613. * @param additionalData additional data for the event
  32614. * @returns the new ActionEvent
  32615. */
  32616. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  32617. }
  32618. }
  32619. declare module BABYLON {
  32620. /**
  32621. * Abstract class used to decouple action Manager from scene and meshes.
  32622. * Do not instantiate.
  32623. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32624. */
  32625. export abstract class AbstractActionManager implements IDisposable {
  32626. /** Gets the list of active triggers */
  32627. static Triggers: {
  32628. [key: string]: number;
  32629. };
  32630. /** Gets the cursor to use when hovering items */
  32631. hoverCursor: string;
  32632. /** Gets the list of actions */
  32633. actions: IAction[];
  32634. /**
  32635. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  32636. */
  32637. isRecursive: boolean;
  32638. /**
  32639. * Releases all associated resources
  32640. */
  32641. abstract dispose(): void;
  32642. /**
  32643. * Does this action manager has pointer triggers
  32644. */
  32645. abstract get hasPointerTriggers(): boolean;
  32646. /**
  32647. * Does this action manager has pick triggers
  32648. */
  32649. abstract get hasPickTriggers(): boolean;
  32650. /**
  32651. * Process a specific trigger
  32652. * @param trigger defines the trigger to process
  32653. * @param evt defines the event details to be processed
  32654. */
  32655. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  32656. /**
  32657. * Does this action manager handles actions of any of the given triggers
  32658. * @param triggers defines the triggers to be tested
  32659. * @return a boolean indicating whether one (or more) of the triggers is handled
  32660. */
  32661. abstract hasSpecificTriggers(triggers: number[]): boolean;
  32662. /**
  32663. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  32664. * speed.
  32665. * @param triggerA defines the trigger to be tested
  32666. * @param triggerB defines the trigger to be tested
  32667. * @return a boolean indicating whether one (or more) of the triggers is handled
  32668. */
  32669. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  32670. /**
  32671. * Does this action manager handles actions of a given trigger
  32672. * @param trigger defines the trigger to be tested
  32673. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  32674. * @return whether the trigger is handled
  32675. */
  32676. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  32677. /**
  32678. * Serialize this manager to a JSON object
  32679. * @param name defines the property name to store this manager
  32680. * @returns a JSON representation of this manager
  32681. */
  32682. abstract serialize(name: string): any;
  32683. /**
  32684. * Registers an action to this action manager
  32685. * @param action defines the action to be registered
  32686. * @return the action amended (prepared) after registration
  32687. */
  32688. abstract registerAction(action: IAction): Nullable<IAction>;
  32689. /**
  32690. * Unregisters an action to this action manager
  32691. * @param action defines the action to be unregistered
  32692. * @return a boolean indicating whether the action has been unregistered
  32693. */
  32694. abstract unregisterAction(action: IAction): Boolean;
  32695. /**
  32696. * Does exist one action manager with at least one trigger
  32697. **/
  32698. static get HasTriggers(): boolean;
  32699. /**
  32700. * Does exist one action manager with at least one pick trigger
  32701. **/
  32702. static get HasPickTriggers(): boolean;
  32703. /**
  32704. * Does exist one action manager that handles actions of a given trigger
  32705. * @param trigger defines the trigger to be tested
  32706. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  32707. **/
  32708. static HasSpecificTrigger(trigger: number): boolean;
  32709. }
  32710. }
  32711. declare module BABYLON {
  32712. /**
  32713. * Defines how a node can be built from a string name.
  32714. */
  32715. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  32716. /**
  32717. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  32718. */
  32719. export class Node implements IBehaviorAware<Node> {
  32720. /** @hidden */
  32721. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  32722. private static _NodeConstructors;
  32723. /**
  32724. * Add a new node constructor
  32725. * @param type defines the type name of the node to construct
  32726. * @param constructorFunc defines the constructor function
  32727. */
  32728. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  32729. /**
  32730. * Returns a node constructor based on type name
  32731. * @param type defines the type name
  32732. * @param name defines the new node name
  32733. * @param scene defines the hosting scene
  32734. * @param options defines optional options to transmit to constructors
  32735. * @returns the new constructor or null
  32736. */
  32737. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  32738. /**
  32739. * Gets or sets the name of the node
  32740. */
  32741. name: string;
  32742. /**
  32743. * Gets or sets the id of the node
  32744. */
  32745. id: string;
  32746. /**
  32747. * Gets or sets the unique id of the node
  32748. */
  32749. uniqueId: number;
  32750. /**
  32751. * Gets or sets a string used to store user defined state for the node
  32752. */
  32753. state: string;
  32754. /**
  32755. * Gets or sets an object used to store user defined information for the node
  32756. */
  32757. metadata: any;
  32758. /**
  32759. * For internal use only. Please do not use.
  32760. */
  32761. reservedDataStore: any;
  32762. /**
  32763. * List of inspectable custom properties (used by the Inspector)
  32764. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  32765. */
  32766. inspectableCustomProperties: IInspectable[];
  32767. private _doNotSerialize;
  32768. /**
  32769. * Gets or sets a boolean used to define if the node must be serialized
  32770. */
  32771. get doNotSerialize(): boolean;
  32772. set doNotSerialize(value: boolean);
  32773. /** @hidden */
  32774. _isDisposed: boolean;
  32775. /**
  32776. * Gets a list of Animations associated with the node
  32777. */
  32778. animations: Animation[];
  32779. protected _ranges: {
  32780. [name: string]: Nullable<AnimationRange>;
  32781. };
  32782. /**
  32783. * Callback raised when the node is ready to be used
  32784. */
  32785. onReady: Nullable<(node: Node) => void>;
  32786. private _isEnabled;
  32787. private _isParentEnabled;
  32788. private _isReady;
  32789. /** @hidden */
  32790. _currentRenderId: number;
  32791. private _parentUpdateId;
  32792. /** @hidden */
  32793. _childUpdateId: number;
  32794. /** @hidden */
  32795. _waitingParentId: Nullable<string>;
  32796. /** @hidden */
  32797. _scene: Scene;
  32798. /** @hidden */
  32799. _cache: any;
  32800. private _parentNode;
  32801. private _children;
  32802. /** @hidden */
  32803. _worldMatrix: Matrix;
  32804. /** @hidden */
  32805. _worldMatrixDeterminant: number;
  32806. /** @hidden */
  32807. _worldMatrixDeterminantIsDirty: boolean;
  32808. /** @hidden */
  32809. private _sceneRootNodesIndex;
  32810. /**
  32811. * Gets a boolean indicating if the node has been disposed
  32812. * @returns true if the node was disposed
  32813. */
  32814. isDisposed(): boolean;
  32815. /**
  32816. * Gets or sets the parent of the node (without keeping the current position in the scene)
  32817. * @see https://doc.babylonjs.com/how_to/parenting
  32818. */
  32819. set parent(parent: Nullable<Node>);
  32820. get parent(): Nullable<Node>;
  32821. /** @hidden */
  32822. _addToSceneRootNodes(): void;
  32823. /** @hidden */
  32824. _removeFromSceneRootNodes(): void;
  32825. private _animationPropertiesOverride;
  32826. /**
  32827. * Gets or sets the animation properties override
  32828. */
  32829. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  32830. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  32831. /**
  32832. * Gets a string idenfifying the name of the class
  32833. * @returns "Node" string
  32834. */
  32835. getClassName(): string;
  32836. /** @hidden */
  32837. readonly _isNode: boolean;
  32838. /**
  32839. * An event triggered when the mesh is disposed
  32840. */
  32841. onDisposeObservable: Observable<Node>;
  32842. private _onDisposeObserver;
  32843. /**
  32844. * Sets a callback that will be raised when the node will be disposed
  32845. */
  32846. set onDispose(callback: () => void);
  32847. /**
  32848. * Creates a new Node
  32849. * @param name the name and id to be given to this node
  32850. * @param scene the scene this node will be added to
  32851. */
  32852. constructor(name: string, scene?: Nullable<Scene>);
  32853. /**
  32854. * Gets the scene of the node
  32855. * @returns a scene
  32856. */
  32857. getScene(): Scene;
  32858. /**
  32859. * Gets the engine of the node
  32860. * @returns a Engine
  32861. */
  32862. getEngine(): Engine;
  32863. private _behaviors;
  32864. /**
  32865. * Attach a behavior to the node
  32866. * @see https://doc.babylonjs.com/features/behaviour
  32867. * @param behavior defines the behavior to attach
  32868. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  32869. * @returns the current Node
  32870. */
  32871. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  32872. /**
  32873. * Remove an attached behavior
  32874. * @see https://doc.babylonjs.com/features/behaviour
  32875. * @param behavior defines the behavior to attach
  32876. * @returns the current Node
  32877. */
  32878. removeBehavior(behavior: Behavior<Node>): Node;
  32879. /**
  32880. * Gets the list of attached behaviors
  32881. * @see https://doc.babylonjs.com/features/behaviour
  32882. */
  32883. get behaviors(): Behavior<Node>[];
  32884. /**
  32885. * Gets an attached behavior by name
  32886. * @param name defines the name of the behavior to look for
  32887. * @see https://doc.babylonjs.com/features/behaviour
  32888. * @returns null if behavior was not found else the requested behavior
  32889. */
  32890. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  32891. /**
  32892. * Returns the latest update of the World matrix
  32893. * @returns a Matrix
  32894. */
  32895. getWorldMatrix(): Matrix;
  32896. /** @hidden */
  32897. _getWorldMatrixDeterminant(): number;
  32898. /**
  32899. * Returns directly the latest state of the mesh World matrix.
  32900. * A Matrix is returned.
  32901. */
  32902. get worldMatrixFromCache(): Matrix;
  32903. /** @hidden */
  32904. _initCache(): void;
  32905. /** @hidden */
  32906. updateCache(force?: boolean): void;
  32907. /** @hidden */
  32908. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32909. /** @hidden */
  32910. _updateCache(ignoreParentClass?: boolean): void;
  32911. /** @hidden */
  32912. _isSynchronized(): boolean;
  32913. /** @hidden */
  32914. _markSyncedWithParent(): void;
  32915. /** @hidden */
  32916. isSynchronizedWithParent(): boolean;
  32917. /** @hidden */
  32918. isSynchronized(): boolean;
  32919. /**
  32920. * Is this node ready to be used/rendered
  32921. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32922. * @return true if the node is ready
  32923. */
  32924. isReady(completeCheck?: boolean): boolean;
  32925. /**
  32926. * Is this node enabled?
  32927. * 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
  32928. * @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
  32929. * @return whether this node (and its parent) is enabled
  32930. */
  32931. isEnabled(checkAncestors?: boolean): boolean;
  32932. /** @hidden */
  32933. protected _syncParentEnabledState(): void;
  32934. /**
  32935. * Set the enabled state of this node
  32936. * @param value defines the new enabled state
  32937. */
  32938. setEnabled(value: boolean): void;
  32939. /**
  32940. * Is this node a descendant of the given node?
  32941. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  32942. * @param ancestor defines the parent node to inspect
  32943. * @returns a boolean indicating if this node is a descendant of the given node
  32944. */
  32945. isDescendantOf(ancestor: Node): boolean;
  32946. /** @hidden */
  32947. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  32948. /**
  32949. * Will return all nodes that have this node as ascendant
  32950. * @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
  32951. * @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
  32952. * @return all children nodes of all types
  32953. */
  32954. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  32955. /**
  32956. * Get all child-meshes of this node
  32957. * @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)
  32958. * @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
  32959. * @returns an array of AbstractMesh
  32960. */
  32961. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  32962. /**
  32963. * Get all direct children of this node
  32964. * @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
  32965. * @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)
  32966. * @returns an array of Node
  32967. */
  32968. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  32969. /** @hidden */
  32970. _setReady(state: boolean): void;
  32971. /**
  32972. * Get an animation by name
  32973. * @param name defines the name of the animation to look for
  32974. * @returns null if not found else the requested animation
  32975. */
  32976. getAnimationByName(name: string): Nullable<Animation>;
  32977. /**
  32978. * Creates an animation range for this node
  32979. * @param name defines the name of the range
  32980. * @param from defines the starting key
  32981. * @param to defines the end key
  32982. */
  32983. createAnimationRange(name: string, from: number, to: number): void;
  32984. /**
  32985. * Delete a specific animation range
  32986. * @param name defines the name of the range to delete
  32987. * @param deleteFrames defines if animation frames from the range must be deleted as well
  32988. */
  32989. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  32990. /**
  32991. * Get an animation range by name
  32992. * @param name defines the name of the animation range to look for
  32993. * @returns null if not found else the requested animation range
  32994. */
  32995. getAnimationRange(name: string): Nullable<AnimationRange>;
  32996. /**
  32997. * Gets the list of all animation ranges defined on this node
  32998. * @returns an array
  32999. */
  33000. getAnimationRanges(): Nullable<AnimationRange>[];
  33001. /**
  33002. * Will start the animation sequence
  33003. * @param name defines the range frames for animation sequence
  33004. * @param loop defines if the animation should loop (false by default)
  33005. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  33006. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  33007. * @returns the object created for this animation. If range does not exist, it will return null
  33008. */
  33009. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  33010. /**
  33011. * Serialize animation ranges into a JSON compatible object
  33012. * @returns serialization object
  33013. */
  33014. serializeAnimationRanges(): any;
  33015. /**
  33016. * Computes the world matrix of the node
  33017. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  33018. * @returns the world matrix
  33019. */
  33020. computeWorldMatrix(force?: boolean): Matrix;
  33021. /**
  33022. * Releases resources associated with this node.
  33023. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33024. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33025. */
  33026. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33027. /**
  33028. * Parse animation range data from a serialization object and store them into a given node
  33029. * @param node defines where to store the animation ranges
  33030. * @param parsedNode defines the serialization object to read data from
  33031. * @param scene defines the hosting scene
  33032. */
  33033. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  33034. /**
  33035. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  33036. * @param includeDescendants Include bounding info from descendants as well (true by default)
  33037. * @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
  33038. * @returns the new bounding vectors
  33039. */
  33040. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  33041. min: Vector3;
  33042. max: Vector3;
  33043. };
  33044. }
  33045. }
  33046. declare module BABYLON {
  33047. /**
  33048. * @hidden
  33049. */
  33050. export class _IAnimationState {
  33051. key: number;
  33052. repeatCount: number;
  33053. workValue?: any;
  33054. loopMode?: number;
  33055. offsetValue?: any;
  33056. highLimitValue?: any;
  33057. }
  33058. /**
  33059. * Class used to store any kind of animation
  33060. */
  33061. export class Animation {
  33062. /**Name of the animation */
  33063. name: string;
  33064. /**Property to animate */
  33065. targetProperty: string;
  33066. /**The frames per second of the animation */
  33067. framePerSecond: number;
  33068. /**The data type of the animation */
  33069. dataType: number;
  33070. /**The loop mode of the animation */
  33071. loopMode?: number | undefined;
  33072. /**Specifies if blending should be enabled */
  33073. enableBlending?: boolean | undefined;
  33074. /**
  33075. * Use matrix interpolation instead of using direct key value when animating matrices
  33076. */
  33077. static AllowMatricesInterpolation: boolean;
  33078. /**
  33079. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  33080. */
  33081. static AllowMatrixDecomposeForInterpolation: boolean;
  33082. /** Define the Url to load snippets */
  33083. static SnippetUrl: string;
  33084. /** Snippet ID if the animation was created from the snippet server */
  33085. snippetId: string;
  33086. /**
  33087. * Stores the key frames of the animation
  33088. */
  33089. private _keys;
  33090. /**
  33091. * Stores the easing function of the animation
  33092. */
  33093. private _easingFunction;
  33094. /**
  33095. * @hidden Internal use only
  33096. */
  33097. _runtimeAnimations: RuntimeAnimation[];
  33098. /**
  33099. * The set of event that will be linked to this animation
  33100. */
  33101. private _events;
  33102. /**
  33103. * Stores an array of target property paths
  33104. */
  33105. targetPropertyPath: string[];
  33106. /**
  33107. * Stores the blending speed of the animation
  33108. */
  33109. blendingSpeed: number;
  33110. /**
  33111. * Stores the animation ranges for the animation
  33112. */
  33113. private _ranges;
  33114. /**
  33115. * @hidden Internal use
  33116. */
  33117. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  33118. /**
  33119. * Sets up an animation
  33120. * @param property The property to animate
  33121. * @param animationType The animation type to apply
  33122. * @param framePerSecond The frames per second of the animation
  33123. * @param easingFunction The easing function used in the animation
  33124. * @returns The created animation
  33125. */
  33126. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  33127. /**
  33128. * Create and start an animation on a node
  33129. * @param name defines the name of the global animation that will be run on all nodes
  33130. * @param node defines the root node where the animation will take place
  33131. * @param targetProperty defines property to animate
  33132. * @param framePerSecond defines the number of frame per second yo use
  33133. * @param totalFrame defines the number of frames in total
  33134. * @param from defines the initial value
  33135. * @param to defines the final value
  33136. * @param loopMode defines which loop mode you want to use (off by default)
  33137. * @param easingFunction defines the easing function to use (linear by default)
  33138. * @param onAnimationEnd defines the callback to call when animation end
  33139. * @returns the animatable created for this animation
  33140. */
  33141. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33142. /**
  33143. * Create and start an animation on a node and its descendants
  33144. * @param name defines the name of the global animation that will be run on all nodes
  33145. * @param node defines the root node where the animation will take place
  33146. * @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
  33147. * @param targetProperty defines property to animate
  33148. * @param framePerSecond defines the number of frame per second to use
  33149. * @param totalFrame defines the number of frames in total
  33150. * @param from defines the initial value
  33151. * @param to defines the final value
  33152. * @param loopMode defines which loop mode you want to use (off by default)
  33153. * @param easingFunction defines the easing function to use (linear by default)
  33154. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33155. * @returns the list of animatables created for all nodes
  33156. * @example https://www.babylonjs-playground.com/#MH0VLI
  33157. */
  33158. 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[]>;
  33159. /**
  33160. * Creates a new animation, merges it with the existing animations and starts it
  33161. * @param name Name of the animation
  33162. * @param node Node which contains the scene that begins the animations
  33163. * @param targetProperty Specifies which property to animate
  33164. * @param framePerSecond The frames per second of the animation
  33165. * @param totalFrame The total number of frames
  33166. * @param from The frame at the beginning of the animation
  33167. * @param to The frame at the end of the animation
  33168. * @param loopMode Specifies the loop mode of the animation
  33169. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  33170. * @param onAnimationEnd Callback to run once the animation is complete
  33171. * @returns Nullable animation
  33172. */
  33173. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33174. /**
  33175. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  33176. * @param sourceAnimation defines the Animation containing keyframes to convert
  33177. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  33178. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  33179. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  33180. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  33181. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  33182. */
  33183. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  33184. /**
  33185. * Transition property of an host to the target Value
  33186. * @param property The property to transition
  33187. * @param targetValue The target Value of the property
  33188. * @param host The object where the property to animate belongs
  33189. * @param scene Scene used to run the animation
  33190. * @param frameRate Framerate (in frame/s) to use
  33191. * @param transition The transition type we want to use
  33192. * @param duration The duration of the animation, in milliseconds
  33193. * @param onAnimationEnd Callback trigger at the end of the animation
  33194. * @returns Nullable animation
  33195. */
  33196. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  33197. /**
  33198. * Return the array of runtime animations currently using this animation
  33199. */
  33200. get runtimeAnimations(): RuntimeAnimation[];
  33201. /**
  33202. * Specifies if any of the runtime animations are currently running
  33203. */
  33204. get hasRunningRuntimeAnimations(): boolean;
  33205. /**
  33206. * Initializes the animation
  33207. * @param name Name of the animation
  33208. * @param targetProperty Property to animate
  33209. * @param framePerSecond The frames per second of the animation
  33210. * @param dataType The data type of the animation
  33211. * @param loopMode The loop mode of the animation
  33212. * @param enableBlending Specifies if blending should be enabled
  33213. */
  33214. constructor(
  33215. /**Name of the animation */
  33216. name: string,
  33217. /**Property to animate */
  33218. targetProperty: string,
  33219. /**The frames per second of the animation */
  33220. framePerSecond: number,
  33221. /**The data type of the animation */
  33222. dataType: number,
  33223. /**The loop mode of the animation */
  33224. loopMode?: number | undefined,
  33225. /**Specifies if blending should be enabled */
  33226. enableBlending?: boolean | undefined);
  33227. /**
  33228. * Converts the animation to a string
  33229. * @param fullDetails support for multiple levels of logging within scene loading
  33230. * @returns String form of the animation
  33231. */
  33232. toString(fullDetails?: boolean): string;
  33233. /**
  33234. * Add an event to this animation
  33235. * @param event Event to add
  33236. */
  33237. addEvent(event: AnimationEvent): void;
  33238. /**
  33239. * Remove all events found at the given frame
  33240. * @param frame The frame to remove events from
  33241. */
  33242. removeEvents(frame: number): void;
  33243. /**
  33244. * Retrieves all the events from the animation
  33245. * @returns Events from the animation
  33246. */
  33247. getEvents(): AnimationEvent[];
  33248. /**
  33249. * Creates an animation range
  33250. * @param name Name of the animation range
  33251. * @param from Starting frame of the animation range
  33252. * @param to Ending frame of the animation
  33253. */
  33254. createRange(name: string, from: number, to: number): void;
  33255. /**
  33256. * Deletes an animation range by name
  33257. * @param name Name of the animation range to delete
  33258. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  33259. */
  33260. deleteRange(name: string, deleteFrames?: boolean): void;
  33261. /**
  33262. * Gets the animation range by name, or null if not defined
  33263. * @param name Name of the animation range
  33264. * @returns Nullable animation range
  33265. */
  33266. getRange(name: string): Nullable<AnimationRange>;
  33267. /**
  33268. * Gets the key frames from the animation
  33269. * @returns The key frames of the animation
  33270. */
  33271. getKeys(): Array<IAnimationKey>;
  33272. /**
  33273. * Gets the highest frame rate of the animation
  33274. * @returns Highest frame rate of the animation
  33275. */
  33276. getHighestFrame(): number;
  33277. /**
  33278. * Gets the easing function of the animation
  33279. * @returns Easing function of the animation
  33280. */
  33281. getEasingFunction(): IEasingFunction;
  33282. /**
  33283. * Sets the easing function of the animation
  33284. * @param easingFunction A custom mathematical formula for animation
  33285. */
  33286. setEasingFunction(easingFunction: EasingFunction): void;
  33287. /**
  33288. * Interpolates a scalar linearly
  33289. * @param startValue Start value of the animation curve
  33290. * @param endValue End value of the animation curve
  33291. * @param gradient Scalar amount to interpolate
  33292. * @returns Interpolated scalar value
  33293. */
  33294. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  33295. /**
  33296. * Interpolates a scalar cubically
  33297. * @param startValue Start value of the animation curve
  33298. * @param outTangent End tangent of the animation
  33299. * @param endValue End value of the animation curve
  33300. * @param inTangent Start tangent of the animation curve
  33301. * @param gradient Scalar amount to interpolate
  33302. * @returns Interpolated scalar value
  33303. */
  33304. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  33305. /**
  33306. * Interpolates a quaternion using a spherical linear interpolation
  33307. * @param startValue Start value of the animation curve
  33308. * @param endValue End value of the animation curve
  33309. * @param gradient Scalar amount to interpolate
  33310. * @returns Interpolated quaternion value
  33311. */
  33312. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  33313. /**
  33314. * Interpolates a quaternion cubically
  33315. * @param startValue Start value of the animation curve
  33316. * @param outTangent End tangent of the animation curve
  33317. * @param endValue End value of the animation curve
  33318. * @param inTangent Start tangent of the animation curve
  33319. * @param gradient Scalar amount to interpolate
  33320. * @returns Interpolated quaternion value
  33321. */
  33322. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  33323. /**
  33324. * Interpolates a Vector3 linearl
  33325. * @param startValue Start value of the animation curve
  33326. * @param endValue End value of the animation curve
  33327. * @param gradient Scalar amount to interpolate
  33328. * @returns Interpolated scalar value
  33329. */
  33330. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  33331. /**
  33332. * Interpolates a Vector3 cubically
  33333. * @param startValue Start value of the animation curve
  33334. * @param outTangent End tangent of the animation
  33335. * @param endValue End value of the animation curve
  33336. * @param inTangent Start tangent of the animation curve
  33337. * @param gradient Scalar amount to interpolate
  33338. * @returns InterpolatedVector3 value
  33339. */
  33340. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  33341. /**
  33342. * Interpolates a Vector2 linearly
  33343. * @param startValue Start value of the animation curve
  33344. * @param endValue End value of the animation curve
  33345. * @param gradient Scalar amount to interpolate
  33346. * @returns Interpolated Vector2 value
  33347. */
  33348. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  33349. /**
  33350. * Interpolates a Vector2 cubically
  33351. * @param startValue Start value of the animation curve
  33352. * @param outTangent End tangent of the animation
  33353. * @param endValue End value of the animation curve
  33354. * @param inTangent Start tangent of the animation curve
  33355. * @param gradient Scalar amount to interpolate
  33356. * @returns Interpolated Vector2 value
  33357. */
  33358. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  33359. /**
  33360. * Interpolates a size linearly
  33361. * @param startValue Start value of the animation curve
  33362. * @param endValue End value of the animation curve
  33363. * @param gradient Scalar amount to interpolate
  33364. * @returns Interpolated Size value
  33365. */
  33366. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  33367. /**
  33368. * Interpolates a Color3 linearly
  33369. * @param startValue Start value of the animation curve
  33370. * @param endValue End value of the animation curve
  33371. * @param gradient Scalar amount to interpolate
  33372. * @returns Interpolated Color3 value
  33373. */
  33374. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  33375. /**
  33376. * Interpolates a Color4 linearly
  33377. * @param startValue Start value of the animation curve
  33378. * @param endValue End value of the animation curve
  33379. * @param gradient Scalar amount to interpolate
  33380. * @returns Interpolated Color3 value
  33381. */
  33382. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  33383. /**
  33384. * @hidden Internal use only
  33385. */
  33386. _getKeyValue(value: any): any;
  33387. /**
  33388. * @hidden Internal use only
  33389. */
  33390. _interpolate(currentFrame: number, state: _IAnimationState): any;
  33391. /**
  33392. * Defines the function to use to interpolate matrices
  33393. * @param startValue defines the start matrix
  33394. * @param endValue defines the end matrix
  33395. * @param gradient defines the gradient between both matrices
  33396. * @param result defines an optional target matrix where to store the interpolation
  33397. * @returns the interpolated matrix
  33398. */
  33399. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  33400. /**
  33401. * Makes a copy of the animation
  33402. * @returns Cloned animation
  33403. */
  33404. clone(): Animation;
  33405. /**
  33406. * Sets the key frames of the animation
  33407. * @param values The animation key frames to set
  33408. */
  33409. setKeys(values: Array<IAnimationKey>): void;
  33410. /**
  33411. * Serializes the animation to an object
  33412. * @returns Serialized object
  33413. */
  33414. serialize(): any;
  33415. /**
  33416. * Float animation type
  33417. */
  33418. static readonly ANIMATIONTYPE_FLOAT: number;
  33419. /**
  33420. * Vector3 animation type
  33421. */
  33422. static readonly ANIMATIONTYPE_VECTOR3: number;
  33423. /**
  33424. * Quaternion animation type
  33425. */
  33426. static readonly ANIMATIONTYPE_QUATERNION: number;
  33427. /**
  33428. * Matrix animation type
  33429. */
  33430. static readonly ANIMATIONTYPE_MATRIX: number;
  33431. /**
  33432. * Color3 animation type
  33433. */
  33434. static readonly ANIMATIONTYPE_COLOR3: number;
  33435. /**
  33436. * Color3 animation type
  33437. */
  33438. static readonly ANIMATIONTYPE_COLOR4: number;
  33439. /**
  33440. * Vector2 animation type
  33441. */
  33442. static readonly ANIMATIONTYPE_VECTOR2: number;
  33443. /**
  33444. * Size animation type
  33445. */
  33446. static readonly ANIMATIONTYPE_SIZE: number;
  33447. /**
  33448. * Relative Loop Mode
  33449. */
  33450. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  33451. /**
  33452. * Cycle Loop Mode
  33453. */
  33454. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  33455. /**
  33456. * Constant Loop Mode
  33457. */
  33458. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  33459. /** @hidden */
  33460. static _UniversalLerp(left: any, right: any, amount: number): any;
  33461. /**
  33462. * Parses an animation object and creates an animation
  33463. * @param parsedAnimation Parsed animation object
  33464. * @returns Animation object
  33465. */
  33466. static Parse(parsedAnimation: any): Animation;
  33467. /**
  33468. * Appends the serialized animations from the source animations
  33469. * @param source Source containing the animations
  33470. * @param destination Target to store the animations
  33471. */
  33472. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33473. /**
  33474. * Creates a new animation or an array of animations from a snippet saved in a remote file
  33475. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  33476. * @param url defines the url to load from
  33477. * @returns a promise that will resolve to the new animation or an array of animations
  33478. */
  33479. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  33480. /**
  33481. * Creates an animation or an array of animations from a snippet saved by the Inspector
  33482. * @param snippetId defines the snippet to load
  33483. * @returns a promise that will resolve to the new animation or a new array of animations
  33484. */
  33485. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  33486. }
  33487. }
  33488. declare module BABYLON {
  33489. /**
  33490. * Interface containing an array of animations
  33491. */
  33492. export interface IAnimatable {
  33493. /**
  33494. * Array of animations
  33495. */
  33496. animations: Nullable<Array<Animation>>;
  33497. }
  33498. }
  33499. declare module BABYLON {
  33500. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  33501. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33502. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33503. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33504. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33505. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33506. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33507. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33508. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33509. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33510. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33511. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33512. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33513. /**
  33514. * Decorator used to define property that can be serialized as reference to a camera
  33515. * @param sourceName defines the name of the property to decorate
  33516. */
  33517. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33518. /**
  33519. * Class used to help serialization objects
  33520. */
  33521. export class SerializationHelper {
  33522. /** @hidden */
  33523. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  33524. /** @hidden */
  33525. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  33526. /** @hidden */
  33527. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  33528. /** @hidden */
  33529. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  33530. /**
  33531. * Appends the serialized animations from the source animations
  33532. * @param source Source containing the animations
  33533. * @param destination Target to store the animations
  33534. */
  33535. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33536. /**
  33537. * Static function used to serialized a specific entity
  33538. * @param entity defines the entity to serialize
  33539. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  33540. * @returns a JSON compatible object representing the serialization of the entity
  33541. */
  33542. static Serialize<T>(entity: T, serializationObject?: any): any;
  33543. /**
  33544. * Creates a new entity from a serialization data object
  33545. * @param creationFunction defines a function used to instanciated the new entity
  33546. * @param source defines the source serialization data
  33547. * @param scene defines the hosting scene
  33548. * @param rootUrl defines the root url for resources
  33549. * @returns a new entity
  33550. */
  33551. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  33552. /**
  33553. * Clones an object
  33554. * @param creationFunction defines the function used to instanciate the new object
  33555. * @param source defines the source object
  33556. * @returns the cloned object
  33557. */
  33558. static Clone<T>(creationFunction: () => T, source: T): T;
  33559. /**
  33560. * Instanciates a new object based on a source one (some data will be shared between both object)
  33561. * @param creationFunction defines the function used to instanciate the new object
  33562. * @param source defines the source object
  33563. * @returns the new object
  33564. */
  33565. static Instanciate<T>(creationFunction: () => T, source: T): T;
  33566. }
  33567. }
  33568. declare module BABYLON {
  33569. /**
  33570. * Base class of all the textures in babylon.
  33571. * It groups all the common properties the materials, post process, lights... might need
  33572. * in order to make a correct use of the texture.
  33573. */
  33574. export class BaseTexture implements IAnimatable {
  33575. /**
  33576. * Default anisotropic filtering level for the application.
  33577. * It is set to 4 as a good tradeoff between perf and quality.
  33578. */
  33579. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  33580. /**
  33581. * Gets or sets the unique id of the texture
  33582. */
  33583. uniqueId: number;
  33584. /**
  33585. * Define the name of the texture.
  33586. */
  33587. name: string;
  33588. /**
  33589. * Gets or sets an object used to store user defined information.
  33590. */
  33591. metadata: any;
  33592. /**
  33593. * For internal use only. Please do not use.
  33594. */
  33595. reservedDataStore: any;
  33596. private _hasAlpha;
  33597. /**
  33598. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  33599. */
  33600. set hasAlpha(value: boolean);
  33601. get hasAlpha(): boolean;
  33602. /**
  33603. * Defines if the alpha value should be determined via the rgb values.
  33604. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  33605. */
  33606. getAlphaFromRGB: boolean;
  33607. /**
  33608. * Intensity or strength of the texture.
  33609. * It is commonly used by materials to fine tune the intensity of the texture
  33610. */
  33611. level: number;
  33612. /**
  33613. * Define the UV chanel to use starting from 0 and defaulting to 0.
  33614. * This is part of the texture as textures usually maps to one uv set.
  33615. */
  33616. coordinatesIndex: number;
  33617. private _coordinatesMode;
  33618. /**
  33619. * How a texture is mapped.
  33620. *
  33621. * | Value | Type | Description |
  33622. * | ----- | ----------------------------------- | ----------- |
  33623. * | 0 | EXPLICIT_MODE | |
  33624. * | 1 | SPHERICAL_MODE | |
  33625. * | 2 | PLANAR_MODE | |
  33626. * | 3 | CUBIC_MODE | |
  33627. * | 4 | PROJECTION_MODE | |
  33628. * | 5 | SKYBOX_MODE | |
  33629. * | 6 | INVCUBIC_MODE | |
  33630. * | 7 | EQUIRECTANGULAR_MODE | |
  33631. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  33632. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  33633. */
  33634. set coordinatesMode(value: number);
  33635. get coordinatesMode(): number;
  33636. /**
  33637. * | Value | Type | Description |
  33638. * | ----- | ------------------ | ----------- |
  33639. * | 0 | CLAMP_ADDRESSMODE | |
  33640. * | 1 | WRAP_ADDRESSMODE | |
  33641. * | 2 | MIRROR_ADDRESSMODE | |
  33642. */
  33643. wrapU: number;
  33644. /**
  33645. * | Value | Type | Description |
  33646. * | ----- | ------------------ | ----------- |
  33647. * | 0 | CLAMP_ADDRESSMODE | |
  33648. * | 1 | WRAP_ADDRESSMODE | |
  33649. * | 2 | MIRROR_ADDRESSMODE | |
  33650. */
  33651. wrapV: number;
  33652. /**
  33653. * | Value | Type | Description |
  33654. * | ----- | ------------------ | ----------- |
  33655. * | 0 | CLAMP_ADDRESSMODE | |
  33656. * | 1 | WRAP_ADDRESSMODE | |
  33657. * | 2 | MIRROR_ADDRESSMODE | |
  33658. */
  33659. wrapR: number;
  33660. /**
  33661. * With compliant hardware and browser (supporting anisotropic filtering)
  33662. * this defines the level of anisotropic filtering in the texture.
  33663. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  33664. */
  33665. anisotropicFilteringLevel: number;
  33666. /**
  33667. * Define if the texture is a cube texture or if false a 2d texture.
  33668. */
  33669. get isCube(): boolean;
  33670. set isCube(value: boolean);
  33671. /**
  33672. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  33673. */
  33674. get is3D(): boolean;
  33675. set is3D(value: boolean);
  33676. /**
  33677. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  33678. */
  33679. get is2DArray(): boolean;
  33680. set is2DArray(value: boolean);
  33681. /**
  33682. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  33683. * HDR texture are usually stored in linear space.
  33684. * This only impacts the PBR and Background materials
  33685. */
  33686. gammaSpace: boolean;
  33687. /**
  33688. * Gets or sets whether or not the texture contains RGBD data.
  33689. */
  33690. get isRGBD(): boolean;
  33691. set isRGBD(value: boolean);
  33692. /**
  33693. * Is Z inverted in the texture (useful in a cube texture).
  33694. */
  33695. invertZ: boolean;
  33696. /**
  33697. * Are mip maps generated for this texture or not.
  33698. */
  33699. get noMipmap(): boolean;
  33700. /**
  33701. * @hidden
  33702. */
  33703. lodLevelInAlpha: boolean;
  33704. /**
  33705. * With prefiltered texture, defined the offset used during the prefiltering steps.
  33706. */
  33707. get lodGenerationOffset(): number;
  33708. set lodGenerationOffset(value: number);
  33709. /**
  33710. * With prefiltered texture, defined the scale used during the prefiltering steps.
  33711. */
  33712. get lodGenerationScale(): number;
  33713. set lodGenerationScale(value: number);
  33714. /**
  33715. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  33716. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  33717. * average roughness values.
  33718. */
  33719. get linearSpecularLOD(): boolean;
  33720. set linearSpecularLOD(value: boolean);
  33721. /**
  33722. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  33723. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  33724. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  33725. */
  33726. get irradianceTexture(): Nullable<BaseTexture>;
  33727. set irradianceTexture(value: Nullable<BaseTexture>);
  33728. /**
  33729. * Define if the texture is a render target.
  33730. */
  33731. isRenderTarget: boolean;
  33732. /**
  33733. * Define the unique id of the texture in the scene.
  33734. */
  33735. get uid(): string;
  33736. /** @hidden */
  33737. _prefiltered: boolean;
  33738. /**
  33739. * Return a string representation of the texture.
  33740. * @returns the texture as a string
  33741. */
  33742. toString(): string;
  33743. /**
  33744. * Get the class name of the texture.
  33745. * @returns "BaseTexture"
  33746. */
  33747. getClassName(): string;
  33748. /**
  33749. * Define the list of animation attached to the texture.
  33750. */
  33751. animations: Animation[];
  33752. /**
  33753. * An event triggered when the texture is disposed.
  33754. */
  33755. onDisposeObservable: Observable<BaseTexture>;
  33756. private _onDisposeObserver;
  33757. /**
  33758. * Callback triggered when the texture has been disposed.
  33759. * Kept for back compatibility, you can use the onDisposeObservable instead.
  33760. */
  33761. set onDispose(callback: () => void);
  33762. /**
  33763. * Define the current state of the loading sequence when in delayed load mode.
  33764. */
  33765. delayLoadState: number;
  33766. private _scene;
  33767. private _engine;
  33768. /** @hidden */
  33769. _texture: Nullable<InternalTexture>;
  33770. private _uid;
  33771. /**
  33772. * Define if the texture is preventinga material to render or not.
  33773. * If not and the texture is not ready, the engine will use a default black texture instead.
  33774. */
  33775. get isBlocking(): boolean;
  33776. /**
  33777. * Instantiates a new BaseTexture.
  33778. * Base class of all the textures in babylon.
  33779. * It groups all the common properties the materials, post process, lights... might need
  33780. * in order to make a correct use of the texture.
  33781. * @param sceneOrEngine Define the scene or engine the texture blongs to
  33782. */
  33783. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  33784. /**
  33785. * Get the scene the texture belongs to.
  33786. * @returns the scene or null if undefined
  33787. */
  33788. getScene(): Nullable<Scene>;
  33789. /** @hidden */
  33790. protected _getEngine(): Nullable<ThinEngine>;
  33791. /**
  33792. * Get the texture transform matrix used to offset tile the texture for istance.
  33793. * @returns the transformation matrix
  33794. */
  33795. getTextureMatrix(): Matrix;
  33796. /**
  33797. * Get the texture reflection matrix used to rotate/transform the reflection.
  33798. * @returns the reflection matrix
  33799. */
  33800. getReflectionTextureMatrix(): Matrix;
  33801. /**
  33802. * Get the underlying lower level texture from Babylon.
  33803. * @returns the insternal texture
  33804. */
  33805. getInternalTexture(): Nullable<InternalTexture>;
  33806. /**
  33807. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  33808. * @returns true if ready or not blocking
  33809. */
  33810. isReadyOrNotBlocking(): boolean;
  33811. /**
  33812. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  33813. * @returns true if fully ready
  33814. */
  33815. isReady(): boolean;
  33816. private _cachedSize;
  33817. /**
  33818. * Get the size of the texture.
  33819. * @returns the texture size.
  33820. */
  33821. getSize(): ISize;
  33822. /**
  33823. * Get the base size of the texture.
  33824. * It can be different from the size if the texture has been resized for POT for instance
  33825. * @returns the base size
  33826. */
  33827. getBaseSize(): ISize;
  33828. /**
  33829. * Update the sampling mode of the texture.
  33830. * Default is Trilinear mode.
  33831. *
  33832. * | Value | Type | Description |
  33833. * | ----- | ------------------ | ----------- |
  33834. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  33835. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  33836. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  33837. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  33838. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  33839. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  33840. * | 7 | NEAREST_LINEAR | |
  33841. * | 8 | NEAREST_NEAREST | |
  33842. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  33843. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  33844. * | 11 | LINEAR_LINEAR | |
  33845. * | 12 | LINEAR_NEAREST | |
  33846. *
  33847. * > _mag_: magnification filter (close to the viewer)
  33848. * > _min_: minification filter (far from the viewer)
  33849. * > _mip_: filter used between mip map levels
  33850. *@param samplingMode Define the new sampling mode of the texture
  33851. */
  33852. updateSamplingMode(samplingMode: number): void;
  33853. /**
  33854. * Scales the texture if is `canRescale()`
  33855. * @param ratio the resize factor we want to use to rescale
  33856. */
  33857. scale(ratio: number): void;
  33858. /**
  33859. * Get if the texture can rescale.
  33860. */
  33861. get canRescale(): boolean;
  33862. /** @hidden */
  33863. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  33864. /** @hidden */
  33865. _rebuild(): void;
  33866. /**
  33867. * Triggers the load sequence in delayed load mode.
  33868. */
  33869. delayLoad(): void;
  33870. /**
  33871. * Clones the texture.
  33872. * @returns the cloned texture
  33873. */
  33874. clone(): Nullable<BaseTexture>;
  33875. /**
  33876. * Get the texture underlying type (INT, FLOAT...)
  33877. */
  33878. get textureType(): number;
  33879. /**
  33880. * Get the texture underlying format (RGB, RGBA...)
  33881. */
  33882. get textureFormat(): number;
  33883. /**
  33884. * Indicates that textures need to be re-calculated for all materials
  33885. */
  33886. protected _markAllSubMeshesAsTexturesDirty(): void;
  33887. /**
  33888. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  33889. * This will returns an RGBA array buffer containing either in values (0-255) or
  33890. * float values (0-1) depending of the underlying buffer type.
  33891. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  33892. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  33893. * @param buffer defines a user defined buffer to fill with data (can be null)
  33894. * @returns The Array buffer containing the pixels data.
  33895. */
  33896. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  33897. /**
  33898. * Release and destroy the underlying lower level texture aka internalTexture.
  33899. */
  33900. releaseInternalTexture(): void;
  33901. /** @hidden */
  33902. get _lodTextureHigh(): Nullable<BaseTexture>;
  33903. /** @hidden */
  33904. get _lodTextureMid(): Nullable<BaseTexture>;
  33905. /** @hidden */
  33906. get _lodTextureLow(): Nullable<BaseTexture>;
  33907. /**
  33908. * Dispose the texture and release its associated resources.
  33909. */
  33910. dispose(): void;
  33911. /**
  33912. * Serialize the texture into a JSON representation that can be parsed later on.
  33913. * @returns the JSON representation of the texture
  33914. */
  33915. serialize(): any;
  33916. /**
  33917. * Helper function to be called back once a list of texture contains only ready textures.
  33918. * @param textures Define the list of textures to wait for
  33919. * @param callback Define the callback triggered once the entire list will be ready
  33920. */
  33921. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  33922. private static _isScene;
  33923. }
  33924. }
  33925. declare module BABYLON {
  33926. /**
  33927. * Options to be used when creating an effect.
  33928. */
  33929. export interface IEffectCreationOptions {
  33930. /**
  33931. * Atrributes that will be used in the shader.
  33932. */
  33933. attributes: string[];
  33934. /**
  33935. * Uniform varible names that will be set in the shader.
  33936. */
  33937. uniformsNames: string[];
  33938. /**
  33939. * Uniform buffer variable names that will be set in the shader.
  33940. */
  33941. uniformBuffersNames: string[];
  33942. /**
  33943. * Sampler texture variable names that will be set in the shader.
  33944. */
  33945. samplers: string[];
  33946. /**
  33947. * Define statements that will be set in the shader.
  33948. */
  33949. defines: any;
  33950. /**
  33951. * Possible fallbacks for this effect to improve performance when needed.
  33952. */
  33953. fallbacks: Nullable<IEffectFallbacks>;
  33954. /**
  33955. * Callback that will be called when the shader is compiled.
  33956. */
  33957. onCompiled: Nullable<(effect: Effect) => void>;
  33958. /**
  33959. * Callback that will be called if an error occurs during shader compilation.
  33960. */
  33961. onError: Nullable<(effect: Effect, errors: string) => void>;
  33962. /**
  33963. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33964. */
  33965. indexParameters?: any;
  33966. /**
  33967. * Max number of lights that can be used in the shader.
  33968. */
  33969. maxSimultaneousLights?: number;
  33970. /**
  33971. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  33972. */
  33973. transformFeedbackVaryings?: Nullable<string[]>;
  33974. /**
  33975. * 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
  33976. */
  33977. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  33978. /**
  33979. * Is this effect rendering to several color attachments ?
  33980. */
  33981. multiTarget?: boolean;
  33982. }
  33983. /**
  33984. * Effect containing vertex and fragment shader that can be executed on an object.
  33985. */
  33986. export class Effect implements IDisposable {
  33987. /**
  33988. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  33989. */
  33990. static ShadersRepository: string;
  33991. /**
  33992. * Enable logging of the shader code when a compilation error occurs
  33993. */
  33994. static LogShaderCodeOnCompilationError: boolean;
  33995. /**
  33996. * Name of the effect.
  33997. */
  33998. name: any;
  33999. /**
  34000. * String container all the define statements that should be set on the shader.
  34001. */
  34002. defines: string;
  34003. /**
  34004. * Callback that will be called when the shader is compiled.
  34005. */
  34006. onCompiled: Nullable<(effect: Effect) => void>;
  34007. /**
  34008. * Callback that will be called if an error occurs during shader compilation.
  34009. */
  34010. onError: Nullable<(effect: Effect, errors: string) => void>;
  34011. /**
  34012. * Callback that will be called when effect is bound.
  34013. */
  34014. onBind: Nullable<(effect: Effect) => void>;
  34015. /**
  34016. * Unique ID of the effect.
  34017. */
  34018. uniqueId: number;
  34019. /**
  34020. * Observable that will be called when the shader is compiled.
  34021. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  34022. */
  34023. onCompileObservable: Observable<Effect>;
  34024. /**
  34025. * Observable that will be called if an error occurs during shader compilation.
  34026. */
  34027. onErrorObservable: Observable<Effect>;
  34028. /** @hidden */
  34029. _onBindObservable: Nullable<Observable<Effect>>;
  34030. /**
  34031. * @hidden
  34032. * Specifies if the effect was previously ready
  34033. */
  34034. _wasPreviouslyReady: boolean;
  34035. /**
  34036. * Observable that will be called when effect is bound.
  34037. */
  34038. get onBindObservable(): Observable<Effect>;
  34039. /** @hidden */
  34040. _bonesComputationForcedToCPU: boolean;
  34041. /** @hidden */
  34042. _multiTarget: boolean;
  34043. private static _uniqueIdSeed;
  34044. private _engine;
  34045. private _uniformBuffersNames;
  34046. private _uniformBuffersNamesList;
  34047. private _uniformsNames;
  34048. private _samplerList;
  34049. private _samplers;
  34050. private _isReady;
  34051. private _compilationError;
  34052. private _allFallbacksProcessed;
  34053. private _attributesNames;
  34054. private _attributes;
  34055. private _attributeLocationByName;
  34056. private _uniforms;
  34057. /**
  34058. * Key for the effect.
  34059. * @hidden
  34060. */
  34061. _key: string;
  34062. private _indexParameters;
  34063. private _fallbacks;
  34064. private _vertexSourceCode;
  34065. private _fragmentSourceCode;
  34066. private _vertexSourceCodeOverride;
  34067. private _fragmentSourceCodeOverride;
  34068. private _transformFeedbackVaryings;
  34069. /**
  34070. * Compiled shader to webGL program.
  34071. * @hidden
  34072. */
  34073. _pipelineContext: Nullable<IPipelineContext>;
  34074. private _valueCache;
  34075. private static _baseCache;
  34076. /**
  34077. * Instantiates an effect.
  34078. * An effect can be used to create/manage/execute vertex and fragment shaders.
  34079. * @param baseName Name of the effect.
  34080. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  34081. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  34082. * @param samplers List of sampler variables that will be passed to the shader.
  34083. * @param engine Engine to be used to render the effect
  34084. * @param defines Define statements to be added to the shader.
  34085. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  34086. * @param onCompiled Callback that will be called when the shader is compiled.
  34087. * @param onError Callback that will be called if an error occurs during shader compilation.
  34088. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34089. */
  34090. 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);
  34091. private _useFinalCode;
  34092. /**
  34093. * Unique key for this effect
  34094. */
  34095. get key(): string;
  34096. /**
  34097. * If the effect has been compiled and prepared.
  34098. * @returns if the effect is compiled and prepared.
  34099. */
  34100. isReady(): boolean;
  34101. private _isReadyInternal;
  34102. /**
  34103. * The engine the effect was initialized with.
  34104. * @returns the engine.
  34105. */
  34106. getEngine(): Engine;
  34107. /**
  34108. * The pipeline context for this effect
  34109. * @returns the associated pipeline context
  34110. */
  34111. getPipelineContext(): Nullable<IPipelineContext>;
  34112. /**
  34113. * The set of names of attribute variables for the shader.
  34114. * @returns An array of attribute names.
  34115. */
  34116. getAttributesNames(): string[];
  34117. /**
  34118. * Returns the attribute at the given index.
  34119. * @param index The index of the attribute.
  34120. * @returns The location of the attribute.
  34121. */
  34122. getAttributeLocation(index: number): number;
  34123. /**
  34124. * Returns the attribute based on the name of the variable.
  34125. * @param name of the attribute to look up.
  34126. * @returns the attribute location.
  34127. */
  34128. getAttributeLocationByName(name: string): number;
  34129. /**
  34130. * The number of attributes.
  34131. * @returns the numnber of attributes.
  34132. */
  34133. getAttributesCount(): number;
  34134. /**
  34135. * Gets the index of a uniform variable.
  34136. * @param uniformName of the uniform to look up.
  34137. * @returns the index.
  34138. */
  34139. getUniformIndex(uniformName: string): number;
  34140. /**
  34141. * Returns the attribute based on the name of the variable.
  34142. * @param uniformName of the uniform to look up.
  34143. * @returns the location of the uniform.
  34144. */
  34145. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  34146. /**
  34147. * Returns an array of sampler variable names
  34148. * @returns The array of sampler variable names.
  34149. */
  34150. getSamplers(): string[];
  34151. /**
  34152. * Returns an array of uniform variable names
  34153. * @returns The array of uniform variable names.
  34154. */
  34155. getUniformNames(): string[];
  34156. /**
  34157. * Returns an array of uniform buffer variable names
  34158. * @returns The array of uniform buffer variable names.
  34159. */
  34160. getUniformBuffersNames(): string[];
  34161. /**
  34162. * Returns the index parameters used to create the effect
  34163. * @returns The index parameters object
  34164. */
  34165. getIndexParameters(): any;
  34166. /**
  34167. * The error from the last compilation.
  34168. * @returns the error string.
  34169. */
  34170. getCompilationError(): string;
  34171. /**
  34172. * Gets a boolean indicating that all fallbacks were used during compilation
  34173. * @returns true if all fallbacks were used
  34174. */
  34175. allFallbacksProcessed(): boolean;
  34176. /**
  34177. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  34178. * @param func The callback to be used.
  34179. */
  34180. executeWhenCompiled(func: (effect: Effect) => void): void;
  34181. private _checkIsReady;
  34182. private _loadShader;
  34183. /**
  34184. * Gets the vertex shader source code of this effect
  34185. */
  34186. get vertexSourceCode(): string;
  34187. /**
  34188. * Gets the fragment shader source code of this effect
  34189. */
  34190. get fragmentSourceCode(): string;
  34191. /**
  34192. * Recompiles the webGL program
  34193. * @param vertexSourceCode The source code for the vertex shader.
  34194. * @param fragmentSourceCode The source code for the fragment shader.
  34195. * @param onCompiled Callback called when completed.
  34196. * @param onError Callback called on error.
  34197. * @hidden
  34198. */
  34199. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  34200. /**
  34201. * Prepares the effect
  34202. * @hidden
  34203. */
  34204. _prepareEffect(): void;
  34205. private _getShaderCodeAndErrorLine;
  34206. private _processCompilationErrors;
  34207. /**
  34208. * Checks if the effect is supported. (Must be called after compilation)
  34209. */
  34210. get isSupported(): boolean;
  34211. /**
  34212. * Binds a texture to the engine to be used as output of the shader.
  34213. * @param channel Name of the output variable.
  34214. * @param texture Texture to bind.
  34215. * @hidden
  34216. */
  34217. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  34218. /**
  34219. * Sets a texture on the engine to be used in the shader.
  34220. * @param channel Name of the sampler variable.
  34221. * @param texture Texture to set.
  34222. */
  34223. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  34224. /**
  34225. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  34226. * @param channel Name of the sampler variable.
  34227. * @param texture Texture to set.
  34228. */
  34229. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  34230. /**
  34231. * Sets an array of textures on the engine to be used in the shader.
  34232. * @param channel Name of the variable.
  34233. * @param textures Textures to set.
  34234. */
  34235. setTextureArray(channel: string, textures: BaseTexture[]): void;
  34236. /**
  34237. * 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)
  34238. * @param channel Name of the sampler variable.
  34239. * @param postProcess Post process to get the input texture from.
  34240. */
  34241. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  34242. /**
  34243. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  34244. * 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)
  34245. * @param channel Name of the sampler variable.
  34246. * @param postProcess Post process to get the output texture from.
  34247. */
  34248. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  34249. /** @hidden */
  34250. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  34251. /** @hidden */
  34252. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  34253. /** @hidden */
  34254. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  34255. /** @hidden */
  34256. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  34257. /**
  34258. * Binds a buffer to a uniform.
  34259. * @param buffer Buffer to bind.
  34260. * @param name Name of the uniform variable to bind to.
  34261. */
  34262. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  34263. /**
  34264. * Binds block to a uniform.
  34265. * @param blockName Name of the block to bind.
  34266. * @param index Index to bind.
  34267. */
  34268. bindUniformBlock(blockName: string, index: number): void;
  34269. /**
  34270. * Sets an interger value on a uniform variable.
  34271. * @param uniformName Name of the variable.
  34272. * @param value Value to be set.
  34273. * @returns this effect.
  34274. */
  34275. setInt(uniformName: string, value: number): Effect;
  34276. /**
  34277. * Sets an int array on a uniform variable.
  34278. * @param uniformName Name of the variable.
  34279. * @param array array to be set.
  34280. * @returns this effect.
  34281. */
  34282. setIntArray(uniformName: string, array: Int32Array): Effect;
  34283. /**
  34284. * 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)
  34285. * @param uniformName Name of the variable.
  34286. * @param array array to be set.
  34287. * @returns this effect.
  34288. */
  34289. setIntArray2(uniformName: string, array: Int32Array): Effect;
  34290. /**
  34291. * 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)
  34292. * @param uniformName Name of the variable.
  34293. * @param array array to be set.
  34294. * @returns this effect.
  34295. */
  34296. setIntArray3(uniformName: string, array: Int32Array): Effect;
  34297. /**
  34298. * 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)
  34299. * @param uniformName Name of the variable.
  34300. * @param array array to be set.
  34301. * @returns this effect.
  34302. */
  34303. setIntArray4(uniformName: string, array: Int32Array): Effect;
  34304. /**
  34305. * Sets an float array on a uniform variable.
  34306. * @param uniformName Name of the variable.
  34307. * @param array array to be set.
  34308. * @returns this effect.
  34309. */
  34310. setFloatArray(uniformName: string, array: Float32Array): Effect;
  34311. /**
  34312. * 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)
  34313. * @param uniformName Name of the variable.
  34314. * @param array array to be set.
  34315. * @returns this effect.
  34316. */
  34317. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  34318. /**
  34319. * 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)
  34320. * @param uniformName Name of the variable.
  34321. * @param array array to be set.
  34322. * @returns this effect.
  34323. */
  34324. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  34325. /**
  34326. * 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)
  34327. * @param uniformName Name of the variable.
  34328. * @param array array to be set.
  34329. * @returns this effect.
  34330. */
  34331. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  34332. /**
  34333. * Sets an array on a uniform variable.
  34334. * @param uniformName Name of the variable.
  34335. * @param array array to be set.
  34336. * @returns this effect.
  34337. */
  34338. setArray(uniformName: string, array: number[]): Effect;
  34339. /**
  34340. * 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)
  34341. * @param uniformName Name of the variable.
  34342. * @param array array to be set.
  34343. * @returns this effect.
  34344. */
  34345. setArray2(uniformName: string, array: number[]): Effect;
  34346. /**
  34347. * 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)
  34348. * @param uniformName Name of the variable.
  34349. * @param array array to be set.
  34350. * @returns this effect.
  34351. */
  34352. setArray3(uniformName: string, array: number[]): Effect;
  34353. /**
  34354. * 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)
  34355. * @param uniformName Name of the variable.
  34356. * @param array array to be set.
  34357. * @returns this effect.
  34358. */
  34359. setArray4(uniformName: string, array: number[]): Effect;
  34360. /**
  34361. * Sets matrices on a uniform variable.
  34362. * @param uniformName Name of the variable.
  34363. * @param matrices matrices to be set.
  34364. * @returns this effect.
  34365. */
  34366. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  34367. /**
  34368. * Sets matrix on a uniform variable.
  34369. * @param uniformName Name of the variable.
  34370. * @param matrix matrix to be set.
  34371. * @returns this effect.
  34372. */
  34373. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  34374. /**
  34375. * 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)
  34376. * @param uniformName Name of the variable.
  34377. * @param matrix matrix to be set.
  34378. * @returns this effect.
  34379. */
  34380. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34381. /**
  34382. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  34383. * @param uniformName Name of the variable.
  34384. * @param matrix matrix to be set.
  34385. * @returns this effect.
  34386. */
  34387. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34388. /**
  34389. * Sets a float on a uniform variable.
  34390. * @param uniformName Name of the variable.
  34391. * @param value value to be set.
  34392. * @returns this effect.
  34393. */
  34394. setFloat(uniformName: string, value: number): Effect;
  34395. /**
  34396. * Sets a boolean on a uniform variable.
  34397. * @param uniformName Name of the variable.
  34398. * @param bool value to be set.
  34399. * @returns this effect.
  34400. */
  34401. setBool(uniformName: string, bool: boolean): Effect;
  34402. /**
  34403. * Sets a Vector2 on a uniform variable.
  34404. * @param uniformName Name of the variable.
  34405. * @param vector2 vector2 to be set.
  34406. * @returns this effect.
  34407. */
  34408. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  34409. /**
  34410. * Sets a float2 on a uniform variable.
  34411. * @param uniformName Name of the variable.
  34412. * @param x First float in float2.
  34413. * @param y Second float in float2.
  34414. * @returns this effect.
  34415. */
  34416. setFloat2(uniformName: string, x: number, y: number): Effect;
  34417. /**
  34418. * Sets a Vector3 on a uniform variable.
  34419. * @param uniformName Name of the variable.
  34420. * @param vector3 Value to be set.
  34421. * @returns this effect.
  34422. */
  34423. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  34424. /**
  34425. * Sets a float3 on a uniform variable.
  34426. * @param uniformName Name of the variable.
  34427. * @param x First float in float3.
  34428. * @param y Second float in float3.
  34429. * @param z Third float in float3.
  34430. * @returns this effect.
  34431. */
  34432. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  34433. /**
  34434. * Sets a Vector4 on a uniform variable.
  34435. * @param uniformName Name of the variable.
  34436. * @param vector4 Value to be set.
  34437. * @returns this effect.
  34438. */
  34439. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  34440. /**
  34441. * Sets a float4 on a uniform variable.
  34442. * @param uniformName Name of the variable.
  34443. * @param x First float in float4.
  34444. * @param y Second float in float4.
  34445. * @param z Third float in float4.
  34446. * @param w Fourth float in float4.
  34447. * @returns this effect.
  34448. */
  34449. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  34450. /**
  34451. * Sets a Color3 on a uniform variable.
  34452. * @param uniformName Name of the variable.
  34453. * @param color3 Value to be set.
  34454. * @returns this effect.
  34455. */
  34456. setColor3(uniformName: string, color3: IColor3Like): Effect;
  34457. /**
  34458. * Sets a Color4 on a uniform variable.
  34459. * @param uniformName Name of the variable.
  34460. * @param color3 Value to be set.
  34461. * @param alpha Alpha value to be set.
  34462. * @returns this effect.
  34463. */
  34464. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  34465. /**
  34466. * Sets a Color4 on a uniform variable
  34467. * @param uniformName defines the name of the variable
  34468. * @param color4 defines the value to be set
  34469. * @returns this effect.
  34470. */
  34471. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  34472. /** Release all associated resources */
  34473. dispose(): void;
  34474. /**
  34475. * This function will add a new shader to the shader store
  34476. * @param name the name of the shader
  34477. * @param pixelShader optional pixel shader content
  34478. * @param vertexShader optional vertex shader content
  34479. */
  34480. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  34481. /**
  34482. * Store of each shader (The can be looked up using effect.key)
  34483. */
  34484. static ShadersStore: {
  34485. [key: string]: string;
  34486. };
  34487. /**
  34488. * Store of each included file for a shader (The can be looked up using effect.key)
  34489. */
  34490. static IncludesShadersStore: {
  34491. [key: string]: string;
  34492. };
  34493. /**
  34494. * Resets the cache of effects.
  34495. */
  34496. static ResetCache(): void;
  34497. }
  34498. }
  34499. declare module BABYLON {
  34500. /**
  34501. * Interface used to describe the capabilities of the engine relatively to the current browser
  34502. */
  34503. export interface EngineCapabilities {
  34504. /** Maximum textures units per fragment shader */
  34505. maxTexturesImageUnits: number;
  34506. /** Maximum texture units per vertex shader */
  34507. maxVertexTextureImageUnits: number;
  34508. /** Maximum textures units in the entire pipeline */
  34509. maxCombinedTexturesImageUnits: number;
  34510. /** Maximum texture size */
  34511. maxTextureSize: number;
  34512. /** Maximum texture samples */
  34513. maxSamples?: number;
  34514. /** Maximum cube texture size */
  34515. maxCubemapTextureSize: number;
  34516. /** Maximum render texture size */
  34517. maxRenderTextureSize: number;
  34518. /** Maximum number of vertex attributes */
  34519. maxVertexAttribs: number;
  34520. /** Maximum number of varyings */
  34521. maxVaryingVectors: number;
  34522. /** Maximum number of uniforms per vertex shader */
  34523. maxVertexUniformVectors: number;
  34524. /** Maximum number of uniforms per fragment shader */
  34525. maxFragmentUniformVectors: number;
  34526. /** Defines if standard derivates (dx/dy) are supported */
  34527. standardDerivatives: boolean;
  34528. /** Defines if s3tc texture compression is supported */
  34529. s3tc?: WEBGL_compressed_texture_s3tc;
  34530. /** Defines if pvrtc texture compression is supported */
  34531. pvrtc: any;
  34532. /** Defines if etc1 texture compression is supported */
  34533. etc1: any;
  34534. /** Defines if etc2 texture compression is supported */
  34535. etc2: any;
  34536. /** Defines if astc texture compression is supported */
  34537. astc: any;
  34538. /** Defines if float textures are supported */
  34539. textureFloat: boolean;
  34540. /** Defines if vertex array objects are supported */
  34541. vertexArrayObject: boolean;
  34542. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  34543. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  34544. /** Gets the maximum level of anisotropy supported */
  34545. maxAnisotropy: number;
  34546. /** Defines if instancing is supported */
  34547. instancedArrays: boolean;
  34548. /** Defines if 32 bits indices are supported */
  34549. uintIndices: boolean;
  34550. /** Defines if high precision shaders are supported */
  34551. highPrecisionShaderSupported: boolean;
  34552. /** Defines if depth reading in the fragment shader is supported */
  34553. fragmentDepthSupported: boolean;
  34554. /** Defines if float texture linear filtering is supported*/
  34555. textureFloatLinearFiltering: boolean;
  34556. /** Defines if rendering to float textures is supported */
  34557. textureFloatRender: boolean;
  34558. /** Defines if half float textures are supported*/
  34559. textureHalfFloat: boolean;
  34560. /** Defines if half float texture linear filtering is supported*/
  34561. textureHalfFloatLinearFiltering: boolean;
  34562. /** Defines if rendering to half float textures is supported */
  34563. textureHalfFloatRender: boolean;
  34564. /** Defines if textureLOD shader command is supported */
  34565. textureLOD: boolean;
  34566. /** Defines if draw buffers extension is supported */
  34567. drawBuffersExtension: boolean;
  34568. /** Defines if depth textures are supported */
  34569. depthTextureExtension: boolean;
  34570. /** Defines if float color buffer are supported */
  34571. colorBufferFloat: boolean;
  34572. /** Gets disjoint timer query extension (null if not supported) */
  34573. timerQuery?: EXT_disjoint_timer_query;
  34574. /** Defines if timestamp can be used with timer query */
  34575. canUseTimestampForTimerQuery: boolean;
  34576. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  34577. multiview?: any;
  34578. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  34579. oculusMultiview?: any;
  34580. /** Function used to let the system compiles shaders in background */
  34581. parallelShaderCompile?: {
  34582. COMPLETION_STATUS_KHR: number;
  34583. };
  34584. /** Max number of texture samples for MSAA */
  34585. maxMSAASamples: number;
  34586. /** Defines if the blend min max extension is supported */
  34587. blendMinMax: boolean;
  34588. }
  34589. }
  34590. declare module BABYLON {
  34591. /**
  34592. * @hidden
  34593. **/
  34594. export class DepthCullingState {
  34595. private _isDepthTestDirty;
  34596. private _isDepthMaskDirty;
  34597. private _isDepthFuncDirty;
  34598. private _isCullFaceDirty;
  34599. private _isCullDirty;
  34600. private _isZOffsetDirty;
  34601. private _isFrontFaceDirty;
  34602. private _depthTest;
  34603. private _depthMask;
  34604. private _depthFunc;
  34605. private _cull;
  34606. private _cullFace;
  34607. private _zOffset;
  34608. private _frontFace;
  34609. /**
  34610. * Initializes the state.
  34611. */
  34612. constructor();
  34613. get isDirty(): boolean;
  34614. get zOffset(): number;
  34615. set zOffset(value: number);
  34616. get cullFace(): Nullable<number>;
  34617. set cullFace(value: Nullable<number>);
  34618. get cull(): Nullable<boolean>;
  34619. set cull(value: Nullable<boolean>);
  34620. get depthFunc(): Nullable<number>;
  34621. set depthFunc(value: Nullable<number>);
  34622. get depthMask(): boolean;
  34623. set depthMask(value: boolean);
  34624. get depthTest(): boolean;
  34625. set depthTest(value: boolean);
  34626. get frontFace(): Nullable<number>;
  34627. set frontFace(value: Nullable<number>);
  34628. reset(): void;
  34629. apply(gl: WebGLRenderingContext): void;
  34630. }
  34631. }
  34632. declare module BABYLON {
  34633. /**
  34634. * @hidden
  34635. **/
  34636. export class StencilState {
  34637. /** 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 */
  34638. static readonly ALWAYS: number;
  34639. /** Passed to stencilOperation to specify that stencil value must be kept */
  34640. static readonly KEEP: number;
  34641. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34642. static readonly REPLACE: number;
  34643. private _isStencilTestDirty;
  34644. private _isStencilMaskDirty;
  34645. private _isStencilFuncDirty;
  34646. private _isStencilOpDirty;
  34647. private _stencilTest;
  34648. private _stencilMask;
  34649. private _stencilFunc;
  34650. private _stencilFuncRef;
  34651. private _stencilFuncMask;
  34652. private _stencilOpStencilFail;
  34653. private _stencilOpDepthFail;
  34654. private _stencilOpStencilDepthPass;
  34655. get isDirty(): boolean;
  34656. get stencilFunc(): number;
  34657. set stencilFunc(value: number);
  34658. get stencilFuncRef(): number;
  34659. set stencilFuncRef(value: number);
  34660. get stencilFuncMask(): number;
  34661. set stencilFuncMask(value: number);
  34662. get stencilOpStencilFail(): number;
  34663. set stencilOpStencilFail(value: number);
  34664. get stencilOpDepthFail(): number;
  34665. set stencilOpDepthFail(value: number);
  34666. get stencilOpStencilDepthPass(): number;
  34667. set stencilOpStencilDepthPass(value: number);
  34668. get stencilMask(): number;
  34669. set stencilMask(value: number);
  34670. get stencilTest(): boolean;
  34671. set stencilTest(value: boolean);
  34672. constructor();
  34673. reset(): void;
  34674. apply(gl: WebGLRenderingContext): void;
  34675. }
  34676. }
  34677. declare module BABYLON {
  34678. /**
  34679. * @hidden
  34680. **/
  34681. export class AlphaState {
  34682. private _isAlphaBlendDirty;
  34683. private _isBlendFunctionParametersDirty;
  34684. private _isBlendEquationParametersDirty;
  34685. private _isBlendConstantsDirty;
  34686. private _alphaBlend;
  34687. private _blendFunctionParameters;
  34688. private _blendEquationParameters;
  34689. private _blendConstants;
  34690. /**
  34691. * Initializes the state.
  34692. */
  34693. constructor();
  34694. get isDirty(): boolean;
  34695. get alphaBlend(): boolean;
  34696. set alphaBlend(value: boolean);
  34697. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  34698. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  34699. setAlphaEquationParameters(rgb: number, alpha: number): void;
  34700. reset(): void;
  34701. apply(gl: WebGLRenderingContext): void;
  34702. }
  34703. }
  34704. declare module BABYLON {
  34705. /** @hidden */
  34706. export class WebGL2ShaderProcessor implements IShaderProcessor {
  34707. attributeProcessor(attribute: string): string;
  34708. varyingProcessor(varying: string, isFragment: boolean): string;
  34709. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  34710. }
  34711. }
  34712. declare module BABYLON {
  34713. /**
  34714. * Interface for attribute information associated with buffer instanciation
  34715. */
  34716. export interface InstancingAttributeInfo {
  34717. /**
  34718. * Name of the GLSL attribute
  34719. * if attribute index is not specified, this is used to retrieve the index from the effect
  34720. */
  34721. attributeName: string;
  34722. /**
  34723. * Index/offset of the attribute in the vertex shader
  34724. * if not specified, this will be computes from the name.
  34725. */
  34726. index?: number;
  34727. /**
  34728. * size of the attribute, 1, 2, 3 or 4
  34729. */
  34730. attributeSize: number;
  34731. /**
  34732. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  34733. */
  34734. offset: number;
  34735. /**
  34736. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  34737. * default to 1
  34738. */
  34739. divisor?: number;
  34740. /**
  34741. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  34742. * default is FLOAT
  34743. */
  34744. attributeType?: number;
  34745. /**
  34746. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  34747. */
  34748. normalized?: boolean;
  34749. }
  34750. }
  34751. declare module BABYLON {
  34752. interface ThinEngine {
  34753. /**
  34754. * Update a video texture
  34755. * @param texture defines the texture to update
  34756. * @param video defines the video element to use
  34757. * @param invertY defines if data must be stored with Y axis inverted
  34758. */
  34759. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  34760. }
  34761. }
  34762. declare module BABYLON {
  34763. interface ThinEngine {
  34764. /**
  34765. * Creates a dynamic texture
  34766. * @param width defines the width of the texture
  34767. * @param height defines the height of the texture
  34768. * @param generateMipMaps defines if the engine should generate the mip levels
  34769. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  34770. * @returns the dynamic texture inside an InternalTexture
  34771. */
  34772. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  34773. /**
  34774. * Update the content of a dynamic texture
  34775. * @param texture defines the texture to update
  34776. * @param canvas defines the canvas containing the source
  34777. * @param invertY defines if data must be stored with Y axis inverted
  34778. * @param premulAlpha defines if alpha is stored as premultiplied
  34779. * @param format defines the format of the data
  34780. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  34781. */
  34782. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  34783. }
  34784. }
  34785. declare module BABYLON {
  34786. /**
  34787. * Settings for finer control over video usage
  34788. */
  34789. export interface VideoTextureSettings {
  34790. /**
  34791. * Applies `autoplay` to video, if specified
  34792. */
  34793. autoPlay?: boolean;
  34794. /**
  34795. * Applies `loop` to video, if specified
  34796. */
  34797. loop?: boolean;
  34798. /**
  34799. * Automatically updates internal texture from video at every frame in the render loop
  34800. */
  34801. autoUpdateTexture: boolean;
  34802. /**
  34803. * Image src displayed during the video loading or until the user interacts with the video.
  34804. */
  34805. poster?: string;
  34806. }
  34807. /**
  34808. * If you want to display a video in your scene, this is the special texture for that.
  34809. * This special texture works similar to other textures, with the exception of a few parameters.
  34810. * @see https://doc.babylonjs.com/how_to/video_texture
  34811. */
  34812. export class VideoTexture extends Texture {
  34813. /**
  34814. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  34815. */
  34816. readonly autoUpdateTexture: boolean;
  34817. /**
  34818. * The video instance used by the texture internally
  34819. */
  34820. readonly video: HTMLVideoElement;
  34821. private _onUserActionRequestedObservable;
  34822. /**
  34823. * Event triggerd when a dom action is required by the user to play the video.
  34824. * This happens due to recent changes in browser policies preventing video to auto start.
  34825. */
  34826. get onUserActionRequestedObservable(): Observable<Texture>;
  34827. private _generateMipMaps;
  34828. private _stillImageCaptured;
  34829. private _displayingPosterTexture;
  34830. private _settings;
  34831. private _createInternalTextureOnEvent;
  34832. private _frameId;
  34833. private _currentSrc;
  34834. /**
  34835. * Creates a video texture.
  34836. * If you want to display a video in your scene, this is the special texture for that.
  34837. * This special texture works similar to other textures, with the exception of a few parameters.
  34838. * @see https://doc.babylonjs.com/how_to/video_texture
  34839. * @param name optional name, will detect from video source, if not defined
  34840. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  34841. * @param scene is obviously the current scene.
  34842. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  34843. * @param invertY is false by default but can be used to invert video on Y axis
  34844. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  34845. * @param settings allows finer control over video usage
  34846. */
  34847. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  34848. private _getName;
  34849. private _getVideo;
  34850. private _createInternalTexture;
  34851. private reset;
  34852. /**
  34853. * @hidden Internal method to initiate `update`.
  34854. */
  34855. _rebuild(): void;
  34856. /**
  34857. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  34858. */
  34859. update(): void;
  34860. /**
  34861. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  34862. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  34863. */
  34864. updateTexture(isVisible: boolean): void;
  34865. protected _updateInternalTexture: () => void;
  34866. /**
  34867. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  34868. * @param url New url.
  34869. */
  34870. updateURL(url: string): void;
  34871. /**
  34872. * Clones the texture.
  34873. * @returns the cloned texture
  34874. */
  34875. clone(): VideoTexture;
  34876. /**
  34877. * Dispose the texture and release its associated resources.
  34878. */
  34879. dispose(): void;
  34880. /**
  34881. * Creates a video texture straight from a stream.
  34882. * @param scene Define the scene the texture should be created in
  34883. * @param stream Define the stream the texture should be created from
  34884. * @returns The created video texture as a promise
  34885. */
  34886. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  34887. /**
  34888. * Creates a video texture straight from your WebCam video feed.
  34889. * @param scene Define the scene the texture should be created in
  34890. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  34891. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  34892. * @returns The created video texture as a promise
  34893. */
  34894. static CreateFromWebCamAsync(scene: Scene, constraints: {
  34895. minWidth: number;
  34896. maxWidth: number;
  34897. minHeight: number;
  34898. maxHeight: number;
  34899. deviceId: string;
  34900. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  34901. /**
  34902. * Creates a video texture straight from your WebCam video feed.
  34903. * @param scene Define the scene the texture should be created in
  34904. * @param onReady Define a callback to triggered once the texture will be ready
  34905. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  34906. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  34907. */
  34908. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  34909. minWidth: number;
  34910. maxWidth: number;
  34911. minHeight: number;
  34912. maxHeight: number;
  34913. deviceId: string;
  34914. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  34915. }
  34916. }
  34917. declare module BABYLON {
  34918. /**
  34919. * Defines the interface used by objects working like Scene
  34920. * @hidden
  34921. */
  34922. export interface ISceneLike {
  34923. _addPendingData(data: any): void;
  34924. _removePendingData(data: any): void;
  34925. offlineProvider: IOfflineProvider;
  34926. }
  34927. /** Interface defining initialization parameters for Engine class */
  34928. export interface EngineOptions extends WebGLContextAttributes {
  34929. /**
  34930. * Defines if the engine should no exceed a specified device ratio
  34931. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  34932. */
  34933. limitDeviceRatio?: number;
  34934. /**
  34935. * Defines if webvr should be enabled automatically
  34936. * @see https://doc.babylonjs.com/how_to/webvr_camera
  34937. */
  34938. autoEnableWebVR?: boolean;
  34939. /**
  34940. * Defines if webgl2 should be turned off even if supported
  34941. * @see https://doc.babylonjs.com/features/webgl2
  34942. */
  34943. disableWebGL2Support?: boolean;
  34944. /**
  34945. * Defines if webaudio should be initialized as well
  34946. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  34947. */
  34948. audioEngine?: boolean;
  34949. /**
  34950. * Defines if animations should run using a deterministic lock step
  34951. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34952. */
  34953. deterministicLockstep?: boolean;
  34954. /** Defines the maximum steps to use with deterministic lock step mode */
  34955. lockstepMaxSteps?: number;
  34956. /** Defines the seconds between each deterministic lock step */
  34957. timeStep?: number;
  34958. /**
  34959. * Defines that engine should ignore context lost events
  34960. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  34961. */
  34962. doNotHandleContextLost?: boolean;
  34963. /**
  34964. * Defines that engine should ignore modifying touch action attribute and style
  34965. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  34966. */
  34967. doNotHandleTouchAction?: boolean;
  34968. /**
  34969. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  34970. */
  34971. useHighPrecisionFloats?: boolean;
  34972. /**
  34973. * Make the canvas XR Compatible for XR sessions
  34974. */
  34975. xrCompatible?: boolean;
  34976. /**
  34977. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  34978. */
  34979. useHighPrecisionMatrix?: boolean;
  34980. }
  34981. /**
  34982. * The base engine class (root of all engines)
  34983. */
  34984. export class ThinEngine {
  34985. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  34986. static ExceptionList: ({
  34987. key: string;
  34988. capture: string;
  34989. captureConstraint: number;
  34990. targets: string[];
  34991. } | {
  34992. key: string;
  34993. capture: null;
  34994. captureConstraint: null;
  34995. targets: string[];
  34996. })[];
  34997. /** @hidden */
  34998. static _TextureLoaders: IInternalTextureLoader[];
  34999. /**
  35000. * Returns the current npm package of the sdk
  35001. */
  35002. static get NpmPackage(): string;
  35003. /**
  35004. * Returns the current version of the framework
  35005. */
  35006. static get Version(): string;
  35007. /**
  35008. * Returns a string describing the current engine
  35009. */
  35010. get description(): string;
  35011. /**
  35012. * Gets or sets the epsilon value used by collision engine
  35013. */
  35014. static CollisionsEpsilon: number;
  35015. /**
  35016. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35017. */
  35018. static get ShadersRepository(): string;
  35019. static set ShadersRepository(value: string);
  35020. /** @hidden */
  35021. _shaderProcessor: IShaderProcessor;
  35022. /**
  35023. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35024. */
  35025. forcePOTTextures: boolean;
  35026. /**
  35027. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35028. */
  35029. isFullscreen: boolean;
  35030. /**
  35031. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35032. */
  35033. cullBackFaces: boolean;
  35034. /**
  35035. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35036. */
  35037. renderEvenInBackground: boolean;
  35038. /**
  35039. * Gets or sets a boolean indicating that cache can be kept between frames
  35040. */
  35041. preventCacheWipeBetweenFrames: boolean;
  35042. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35043. validateShaderPrograms: boolean;
  35044. /**
  35045. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35046. * This can provide greater z depth for distant objects.
  35047. */
  35048. useReverseDepthBuffer: boolean;
  35049. /**
  35050. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35051. */
  35052. disableUniformBuffers: boolean;
  35053. /** @hidden */
  35054. _uniformBuffers: UniformBuffer[];
  35055. /**
  35056. * Gets a boolean indicating that the engine supports uniform buffers
  35057. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35058. */
  35059. get supportsUniformBuffers(): boolean;
  35060. /** @hidden */
  35061. _gl: WebGLRenderingContext;
  35062. /** @hidden */
  35063. _webGLVersion: number;
  35064. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35065. protected _windowIsBackground: boolean;
  35066. protected _creationOptions: EngineOptions;
  35067. protected _highPrecisionShadersAllowed: boolean;
  35068. /** @hidden */
  35069. get _shouldUseHighPrecisionShader(): boolean;
  35070. /**
  35071. * Gets a boolean indicating that only power of 2 textures are supported
  35072. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35073. */
  35074. get needPOTTextures(): boolean;
  35075. /** @hidden */
  35076. _badOS: boolean;
  35077. /** @hidden */
  35078. _badDesktopOS: boolean;
  35079. private _hardwareScalingLevel;
  35080. /** @hidden */
  35081. _caps: EngineCapabilities;
  35082. private _isStencilEnable;
  35083. private _glVersion;
  35084. private _glRenderer;
  35085. private _glVendor;
  35086. /** @hidden */
  35087. _videoTextureSupported: boolean;
  35088. protected _renderingQueueLaunched: boolean;
  35089. protected _activeRenderLoops: (() => void)[];
  35090. /**
  35091. * Observable signaled when a context lost event is raised
  35092. */
  35093. onContextLostObservable: Observable<ThinEngine>;
  35094. /**
  35095. * Observable signaled when a context restored event is raised
  35096. */
  35097. onContextRestoredObservable: Observable<ThinEngine>;
  35098. private _onContextLost;
  35099. private _onContextRestored;
  35100. protected _contextWasLost: boolean;
  35101. /** @hidden */
  35102. _doNotHandleContextLost: boolean;
  35103. /**
  35104. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35105. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35106. */
  35107. get doNotHandleContextLost(): boolean;
  35108. set doNotHandleContextLost(value: boolean);
  35109. /**
  35110. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35111. */
  35112. disableVertexArrayObjects: boolean;
  35113. /** @hidden */
  35114. protected _colorWrite: boolean;
  35115. /** @hidden */
  35116. protected _colorWriteChanged: boolean;
  35117. /** @hidden */
  35118. protected _depthCullingState: DepthCullingState;
  35119. /** @hidden */
  35120. protected _stencilState: StencilState;
  35121. /** @hidden */
  35122. _alphaState: AlphaState;
  35123. /** @hidden */
  35124. _alphaMode: number;
  35125. /** @hidden */
  35126. _alphaEquation: number;
  35127. /** @hidden */
  35128. _internalTexturesCache: InternalTexture[];
  35129. /** @hidden */
  35130. protected _activeChannel: number;
  35131. private _currentTextureChannel;
  35132. /** @hidden */
  35133. protected _boundTexturesCache: {
  35134. [key: string]: Nullable<InternalTexture>;
  35135. };
  35136. /** @hidden */
  35137. protected _currentEffect: Nullable<Effect>;
  35138. /** @hidden */
  35139. protected _currentProgram: Nullable<WebGLProgram>;
  35140. private _compiledEffects;
  35141. private _vertexAttribArraysEnabled;
  35142. /** @hidden */
  35143. protected _cachedViewport: Nullable<IViewportLike>;
  35144. private _cachedVertexArrayObject;
  35145. /** @hidden */
  35146. protected _cachedVertexBuffers: any;
  35147. /** @hidden */
  35148. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35149. /** @hidden */
  35150. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35151. /** @hidden */
  35152. _currentRenderTarget: Nullable<InternalTexture>;
  35153. private _uintIndicesCurrentlySet;
  35154. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35155. /** @hidden */
  35156. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35157. /** @hidden */
  35158. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35159. private _currentBufferPointers;
  35160. private _currentInstanceLocations;
  35161. private _currentInstanceBuffers;
  35162. private _textureUnits;
  35163. /** @hidden */
  35164. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35165. /** @hidden */
  35166. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35167. /** @hidden */
  35168. _boundRenderFunction: any;
  35169. private _vaoRecordInProgress;
  35170. private _mustWipeVertexAttributes;
  35171. private _emptyTexture;
  35172. private _emptyCubeTexture;
  35173. private _emptyTexture3D;
  35174. private _emptyTexture2DArray;
  35175. /** @hidden */
  35176. _frameHandler: number;
  35177. private _nextFreeTextureSlots;
  35178. private _maxSimultaneousTextures;
  35179. private _activeRequests;
  35180. /** @hidden */
  35181. _transformTextureUrl: Nullable<(url: string) => string>;
  35182. protected get _supportsHardwareTextureRescaling(): boolean;
  35183. private _framebufferDimensionsObject;
  35184. /**
  35185. * sets the object from which width and height will be taken from when getting render width and height
  35186. * Will fallback to the gl object
  35187. * @param dimensions the framebuffer width and height that will be used.
  35188. */
  35189. set framebufferDimensionsObject(dimensions: Nullable<{
  35190. framebufferWidth: number;
  35191. framebufferHeight: number;
  35192. }>);
  35193. /**
  35194. * Gets the current viewport
  35195. */
  35196. get currentViewport(): Nullable<IViewportLike>;
  35197. /**
  35198. * Gets the default empty texture
  35199. */
  35200. get emptyTexture(): InternalTexture;
  35201. /**
  35202. * Gets the default empty 3D texture
  35203. */
  35204. get emptyTexture3D(): InternalTexture;
  35205. /**
  35206. * Gets the default empty 2D array texture
  35207. */
  35208. get emptyTexture2DArray(): InternalTexture;
  35209. /**
  35210. * Gets the default empty cube texture
  35211. */
  35212. get emptyCubeTexture(): InternalTexture;
  35213. /**
  35214. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35215. */
  35216. readonly premultipliedAlpha: boolean;
  35217. /**
  35218. * Observable event triggered before each texture is initialized
  35219. */
  35220. onBeforeTextureInitObservable: Observable<Texture>;
  35221. /**
  35222. * Creates a new engine
  35223. * @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
  35224. * @param antialias defines enable antialiasing (default: false)
  35225. * @param options defines further options to be sent to the getContext() function
  35226. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35227. */
  35228. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35229. private _rebuildInternalTextures;
  35230. private _rebuildEffects;
  35231. /**
  35232. * Gets a boolean indicating if all created effects are ready
  35233. * @returns true if all effects are ready
  35234. */
  35235. areAllEffectsReady(): boolean;
  35236. protected _rebuildBuffers(): void;
  35237. protected _initGLContext(): void;
  35238. /**
  35239. * Gets version of the current webGL context
  35240. */
  35241. get webGLVersion(): number;
  35242. /**
  35243. * Gets a string idenfifying the name of the class
  35244. * @returns "Engine" string
  35245. */
  35246. getClassName(): string;
  35247. /**
  35248. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35249. */
  35250. get isStencilEnable(): boolean;
  35251. /** @hidden */
  35252. _prepareWorkingCanvas(): void;
  35253. /**
  35254. * Reset the texture cache to empty state
  35255. */
  35256. resetTextureCache(): void;
  35257. /**
  35258. * Gets an object containing information about the current webGL context
  35259. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35260. */
  35261. getGlInfo(): {
  35262. vendor: string;
  35263. renderer: string;
  35264. version: string;
  35265. };
  35266. /**
  35267. * Defines the hardware scaling level.
  35268. * By default the hardware scaling level is computed from the window device ratio.
  35269. * 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.
  35270. * @param level defines the level to use
  35271. */
  35272. setHardwareScalingLevel(level: number): void;
  35273. /**
  35274. * Gets the current hardware scaling level.
  35275. * By default the hardware scaling level is computed from the window device ratio.
  35276. * 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.
  35277. * @returns a number indicating the current hardware scaling level
  35278. */
  35279. getHardwareScalingLevel(): number;
  35280. /**
  35281. * Gets the list of loaded textures
  35282. * @returns an array containing all loaded textures
  35283. */
  35284. getLoadedTexturesCache(): InternalTexture[];
  35285. /**
  35286. * Gets the object containing all engine capabilities
  35287. * @returns the EngineCapabilities object
  35288. */
  35289. getCaps(): EngineCapabilities;
  35290. /**
  35291. * stop executing a render loop function and remove it from the execution array
  35292. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35293. */
  35294. stopRenderLoop(renderFunction?: () => void): void;
  35295. /** @hidden */
  35296. _renderLoop(): void;
  35297. /**
  35298. * Gets the HTML canvas attached with the current webGL context
  35299. * @returns a HTML canvas
  35300. */
  35301. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35302. /**
  35303. * Gets host window
  35304. * @returns the host window object
  35305. */
  35306. getHostWindow(): Nullable<Window>;
  35307. /**
  35308. * Gets the current render width
  35309. * @param useScreen defines if screen size must be used (or the current render target if any)
  35310. * @returns a number defining the current render width
  35311. */
  35312. getRenderWidth(useScreen?: boolean): number;
  35313. /**
  35314. * Gets the current render height
  35315. * @param useScreen defines if screen size must be used (or the current render target if any)
  35316. * @returns a number defining the current render height
  35317. */
  35318. getRenderHeight(useScreen?: boolean): number;
  35319. /**
  35320. * Can be used to override the current requestAnimationFrame requester.
  35321. * @hidden
  35322. */
  35323. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35324. /**
  35325. * Register and execute a render loop. The engine can have more than one render function
  35326. * @param renderFunction defines the function to continuously execute
  35327. */
  35328. runRenderLoop(renderFunction: () => void): void;
  35329. /**
  35330. * Clear the current render buffer or the current render target (if any is set up)
  35331. * @param color defines the color to use
  35332. * @param backBuffer defines if the back buffer must be cleared
  35333. * @param depth defines if the depth buffer must be cleared
  35334. * @param stencil defines if the stencil buffer must be cleared
  35335. */
  35336. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35337. private _viewportCached;
  35338. /** @hidden */
  35339. _viewport(x: number, y: number, width: number, height: number): void;
  35340. /**
  35341. * Set the WebGL's viewport
  35342. * @param viewport defines the viewport element to be used
  35343. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35344. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35345. */
  35346. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35347. /**
  35348. * Begin a new frame
  35349. */
  35350. beginFrame(): void;
  35351. /**
  35352. * Enf the current frame
  35353. */
  35354. endFrame(): void;
  35355. /**
  35356. * Resize the view according to the canvas' size
  35357. */
  35358. resize(): void;
  35359. /**
  35360. * Force a specific size of the canvas
  35361. * @param width defines the new canvas' width
  35362. * @param height defines the new canvas' height
  35363. * @returns true if the size was changed
  35364. */
  35365. setSize(width: number, height: number): boolean;
  35366. /**
  35367. * Binds the frame buffer to the specified texture.
  35368. * @param texture The texture to render to or null for the default canvas
  35369. * @param faceIndex The face of the texture to render to in case of cube texture
  35370. * @param requiredWidth The width of the target to render to
  35371. * @param requiredHeight The height of the target to render to
  35372. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35373. * @param lodLevel defines the lod level to bind to the frame buffer
  35374. * @param layer defines the 2d array index to bind to frame buffer to
  35375. */
  35376. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35377. /** @hidden */
  35378. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35379. /**
  35380. * Unbind the current render target texture from the webGL context
  35381. * @param texture defines the render target texture to unbind
  35382. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35383. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35384. */
  35385. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35386. /**
  35387. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35388. */
  35389. flushFramebuffer(): void;
  35390. /**
  35391. * Unbind the current render target and bind the default framebuffer
  35392. */
  35393. restoreDefaultFramebuffer(): void;
  35394. /** @hidden */
  35395. protected _resetVertexBufferBinding(): void;
  35396. /**
  35397. * Creates a vertex buffer
  35398. * @param data the data for the vertex buffer
  35399. * @returns the new WebGL static buffer
  35400. */
  35401. createVertexBuffer(data: DataArray): DataBuffer;
  35402. private _createVertexBuffer;
  35403. /**
  35404. * Creates a dynamic vertex buffer
  35405. * @param data the data for the dynamic vertex buffer
  35406. * @returns the new WebGL dynamic buffer
  35407. */
  35408. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35409. protected _resetIndexBufferBinding(): void;
  35410. /**
  35411. * Creates a new index buffer
  35412. * @param indices defines the content of the index buffer
  35413. * @param updatable defines if the index buffer must be updatable
  35414. * @returns a new webGL buffer
  35415. */
  35416. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  35417. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  35418. /**
  35419. * Bind a webGL buffer to the webGL context
  35420. * @param buffer defines the buffer to bind
  35421. */
  35422. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  35423. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  35424. private bindBuffer;
  35425. /**
  35426. * update the bound buffer with the given data
  35427. * @param data defines the data to update
  35428. */
  35429. updateArrayBuffer(data: Float32Array): void;
  35430. private _vertexAttribPointer;
  35431. /** @hidden */
  35432. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  35433. private _bindVertexBuffersAttributes;
  35434. /**
  35435. * Records a vertex array object
  35436. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35437. * @param vertexBuffers defines the list of vertex buffers to store
  35438. * @param indexBuffer defines the index buffer to store
  35439. * @param effect defines the effect to store
  35440. * @returns the new vertex array object
  35441. */
  35442. recordVertexArrayObject(vertexBuffers: {
  35443. [key: string]: VertexBuffer;
  35444. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  35445. /**
  35446. * Bind a specific vertex array object
  35447. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35448. * @param vertexArrayObject defines the vertex array object to bind
  35449. * @param indexBuffer defines the index buffer to bind
  35450. */
  35451. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  35452. /**
  35453. * Bind webGl buffers directly to the webGL context
  35454. * @param vertexBuffer defines the vertex buffer to bind
  35455. * @param indexBuffer defines the index buffer to bind
  35456. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  35457. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  35458. * @param effect defines the effect associated with the vertex buffer
  35459. */
  35460. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  35461. private _unbindVertexArrayObject;
  35462. /**
  35463. * Bind a list of vertex buffers to the webGL context
  35464. * @param vertexBuffers defines the list of vertex buffers to bind
  35465. * @param indexBuffer defines the index buffer to bind
  35466. * @param effect defines the effect associated with the vertex buffers
  35467. */
  35468. bindBuffers(vertexBuffers: {
  35469. [key: string]: Nullable<VertexBuffer>;
  35470. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  35471. /**
  35472. * Unbind all instance attributes
  35473. */
  35474. unbindInstanceAttributes(): void;
  35475. /**
  35476. * Release and free the memory of a vertex array object
  35477. * @param vao defines the vertex array object to delete
  35478. */
  35479. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  35480. /** @hidden */
  35481. _releaseBuffer(buffer: DataBuffer): boolean;
  35482. protected _deleteBuffer(buffer: DataBuffer): void;
  35483. /**
  35484. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  35485. * @param instancesBuffer defines the webGL buffer to update and bind
  35486. * @param data defines the data to store in the buffer
  35487. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  35488. */
  35489. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  35490. /**
  35491. * Bind the content of a webGL buffer used with instantiation
  35492. * @param instancesBuffer defines the webGL buffer to bind
  35493. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  35494. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  35495. */
  35496. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  35497. /**
  35498. * Disable the instance attribute corresponding to the name in parameter
  35499. * @param name defines the name of the attribute to disable
  35500. */
  35501. disableInstanceAttributeByName(name: string): void;
  35502. /**
  35503. * Disable the instance attribute corresponding to the location in parameter
  35504. * @param attributeLocation defines the attribute location of the attribute to disable
  35505. */
  35506. disableInstanceAttribute(attributeLocation: number): void;
  35507. /**
  35508. * Disable the attribute corresponding to the location in parameter
  35509. * @param attributeLocation defines the attribute location of the attribute to disable
  35510. */
  35511. disableAttributeByIndex(attributeLocation: number): void;
  35512. /**
  35513. * Send a draw order
  35514. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35515. * @param indexStart defines the starting index
  35516. * @param indexCount defines the number of index to draw
  35517. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35518. */
  35519. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  35520. /**
  35521. * Draw a list of points
  35522. * @param verticesStart defines the index of first vertex to draw
  35523. * @param verticesCount defines the count of vertices to draw
  35524. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35525. */
  35526. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35527. /**
  35528. * Draw a list of unindexed primitives
  35529. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35530. * @param verticesStart defines the index of first vertex to draw
  35531. * @param verticesCount defines the count of vertices to draw
  35532. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35533. */
  35534. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35535. /**
  35536. * Draw a list of indexed primitives
  35537. * @param fillMode defines the primitive to use
  35538. * @param indexStart defines the starting index
  35539. * @param indexCount defines the number of index to draw
  35540. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35541. */
  35542. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  35543. /**
  35544. * Draw a list of unindexed primitives
  35545. * @param fillMode defines the primitive to use
  35546. * @param verticesStart defines the index of first vertex to draw
  35547. * @param verticesCount defines the count of vertices to draw
  35548. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35549. */
  35550. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35551. private _drawMode;
  35552. /** @hidden */
  35553. protected _reportDrawCall(): void;
  35554. /** @hidden */
  35555. _releaseEffect(effect: Effect): void;
  35556. /** @hidden */
  35557. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35558. /**
  35559. * Create a new effect (used to store vertex/fragment shaders)
  35560. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  35561. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  35562. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  35563. * @param samplers defines an array of string used to represent textures
  35564. * @param defines defines the string containing the defines to use to compile the shaders
  35565. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  35566. * @param onCompiled defines a function to call when the effect creation is successful
  35567. * @param onError defines a function to call when the effect creation has failed
  35568. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  35569. * @returns the new Effect
  35570. */
  35571. 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;
  35572. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  35573. private _compileShader;
  35574. private _compileRawShader;
  35575. /** @hidden */
  35576. _getShaderSource(shader: WebGLShader): Nullable<string>;
  35577. /**
  35578. * Directly creates a webGL program
  35579. * @param pipelineContext defines the pipeline context to attach to
  35580. * @param vertexCode defines the vertex shader code to use
  35581. * @param fragmentCode defines the fragment shader code to use
  35582. * @param context defines the webGL context to use (if not set, the current one will be used)
  35583. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35584. * @returns the new webGL program
  35585. */
  35586. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35587. /**
  35588. * Creates a webGL program
  35589. * @param pipelineContext defines the pipeline context to attach to
  35590. * @param vertexCode defines the vertex shader code to use
  35591. * @param fragmentCode defines the fragment shader code to use
  35592. * @param defines defines the string containing the defines to use to compile the shaders
  35593. * @param context defines the webGL context to use (if not set, the current one will be used)
  35594. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35595. * @returns the new webGL program
  35596. */
  35597. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35598. /**
  35599. * Creates a new pipeline context
  35600. * @returns the new pipeline
  35601. */
  35602. createPipelineContext(): IPipelineContext;
  35603. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35604. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  35605. /** @hidden */
  35606. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  35607. /** @hidden */
  35608. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  35609. /** @hidden */
  35610. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  35611. /**
  35612. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  35613. * @param pipelineContext defines the pipeline context to use
  35614. * @param uniformsNames defines the list of uniform names
  35615. * @returns an array of webGL uniform locations
  35616. */
  35617. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  35618. /**
  35619. * Gets the lsit of active attributes for a given webGL program
  35620. * @param pipelineContext defines the pipeline context to use
  35621. * @param attributesNames defines the list of attribute names to get
  35622. * @returns an array of indices indicating the offset of each attribute
  35623. */
  35624. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  35625. /**
  35626. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  35627. * @param effect defines the effect to activate
  35628. */
  35629. enableEffect(effect: Nullable<Effect>): void;
  35630. /**
  35631. * Set the value of an uniform to a number (int)
  35632. * @param uniform defines the webGL uniform location where to store the value
  35633. * @param value defines the int number to store
  35634. */
  35635. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35636. /**
  35637. * Set the value of an uniform to an array of int32
  35638. * @param uniform defines the webGL uniform location where to store the value
  35639. * @param array defines the array of int32 to store
  35640. */
  35641. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35642. /**
  35643. * Set the value of an uniform to an array of int32 (stored as vec2)
  35644. * @param uniform defines the webGL uniform location where to store the value
  35645. * @param array defines the array of int32 to store
  35646. */
  35647. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35648. /**
  35649. * Set the value of an uniform to an array of int32 (stored as vec3)
  35650. * @param uniform defines the webGL uniform location where to store the value
  35651. * @param array defines the array of int32 to store
  35652. */
  35653. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35654. /**
  35655. * Set the value of an uniform to an array of int32 (stored as vec4)
  35656. * @param uniform defines the webGL uniform location where to store the value
  35657. * @param array defines the array of int32 to store
  35658. */
  35659. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35660. /**
  35661. * Set the value of an uniform to an array of number
  35662. * @param uniform defines the webGL uniform location where to store the value
  35663. * @param array defines the array of number to store
  35664. */
  35665. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35666. /**
  35667. * Set the value of an uniform to an array of number (stored as vec2)
  35668. * @param uniform defines the webGL uniform location where to store the value
  35669. * @param array defines the array of number to store
  35670. */
  35671. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35672. /**
  35673. * Set the value of an uniform to an array of number (stored as vec3)
  35674. * @param uniform defines the webGL uniform location where to store the value
  35675. * @param array defines the array of number to store
  35676. */
  35677. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35678. /**
  35679. * Set the value of an uniform to an array of number (stored as vec4)
  35680. * @param uniform defines the webGL uniform location where to store the value
  35681. * @param array defines the array of number to store
  35682. */
  35683. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35684. /**
  35685. * Set the value of an uniform to an array of float32 (stored as matrices)
  35686. * @param uniform defines the webGL uniform location where to store the value
  35687. * @param matrices defines the array of float32 to store
  35688. */
  35689. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  35690. /**
  35691. * Set the value of an uniform to a matrix (3x3)
  35692. * @param uniform defines the webGL uniform location where to store the value
  35693. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  35694. */
  35695. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35696. /**
  35697. * Set the value of an uniform to a matrix (2x2)
  35698. * @param uniform defines the webGL uniform location where to store the value
  35699. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  35700. */
  35701. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35702. /**
  35703. * Set the value of an uniform to a number (float)
  35704. * @param uniform defines the webGL uniform location where to store the value
  35705. * @param value defines the float number to store
  35706. */
  35707. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35708. /**
  35709. * Set the value of an uniform to a vec2
  35710. * @param uniform defines the webGL uniform location where to store the value
  35711. * @param x defines the 1st component of the value
  35712. * @param y defines the 2nd component of the value
  35713. */
  35714. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  35715. /**
  35716. * Set the value of an uniform to a vec3
  35717. * @param uniform defines the webGL uniform location where to store the value
  35718. * @param x defines the 1st component of the value
  35719. * @param y defines the 2nd component of the value
  35720. * @param z defines the 3rd component of the value
  35721. */
  35722. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  35723. /**
  35724. * Set the value of an uniform to a vec4
  35725. * @param uniform defines the webGL uniform location where to store the value
  35726. * @param x defines the 1st component of the value
  35727. * @param y defines the 2nd component of the value
  35728. * @param z defines the 3rd component of the value
  35729. * @param w defines the 4th component of the value
  35730. */
  35731. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  35732. /**
  35733. * Apply all cached states (depth, culling, stencil and alpha)
  35734. */
  35735. applyStates(): void;
  35736. /**
  35737. * Enable or disable color writing
  35738. * @param enable defines the state to set
  35739. */
  35740. setColorWrite(enable: boolean): void;
  35741. /**
  35742. * Gets a boolean indicating if color writing is enabled
  35743. * @returns the current color writing state
  35744. */
  35745. getColorWrite(): boolean;
  35746. /**
  35747. * Gets the depth culling state manager
  35748. */
  35749. get depthCullingState(): DepthCullingState;
  35750. /**
  35751. * Gets the alpha state manager
  35752. */
  35753. get alphaState(): AlphaState;
  35754. /**
  35755. * Gets the stencil state manager
  35756. */
  35757. get stencilState(): StencilState;
  35758. /**
  35759. * Clears the list of texture accessible through engine.
  35760. * This can help preventing texture load conflict due to name collision.
  35761. */
  35762. clearInternalTexturesCache(): void;
  35763. /**
  35764. * Force the entire cache to be cleared
  35765. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  35766. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  35767. */
  35768. wipeCaches(bruteForce?: boolean): void;
  35769. /** @hidden */
  35770. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  35771. min: number;
  35772. mag: number;
  35773. };
  35774. /** @hidden */
  35775. _createTexture(): WebGLTexture;
  35776. /**
  35777. * Usually called from Texture.ts.
  35778. * Passed information to create a WebGLTexture
  35779. * @param url defines a value which contains one of the following:
  35780. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  35781. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  35782. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  35783. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  35784. * @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)
  35785. * @param scene needed for loading to the correct scene
  35786. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  35787. * @param onLoad optional callback to be called upon successful completion
  35788. * @param onError optional callback to be called upon failure
  35789. * @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
  35790. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  35791. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  35792. * @param forcedExtension defines the extension to use to pick the right loader
  35793. * @param mimeType defines an optional mime type
  35794. * @returns a InternalTexture for assignment back into BABYLON.Texture
  35795. */
  35796. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  35797. /**
  35798. * Loads an image as an HTMLImageElement.
  35799. * @param input url string, ArrayBuffer, or Blob to load
  35800. * @param onLoad callback called when the image successfully loads
  35801. * @param onError callback called when the image fails to load
  35802. * @param offlineProvider offline provider for caching
  35803. * @param mimeType optional mime type
  35804. * @returns the HTMLImageElement of the loaded image
  35805. * @hidden
  35806. */
  35807. 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>;
  35808. /**
  35809. * @hidden
  35810. */
  35811. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  35812. private _unpackFlipYCached;
  35813. /**
  35814. * In case you are sharing the context with other applications, it might
  35815. * be interested to not cache the unpack flip y state to ensure a consistent
  35816. * value would be set.
  35817. */
  35818. enableUnpackFlipYCached: boolean;
  35819. /** @hidden */
  35820. _unpackFlipY(value: boolean): void;
  35821. /** @hidden */
  35822. _getUnpackAlignement(): number;
  35823. private _getTextureTarget;
  35824. /**
  35825. * Update the sampling mode of a given texture
  35826. * @param samplingMode defines the required sampling mode
  35827. * @param texture defines the texture to update
  35828. * @param generateMipMaps defines whether to generate mipmaps for the texture
  35829. */
  35830. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  35831. /**
  35832. * Update the sampling mode of a given texture
  35833. * @param texture defines the texture to update
  35834. * @param wrapU defines the texture wrap mode of the u coordinates
  35835. * @param wrapV defines the texture wrap mode of the v coordinates
  35836. * @param wrapR defines the texture wrap mode of the r coordinates
  35837. */
  35838. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  35839. /** @hidden */
  35840. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  35841. width: number;
  35842. height: number;
  35843. layers?: number;
  35844. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  35845. /** @hidden */
  35846. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  35847. /** @hidden */
  35848. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  35849. /**
  35850. * Update a portion of an internal texture
  35851. * @param texture defines the texture to update
  35852. * @param imageData defines the data to store into the texture
  35853. * @param xOffset defines the x coordinates of the update rectangle
  35854. * @param yOffset defines the y coordinates of the update rectangle
  35855. * @param width defines the width of the update rectangle
  35856. * @param height defines the height of the update rectangle
  35857. * @param faceIndex defines the face index if texture is a cube (0 by default)
  35858. * @param lod defines the lod level to update (0 by default)
  35859. */
  35860. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  35861. /** @hidden */
  35862. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  35863. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  35864. private _prepareWebGLTexture;
  35865. /** @hidden */
  35866. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  35867. private _getDepthStencilBuffer;
  35868. /** @hidden */
  35869. _releaseFramebufferObjects(texture: InternalTexture): void;
  35870. /** @hidden */
  35871. _releaseTexture(texture: InternalTexture): void;
  35872. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  35873. protected _setProgram(program: WebGLProgram): void;
  35874. protected _boundUniforms: {
  35875. [key: number]: WebGLUniformLocation;
  35876. };
  35877. /**
  35878. * Binds an effect to the webGL context
  35879. * @param effect defines the effect to bind
  35880. */
  35881. bindSamplers(effect: Effect): void;
  35882. private _activateCurrentTexture;
  35883. /** @hidden */
  35884. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  35885. /** @hidden */
  35886. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  35887. /**
  35888. * Unbind all textures from the webGL context
  35889. */
  35890. unbindAllTextures(): void;
  35891. /**
  35892. * Sets a texture to the according uniform.
  35893. * @param channel The texture channel
  35894. * @param uniform The uniform to set
  35895. * @param texture The texture to apply
  35896. */
  35897. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  35898. private _bindSamplerUniformToChannel;
  35899. private _getTextureWrapMode;
  35900. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  35901. /**
  35902. * Sets an array of texture to the webGL context
  35903. * @param channel defines the channel where the texture array must be set
  35904. * @param uniform defines the associated uniform location
  35905. * @param textures defines the array of textures to bind
  35906. */
  35907. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  35908. /** @hidden */
  35909. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  35910. private _setTextureParameterFloat;
  35911. private _setTextureParameterInteger;
  35912. /**
  35913. * Unbind all vertex attributes from the webGL context
  35914. */
  35915. unbindAllAttributes(): void;
  35916. /**
  35917. * 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
  35918. */
  35919. releaseEffects(): void;
  35920. /**
  35921. * Dispose and release all associated resources
  35922. */
  35923. dispose(): void;
  35924. /**
  35925. * Attach a new callback raised when context lost event is fired
  35926. * @param callback defines the callback to call
  35927. */
  35928. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35929. /**
  35930. * Attach a new callback raised when context restored event is fired
  35931. * @param callback defines the callback to call
  35932. */
  35933. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35934. /**
  35935. * Get the current error code of the webGL context
  35936. * @returns the error code
  35937. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  35938. */
  35939. getError(): number;
  35940. private _canRenderToFloatFramebuffer;
  35941. private _canRenderToHalfFloatFramebuffer;
  35942. private _canRenderToFramebuffer;
  35943. /** @hidden */
  35944. _getWebGLTextureType(type: number): number;
  35945. /** @hidden */
  35946. _getInternalFormat(format: number): number;
  35947. /** @hidden */
  35948. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  35949. /** @hidden */
  35950. _getRGBAMultiSampleBufferFormat(type: number): number;
  35951. /** @hidden */
  35952. _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;
  35953. /**
  35954. * Loads a file from a url
  35955. * @param url url to load
  35956. * @param onSuccess callback called when the file successfully loads
  35957. * @param onProgress callback called while file is loading (if the server supports this mode)
  35958. * @param offlineProvider defines the offline provider for caching
  35959. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35960. * @param onError callback called when the file fails to load
  35961. * @returns a file request object
  35962. * @hidden
  35963. */
  35964. 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;
  35965. /**
  35966. * Reads pixels from the current frame buffer. Please note that this function can be slow
  35967. * @param x defines the x coordinate of the rectangle where pixels must be read
  35968. * @param y defines the y coordinate of the rectangle where pixels must be read
  35969. * @param width defines the width of the rectangle where pixels must be read
  35970. * @param height defines the height of the rectangle where pixels must be read
  35971. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  35972. * @returns a Uint8Array containing RGBA colors
  35973. */
  35974. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  35975. private static _isSupported;
  35976. /**
  35977. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  35978. * @returns true if the engine can be created
  35979. * @ignorenaming
  35980. */
  35981. static isSupported(): boolean;
  35982. /**
  35983. * Find the next highest power of two.
  35984. * @param x Number to start search from.
  35985. * @return Next highest power of two.
  35986. */
  35987. static CeilingPOT(x: number): number;
  35988. /**
  35989. * Find the next lowest power of two.
  35990. * @param x Number to start search from.
  35991. * @return Next lowest power of two.
  35992. */
  35993. static FloorPOT(x: number): number;
  35994. /**
  35995. * Find the nearest power of two.
  35996. * @param x Number to start search from.
  35997. * @return Next nearest power of two.
  35998. */
  35999. static NearestPOT(x: number): number;
  36000. /**
  36001. * Get the closest exponent of two
  36002. * @param value defines the value to approximate
  36003. * @param max defines the maximum value to return
  36004. * @param mode defines how to define the closest value
  36005. * @returns closest exponent of two of the given value
  36006. */
  36007. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36008. /**
  36009. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36010. * @param func - the function to be called
  36011. * @param requester - the object that will request the next frame. Falls back to window.
  36012. * @returns frame number
  36013. */
  36014. static QueueNewFrame(func: () => void, requester?: any): number;
  36015. /**
  36016. * Gets host document
  36017. * @returns the host document object
  36018. */
  36019. getHostDocument(): Nullable<Document>;
  36020. }
  36021. }
  36022. declare module BABYLON {
  36023. /**
  36024. * Class representing spherical harmonics coefficients to the 3rd degree
  36025. */
  36026. export class SphericalHarmonics {
  36027. /**
  36028. * Defines whether or not the harmonics have been prescaled for rendering.
  36029. */
  36030. preScaled: boolean;
  36031. /**
  36032. * The l0,0 coefficients of the spherical harmonics
  36033. */
  36034. l00: Vector3;
  36035. /**
  36036. * The l1,-1 coefficients of the spherical harmonics
  36037. */
  36038. l1_1: Vector3;
  36039. /**
  36040. * The l1,0 coefficients of the spherical harmonics
  36041. */
  36042. l10: Vector3;
  36043. /**
  36044. * The l1,1 coefficients of the spherical harmonics
  36045. */
  36046. l11: Vector3;
  36047. /**
  36048. * The l2,-2 coefficients of the spherical harmonics
  36049. */
  36050. l2_2: Vector3;
  36051. /**
  36052. * The l2,-1 coefficients of the spherical harmonics
  36053. */
  36054. l2_1: Vector3;
  36055. /**
  36056. * The l2,0 coefficients of the spherical harmonics
  36057. */
  36058. l20: Vector3;
  36059. /**
  36060. * The l2,1 coefficients of the spherical harmonics
  36061. */
  36062. l21: Vector3;
  36063. /**
  36064. * The l2,2 coefficients of the spherical harmonics
  36065. */
  36066. l22: Vector3;
  36067. /**
  36068. * Adds a light to the spherical harmonics
  36069. * @param direction the direction of the light
  36070. * @param color the color of the light
  36071. * @param deltaSolidAngle the delta solid angle of the light
  36072. */
  36073. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36074. /**
  36075. * Scales the spherical harmonics by the given amount
  36076. * @param scale the amount to scale
  36077. */
  36078. scaleInPlace(scale: number): void;
  36079. /**
  36080. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36081. *
  36082. * ```
  36083. * E_lm = A_l * L_lm
  36084. * ```
  36085. *
  36086. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36087. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36088. * the scaling factors are given in equation 9.
  36089. */
  36090. convertIncidentRadianceToIrradiance(): void;
  36091. /**
  36092. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36093. *
  36094. * ```
  36095. * L = (1/pi) * E * rho
  36096. * ```
  36097. *
  36098. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36099. */
  36100. convertIrradianceToLambertianRadiance(): void;
  36101. /**
  36102. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36103. * required operations at run time.
  36104. *
  36105. * This is simply done by scaling back the SH with Ylm constants parameter.
  36106. * The trigonometric part being applied by the shader at run time.
  36107. */
  36108. preScaleForRendering(): void;
  36109. /**
  36110. * Constructs a spherical harmonics from an array.
  36111. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36112. * @returns the spherical harmonics
  36113. */
  36114. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36115. /**
  36116. * Gets the spherical harmonics from polynomial
  36117. * @param polynomial the spherical polynomial
  36118. * @returns the spherical harmonics
  36119. */
  36120. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36121. }
  36122. /**
  36123. * Class representing spherical polynomial coefficients to the 3rd degree
  36124. */
  36125. export class SphericalPolynomial {
  36126. private _harmonics;
  36127. /**
  36128. * The spherical harmonics used to create the polynomials.
  36129. */
  36130. get preScaledHarmonics(): SphericalHarmonics;
  36131. /**
  36132. * The x coefficients of the spherical polynomial
  36133. */
  36134. x: Vector3;
  36135. /**
  36136. * The y coefficients of the spherical polynomial
  36137. */
  36138. y: Vector3;
  36139. /**
  36140. * The z coefficients of the spherical polynomial
  36141. */
  36142. z: Vector3;
  36143. /**
  36144. * The xx coefficients of the spherical polynomial
  36145. */
  36146. xx: Vector3;
  36147. /**
  36148. * The yy coefficients of the spherical polynomial
  36149. */
  36150. yy: Vector3;
  36151. /**
  36152. * The zz coefficients of the spherical polynomial
  36153. */
  36154. zz: Vector3;
  36155. /**
  36156. * The xy coefficients of the spherical polynomial
  36157. */
  36158. xy: Vector3;
  36159. /**
  36160. * The yz coefficients of the spherical polynomial
  36161. */
  36162. yz: Vector3;
  36163. /**
  36164. * The zx coefficients of the spherical polynomial
  36165. */
  36166. zx: Vector3;
  36167. /**
  36168. * Adds an ambient color to the spherical polynomial
  36169. * @param color the color to add
  36170. */
  36171. addAmbient(color: Color3): void;
  36172. /**
  36173. * Scales the spherical polynomial by the given amount
  36174. * @param scale the amount to scale
  36175. */
  36176. scaleInPlace(scale: number): void;
  36177. /**
  36178. * Gets the spherical polynomial from harmonics
  36179. * @param harmonics the spherical harmonics
  36180. * @returns the spherical polynomial
  36181. */
  36182. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36183. /**
  36184. * Constructs a spherical polynomial from an array.
  36185. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36186. * @returns the spherical polynomial
  36187. */
  36188. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36189. }
  36190. }
  36191. declare module BABYLON {
  36192. /**
  36193. * Defines the source of the internal texture
  36194. */
  36195. export enum InternalTextureSource {
  36196. /**
  36197. * The source of the texture data is unknown
  36198. */
  36199. Unknown = 0,
  36200. /**
  36201. * Texture data comes from an URL
  36202. */
  36203. Url = 1,
  36204. /**
  36205. * Texture data is only used for temporary storage
  36206. */
  36207. Temp = 2,
  36208. /**
  36209. * Texture data comes from raw data (ArrayBuffer)
  36210. */
  36211. Raw = 3,
  36212. /**
  36213. * Texture content is dynamic (video or dynamic texture)
  36214. */
  36215. Dynamic = 4,
  36216. /**
  36217. * Texture content is generated by rendering to it
  36218. */
  36219. RenderTarget = 5,
  36220. /**
  36221. * Texture content is part of a multi render target process
  36222. */
  36223. MultiRenderTarget = 6,
  36224. /**
  36225. * Texture data comes from a cube data file
  36226. */
  36227. Cube = 7,
  36228. /**
  36229. * Texture data comes from a raw cube data
  36230. */
  36231. CubeRaw = 8,
  36232. /**
  36233. * Texture data come from a prefiltered cube data file
  36234. */
  36235. CubePrefiltered = 9,
  36236. /**
  36237. * Texture content is raw 3D data
  36238. */
  36239. Raw3D = 10,
  36240. /**
  36241. * Texture content is raw 2D array data
  36242. */
  36243. Raw2DArray = 11,
  36244. /**
  36245. * Texture content is a depth texture
  36246. */
  36247. Depth = 12,
  36248. /**
  36249. * Texture data comes from a raw cube data encoded with RGBD
  36250. */
  36251. CubeRawRGBD = 13
  36252. }
  36253. /**
  36254. * Class used to store data associated with WebGL texture data for the engine
  36255. * This class should not be used directly
  36256. */
  36257. export class InternalTexture {
  36258. /** @hidden */
  36259. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36260. /**
  36261. * Defines if the texture is ready
  36262. */
  36263. isReady: boolean;
  36264. /**
  36265. * Defines if the texture is a cube texture
  36266. */
  36267. isCube: boolean;
  36268. /**
  36269. * Defines if the texture contains 3D data
  36270. */
  36271. is3D: boolean;
  36272. /**
  36273. * Defines if the texture contains 2D array data
  36274. */
  36275. is2DArray: boolean;
  36276. /**
  36277. * Defines if the texture contains multiview data
  36278. */
  36279. isMultiview: boolean;
  36280. /**
  36281. * Gets the URL used to load this texture
  36282. */
  36283. url: string;
  36284. /**
  36285. * Gets the sampling mode of the texture
  36286. */
  36287. samplingMode: number;
  36288. /**
  36289. * Gets a boolean indicating if the texture needs mipmaps generation
  36290. */
  36291. generateMipMaps: boolean;
  36292. /**
  36293. * Gets the number of samples used by the texture (WebGL2+ only)
  36294. */
  36295. samples: number;
  36296. /**
  36297. * Gets the type of the texture (int, float...)
  36298. */
  36299. type: number;
  36300. /**
  36301. * Gets the format of the texture (RGB, RGBA...)
  36302. */
  36303. format: number;
  36304. /**
  36305. * Observable called when the texture is loaded
  36306. */
  36307. onLoadedObservable: Observable<InternalTexture>;
  36308. /**
  36309. * Gets the width of the texture
  36310. */
  36311. width: number;
  36312. /**
  36313. * Gets the height of the texture
  36314. */
  36315. height: number;
  36316. /**
  36317. * Gets the depth of the texture
  36318. */
  36319. depth: number;
  36320. /**
  36321. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36322. */
  36323. baseWidth: number;
  36324. /**
  36325. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36326. */
  36327. baseHeight: number;
  36328. /**
  36329. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36330. */
  36331. baseDepth: number;
  36332. /**
  36333. * Gets a boolean indicating if the texture is inverted on Y axis
  36334. */
  36335. invertY: boolean;
  36336. /** @hidden */
  36337. _invertVScale: boolean;
  36338. /** @hidden */
  36339. _associatedChannel: number;
  36340. /** @hidden */
  36341. _source: InternalTextureSource;
  36342. /** @hidden */
  36343. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36344. /** @hidden */
  36345. _bufferView: Nullable<ArrayBufferView>;
  36346. /** @hidden */
  36347. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36348. /** @hidden */
  36349. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36350. /** @hidden */
  36351. _size: number;
  36352. /** @hidden */
  36353. _extension: string;
  36354. /** @hidden */
  36355. _files: Nullable<string[]>;
  36356. /** @hidden */
  36357. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36358. /** @hidden */
  36359. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36360. /** @hidden */
  36361. _framebuffer: Nullable<WebGLFramebuffer>;
  36362. /** @hidden */
  36363. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36364. /** @hidden */
  36365. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36366. /** @hidden */
  36367. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36368. /** @hidden */
  36369. _attachments: Nullable<number[]>;
  36370. /** @hidden */
  36371. _textureArray: Nullable<InternalTexture[]>;
  36372. /** @hidden */
  36373. _cachedCoordinatesMode: Nullable<number>;
  36374. /** @hidden */
  36375. _cachedWrapU: Nullable<number>;
  36376. /** @hidden */
  36377. _cachedWrapV: Nullable<number>;
  36378. /** @hidden */
  36379. _cachedWrapR: Nullable<number>;
  36380. /** @hidden */
  36381. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36382. /** @hidden */
  36383. _isDisabled: boolean;
  36384. /** @hidden */
  36385. _compression: Nullable<string>;
  36386. /** @hidden */
  36387. _generateStencilBuffer: boolean;
  36388. /** @hidden */
  36389. _generateDepthBuffer: boolean;
  36390. /** @hidden */
  36391. _comparisonFunction: number;
  36392. /** @hidden */
  36393. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36394. /** @hidden */
  36395. _lodGenerationScale: number;
  36396. /** @hidden */
  36397. _lodGenerationOffset: number;
  36398. /** @hidden */
  36399. _depthStencilTexture: Nullable<InternalTexture>;
  36400. /** @hidden */
  36401. _colorTextureArray: Nullable<WebGLTexture>;
  36402. /** @hidden */
  36403. _depthStencilTextureArray: Nullable<WebGLTexture>;
  36404. /** @hidden */
  36405. _lodTextureHigh: Nullable<BaseTexture>;
  36406. /** @hidden */
  36407. _lodTextureMid: Nullable<BaseTexture>;
  36408. /** @hidden */
  36409. _lodTextureLow: Nullable<BaseTexture>;
  36410. /** @hidden */
  36411. _isRGBD: boolean;
  36412. /** @hidden */
  36413. _linearSpecularLOD: boolean;
  36414. /** @hidden */
  36415. _irradianceTexture: Nullable<BaseTexture>;
  36416. /** @hidden */
  36417. _webGLTexture: Nullable<WebGLTexture>;
  36418. /** @hidden */
  36419. _references: number;
  36420. private _engine;
  36421. /**
  36422. * Gets the Engine the texture belongs to.
  36423. * @returns The babylon engine
  36424. */
  36425. getEngine(): ThinEngine;
  36426. /**
  36427. * Gets the data source type of the texture
  36428. */
  36429. get source(): InternalTextureSource;
  36430. /**
  36431. * Creates a new InternalTexture
  36432. * @param engine defines the engine to use
  36433. * @param source defines the type of data that will be used
  36434. * @param delayAllocation if the texture allocation should be delayed (default: false)
  36435. */
  36436. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  36437. /**
  36438. * Increments the number of references (ie. the number of Texture that point to it)
  36439. */
  36440. incrementReferences(): void;
  36441. /**
  36442. * Change the size of the texture (not the size of the content)
  36443. * @param width defines the new width
  36444. * @param height defines the new height
  36445. * @param depth defines the new depth (1 by default)
  36446. */
  36447. updateSize(width: int, height: int, depth?: int): void;
  36448. /** @hidden */
  36449. _rebuild(): void;
  36450. /** @hidden */
  36451. _swapAndDie(target: InternalTexture): void;
  36452. /**
  36453. * Dispose the current allocated resources
  36454. */
  36455. dispose(): void;
  36456. }
  36457. }
  36458. declare module BABYLON {
  36459. /**
  36460. * Class used to work with sound analyzer using fast fourier transform (FFT)
  36461. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36462. */
  36463. export class Analyser {
  36464. /**
  36465. * Gets or sets the smoothing
  36466. * @ignorenaming
  36467. */
  36468. SMOOTHING: number;
  36469. /**
  36470. * Gets or sets the FFT table size
  36471. * @ignorenaming
  36472. */
  36473. FFT_SIZE: number;
  36474. /**
  36475. * Gets or sets the bar graph amplitude
  36476. * @ignorenaming
  36477. */
  36478. BARGRAPHAMPLITUDE: number;
  36479. /**
  36480. * Gets or sets the position of the debug canvas
  36481. * @ignorenaming
  36482. */
  36483. DEBUGCANVASPOS: {
  36484. x: number;
  36485. y: number;
  36486. };
  36487. /**
  36488. * Gets or sets the debug canvas size
  36489. * @ignorenaming
  36490. */
  36491. DEBUGCANVASSIZE: {
  36492. width: number;
  36493. height: number;
  36494. };
  36495. private _byteFreqs;
  36496. private _byteTime;
  36497. private _floatFreqs;
  36498. private _webAudioAnalyser;
  36499. private _debugCanvas;
  36500. private _debugCanvasContext;
  36501. private _scene;
  36502. private _registerFunc;
  36503. private _audioEngine;
  36504. /**
  36505. * Creates a new analyser
  36506. * @param scene defines hosting scene
  36507. */
  36508. constructor(scene: Scene);
  36509. /**
  36510. * Get the number of data values you will have to play with for the visualization
  36511. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  36512. * @returns a number
  36513. */
  36514. getFrequencyBinCount(): number;
  36515. /**
  36516. * Gets the current frequency data as a byte array
  36517. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36518. * @returns a Uint8Array
  36519. */
  36520. getByteFrequencyData(): Uint8Array;
  36521. /**
  36522. * Gets the current waveform as a byte array
  36523. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  36524. * @returns a Uint8Array
  36525. */
  36526. getByteTimeDomainData(): Uint8Array;
  36527. /**
  36528. * Gets the current frequency data as a float array
  36529. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36530. * @returns a Float32Array
  36531. */
  36532. getFloatFrequencyData(): Float32Array;
  36533. /**
  36534. * Renders the debug canvas
  36535. */
  36536. drawDebugCanvas(): void;
  36537. /**
  36538. * Stops rendering the debug canvas and removes it
  36539. */
  36540. stopDebugCanvas(): void;
  36541. /**
  36542. * Connects two audio nodes
  36543. * @param inputAudioNode defines first node to connect
  36544. * @param outputAudioNode defines second node to connect
  36545. */
  36546. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  36547. /**
  36548. * Releases all associated resources
  36549. */
  36550. dispose(): void;
  36551. }
  36552. }
  36553. declare module BABYLON {
  36554. /**
  36555. * This represents an audio engine and it is responsible
  36556. * to play, synchronize and analyse sounds throughout the application.
  36557. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36558. */
  36559. export interface IAudioEngine extends IDisposable {
  36560. /**
  36561. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36562. */
  36563. readonly canUseWebAudio: boolean;
  36564. /**
  36565. * Gets the current AudioContext if available.
  36566. */
  36567. readonly audioContext: Nullable<AudioContext>;
  36568. /**
  36569. * The master gain node defines the global audio volume of your audio engine.
  36570. */
  36571. readonly masterGain: GainNode;
  36572. /**
  36573. * Gets whether or not mp3 are supported by your browser.
  36574. */
  36575. readonly isMP3supported: boolean;
  36576. /**
  36577. * Gets whether or not ogg are supported by your browser.
  36578. */
  36579. readonly isOGGsupported: boolean;
  36580. /**
  36581. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36582. * @ignoreNaming
  36583. */
  36584. WarnedWebAudioUnsupported: boolean;
  36585. /**
  36586. * Defines if the audio engine relies on a custom unlocked button.
  36587. * In this case, the embedded button will not be displayed.
  36588. */
  36589. useCustomUnlockedButton: boolean;
  36590. /**
  36591. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  36592. */
  36593. readonly unlocked: boolean;
  36594. /**
  36595. * Event raised when audio has been unlocked on the browser.
  36596. */
  36597. onAudioUnlockedObservable: Observable<AudioEngine>;
  36598. /**
  36599. * Event raised when audio has been locked on the browser.
  36600. */
  36601. onAudioLockedObservable: Observable<AudioEngine>;
  36602. /**
  36603. * Flags the audio engine in Locked state.
  36604. * This happens due to new browser policies preventing audio to autoplay.
  36605. */
  36606. lock(): void;
  36607. /**
  36608. * Unlocks the audio engine once a user action has been done on the dom.
  36609. * This is helpful to resume play once browser policies have been satisfied.
  36610. */
  36611. unlock(): void;
  36612. /**
  36613. * Gets the global volume sets on the master gain.
  36614. * @returns the global volume if set or -1 otherwise
  36615. */
  36616. getGlobalVolume(): number;
  36617. /**
  36618. * Sets the global volume of your experience (sets on the master gain).
  36619. * @param newVolume Defines the new global volume of the application
  36620. */
  36621. setGlobalVolume(newVolume: number): void;
  36622. /**
  36623. * Connect the audio engine to an audio analyser allowing some amazing
  36624. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36625. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36626. * @param analyser The analyser to connect to the engine
  36627. */
  36628. connectToAnalyser(analyser: Analyser): void;
  36629. }
  36630. /**
  36631. * This represents the default audio engine used in babylon.
  36632. * It is responsible to play, synchronize and analyse sounds throughout the application.
  36633. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36634. */
  36635. export class AudioEngine implements IAudioEngine {
  36636. private _audioContext;
  36637. private _audioContextInitialized;
  36638. private _muteButton;
  36639. private _hostElement;
  36640. /**
  36641. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36642. */
  36643. canUseWebAudio: boolean;
  36644. /**
  36645. * The master gain node defines the global audio volume of your audio engine.
  36646. */
  36647. masterGain: GainNode;
  36648. /**
  36649. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36650. * @ignoreNaming
  36651. */
  36652. WarnedWebAudioUnsupported: boolean;
  36653. /**
  36654. * Gets whether or not mp3 are supported by your browser.
  36655. */
  36656. isMP3supported: boolean;
  36657. /**
  36658. * Gets whether or not ogg are supported by your browser.
  36659. */
  36660. isOGGsupported: boolean;
  36661. /**
  36662. * Gets whether audio has been unlocked on the device.
  36663. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  36664. * a user interaction has happened.
  36665. */
  36666. unlocked: boolean;
  36667. /**
  36668. * Defines if the audio engine relies on a custom unlocked button.
  36669. * In this case, the embedded button will not be displayed.
  36670. */
  36671. useCustomUnlockedButton: boolean;
  36672. /**
  36673. * Event raised when audio has been unlocked on the browser.
  36674. */
  36675. onAudioUnlockedObservable: Observable<AudioEngine>;
  36676. /**
  36677. * Event raised when audio has been locked on the browser.
  36678. */
  36679. onAudioLockedObservable: Observable<AudioEngine>;
  36680. /**
  36681. * Gets the current AudioContext if available.
  36682. */
  36683. get audioContext(): Nullable<AudioContext>;
  36684. private _connectedAnalyser;
  36685. /**
  36686. * Instantiates a new audio engine.
  36687. *
  36688. * There should be only one per page as some browsers restrict the number
  36689. * of audio contexts you can create.
  36690. * @param hostElement defines the host element where to display the mute icon if necessary
  36691. */
  36692. constructor(hostElement?: Nullable<HTMLElement>);
  36693. /**
  36694. * Flags the audio engine in Locked state.
  36695. * This happens due to new browser policies preventing audio to autoplay.
  36696. */
  36697. lock(): void;
  36698. /**
  36699. * Unlocks the audio engine once a user action has been done on the dom.
  36700. * This is helpful to resume play once browser policies have been satisfied.
  36701. */
  36702. unlock(): void;
  36703. private _resumeAudioContext;
  36704. private _initializeAudioContext;
  36705. private _tryToRun;
  36706. private _triggerRunningState;
  36707. private _triggerSuspendedState;
  36708. private _displayMuteButton;
  36709. private _moveButtonToTopLeft;
  36710. private _onResize;
  36711. private _hideMuteButton;
  36712. /**
  36713. * Destroy and release the resources associated with the audio ccontext.
  36714. */
  36715. dispose(): void;
  36716. /**
  36717. * Gets the global volume sets on the master gain.
  36718. * @returns the global volume if set or -1 otherwise
  36719. */
  36720. getGlobalVolume(): number;
  36721. /**
  36722. * Sets the global volume of your experience (sets on the master gain).
  36723. * @param newVolume Defines the new global volume of the application
  36724. */
  36725. setGlobalVolume(newVolume: number): void;
  36726. /**
  36727. * Connect the audio engine to an audio analyser allowing some amazing
  36728. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36729. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36730. * @param analyser The analyser to connect to the engine
  36731. */
  36732. connectToAnalyser(analyser: Analyser): void;
  36733. }
  36734. }
  36735. declare module BABYLON {
  36736. /**
  36737. * Interface used to present a loading screen while loading a scene
  36738. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36739. */
  36740. export interface ILoadingScreen {
  36741. /**
  36742. * Function called to display the loading screen
  36743. */
  36744. displayLoadingUI: () => void;
  36745. /**
  36746. * Function called to hide the loading screen
  36747. */
  36748. hideLoadingUI: () => void;
  36749. /**
  36750. * Gets or sets the color to use for the background
  36751. */
  36752. loadingUIBackgroundColor: string;
  36753. /**
  36754. * Gets or sets the text to display while loading
  36755. */
  36756. loadingUIText: string;
  36757. }
  36758. /**
  36759. * Class used for the default loading screen
  36760. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36761. */
  36762. export class DefaultLoadingScreen implements ILoadingScreen {
  36763. private _renderingCanvas;
  36764. private _loadingText;
  36765. private _loadingDivBackgroundColor;
  36766. private _loadingDiv;
  36767. private _loadingTextDiv;
  36768. /** Gets or sets the logo url to use for the default loading screen */
  36769. static DefaultLogoUrl: string;
  36770. /** Gets or sets the spinner url to use for the default loading screen */
  36771. static DefaultSpinnerUrl: string;
  36772. /**
  36773. * Creates a new default loading screen
  36774. * @param _renderingCanvas defines the canvas used to render the scene
  36775. * @param _loadingText defines the default text to display
  36776. * @param _loadingDivBackgroundColor defines the default background color
  36777. */
  36778. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  36779. /**
  36780. * Function called to display the loading screen
  36781. */
  36782. displayLoadingUI(): void;
  36783. /**
  36784. * Function called to hide the loading screen
  36785. */
  36786. hideLoadingUI(): void;
  36787. /**
  36788. * Gets or sets the text to display while loading
  36789. */
  36790. set loadingUIText(text: string);
  36791. get loadingUIText(): string;
  36792. /**
  36793. * Gets or sets the color to use for the background
  36794. */
  36795. get loadingUIBackgroundColor(): string;
  36796. set loadingUIBackgroundColor(color: string);
  36797. private _resizeLoadingUI;
  36798. }
  36799. }
  36800. declare module BABYLON {
  36801. /**
  36802. * Interface for any object that can request an animation frame
  36803. */
  36804. export interface ICustomAnimationFrameRequester {
  36805. /**
  36806. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  36807. */
  36808. renderFunction?: Function;
  36809. /**
  36810. * Called to request the next frame to render to
  36811. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  36812. */
  36813. requestAnimationFrame: Function;
  36814. /**
  36815. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  36816. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  36817. */
  36818. requestID?: number;
  36819. }
  36820. }
  36821. declare module BABYLON {
  36822. /**
  36823. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  36824. */
  36825. export class PerformanceMonitor {
  36826. private _enabled;
  36827. private _rollingFrameTime;
  36828. private _lastFrameTimeMs;
  36829. /**
  36830. * constructor
  36831. * @param frameSampleSize The number of samples required to saturate the sliding window
  36832. */
  36833. constructor(frameSampleSize?: number);
  36834. /**
  36835. * Samples current frame
  36836. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  36837. */
  36838. sampleFrame(timeMs?: number): void;
  36839. /**
  36840. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  36841. */
  36842. get averageFrameTime(): number;
  36843. /**
  36844. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  36845. */
  36846. get averageFrameTimeVariance(): number;
  36847. /**
  36848. * Returns the frame time of the most recent frame
  36849. */
  36850. get instantaneousFrameTime(): number;
  36851. /**
  36852. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  36853. */
  36854. get averageFPS(): number;
  36855. /**
  36856. * Returns the average framerate in frames per second using the most recent frame time
  36857. */
  36858. get instantaneousFPS(): number;
  36859. /**
  36860. * Returns true if enough samples have been taken to completely fill the sliding window
  36861. */
  36862. get isSaturated(): boolean;
  36863. /**
  36864. * Enables contributions to the sliding window sample set
  36865. */
  36866. enable(): void;
  36867. /**
  36868. * Disables contributions to the sliding window sample set
  36869. * Samples will not be interpolated over the disabled period
  36870. */
  36871. disable(): void;
  36872. /**
  36873. * Returns true if sampling is enabled
  36874. */
  36875. get isEnabled(): boolean;
  36876. /**
  36877. * Resets performance monitor
  36878. */
  36879. reset(): void;
  36880. }
  36881. /**
  36882. * RollingAverage
  36883. *
  36884. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  36885. */
  36886. export class RollingAverage {
  36887. /**
  36888. * Current average
  36889. */
  36890. average: number;
  36891. /**
  36892. * Current variance
  36893. */
  36894. variance: number;
  36895. protected _samples: Array<number>;
  36896. protected _sampleCount: number;
  36897. protected _pos: number;
  36898. protected _m2: number;
  36899. /**
  36900. * constructor
  36901. * @param length The number of samples required to saturate the sliding window
  36902. */
  36903. constructor(length: number);
  36904. /**
  36905. * Adds a sample to the sample set
  36906. * @param v The sample value
  36907. */
  36908. add(v: number): void;
  36909. /**
  36910. * Returns previously added values or null if outside of history or outside the sliding window domain
  36911. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  36912. * @return Value previously recorded with add() or null if outside of range
  36913. */
  36914. history(i: number): number;
  36915. /**
  36916. * Returns true if enough samples have been taken to completely fill the sliding window
  36917. * @return true if sample-set saturated
  36918. */
  36919. isSaturated(): boolean;
  36920. /**
  36921. * Resets the rolling average (equivalent to 0 samples taken so far)
  36922. */
  36923. reset(): void;
  36924. /**
  36925. * Wraps a value around the sample range boundaries
  36926. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  36927. * @return Wrapped position in sample range
  36928. */
  36929. protected _wrapPosition(i: number): number;
  36930. }
  36931. }
  36932. declare module BABYLON {
  36933. /**
  36934. * This class is used to track a performance counter which is number based.
  36935. * The user has access to many properties which give statistics of different nature.
  36936. *
  36937. * The implementer can track two kinds of Performance Counter: time and count.
  36938. * 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.
  36939. * 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.
  36940. */
  36941. export class PerfCounter {
  36942. /**
  36943. * Gets or sets a global boolean to turn on and off all the counters
  36944. */
  36945. static Enabled: boolean;
  36946. /**
  36947. * Returns the smallest value ever
  36948. */
  36949. get min(): number;
  36950. /**
  36951. * Returns the biggest value ever
  36952. */
  36953. get max(): number;
  36954. /**
  36955. * Returns the average value since the performance counter is running
  36956. */
  36957. get average(): number;
  36958. /**
  36959. * Returns the average value of the last second the counter was monitored
  36960. */
  36961. get lastSecAverage(): number;
  36962. /**
  36963. * Returns the current value
  36964. */
  36965. get current(): number;
  36966. /**
  36967. * Gets the accumulated total
  36968. */
  36969. get total(): number;
  36970. /**
  36971. * Gets the total value count
  36972. */
  36973. get count(): number;
  36974. /**
  36975. * Creates a new counter
  36976. */
  36977. constructor();
  36978. /**
  36979. * Call this method to start monitoring a new frame.
  36980. * 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.
  36981. */
  36982. fetchNewFrame(): void;
  36983. /**
  36984. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  36985. * @param newCount the count value to add to the monitored count
  36986. * @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.
  36987. */
  36988. addCount(newCount: number, fetchResult: boolean): void;
  36989. /**
  36990. * Start monitoring this performance counter
  36991. */
  36992. beginMonitoring(): void;
  36993. /**
  36994. * Compute the time lapsed since the previous beginMonitoring() call.
  36995. * @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
  36996. */
  36997. endMonitoring(newFrame?: boolean): void;
  36998. private _fetchResult;
  36999. private _startMonitoringTime;
  37000. private _min;
  37001. private _max;
  37002. private _average;
  37003. private _current;
  37004. private _totalValueCount;
  37005. private _totalAccumulated;
  37006. private _lastSecAverage;
  37007. private _lastSecAccumulated;
  37008. private _lastSecTime;
  37009. private _lastSecValueCount;
  37010. }
  37011. }
  37012. declare module BABYLON {
  37013. interface ThinEngine {
  37014. /**
  37015. * Sets alpha constants used by some alpha blending modes
  37016. * @param r defines the red component
  37017. * @param g defines the green component
  37018. * @param b defines the blue component
  37019. * @param a defines the alpha component
  37020. */
  37021. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  37022. /**
  37023. * Sets the current alpha mode
  37024. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  37025. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  37026. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37027. */
  37028. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  37029. /**
  37030. * Gets the current alpha mode
  37031. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37032. * @returns the current alpha mode
  37033. */
  37034. getAlphaMode(): number;
  37035. /**
  37036. * Sets the current alpha equation
  37037. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  37038. */
  37039. setAlphaEquation(equation: number): void;
  37040. /**
  37041. * Gets the current alpha equation.
  37042. * @returns the current alpha equation
  37043. */
  37044. getAlphaEquation(): number;
  37045. }
  37046. }
  37047. declare module BABYLON {
  37048. interface ThinEngine {
  37049. /** @hidden */
  37050. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37051. }
  37052. }
  37053. declare module BABYLON {
  37054. /**
  37055. * Defines the interface used by display changed events
  37056. */
  37057. export interface IDisplayChangedEventArgs {
  37058. /** Gets the vrDisplay object (if any) */
  37059. vrDisplay: Nullable<any>;
  37060. /** Gets a boolean indicating if webVR is supported */
  37061. vrSupported: boolean;
  37062. }
  37063. /**
  37064. * Defines the interface used by objects containing a viewport (like a camera)
  37065. */
  37066. interface IViewportOwnerLike {
  37067. /**
  37068. * Gets or sets the viewport
  37069. */
  37070. viewport: IViewportLike;
  37071. }
  37072. /**
  37073. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37074. */
  37075. export class Engine extends ThinEngine {
  37076. /** Defines that alpha blending is disabled */
  37077. static readonly ALPHA_DISABLE: number;
  37078. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37079. static readonly ALPHA_ADD: number;
  37080. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37081. static readonly ALPHA_COMBINE: number;
  37082. /** Defines that alpha blending to DEST - SRC * DEST */
  37083. static readonly ALPHA_SUBTRACT: number;
  37084. /** Defines that alpha blending to SRC * DEST */
  37085. static readonly ALPHA_MULTIPLY: number;
  37086. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37087. static readonly ALPHA_MAXIMIZED: number;
  37088. /** Defines that alpha blending to SRC + DEST */
  37089. static readonly ALPHA_ONEONE: number;
  37090. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37091. static readonly ALPHA_PREMULTIPLIED: number;
  37092. /**
  37093. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37094. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37095. */
  37096. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37097. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37098. static readonly ALPHA_INTERPOLATE: number;
  37099. /**
  37100. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37101. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37102. */
  37103. static readonly ALPHA_SCREENMODE: number;
  37104. /** Defines that the ressource is not delayed*/
  37105. static readonly DELAYLOADSTATE_NONE: number;
  37106. /** Defines that the ressource was successfully delay loaded */
  37107. static readonly DELAYLOADSTATE_LOADED: number;
  37108. /** Defines that the ressource is currently delay loading */
  37109. static readonly DELAYLOADSTATE_LOADING: number;
  37110. /** Defines that the ressource is delayed and has not started loading */
  37111. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37112. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37113. static readonly NEVER: number;
  37114. /** 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 */
  37115. static readonly ALWAYS: number;
  37116. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37117. static readonly LESS: number;
  37118. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37119. static readonly EQUAL: number;
  37120. /** 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 */
  37121. static readonly LEQUAL: number;
  37122. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37123. static readonly GREATER: number;
  37124. /** 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 */
  37125. static readonly GEQUAL: number;
  37126. /** 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 */
  37127. static readonly NOTEQUAL: number;
  37128. /** Passed to stencilOperation to specify that stencil value must be kept */
  37129. static readonly KEEP: number;
  37130. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37131. static readonly REPLACE: number;
  37132. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37133. static readonly INCR: number;
  37134. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37135. static readonly DECR: number;
  37136. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37137. static readonly INVERT: number;
  37138. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37139. static readonly INCR_WRAP: number;
  37140. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37141. static readonly DECR_WRAP: number;
  37142. /** Texture is not repeating outside of 0..1 UVs */
  37143. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37144. /** Texture is repeating outside of 0..1 UVs */
  37145. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37146. /** Texture is repeating and mirrored */
  37147. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37148. /** ALPHA */
  37149. static readonly TEXTUREFORMAT_ALPHA: number;
  37150. /** LUMINANCE */
  37151. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37152. /** LUMINANCE_ALPHA */
  37153. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37154. /** RGB */
  37155. static readonly TEXTUREFORMAT_RGB: number;
  37156. /** RGBA */
  37157. static readonly TEXTUREFORMAT_RGBA: number;
  37158. /** RED */
  37159. static readonly TEXTUREFORMAT_RED: number;
  37160. /** RED (2nd reference) */
  37161. static readonly TEXTUREFORMAT_R: number;
  37162. /** RG */
  37163. static readonly TEXTUREFORMAT_RG: number;
  37164. /** RED_INTEGER */
  37165. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37166. /** RED_INTEGER (2nd reference) */
  37167. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37168. /** RG_INTEGER */
  37169. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37170. /** RGB_INTEGER */
  37171. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37172. /** RGBA_INTEGER */
  37173. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37174. /** UNSIGNED_BYTE */
  37175. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37176. /** UNSIGNED_BYTE (2nd reference) */
  37177. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37178. /** FLOAT */
  37179. static readonly TEXTURETYPE_FLOAT: number;
  37180. /** HALF_FLOAT */
  37181. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37182. /** BYTE */
  37183. static readonly TEXTURETYPE_BYTE: number;
  37184. /** SHORT */
  37185. static readonly TEXTURETYPE_SHORT: number;
  37186. /** UNSIGNED_SHORT */
  37187. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37188. /** INT */
  37189. static readonly TEXTURETYPE_INT: number;
  37190. /** UNSIGNED_INT */
  37191. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37192. /** UNSIGNED_SHORT_4_4_4_4 */
  37193. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37194. /** UNSIGNED_SHORT_5_5_5_1 */
  37195. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37196. /** UNSIGNED_SHORT_5_6_5 */
  37197. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37198. /** UNSIGNED_INT_2_10_10_10_REV */
  37199. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37200. /** UNSIGNED_INT_24_8 */
  37201. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37202. /** UNSIGNED_INT_10F_11F_11F_REV */
  37203. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37204. /** UNSIGNED_INT_5_9_9_9_REV */
  37205. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37206. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37207. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37208. /** nearest is mag = nearest and min = nearest and mip = linear */
  37209. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37210. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37211. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37212. /** Trilinear is mag = linear and min = linear and mip = linear */
  37213. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37214. /** nearest is mag = nearest and min = nearest and mip = linear */
  37215. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37216. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37217. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37218. /** Trilinear is mag = linear and min = linear and mip = linear */
  37219. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37220. /** mag = nearest and min = nearest and mip = nearest */
  37221. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37222. /** mag = nearest and min = linear and mip = nearest */
  37223. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37224. /** mag = nearest and min = linear and mip = linear */
  37225. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37226. /** mag = nearest and min = linear and mip = none */
  37227. static readonly TEXTURE_NEAREST_LINEAR: number;
  37228. /** mag = nearest and min = nearest and mip = none */
  37229. static readonly TEXTURE_NEAREST_NEAREST: number;
  37230. /** mag = linear and min = nearest and mip = nearest */
  37231. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37232. /** mag = linear and min = nearest and mip = linear */
  37233. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37234. /** mag = linear and min = linear and mip = none */
  37235. static readonly TEXTURE_LINEAR_LINEAR: number;
  37236. /** mag = linear and min = nearest and mip = none */
  37237. static readonly TEXTURE_LINEAR_NEAREST: number;
  37238. /** Explicit coordinates mode */
  37239. static readonly TEXTURE_EXPLICIT_MODE: number;
  37240. /** Spherical coordinates mode */
  37241. static readonly TEXTURE_SPHERICAL_MODE: number;
  37242. /** Planar coordinates mode */
  37243. static readonly TEXTURE_PLANAR_MODE: number;
  37244. /** Cubic coordinates mode */
  37245. static readonly TEXTURE_CUBIC_MODE: number;
  37246. /** Projection coordinates mode */
  37247. static readonly TEXTURE_PROJECTION_MODE: number;
  37248. /** Skybox coordinates mode */
  37249. static readonly TEXTURE_SKYBOX_MODE: number;
  37250. /** Inverse Cubic coordinates mode */
  37251. static readonly TEXTURE_INVCUBIC_MODE: number;
  37252. /** Equirectangular coordinates mode */
  37253. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37254. /** Equirectangular Fixed coordinates mode */
  37255. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37256. /** Equirectangular Fixed Mirrored coordinates mode */
  37257. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37258. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37259. static readonly SCALEMODE_FLOOR: number;
  37260. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37261. static readonly SCALEMODE_NEAREST: number;
  37262. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37263. static readonly SCALEMODE_CEILING: number;
  37264. /**
  37265. * Returns the current npm package of the sdk
  37266. */
  37267. static get NpmPackage(): string;
  37268. /**
  37269. * Returns the current version of the framework
  37270. */
  37271. static get Version(): string;
  37272. /** Gets the list of created engines */
  37273. static get Instances(): Engine[];
  37274. /**
  37275. * Gets the latest created engine
  37276. */
  37277. static get LastCreatedEngine(): Nullable<Engine>;
  37278. /**
  37279. * Gets the latest created scene
  37280. */
  37281. static get LastCreatedScene(): Nullable<Scene>;
  37282. /**
  37283. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37284. * @param flag defines which part of the materials must be marked as dirty
  37285. * @param predicate defines a predicate used to filter which materials should be affected
  37286. */
  37287. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37288. /**
  37289. * Method called to create the default loading screen.
  37290. * This can be overriden in your own app.
  37291. * @param canvas The rendering canvas element
  37292. * @returns The loading screen
  37293. */
  37294. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37295. /**
  37296. * Method called to create the default rescale post process on each engine.
  37297. */
  37298. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37299. /**
  37300. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37301. **/
  37302. enableOfflineSupport: boolean;
  37303. /**
  37304. * 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)
  37305. **/
  37306. disableManifestCheck: boolean;
  37307. /**
  37308. * Gets the list of created scenes
  37309. */
  37310. scenes: Scene[];
  37311. /**
  37312. * Event raised when a new scene is created
  37313. */
  37314. onNewSceneAddedObservable: Observable<Scene>;
  37315. /**
  37316. * Gets the list of created postprocesses
  37317. */
  37318. postProcesses: PostProcess[];
  37319. /**
  37320. * Gets a boolean indicating if the pointer is currently locked
  37321. */
  37322. isPointerLock: boolean;
  37323. /**
  37324. * Observable event triggered each time the rendering canvas is resized
  37325. */
  37326. onResizeObservable: Observable<Engine>;
  37327. /**
  37328. * Observable event triggered each time the canvas loses focus
  37329. */
  37330. onCanvasBlurObservable: Observable<Engine>;
  37331. /**
  37332. * Observable event triggered each time the canvas gains focus
  37333. */
  37334. onCanvasFocusObservable: Observable<Engine>;
  37335. /**
  37336. * Observable event triggered each time the canvas receives pointerout event
  37337. */
  37338. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37339. /**
  37340. * Observable raised when the engine begins a new frame
  37341. */
  37342. onBeginFrameObservable: Observable<Engine>;
  37343. /**
  37344. * If set, will be used to request the next animation frame for the render loop
  37345. */
  37346. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37347. /**
  37348. * Observable raised when the engine ends the current frame
  37349. */
  37350. onEndFrameObservable: Observable<Engine>;
  37351. /**
  37352. * Observable raised when the engine is about to compile a shader
  37353. */
  37354. onBeforeShaderCompilationObservable: Observable<Engine>;
  37355. /**
  37356. * Observable raised when the engine has jsut compiled a shader
  37357. */
  37358. onAfterShaderCompilationObservable: Observable<Engine>;
  37359. /**
  37360. * Gets the audio engine
  37361. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37362. * @ignorenaming
  37363. */
  37364. static audioEngine: IAudioEngine;
  37365. /**
  37366. * Default AudioEngine factory responsible of creating the Audio Engine.
  37367. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37368. */
  37369. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37370. /**
  37371. * Default offline support factory responsible of creating a tool used to store data locally.
  37372. * By default, this will create a Database object if the workload has been embedded.
  37373. */
  37374. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  37375. private _loadingScreen;
  37376. private _pointerLockRequested;
  37377. private _rescalePostProcess;
  37378. private _deterministicLockstep;
  37379. private _lockstepMaxSteps;
  37380. private _timeStep;
  37381. protected get _supportsHardwareTextureRescaling(): boolean;
  37382. private _fps;
  37383. private _deltaTime;
  37384. /** @hidden */
  37385. _drawCalls: PerfCounter;
  37386. /** 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 */
  37387. canvasTabIndex: number;
  37388. /**
  37389. * Turn this value on if you want to pause FPS computation when in background
  37390. */
  37391. disablePerformanceMonitorInBackground: boolean;
  37392. private _performanceMonitor;
  37393. /**
  37394. * Gets the performance monitor attached to this engine
  37395. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  37396. */
  37397. get performanceMonitor(): PerformanceMonitor;
  37398. private _onFocus;
  37399. private _onBlur;
  37400. private _onCanvasPointerOut;
  37401. private _onCanvasBlur;
  37402. private _onCanvasFocus;
  37403. private _onFullscreenChange;
  37404. private _onPointerLockChange;
  37405. /**
  37406. * Gets the HTML element used to attach event listeners
  37407. * @returns a HTML element
  37408. */
  37409. getInputElement(): Nullable<HTMLElement>;
  37410. /**
  37411. * Creates a new engine
  37412. * @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
  37413. * @param antialias defines enable antialiasing (default: false)
  37414. * @param options defines further options to be sent to the getContext() function
  37415. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  37416. */
  37417. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  37418. /**
  37419. * Gets current aspect ratio
  37420. * @param viewportOwner defines the camera to use to get the aspect ratio
  37421. * @param useScreen defines if screen size must be used (or the current render target if any)
  37422. * @returns a number defining the aspect ratio
  37423. */
  37424. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  37425. /**
  37426. * Gets current screen aspect ratio
  37427. * @returns a number defining the aspect ratio
  37428. */
  37429. getScreenAspectRatio(): number;
  37430. /**
  37431. * Gets the client rect of the HTML canvas attached with the current webGL context
  37432. * @returns a client rectanglee
  37433. */
  37434. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  37435. /**
  37436. * Gets the client rect of the HTML element used for events
  37437. * @returns a client rectanglee
  37438. */
  37439. getInputElementClientRect(): Nullable<ClientRect>;
  37440. /**
  37441. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  37442. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37443. * @returns true if engine is in deterministic lock step mode
  37444. */
  37445. isDeterministicLockStep(): boolean;
  37446. /**
  37447. * Gets the max steps when engine is running in deterministic lock step
  37448. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37449. * @returns the max steps
  37450. */
  37451. getLockstepMaxSteps(): number;
  37452. /**
  37453. * Returns the time in ms between steps when using deterministic lock step.
  37454. * @returns time step in (ms)
  37455. */
  37456. getTimeStep(): number;
  37457. /**
  37458. * Force the mipmap generation for the given render target texture
  37459. * @param texture defines the render target texture to use
  37460. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  37461. */
  37462. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  37463. /** States */
  37464. /**
  37465. * Set various states to the webGL context
  37466. * @param culling defines backface culling state
  37467. * @param zOffset defines the value to apply to zOffset (0 by default)
  37468. * @param force defines if states must be applied even if cache is up to date
  37469. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  37470. */
  37471. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  37472. /**
  37473. * Set the z offset to apply to current rendering
  37474. * @param value defines the offset to apply
  37475. */
  37476. setZOffset(value: number): void;
  37477. /**
  37478. * Gets the current value of the zOffset
  37479. * @returns the current zOffset state
  37480. */
  37481. getZOffset(): number;
  37482. /**
  37483. * Enable or disable depth buffering
  37484. * @param enable defines the state to set
  37485. */
  37486. setDepthBuffer(enable: boolean): void;
  37487. /**
  37488. * Gets a boolean indicating if depth writing is enabled
  37489. * @returns the current depth writing state
  37490. */
  37491. getDepthWrite(): boolean;
  37492. /**
  37493. * Enable or disable depth writing
  37494. * @param enable defines the state to set
  37495. */
  37496. setDepthWrite(enable: boolean): void;
  37497. /**
  37498. * Gets a boolean indicating if stencil buffer is enabled
  37499. * @returns the current stencil buffer state
  37500. */
  37501. getStencilBuffer(): boolean;
  37502. /**
  37503. * Enable or disable the stencil buffer
  37504. * @param enable defines if the stencil buffer must be enabled or disabled
  37505. */
  37506. setStencilBuffer(enable: boolean): void;
  37507. /**
  37508. * Gets the current stencil mask
  37509. * @returns a number defining the new stencil mask to use
  37510. */
  37511. getStencilMask(): number;
  37512. /**
  37513. * Sets the current stencil mask
  37514. * @param mask defines the new stencil mask to use
  37515. */
  37516. setStencilMask(mask: number): void;
  37517. /**
  37518. * Gets the current stencil function
  37519. * @returns a number defining the stencil function to use
  37520. */
  37521. getStencilFunction(): number;
  37522. /**
  37523. * Gets the current stencil reference value
  37524. * @returns a number defining the stencil reference value to use
  37525. */
  37526. getStencilFunctionReference(): number;
  37527. /**
  37528. * Gets the current stencil mask
  37529. * @returns a number defining the stencil mask to use
  37530. */
  37531. getStencilFunctionMask(): number;
  37532. /**
  37533. * Sets the current stencil function
  37534. * @param stencilFunc defines the new stencil function to use
  37535. */
  37536. setStencilFunction(stencilFunc: number): void;
  37537. /**
  37538. * Sets the current stencil reference
  37539. * @param reference defines the new stencil reference to use
  37540. */
  37541. setStencilFunctionReference(reference: number): void;
  37542. /**
  37543. * Sets the current stencil mask
  37544. * @param mask defines the new stencil mask to use
  37545. */
  37546. setStencilFunctionMask(mask: number): void;
  37547. /**
  37548. * Gets the current stencil operation when stencil fails
  37549. * @returns a number defining stencil operation to use when stencil fails
  37550. */
  37551. getStencilOperationFail(): number;
  37552. /**
  37553. * Gets the current stencil operation when depth fails
  37554. * @returns a number defining stencil operation to use when depth fails
  37555. */
  37556. getStencilOperationDepthFail(): number;
  37557. /**
  37558. * Gets the current stencil operation when stencil passes
  37559. * @returns a number defining stencil operation to use when stencil passes
  37560. */
  37561. getStencilOperationPass(): number;
  37562. /**
  37563. * Sets the stencil operation to use when stencil fails
  37564. * @param operation defines the stencil operation to use when stencil fails
  37565. */
  37566. setStencilOperationFail(operation: number): void;
  37567. /**
  37568. * Sets the stencil operation to use when depth fails
  37569. * @param operation defines the stencil operation to use when depth fails
  37570. */
  37571. setStencilOperationDepthFail(operation: number): void;
  37572. /**
  37573. * Sets the stencil operation to use when stencil passes
  37574. * @param operation defines the stencil operation to use when stencil passes
  37575. */
  37576. setStencilOperationPass(operation: number): void;
  37577. /**
  37578. * Sets a boolean indicating if the dithering state is enabled or disabled
  37579. * @param value defines the dithering state
  37580. */
  37581. setDitheringState(value: boolean): void;
  37582. /**
  37583. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  37584. * @param value defines the rasterizer state
  37585. */
  37586. setRasterizerState(value: boolean): void;
  37587. /**
  37588. * Gets the current depth function
  37589. * @returns a number defining the depth function
  37590. */
  37591. getDepthFunction(): Nullable<number>;
  37592. /**
  37593. * Sets the current depth function
  37594. * @param depthFunc defines the function to use
  37595. */
  37596. setDepthFunction(depthFunc: number): void;
  37597. /**
  37598. * Sets the current depth function to GREATER
  37599. */
  37600. setDepthFunctionToGreater(): void;
  37601. /**
  37602. * Sets the current depth function to GEQUAL
  37603. */
  37604. setDepthFunctionToGreaterOrEqual(): void;
  37605. /**
  37606. * Sets the current depth function to LESS
  37607. */
  37608. setDepthFunctionToLess(): void;
  37609. /**
  37610. * Sets the current depth function to LEQUAL
  37611. */
  37612. setDepthFunctionToLessOrEqual(): void;
  37613. private _cachedStencilBuffer;
  37614. private _cachedStencilFunction;
  37615. private _cachedStencilMask;
  37616. private _cachedStencilOperationPass;
  37617. private _cachedStencilOperationFail;
  37618. private _cachedStencilOperationDepthFail;
  37619. private _cachedStencilReference;
  37620. /**
  37621. * Caches the the state of the stencil buffer
  37622. */
  37623. cacheStencilState(): void;
  37624. /**
  37625. * Restores the state of the stencil buffer
  37626. */
  37627. restoreStencilState(): void;
  37628. /**
  37629. * Directly set the WebGL Viewport
  37630. * @param x defines the x coordinate of the viewport (in screen space)
  37631. * @param y defines the y coordinate of the viewport (in screen space)
  37632. * @param width defines the width of the viewport (in screen space)
  37633. * @param height defines the height of the viewport (in screen space)
  37634. * @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
  37635. */
  37636. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  37637. /**
  37638. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  37639. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37640. * @param y defines the y-coordinate of the corner of the clear rectangle
  37641. * @param width defines the width of the clear rectangle
  37642. * @param height defines the height of the clear rectangle
  37643. * @param clearColor defines the clear color
  37644. */
  37645. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  37646. /**
  37647. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  37648. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37649. * @param y defines the y-coordinate of the corner of the clear rectangle
  37650. * @param width defines the width of the clear rectangle
  37651. * @param height defines the height of the clear rectangle
  37652. */
  37653. enableScissor(x: number, y: number, width: number, height: number): void;
  37654. /**
  37655. * Disable previously set scissor test rectangle
  37656. */
  37657. disableScissor(): void;
  37658. protected _reportDrawCall(): void;
  37659. /**
  37660. * Initializes a webVR display and starts listening to display change events
  37661. * The onVRDisplayChangedObservable will be notified upon these changes
  37662. * @returns The onVRDisplayChangedObservable
  37663. */
  37664. initWebVR(): Observable<IDisplayChangedEventArgs>;
  37665. /** @hidden */
  37666. _prepareVRComponent(): void;
  37667. /** @hidden */
  37668. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  37669. /** @hidden */
  37670. _submitVRFrame(): void;
  37671. /**
  37672. * Call this function to leave webVR mode
  37673. * Will do nothing if webVR is not supported or if there is no webVR device
  37674. * @see https://doc.babylonjs.com/how_to/webvr_camera
  37675. */
  37676. disableVR(): void;
  37677. /**
  37678. * Gets a boolean indicating that the system is in VR mode and is presenting
  37679. * @returns true if VR mode is engaged
  37680. */
  37681. isVRPresenting(): boolean;
  37682. /** @hidden */
  37683. _requestVRFrame(): void;
  37684. /** @hidden */
  37685. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37686. /**
  37687. * Gets the source code of the vertex shader associated with a specific webGL program
  37688. * @param program defines the program to use
  37689. * @returns a string containing the source code of the vertex shader associated with the program
  37690. */
  37691. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  37692. /**
  37693. * Gets the source code of the fragment shader associated with a specific webGL program
  37694. * @param program defines the program to use
  37695. * @returns a string containing the source code of the fragment shader associated with the program
  37696. */
  37697. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  37698. /**
  37699. * Sets a depth stencil texture from a render target to the according uniform.
  37700. * @param channel The texture channel
  37701. * @param uniform The uniform to set
  37702. * @param texture The render target texture containing the depth stencil texture to apply
  37703. */
  37704. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  37705. /**
  37706. * Sets a texture to the webGL context from a postprocess
  37707. * @param channel defines the channel to use
  37708. * @param postProcess defines the source postprocess
  37709. */
  37710. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  37711. /**
  37712. * Binds the output of the passed in post process to the texture channel specified
  37713. * @param channel The channel the texture should be bound to
  37714. * @param postProcess The post process which's output should be bound
  37715. */
  37716. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  37717. protected _rebuildBuffers(): void;
  37718. /** @hidden */
  37719. _renderFrame(): void;
  37720. _renderLoop(): void;
  37721. /** @hidden */
  37722. _renderViews(): boolean;
  37723. /**
  37724. * Toggle full screen mode
  37725. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37726. */
  37727. switchFullscreen(requestPointerLock: boolean): void;
  37728. /**
  37729. * Enters full screen mode
  37730. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37731. */
  37732. enterFullscreen(requestPointerLock: boolean): void;
  37733. /**
  37734. * Exits full screen mode
  37735. */
  37736. exitFullscreen(): void;
  37737. /**
  37738. * Enters Pointerlock mode
  37739. */
  37740. enterPointerlock(): void;
  37741. /**
  37742. * Exits Pointerlock mode
  37743. */
  37744. exitPointerlock(): void;
  37745. /**
  37746. * Begin a new frame
  37747. */
  37748. beginFrame(): void;
  37749. /**
  37750. * Enf the current frame
  37751. */
  37752. endFrame(): void;
  37753. resize(): void;
  37754. /**
  37755. * Force a specific size of the canvas
  37756. * @param width defines the new canvas' width
  37757. * @param height defines the new canvas' height
  37758. * @returns true if the size was changed
  37759. */
  37760. setSize(width: number, height: number): boolean;
  37761. /**
  37762. * Updates a dynamic vertex buffer.
  37763. * @param vertexBuffer the vertex buffer to update
  37764. * @param data the data used to update the vertex buffer
  37765. * @param byteOffset the byte offset of the data
  37766. * @param byteLength the byte length of the data
  37767. */
  37768. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  37769. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37770. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37771. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37772. _releaseTexture(texture: InternalTexture): void;
  37773. /**
  37774. * @hidden
  37775. * Rescales a texture
  37776. * @param source input texutre
  37777. * @param destination destination texture
  37778. * @param scene scene to use to render the resize
  37779. * @param internalFormat format to use when resizing
  37780. * @param onComplete callback to be called when resize has completed
  37781. */
  37782. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37783. /**
  37784. * Gets the current framerate
  37785. * @returns a number representing the framerate
  37786. */
  37787. getFps(): number;
  37788. /**
  37789. * Gets the time spent between current and previous frame
  37790. * @returns a number representing the delta time in ms
  37791. */
  37792. getDeltaTime(): number;
  37793. private _measureFps;
  37794. /** @hidden */
  37795. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  37796. /**
  37797. * Update a dynamic index buffer
  37798. * @param indexBuffer defines the target index buffer
  37799. * @param indices defines the data to update
  37800. * @param offset defines the offset in the target index buffer where update should start
  37801. */
  37802. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  37803. /**
  37804. * Updates the sample count of a render target texture
  37805. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  37806. * @param texture defines the texture to update
  37807. * @param samples defines the sample count to set
  37808. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  37809. */
  37810. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  37811. /**
  37812. * Updates a depth texture Comparison Mode and Function.
  37813. * If the comparison Function is equal to 0, the mode will be set to none.
  37814. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  37815. * @param texture The texture to set the comparison function for
  37816. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  37817. */
  37818. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  37819. /**
  37820. * Creates a webGL buffer to use with instanciation
  37821. * @param capacity defines the size of the buffer
  37822. * @returns the webGL buffer
  37823. */
  37824. createInstancesBuffer(capacity: number): DataBuffer;
  37825. /**
  37826. * Delete a webGL buffer used with instanciation
  37827. * @param buffer defines the webGL buffer to delete
  37828. */
  37829. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  37830. private _clientWaitAsync;
  37831. /** @hidden */
  37832. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  37833. dispose(): void;
  37834. private _disableTouchAction;
  37835. /**
  37836. * Display the loading screen
  37837. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37838. */
  37839. displayLoadingUI(): void;
  37840. /**
  37841. * Hide the loading screen
  37842. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37843. */
  37844. hideLoadingUI(): void;
  37845. /**
  37846. * Gets the current loading screen object
  37847. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37848. */
  37849. get loadingScreen(): ILoadingScreen;
  37850. /**
  37851. * Sets the current loading screen object
  37852. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37853. */
  37854. set loadingScreen(loadingScreen: ILoadingScreen);
  37855. /**
  37856. * Sets the current loading screen text
  37857. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37858. */
  37859. set loadingUIText(text: string);
  37860. /**
  37861. * Sets the current loading screen background color
  37862. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37863. */
  37864. set loadingUIBackgroundColor(color: string);
  37865. /** Pointerlock and fullscreen */
  37866. /**
  37867. * Ask the browser to promote the current element to pointerlock mode
  37868. * @param element defines the DOM element to promote
  37869. */
  37870. static _RequestPointerlock(element: HTMLElement): void;
  37871. /**
  37872. * Asks the browser to exit pointerlock mode
  37873. */
  37874. static _ExitPointerlock(): void;
  37875. /**
  37876. * Ask the browser to promote the current element to fullscreen rendering mode
  37877. * @param element defines the DOM element to promote
  37878. */
  37879. static _RequestFullscreen(element: HTMLElement): void;
  37880. /**
  37881. * Asks the browser to exit fullscreen mode
  37882. */
  37883. static _ExitFullscreen(): void;
  37884. }
  37885. }
  37886. declare module BABYLON {
  37887. /**
  37888. * The engine store class is responsible to hold all the instances of Engine and Scene created
  37889. * during the life time of the application.
  37890. */
  37891. export class EngineStore {
  37892. /** Gets the list of created engines */
  37893. static Instances: Engine[];
  37894. /** @hidden */
  37895. static _LastCreatedScene: Nullable<Scene>;
  37896. /**
  37897. * Gets the latest created engine
  37898. */
  37899. static get LastCreatedEngine(): Nullable<Engine>;
  37900. /**
  37901. * Gets the latest created scene
  37902. */
  37903. static get LastCreatedScene(): Nullable<Scene>;
  37904. /**
  37905. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37906. * @ignorenaming
  37907. */
  37908. static UseFallbackTexture: boolean;
  37909. /**
  37910. * Texture content used if a texture cannot loaded
  37911. * @ignorenaming
  37912. */
  37913. static FallbackTexture: string;
  37914. }
  37915. }
  37916. declare module BABYLON {
  37917. /**
  37918. * Helper class that provides a small promise polyfill
  37919. */
  37920. export class PromisePolyfill {
  37921. /**
  37922. * Static function used to check if the polyfill is required
  37923. * If this is the case then the function will inject the polyfill to window.Promise
  37924. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  37925. */
  37926. static Apply(force?: boolean): void;
  37927. }
  37928. }
  37929. declare module BABYLON {
  37930. /**
  37931. * Interface for screenshot methods with describe argument called `size` as object with options
  37932. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  37933. */
  37934. export interface IScreenshotSize {
  37935. /**
  37936. * number in pixels for canvas height
  37937. */
  37938. height?: number;
  37939. /**
  37940. * multiplier allowing render at a higher or lower resolution
  37941. * If value is defined then height and width will be ignored and taken from camera
  37942. */
  37943. precision?: number;
  37944. /**
  37945. * number in pixels for canvas width
  37946. */
  37947. width?: number;
  37948. }
  37949. }
  37950. declare module BABYLON {
  37951. interface IColor4Like {
  37952. r: float;
  37953. g: float;
  37954. b: float;
  37955. a: float;
  37956. }
  37957. /**
  37958. * Class containing a set of static utilities functions
  37959. */
  37960. export class Tools {
  37961. /**
  37962. * Gets or sets the base URL to use to load assets
  37963. */
  37964. static get BaseUrl(): string;
  37965. static set BaseUrl(value: string);
  37966. /**
  37967. * Enable/Disable Custom HTTP Request Headers globally.
  37968. * default = false
  37969. * @see CustomRequestHeaders
  37970. */
  37971. static UseCustomRequestHeaders: boolean;
  37972. /**
  37973. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  37974. * i.e. when loading files, where the server/service expects an Authorization header
  37975. */
  37976. static CustomRequestHeaders: {
  37977. [key: string]: string;
  37978. };
  37979. /**
  37980. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  37981. */
  37982. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  37983. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  37984. /**
  37985. * Default behaviour for cors in the application.
  37986. * It can be a string if the expected behavior is identical in the entire app.
  37987. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  37988. */
  37989. static get CorsBehavior(): string | ((url: string | string[]) => string);
  37990. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  37991. /**
  37992. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37993. * @ignorenaming
  37994. */
  37995. static get UseFallbackTexture(): boolean;
  37996. static set UseFallbackTexture(value: boolean);
  37997. /**
  37998. * Use this object to register external classes like custom textures or material
  37999. * to allow the laoders to instantiate them
  38000. */
  38001. static get RegisteredExternalClasses(): {
  38002. [key: string]: Object;
  38003. };
  38004. static set RegisteredExternalClasses(classes: {
  38005. [key: string]: Object;
  38006. });
  38007. /**
  38008. * Texture content used if a texture cannot loaded
  38009. * @ignorenaming
  38010. */
  38011. static get fallbackTexture(): string;
  38012. static set fallbackTexture(value: string);
  38013. /**
  38014. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38015. * @param u defines the coordinate on X axis
  38016. * @param v defines the coordinate on Y axis
  38017. * @param width defines the width of the source data
  38018. * @param height defines the height of the source data
  38019. * @param pixels defines the source byte array
  38020. * @param color defines the output color
  38021. */
  38022. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38023. /**
  38024. * Interpolates between a and b via alpha
  38025. * @param a The lower value (returned when alpha = 0)
  38026. * @param b The upper value (returned when alpha = 1)
  38027. * @param alpha The interpolation-factor
  38028. * @return The mixed value
  38029. */
  38030. static Mix(a: number, b: number, alpha: number): number;
  38031. /**
  38032. * Tries to instantiate a new object from a given class name
  38033. * @param className defines the class name to instantiate
  38034. * @returns the new object or null if the system was not able to do the instantiation
  38035. */
  38036. static Instantiate(className: string): any;
  38037. /**
  38038. * Provides a slice function that will work even on IE
  38039. * @param data defines the array to slice
  38040. * @param start defines the start of the data (optional)
  38041. * @param end defines the end of the data (optional)
  38042. * @returns the new sliced array
  38043. */
  38044. static Slice<T>(data: T, start?: number, end?: number): T;
  38045. /**
  38046. * Polyfill for setImmediate
  38047. * @param action defines the action to execute after the current execution block
  38048. */
  38049. static SetImmediate(action: () => void): void;
  38050. /**
  38051. * Function indicating if a number is an exponent of 2
  38052. * @param value defines the value to test
  38053. * @returns true if the value is an exponent of 2
  38054. */
  38055. static IsExponentOfTwo(value: number): boolean;
  38056. private static _tmpFloatArray;
  38057. /**
  38058. * Returns the nearest 32-bit single precision float representation of a Number
  38059. * @param value A Number. If the parameter is of a different type, it will get converted
  38060. * to a number or to NaN if it cannot be converted
  38061. * @returns number
  38062. */
  38063. static FloatRound(value: number): number;
  38064. /**
  38065. * Extracts the filename from a path
  38066. * @param path defines the path to use
  38067. * @returns the filename
  38068. */
  38069. static GetFilename(path: string): string;
  38070. /**
  38071. * Extracts the "folder" part of a path (everything before the filename).
  38072. * @param uri The URI to extract the info from
  38073. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38074. * @returns The "folder" part of the path
  38075. */
  38076. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38077. /**
  38078. * Extracts text content from a DOM element hierarchy
  38079. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38080. */
  38081. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38082. /**
  38083. * Convert an angle in radians to degrees
  38084. * @param angle defines the angle to convert
  38085. * @returns the angle in degrees
  38086. */
  38087. static ToDegrees(angle: number): number;
  38088. /**
  38089. * Convert an angle in degrees to radians
  38090. * @param angle defines the angle to convert
  38091. * @returns the angle in radians
  38092. */
  38093. static ToRadians(angle: number): number;
  38094. /**
  38095. * Returns an array if obj is not an array
  38096. * @param obj defines the object to evaluate as an array
  38097. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38098. * @returns either obj directly if obj is an array or a new array containing obj
  38099. */
  38100. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38101. /**
  38102. * Gets the pointer prefix to use
  38103. * @param engine defines the engine we are finding the prefix for
  38104. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38105. */
  38106. static GetPointerPrefix(engine: Engine): string;
  38107. /**
  38108. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38109. * @param url define the url we are trying
  38110. * @param element define the dom element where to configure the cors policy
  38111. */
  38112. static SetCorsBehavior(url: string | string[], element: {
  38113. crossOrigin: string | null;
  38114. }): void;
  38115. /**
  38116. * Removes unwanted characters from an url
  38117. * @param url defines the url to clean
  38118. * @returns the cleaned url
  38119. */
  38120. static CleanUrl(url: string): string;
  38121. /**
  38122. * Gets or sets a function used to pre-process url before using them to load assets
  38123. */
  38124. static get PreprocessUrl(): (url: string) => string;
  38125. static set PreprocessUrl(processor: (url: string) => string);
  38126. /**
  38127. * Loads an image as an HTMLImageElement.
  38128. * @param input url string, ArrayBuffer, or Blob to load
  38129. * @param onLoad callback called when the image successfully loads
  38130. * @param onError callback called when the image fails to load
  38131. * @param offlineProvider offline provider for caching
  38132. * @param mimeType optional mime type
  38133. * @returns the HTMLImageElement of the loaded image
  38134. */
  38135. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38136. /**
  38137. * Loads a file from a url
  38138. * @param url url string, ArrayBuffer, or Blob to load
  38139. * @param onSuccess callback called when the file successfully loads
  38140. * @param onProgress callback called while file is loading (if the server supports this mode)
  38141. * @param offlineProvider defines the offline provider for caching
  38142. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38143. * @param onError callback called when the file fails to load
  38144. * @returns a file request object
  38145. */
  38146. 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;
  38147. /**
  38148. * Loads a file from a url
  38149. * @param url the file url to load
  38150. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38151. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38152. */
  38153. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38154. /**
  38155. * Load a script (identified by an url). When the url returns, the
  38156. * content of this file is added into a new script element, attached to the DOM (body element)
  38157. * @param scriptUrl defines the url of the script to laod
  38158. * @param onSuccess defines the callback called when the script is loaded
  38159. * @param onError defines the callback to call if an error occurs
  38160. * @param scriptId defines the id of the script element
  38161. */
  38162. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38163. /**
  38164. * Load an asynchronous script (identified by an url). When the url returns, the
  38165. * content of this file is added into a new script element, attached to the DOM (body element)
  38166. * @param scriptUrl defines the url of the script to laod
  38167. * @param scriptId defines the id of the script element
  38168. * @returns a promise request object
  38169. */
  38170. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38171. /**
  38172. * Loads a file from a blob
  38173. * @param fileToLoad defines the blob to use
  38174. * @param callback defines the callback to call when data is loaded
  38175. * @param progressCallback defines the callback to call during loading process
  38176. * @returns a file request object
  38177. */
  38178. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38179. /**
  38180. * Reads a file from a File object
  38181. * @param file defines the file to load
  38182. * @param onSuccess defines the callback to call when data is loaded
  38183. * @param onProgress defines the callback to call during loading process
  38184. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38185. * @param onError defines the callback to call when an error occurs
  38186. * @returns a file request object
  38187. */
  38188. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38189. /**
  38190. * Creates a data url from a given string content
  38191. * @param content defines the content to convert
  38192. * @returns the new data url link
  38193. */
  38194. static FileAsURL(content: string): string;
  38195. /**
  38196. * Format the given number to a specific decimal format
  38197. * @param value defines the number to format
  38198. * @param decimals defines the number of decimals to use
  38199. * @returns the formatted string
  38200. */
  38201. static Format(value: number, decimals?: number): string;
  38202. /**
  38203. * Tries to copy an object by duplicating every property
  38204. * @param source defines the source object
  38205. * @param destination defines the target object
  38206. * @param doNotCopyList defines a list of properties to avoid
  38207. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38208. */
  38209. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38210. /**
  38211. * Gets a boolean indicating if the given object has no own property
  38212. * @param obj defines the object to test
  38213. * @returns true if object has no own property
  38214. */
  38215. static IsEmpty(obj: any): boolean;
  38216. /**
  38217. * Function used to register events at window level
  38218. * @param windowElement defines the Window object to use
  38219. * @param events defines the events to register
  38220. */
  38221. static RegisterTopRootEvents(windowElement: Window, events: {
  38222. name: string;
  38223. handler: Nullable<(e: FocusEvent) => any>;
  38224. }[]): void;
  38225. /**
  38226. * Function used to unregister events from window level
  38227. * @param windowElement defines the Window object to use
  38228. * @param events defines the events to unregister
  38229. */
  38230. static UnregisterTopRootEvents(windowElement: Window, events: {
  38231. name: string;
  38232. handler: Nullable<(e: FocusEvent) => any>;
  38233. }[]): void;
  38234. /**
  38235. * @ignore
  38236. */
  38237. static _ScreenshotCanvas: HTMLCanvasElement;
  38238. /**
  38239. * Dumps the current bound framebuffer
  38240. * @param width defines the rendering width
  38241. * @param height defines the rendering height
  38242. * @param engine defines the hosting engine
  38243. * @param successCallback defines the callback triggered once the data are available
  38244. * @param mimeType defines the mime type of the result
  38245. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38246. */
  38247. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38248. /**
  38249. * Converts the canvas data to blob.
  38250. * This acts as a polyfill for browsers not supporting the to blob function.
  38251. * @param canvas Defines the canvas to extract the data from
  38252. * @param successCallback Defines the callback triggered once the data are available
  38253. * @param mimeType Defines the mime type of the result
  38254. */
  38255. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38256. /**
  38257. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38258. * @param successCallback defines the callback triggered once the data are available
  38259. * @param mimeType defines the mime type of the result
  38260. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38261. */
  38262. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38263. /**
  38264. * Downloads a blob in the browser
  38265. * @param blob defines the blob to download
  38266. * @param fileName defines the name of the downloaded file
  38267. */
  38268. static Download(blob: Blob, fileName: string): void;
  38269. /**
  38270. * Captures a screenshot of the current rendering
  38271. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38272. * @param engine defines the rendering engine
  38273. * @param camera defines the source camera
  38274. * @param size This parameter can be set to a single number or to an object with the
  38275. * following (optional) properties: precision, width, height. If a single number is passed,
  38276. * it will be used for both width and height. If an object is passed, the screenshot size
  38277. * will be derived from the parameters. The precision property is a multiplier allowing
  38278. * rendering at a higher or lower resolution
  38279. * @param successCallback defines the callback receives a single parameter which contains the
  38280. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38281. * src parameter of an <img> to display it
  38282. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38283. * Check your browser for supported MIME types
  38284. */
  38285. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38286. /**
  38287. * Captures a screenshot of the current rendering
  38288. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38289. * @param engine defines the rendering engine
  38290. * @param camera defines the source camera
  38291. * @param size This parameter can be set to a single number or to an object with the
  38292. * following (optional) properties: precision, width, height. If a single number is passed,
  38293. * it will be used for both width and height. If an object is passed, the screenshot size
  38294. * will be derived from the parameters. The precision property is a multiplier allowing
  38295. * rendering at a higher or lower resolution
  38296. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38297. * Check your browser for supported MIME types
  38298. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38299. * to the src parameter of an <img> to display it
  38300. */
  38301. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38302. /**
  38303. * Generates an image screenshot from the specified camera.
  38304. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38305. * @param engine The engine to use for rendering
  38306. * @param camera The camera to use for rendering
  38307. * @param size This parameter can be set to a single number or to an object with the
  38308. * following (optional) properties: precision, width, height. If a single number is passed,
  38309. * it will be used for both width and height. If an object is passed, the screenshot size
  38310. * will be derived from the parameters. The precision property is a multiplier allowing
  38311. * rendering at a higher or lower resolution
  38312. * @param successCallback The callback receives a single parameter which contains the
  38313. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38314. * src parameter of an <img> to display it
  38315. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38316. * Check your browser for supported MIME types
  38317. * @param samples Texture samples (default: 1)
  38318. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38319. * @param fileName A name for for the downloaded file.
  38320. */
  38321. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38322. /**
  38323. * Generates an image screenshot from the specified camera.
  38324. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38325. * @param engine The engine to use for rendering
  38326. * @param camera The camera to use for rendering
  38327. * @param size This parameter can be set to a single number or to an object with the
  38328. * following (optional) properties: precision, width, height. If a single number is passed,
  38329. * it will be used for both width and height. If an object is passed, the screenshot size
  38330. * will be derived from the parameters. The precision property is a multiplier allowing
  38331. * rendering at a higher or lower resolution
  38332. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38333. * Check your browser for supported MIME types
  38334. * @param samples Texture samples (default: 1)
  38335. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38336. * @param fileName A name for for the downloaded file.
  38337. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38338. * to the src parameter of an <img> to display it
  38339. */
  38340. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38341. /**
  38342. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38343. * Be aware Math.random() could cause collisions, but:
  38344. * "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"
  38345. * @returns a pseudo random id
  38346. */
  38347. static RandomId(): string;
  38348. /**
  38349. * Test if the given uri is a base64 string
  38350. * @param uri The uri to test
  38351. * @return True if the uri is a base64 string or false otherwise
  38352. */
  38353. static IsBase64(uri: string): boolean;
  38354. /**
  38355. * Decode the given base64 uri.
  38356. * @param uri The uri to decode
  38357. * @return The decoded base64 data.
  38358. */
  38359. static DecodeBase64(uri: string): ArrayBuffer;
  38360. /**
  38361. * Gets the absolute url.
  38362. * @param url the input url
  38363. * @return the absolute url
  38364. */
  38365. static GetAbsoluteUrl(url: string): string;
  38366. /**
  38367. * No log
  38368. */
  38369. static readonly NoneLogLevel: number;
  38370. /**
  38371. * Only message logs
  38372. */
  38373. static readonly MessageLogLevel: number;
  38374. /**
  38375. * Only warning logs
  38376. */
  38377. static readonly WarningLogLevel: number;
  38378. /**
  38379. * Only error logs
  38380. */
  38381. static readonly ErrorLogLevel: number;
  38382. /**
  38383. * All logs
  38384. */
  38385. static readonly AllLogLevel: number;
  38386. /**
  38387. * Gets a value indicating the number of loading errors
  38388. * @ignorenaming
  38389. */
  38390. static get errorsCount(): number;
  38391. /**
  38392. * Callback called when a new log is added
  38393. */
  38394. static OnNewCacheEntry: (entry: string) => void;
  38395. /**
  38396. * Log a message to the console
  38397. * @param message defines the message to log
  38398. */
  38399. static Log(message: string): void;
  38400. /**
  38401. * Write a warning message to the console
  38402. * @param message defines the message to log
  38403. */
  38404. static Warn(message: string): void;
  38405. /**
  38406. * Write an error message to the console
  38407. * @param message defines the message to log
  38408. */
  38409. static Error(message: string): void;
  38410. /**
  38411. * Gets current log cache (list of logs)
  38412. */
  38413. static get LogCache(): string;
  38414. /**
  38415. * Clears the log cache
  38416. */
  38417. static ClearLogCache(): void;
  38418. /**
  38419. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38420. */
  38421. static set LogLevels(level: number);
  38422. /**
  38423. * Checks if the window object exists
  38424. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  38425. */
  38426. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  38427. /**
  38428. * No performance log
  38429. */
  38430. static readonly PerformanceNoneLogLevel: number;
  38431. /**
  38432. * Use user marks to log performance
  38433. */
  38434. static readonly PerformanceUserMarkLogLevel: number;
  38435. /**
  38436. * Log performance to the console
  38437. */
  38438. static readonly PerformanceConsoleLogLevel: number;
  38439. private static _performance;
  38440. /**
  38441. * Sets the current performance log level
  38442. */
  38443. static set PerformanceLogLevel(level: number);
  38444. private static _StartPerformanceCounterDisabled;
  38445. private static _EndPerformanceCounterDisabled;
  38446. private static _StartUserMark;
  38447. private static _EndUserMark;
  38448. private static _StartPerformanceConsole;
  38449. private static _EndPerformanceConsole;
  38450. /**
  38451. * Starts a performance counter
  38452. */
  38453. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38454. /**
  38455. * Ends a specific performance coutner
  38456. */
  38457. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38458. /**
  38459. * Gets either window.performance.now() if supported or Date.now() else
  38460. */
  38461. static get Now(): number;
  38462. /**
  38463. * This method will return the name of the class used to create the instance of the given object.
  38464. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  38465. * @param object the object to get the class name from
  38466. * @param isType defines if the object is actually a type
  38467. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  38468. */
  38469. static GetClassName(object: any, isType?: boolean): string;
  38470. /**
  38471. * Gets the first element of an array satisfying a given predicate
  38472. * @param array defines the array to browse
  38473. * @param predicate defines the predicate to use
  38474. * @returns null if not found or the element
  38475. */
  38476. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  38477. /**
  38478. * This method will return the name of the full name of the class, including its owning module (if any).
  38479. * 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).
  38480. * @param object the object to get the class name from
  38481. * @param isType defines if the object is actually a type
  38482. * @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.
  38483. * @ignorenaming
  38484. */
  38485. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  38486. /**
  38487. * Returns a promise that resolves after the given amount of time.
  38488. * @param delay Number of milliseconds to delay
  38489. * @returns Promise that resolves after the given amount of time
  38490. */
  38491. static DelayAsync(delay: number): Promise<void>;
  38492. /**
  38493. * Utility function to detect if the current user agent is Safari
  38494. * @returns whether or not the current user agent is safari
  38495. */
  38496. static IsSafari(): boolean;
  38497. }
  38498. /**
  38499. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  38500. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  38501. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  38502. * @param name The name of the class, case should be preserved
  38503. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  38504. */
  38505. export function className(name: string, module?: string): (target: Object) => void;
  38506. /**
  38507. * An implementation of a loop for asynchronous functions.
  38508. */
  38509. export class AsyncLoop {
  38510. /**
  38511. * Defines the number of iterations for the loop
  38512. */
  38513. iterations: number;
  38514. /**
  38515. * Defines the current index of the loop.
  38516. */
  38517. index: number;
  38518. private _done;
  38519. private _fn;
  38520. private _successCallback;
  38521. /**
  38522. * Constructor.
  38523. * @param iterations the number of iterations.
  38524. * @param func the function to run each iteration
  38525. * @param successCallback the callback that will be called upon succesful execution
  38526. * @param offset starting offset.
  38527. */
  38528. constructor(
  38529. /**
  38530. * Defines the number of iterations for the loop
  38531. */
  38532. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  38533. /**
  38534. * Execute the next iteration. Must be called after the last iteration was finished.
  38535. */
  38536. executeNext(): void;
  38537. /**
  38538. * Break the loop and run the success callback.
  38539. */
  38540. breakLoop(): void;
  38541. /**
  38542. * Create and run an async loop.
  38543. * @param iterations the number of iterations.
  38544. * @param fn the function to run each iteration
  38545. * @param successCallback the callback that will be called upon succesful execution
  38546. * @param offset starting offset.
  38547. * @returns the created async loop object
  38548. */
  38549. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  38550. /**
  38551. * A for-loop that will run a given number of iterations synchronous and the rest async.
  38552. * @param iterations total number of iterations
  38553. * @param syncedIterations number of synchronous iterations in each async iteration.
  38554. * @param fn the function to call each iteration.
  38555. * @param callback a success call back that will be called when iterating stops.
  38556. * @param breakFunction a break condition (optional)
  38557. * @param timeout timeout settings for the setTimeout function. default - 0.
  38558. * @returns the created async loop object
  38559. */
  38560. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  38561. }
  38562. }
  38563. declare module BABYLON {
  38564. /**
  38565. * This class implement a typical dictionary using a string as key and the generic type T as value.
  38566. * The underlying implementation relies on an associative array to ensure the best performances.
  38567. * The value can be anything including 'null' but except 'undefined'
  38568. */
  38569. export class StringDictionary<T> {
  38570. /**
  38571. * This will clear this dictionary and copy the content from the 'source' one.
  38572. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  38573. * @param source the dictionary to take the content from and copy to this dictionary
  38574. */
  38575. copyFrom(source: StringDictionary<T>): void;
  38576. /**
  38577. * Get a value based from its key
  38578. * @param key the given key to get the matching value from
  38579. * @return the value if found, otherwise undefined is returned
  38580. */
  38581. get(key: string): T | undefined;
  38582. /**
  38583. * Get a value from its key or add it if it doesn't exist.
  38584. * This method will ensure you that a given key/data will be present in the dictionary.
  38585. * @param key the given key to get the matching value from
  38586. * @param factory the factory that will create the value if the key is not present in the dictionary.
  38587. * The factory will only be invoked if there's no data for the given key.
  38588. * @return the value corresponding to the key.
  38589. */
  38590. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  38591. /**
  38592. * Get a value from its key if present in the dictionary otherwise add it
  38593. * @param key the key to get the value from
  38594. * @param val if there's no such key/value pair in the dictionary add it with this value
  38595. * @return the value corresponding to the key
  38596. */
  38597. getOrAdd(key: string, val: T): T;
  38598. /**
  38599. * Check if there's a given key in the dictionary
  38600. * @param key the key to check for
  38601. * @return true if the key is present, false otherwise
  38602. */
  38603. contains(key: string): boolean;
  38604. /**
  38605. * Add a new key and its corresponding value
  38606. * @param key the key to add
  38607. * @param value the value corresponding to the key
  38608. * @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
  38609. */
  38610. add(key: string, value: T): boolean;
  38611. /**
  38612. * Update a specific value associated to a key
  38613. * @param key defines the key to use
  38614. * @param value defines the value to store
  38615. * @returns true if the value was updated (or false if the key was not found)
  38616. */
  38617. set(key: string, value: T): boolean;
  38618. /**
  38619. * Get the element of the given key and remove it from the dictionary
  38620. * @param key defines the key to search
  38621. * @returns the value associated with the key or null if not found
  38622. */
  38623. getAndRemove(key: string): Nullable<T>;
  38624. /**
  38625. * Remove a key/value from the dictionary.
  38626. * @param key the key to remove
  38627. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  38628. */
  38629. remove(key: string): boolean;
  38630. /**
  38631. * Clear the whole content of the dictionary
  38632. */
  38633. clear(): void;
  38634. /**
  38635. * Gets the current count
  38636. */
  38637. get count(): number;
  38638. /**
  38639. * Execute a callback on each key/val of the dictionary.
  38640. * Note that you can remove any element in this dictionary in the callback implementation
  38641. * @param callback the callback to execute on a given key/value pair
  38642. */
  38643. forEach(callback: (key: string, val: T) => void): void;
  38644. /**
  38645. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  38646. * If the callback returns null or undefined the method will iterate to the next key/value pair
  38647. * Note that you can remove any element in this dictionary in the callback implementation
  38648. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  38649. * @returns the first item
  38650. */
  38651. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  38652. private _count;
  38653. private _data;
  38654. }
  38655. }
  38656. declare module BABYLON {
  38657. /** @hidden */
  38658. export interface ICollisionCoordinator {
  38659. createCollider(): Collider;
  38660. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38661. init(scene: Scene): void;
  38662. }
  38663. /** @hidden */
  38664. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  38665. private _scene;
  38666. private _scaledPosition;
  38667. private _scaledVelocity;
  38668. private _finalPosition;
  38669. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38670. createCollider(): Collider;
  38671. init(scene: Scene): void;
  38672. private _collideWithWorld;
  38673. }
  38674. }
  38675. declare module BABYLON {
  38676. /**
  38677. * Class used to manage all inputs for the scene.
  38678. */
  38679. export class InputManager {
  38680. /** The distance in pixel that you have to move to prevent some events */
  38681. static DragMovementThreshold: number;
  38682. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  38683. static LongPressDelay: number;
  38684. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  38685. static DoubleClickDelay: number;
  38686. /** If you need to check double click without raising a single click at first click, enable this flag */
  38687. static ExclusiveDoubleClickMode: boolean;
  38688. private _wheelEventName;
  38689. private _onPointerMove;
  38690. private _onPointerDown;
  38691. private _onPointerUp;
  38692. private _initClickEvent;
  38693. private _initActionManager;
  38694. private _delayedSimpleClick;
  38695. private _delayedSimpleClickTimeout;
  38696. private _previousDelayedSimpleClickTimeout;
  38697. private _meshPickProceed;
  38698. private _previousButtonPressed;
  38699. private _currentPickResult;
  38700. private _previousPickResult;
  38701. private _totalPointersPressed;
  38702. private _doubleClickOccured;
  38703. private _pointerOverMesh;
  38704. private _pickedDownMesh;
  38705. private _pickedUpMesh;
  38706. private _pointerX;
  38707. private _pointerY;
  38708. private _unTranslatedPointerX;
  38709. private _unTranslatedPointerY;
  38710. private _startingPointerPosition;
  38711. private _previousStartingPointerPosition;
  38712. private _startingPointerTime;
  38713. private _previousStartingPointerTime;
  38714. private _pointerCaptures;
  38715. private _onKeyDown;
  38716. private _onKeyUp;
  38717. private _onCanvasFocusObserver;
  38718. private _onCanvasBlurObserver;
  38719. private _scene;
  38720. /**
  38721. * Creates a new InputManager
  38722. * @param scene defines the hosting scene
  38723. */
  38724. constructor(scene: Scene);
  38725. /**
  38726. * Gets the mesh that is currently under the pointer
  38727. */
  38728. get meshUnderPointer(): Nullable<AbstractMesh>;
  38729. /**
  38730. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  38731. */
  38732. get unTranslatedPointer(): Vector2;
  38733. /**
  38734. * Gets or sets the current on-screen X position of the pointer
  38735. */
  38736. get pointerX(): number;
  38737. set pointerX(value: number);
  38738. /**
  38739. * Gets or sets the current on-screen Y position of the pointer
  38740. */
  38741. get pointerY(): number;
  38742. set pointerY(value: number);
  38743. private _updatePointerPosition;
  38744. private _processPointerMove;
  38745. private _setRayOnPointerInfo;
  38746. private _checkPrePointerObservable;
  38747. /**
  38748. * Use this method to simulate a pointer move on a mesh
  38749. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38750. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38751. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38752. */
  38753. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38754. /**
  38755. * Use this method to simulate a pointer down on a mesh
  38756. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38757. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38758. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38759. */
  38760. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38761. private _processPointerDown;
  38762. /** @hidden */
  38763. _isPointerSwiping(): boolean;
  38764. /**
  38765. * Use this method to simulate a pointer up on a mesh
  38766. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38767. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38768. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38769. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  38770. */
  38771. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  38772. private _processPointerUp;
  38773. /**
  38774. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  38775. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  38776. * @returns true if the pointer was captured
  38777. */
  38778. isPointerCaptured(pointerId?: number): boolean;
  38779. /**
  38780. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  38781. * @param attachUp defines if you want to attach events to pointerup
  38782. * @param attachDown defines if you want to attach events to pointerdown
  38783. * @param attachMove defines if you want to attach events to pointermove
  38784. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  38785. */
  38786. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  38787. /**
  38788. * Detaches all event handlers
  38789. */
  38790. detachControl(): void;
  38791. /**
  38792. * Force the value of meshUnderPointer
  38793. * @param mesh defines the mesh to use
  38794. */
  38795. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  38796. /**
  38797. * Gets the mesh under the pointer
  38798. * @returns a Mesh or null if no mesh is under the pointer
  38799. */
  38800. getPointerOverMesh(): Nullable<AbstractMesh>;
  38801. }
  38802. }
  38803. declare module BABYLON {
  38804. /**
  38805. * This class defines the direct association between an animation and a target
  38806. */
  38807. export class TargetedAnimation {
  38808. /**
  38809. * Animation to perform
  38810. */
  38811. animation: Animation;
  38812. /**
  38813. * Target to animate
  38814. */
  38815. target: any;
  38816. /**
  38817. * Returns the string "TargetedAnimation"
  38818. * @returns "TargetedAnimation"
  38819. */
  38820. getClassName(): string;
  38821. /**
  38822. * Serialize the object
  38823. * @returns the JSON object representing the current entity
  38824. */
  38825. serialize(): any;
  38826. }
  38827. /**
  38828. * Use this class to create coordinated animations on multiple targets
  38829. */
  38830. export class AnimationGroup implements IDisposable {
  38831. /** The name of the animation group */
  38832. name: string;
  38833. private _scene;
  38834. private _targetedAnimations;
  38835. private _animatables;
  38836. private _from;
  38837. private _to;
  38838. private _isStarted;
  38839. private _isPaused;
  38840. private _speedRatio;
  38841. private _loopAnimation;
  38842. private _isAdditive;
  38843. /**
  38844. * Gets or sets the unique id of the node
  38845. */
  38846. uniqueId: number;
  38847. /**
  38848. * This observable will notify when one animation have ended
  38849. */
  38850. onAnimationEndObservable: Observable<TargetedAnimation>;
  38851. /**
  38852. * Observer raised when one animation loops
  38853. */
  38854. onAnimationLoopObservable: Observable<TargetedAnimation>;
  38855. /**
  38856. * Observer raised when all animations have looped
  38857. */
  38858. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  38859. /**
  38860. * This observable will notify when all animations have ended.
  38861. */
  38862. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  38863. /**
  38864. * This observable will notify when all animations have paused.
  38865. */
  38866. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  38867. /**
  38868. * This observable will notify when all animations are playing.
  38869. */
  38870. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  38871. /**
  38872. * Gets the first frame
  38873. */
  38874. get from(): number;
  38875. /**
  38876. * Gets the last frame
  38877. */
  38878. get to(): number;
  38879. /**
  38880. * Define if the animations are started
  38881. */
  38882. get isStarted(): boolean;
  38883. /**
  38884. * Gets a value indicating that the current group is playing
  38885. */
  38886. get isPlaying(): boolean;
  38887. /**
  38888. * Gets or sets the speed ratio to use for all animations
  38889. */
  38890. get speedRatio(): number;
  38891. /**
  38892. * Gets or sets the speed ratio to use for all animations
  38893. */
  38894. set speedRatio(value: number);
  38895. /**
  38896. * Gets or sets if all animations should loop or not
  38897. */
  38898. get loopAnimation(): boolean;
  38899. set loopAnimation(value: boolean);
  38900. /**
  38901. * Gets or sets if all animations should be evaluated additively
  38902. */
  38903. get isAdditive(): boolean;
  38904. set isAdditive(value: boolean);
  38905. /**
  38906. * Gets the targeted animations for this animation group
  38907. */
  38908. get targetedAnimations(): Array<TargetedAnimation>;
  38909. /**
  38910. * returning the list of animatables controlled by this animation group.
  38911. */
  38912. get animatables(): Array<Animatable>;
  38913. /**
  38914. * Gets the list of target animations
  38915. */
  38916. get children(): TargetedAnimation[];
  38917. /**
  38918. * Instantiates a new Animation Group.
  38919. * This helps managing several animations at once.
  38920. * @see https://doc.babylonjs.com/how_to/group
  38921. * @param name Defines the name of the group
  38922. * @param scene Defines the scene the group belongs to
  38923. */
  38924. constructor(
  38925. /** The name of the animation group */
  38926. name: string, scene?: Nullable<Scene>);
  38927. /**
  38928. * Add an animation (with its target) in the group
  38929. * @param animation defines the animation we want to add
  38930. * @param target defines the target of the animation
  38931. * @returns the TargetedAnimation object
  38932. */
  38933. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  38934. /**
  38935. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  38936. * It can add constant keys at begin or end
  38937. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  38938. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  38939. * @returns the animation group
  38940. */
  38941. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  38942. private _animationLoopCount;
  38943. private _animationLoopFlags;
  38944. private _processLoop;
  38945. /**
  38946. * Start all animations on given targets
  38947. * @param loop defines if animations must loop
  38948. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  38949. * @param from defines the from key (optional)
  38950. * @param to defines the to key (optional)
  38951. * @param isAdditive defines the additive state for the resulting animatables (optional)
  38952. * @returns the current animation group
  38953. */
  38954. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  38955. /**
  38956. * Pause all animations
  38957. * @returns the animation group
  38958. */
  38959. pause(): AnimationGroup;
  38960. /**
  38961. * Play all animations to initial state
  38962. * This function will start() the animations if they were not started or will restart() them if they were paused
  38963. * @param loop defines if animations must loop
  38964. * @returns the animation group
  38965. */
  38966. play(loop?: boolean): AnimationGroup;
  38967. /**
  38968. * Reset all animations to initial state
  38969. * @returns the animation group
  38970. */
  38971. reset(): AnimationGroup;
  38972. /**
  38973. * Restart animations from key 0
  38974. * @returns the animation group
  38975. */
  38976. restart(): AnimationGroup;
  38977. /**
  38978. * Stop all animations
  38979. * @returns the animation group
  38980. */
  38981. stop(): AnimationGroup;
  38982. /**
  38983. * Set animation weight for all animatables
  38984. * @param weight defines the weight to use
  38985. * @return the animationGroup
  38986. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  38987. */
  38988. setWeightForAllAnimatables(weight: number): AnimationGroup;
  38989. /**
  38990. * Synchronize and normalize all animatables with a source animatable
  38991. * @param root defines the root animatable to synchronize with
  38992. * @return the animationGroup
  38993. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  38994. */
  38995. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  38996. /**
  38997. * Goes to a specific frame in this animation group
  38998. * @param frame the frame number to go to
  38999. * @return the animationGroup
  39000. */
  39001. goToFrame(frame: number): AnimationGroup;
  39002. /**
  39003. * Dispose all associated resources
  39004. */
  39005. dispose(): void;
  39006. private _checkAnimationGroupEnded;
  39007. /**
  39008. * Clone the current animation group and returns a copy
  39009. * @param newName defines the name of the new group
  39010. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39011. * @returns the new aniamtion group
  39012. */
  39013. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39014. /**
  39015. * Serializes the animationGroup to an object
  39016. * @returns Serialized object
  39017. */
  39018. serialize(): any;
  39019. /**
  39020. * Returns a new AnimationGroup object parsed from the source provided.
  39021. * @param parsedAnimationGroup defines the source
  39022. * @param scene defines the scene that will receive the animationGroup
  39023. * @returns a new AnimationGroup
  39024. */
  39025. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39026. /**
  39027. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39028. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39029. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39030. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39031. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39032. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39033. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39034. */
  39035. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39036. /**
  39037. * Returns the string "AnimationGroup"
  39038. * @returns "AnimationGroup"
  39039. */
  39040. getClassName(): string;
  39041. /**
  39042. * Creates a detailled string about the object
  39043. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39044. * @returns a string representing the object
  39045. */
  39046. toString(fullDetails?: boolean): string;
  39047. }
  39048. }
  39049. declare module BABYLON {
  39050. /**
  39051. * Define an interface for all classes that will hold resources
  39052. */
  39053. export interface IDisposable {
  39054. /**
  39055. * Releases all held resources
  39056. */
  39057. dispose(): void;
  39058. }
  39059. /** Interface defining initialization parameters for Scene class */
  39060. export interface SceneOptions {
  39061. /**
  39062. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39063. * It will improve performance when the number of geometries becomes important.
  39064. */
  39065. useGeometryUniqueIdsMap?: boolean;
  39066. /**
  39067. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39068. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39069. */
  39070. useMaterialMeshMap?: boolean;
  39071. /**
  39072. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39073. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39074. */
  39075. useClonedMeshMap?: boolean;
  39076. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39077. virtual?: boolean;
  39078. }
  39079. /**
  39080. * Represents a scene to be rendered by the engine.
  39081. * @see https://doc.babylonjs.com/features/scene
  39082. */
  39083. export class Scene extends AbstractScene implements IAnimatable {
  39084. /** The fog is deactivated */
  39085. static readonly FOGMODE_NONE: number;
  39086. /** The fog density is following an exponential function */
  39087. static readonly FOGMODE_EXP: number;
  39088. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39089. static readonly FOGMODE_EXP2: number;
  39090. /** The fog density is following a linear function. */
  39091. static readonly FOGMODE_LINEAR: number;
  39092. /**
  39093. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39094. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39095. */
  39096. static MinDeltaTime: number;
  39097. /**
  39098. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39099. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39100. */
  39101. static MaxDeltaTime: number;
  39102. /**
  39103. * Factory used to create the default material.
  39104. * @param name The name of the material to create
  39105. * @param scene The scene to create the material for
  39106. * @returns The default material
  39107. */
  39108. static DefaultMaterialFactory(scene: Scene): Material;
  39109. /**
  39110. * Factory used to create the a collision coordinator.
  39111. * @returns The collision coordinator
  39112. */
  39113. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39114. /** @hidden */
  39115. _inputManager: InputManager;
  39116. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39117. cameraToUseForPointers: Nullable<Camera>;
  39118. /** @hidden */
  39119. readonly _isScene: boolean;
  39120. /** @hidden */
  39121. _blockEntityCollection: boolean;
  39122. /**
  39123. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39124. */
  39125. autoClear: boolean;
  39126. /**
  39127. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39128. */
  39129. autoClearDepthAndStencil: boolean;
  39130. /**
  39131. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39132. */
  39133. clearColor: Color4;
  39134. /**
  39135. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39136. */
  39137. ambientColor: Color3;
  39138. /**
  39139. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39140. * It should only be one of the following (if not the default embedded one):
  39141. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39142. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39143. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39144. * The material properties need to be setup according to the type of texture in use.
  39145. */
  39146. environmentBRDFTexture: BaseTexture;
  39147. /** @hidden */
  39148. protected _environmentTexture: Nullable<BaseTexture>;
  39149. /**
  39150. * Texture used in all pbr material as the reflection texture.
  39151. * As in the majority of the scene they are the same (exception for multi room and so on),
  39152. * this is easier to reference from here than from all the materials.
  39153. */
  39154. get environmentTexture(): Nullable<BaseTexture>;
  39155. /**
  39156. * Texture used in all pbr material as the reflection texture.
  39157. * As in the majority of the scene they are the same (exception for multi room and so on),
  39158. * this is easier to set here than in all the materials.
  39159. */
  39160. set environmentTexture(value: Nullable<BaseTexture>);
  39161. /** @hidden */
  39162. protected _environmentIntensity: number;
  39163. /**
  39164. * Intensity of the environment in all pbr material.
  39165. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39166. * As in the majority of the scene they are the same (exception for multi room and so on),
  39167. * this is easier to reference from here than from all the materials.
  39168. */
  39169. get environmentIntensity(): number;
  39170. /**
  39171. * Intensity of the environment in all pbr material.
  39172. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39173. * As in the majority of the scene they are the same (exception for multi room and so on),
  39174. * this is easier to set here than in all the materials.
  39175. */
  39176. set environmentIntensity(value: number);
  39177. /** @hidden */
  39178. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39179. /**
  39180. * Default image processing configuration used either in the rendering
  39181. * Forward main pass or through the imageProcessingPostProcess if present.
  39182. * As in the majority of the scene they are the same (exception for multi camera),
  39183. * this is easier to reference from here than from all the materials and post process.
  39184. *
  39185. * No setter as we it is a shared configuration, you can set the values instead.
  39186. */
  39187. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39188. private _forceWireframe;
  39189. /**
  39190. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39191. */
  39192. set forceWireframe(value: boolean);
  39193. get forceWireframe(): boolean;
  39194. private _skipFrustumClipping;
  39195. /**
  39196. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39197. */
  39198. set skipFrustumClipping(value: boolean);
  39199. get skipFrustumClipping(): boolean;
  39200. private _forcePointsCloud;
  39201. /**
  39202. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39203. */
  39204. set forcePointsCloud(value: boolean);
  39205. get forcePointsCloud(): boolean;
  39206. /**
  39207. * Gets or sets the active clipplane 1
  39208. */
  39209. clipPlane: Nullable<Plane>;
  39210. /**
  39211. * Gets or sets the active clipplane 2
  39212. */
  39213. clipPlane2: Nullable<Plane>;
  39214. /**
  39215. * Gets or sets the active clipplane 3
  39216. */
  39217. clipPlane3: Nullable<Plane>;
  39218. /**
  39219. * Gets or sets the active clipplane 4
  39220. */
  39221. clipPlane4: Nullable<Plane>;
  39222. /**
  39223. * Gets or sets the active clipplane 5
  39224. */
  39225. clipPlane5: Nullable<Plane>;
  39226. /**
  39227. * Gets or sets the active clipplane 6
  39228. */
  39229. clipPlane6: Nullable<Plane>;
  39230. /**
  39231. * Gets or sets a boolean indicating if animations are enabled
  39232. */
  39233. animationsEnabled: boolean;
  39234. private _animationPropertiesOverride;
  39235. /**
  39236. * Gets or sets the animation properties override
  39237. */
  39238. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39239. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39240. /**
  39241. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39242. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39243. */
  39244. useConstantAnimationDeltaTime: boolean;
  39245. /**
  39246. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39247. * Please note that it requires to run a ray cast through the scene on every frame
  39248. */
  39249. constantlyUpdateMeshUnderPointer: boolean;
  39250. /**
  39251. * Defines the HTML cursor to use when hovering over interactive elements
  39252. */
  39253. hoverCursor: string;
  39254. /**
  39255. * Defines the HTML default cursor to use (empty by default)
  39256. */
  39257. defaultCursor: string;
  39258. /**
  39259. * Defines whether cursors are handled by the scene.
  39260. */
  39261. doNotHandleCursors: boolean;
  39262. /**
  39263. * This is used to call preventDefault() on pointer down
  39264. * in order to block unwanted artifacts like system double clicks
  39265. */
  39266. preventDefaultOnPointerDown: boolean;
  39267. /**
  39268. * This is used to call preventDefault() on pointer up
  39269. * in order to block unwanted artifacts like system double clicks
  39270. */
  39271. preventDefaultOnPointerUp: boolean;
  39272. /**
  39273. * Gets or sets user defined metadata
  39274. */
  39275. metadata: any;
  39276. /**
  39277. * For internal use only. Please do not use.
  39278. */
  39279. reservedDataStore: any;
  39280. /**
  39281. * Gets the name of the plugin used to load this scene (null by default)
  39282. */
  39283. loadingPluginName: string;
  39284. /**
  39285. * Use this array to add regular expressions used to disable offline support for specific urls
  39286. */
  39287. disableOfflineSupportExceptionRules: RegExp[];
  39288. /**
  39289. * An event triggered when the scene is disposed.
  39290. */
  39291. onDisposeObservable: Observable<Scene>;
  39292. private _onDisposeObserver;
  39293. /** Sets a function to be executed when this scene is disposed. */
  39294. set onDispose(callback: () => void);
  39295. /**
  39296. * An event triggered before rendering the scene (right after animations and physics)
  39297. */
  39298. onBeforeRenderObservable: Observable<Scene>;
  39299. private _onBeforeRenderObserver;
  39300. /** Sets a function to be executed before rendering this scene */
  39301. set beforeRender(callback: Nullable<() => void>);
  39302. /**
  39303. * An event triggered after rendering the scene
  39304. */
  39305. onAfterRenderObservable: Observable<Scene>;
  39306. /**
  39307. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39308. */
  39309. onAfterRenderCameraObservable: Observable<Camera>;
  39310. private _onAfterRenderObserver;
  39311. /** Sets a function to be executed after rendering this scene */
  39312. set afterRender(callback: Nullable<() => void>);
  39313. /**
  39314. * An event triggered before animating the scene
  39315. */
  39316. onBeforeAnimationsObservable: Observable<Scene>;
  39317. /**
  39318. * An event triggered after animations processing
  39319. */
  39320. onAfterAnimationsObservable: Observable<Scene>;
  39321. /**
  39322. * An event triggered before draw calls are ready to be sent
  39323. */
  39324. onBeforeDrawPhaseObservable: Observable<Scene>;
  39325. /**
  39326. * An event triggered after draw calls have been sent
  39327. */
  39328. onAfterDrawPhaseObservable: Observable<Scene>;
  39329. /**
  39330. * An event triggered when the scene is ready
  39331. */
  39332. onReadyObservable: Observable<Scene>;
  39333. /**
  39334. * An event triggered before rendering a camera
  39335. */
  39336. onBeforeCameraRenderObservable: Observable<Camera>;
  39337. private _onBeforeCameraRenderObserver;
  39338. /** Sets a function to be executed before rendering a camera*/
  39339. set beforeCameraRender(callback: () => void);
  39340. /**
  39341. * An event triggered after rendering a camera
  39342. */
  39343. onAfterCameraRenderObservable: Observable<Camera>;
  39344. private _onAfterCameraRenderObserver;
  39345. /** Sets a function to be executed after rendering a camera*/
  39346. set afterCameraRender(callback: () => void);
  39347. /**
  39348. * An event triggered when active meshes evaluation is about to start
  39349. */
  39350. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  39351. /**
  39352. * An event triggered when active meshes evaluation is done
  39353. */
  39354. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  39355. /**
  39356. * An event triggered when particles rendering is about to start
  39357. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39358. */
  39359. onBeforeParticlesRenderingObservable: Observable<Scene>;
  39360. /**
  39361. * An event triggered when particles rendering is done
  39362. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39363. */
  39364. onAfterParticlesRenderingObservable: Observable<Scene>;
  39365. /**
  39366. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  39367. */
  39368. onDataLoadedObservable: Observable<Scene>;
  39369. /**
  39370. * An event triggered when a camera is created
  39371. */
  39372. onNewCameraAddedObservable: Observable<Camera>;
  39373. /**
  39374. * An event triggered when a camera is removed
  39375. */
  39376. onCameraRemovedObservable: Observable<Camera>;
  39377. /**
  39378. * An event triggered when a light is created
  39379. */
  39380. onNewLightAddedObservable: Observable<Light>;
  39381. /**
  39382. * An event triggered when a light is removed
  39383. */
  39384. onLightRemovedObservable: Observable<Light>;
  39385. /**
  39386. * An event triggered when a geometry is created
  39387. */
  39388. onNewGeometryAddedObservable: Observable<Geometry>;
  39389. /**
  39390. * An event triggered when a geometry is removed
  39391. */
  39392. onGeometryRemovedObservable: Observable<Geometry>;
  39393. /**
  39394. * An event triggered when a transform node is created
  39395. */
  39396. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  39397. /**
  39398. * An event triggered when a transform node is removed
  39399. */
  39400. onTransformNodeRemovedObservable: Observable<TransformNode>;
  39401. /**
  39402. * An event triggered when a mesh is created
  39403. */
  39404. onNewMeshAddedObservable: Observable<AbstractMesh>;
  39405. /**
  39406. * An event triggered when a mesh is removed
  39407. */
  39408. onMeshRemovedObservable: Observable<AbstractMesh>;
  39409. /**
  39410. * An event triggered when a skeleton is created
  39411. */
  39412. onNewSkeletonAddedObservable: Observable<Skeleton>;
  39413. /**
  39414. * An event triggered when a skeleton is removed
  39415. */
  39416. onSkeletonRemovedObservable: Observable<Skeleton>;
  39417. /**
  39418. * An event triggered when a material is created
  39419. */
  39420. onNewMaterialAddedObservable: Observable<Material>;
  39421. /**
  39422. * An event triggered when a material is removed
  39423. */
  39424. onMaterialRemovedObservable: Observable<Material>;
  39425. /**
  39426. * An event triggered when a texture is created
  39427. */
  39428. onNewTextureAddedObservable: Observable<BaseTexture>;
  39429. /**
  39430. * An event triggered when a texture is removed
  39431. */
  39432. onTextureRemovedObservable: Observable<BaseTexture>;
  39433. /**
  39434. * An event triggered when render targets are about to be rendered
  39435. * Can happen multiple times per frame.
  39436. */
  39437. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  39438. /**
  39439. * An event triggered when render targets were rendered.
  39440. * Can happen multiple times per frame.
  39441. */
  39442. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  39443. /**
  39444. * An event triggered before calculating deterministic simulation step
  39445. */
  39446. onBeforeStepObservable: Observable<Scene>;
  39447. /**
  39448. * An event triggered after calculating deterministic simulation step
  39449. */
  39450. onAfterStepObservable: Observable<Scene>;
  39451. /**
  39452. * An event triggered when the activeCamera property is updated
  39453. */
  39454. onActiveCameraChanged: Observable<Scene>;
  39455. /**
  39456. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  39457. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39458. * 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)
  39459. */
  39460. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39461. /**
  39462. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  39463. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39464. * 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)
  39465. */
  39466. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39467. /**
  39468. * This Observable will when a mesh has been imported into the scene.
  39469. */
  39470. onMeshImportedObservable: Observable<AbstractMesh>;
  39471. /**
  39472. * This Observable will when an animation file has been imported into the scene.
  39473. */
  39474. onAnimationFileImportedObservable: Observable<Scene>;
  39475. /**
  39476. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  39477. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  39478. */
  39479. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  39480. /** @hidden */
  39481. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  39482. /**
  39483. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  39484. */
  39485. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  39486. /**
  39487. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  39488. */
  39489. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  39490. /**
  39491. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  39492. */
  39493. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  39494. /** Callback called when a pointer move is detected */
  39495. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39496. /** Callback called when a pointer down is detected */
  39497. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39498. /** Callback called when a pointer up is detected */
  39499. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  39500. /** Callback called when a pointer pick is detected */
  39501. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  39502. /**
  39503. * 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).
  39504. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  39505. */
  39506. onPrePointerObservable: Observable<PointerInfoPre>;
  39507. /**
  39508. * Observable event triggered each time an input event is received from the rendering canvas
  39509. */
  39510. onPointerObservable: Observable<PointerInfo>;
  39511. /**
  39512. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  39513. */
  39514. get unTranslatedPointer(): Vector2;
  39515. /**
  39516. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  39517. */
  39518. static get DragMovementThreshold(): number;
  39519. static set DragMovementThreshold(value: number);
  39520. /**
  39521. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  39522. */
  39523. static get LongPressDelay(): number;
  39524. static set LongPressDelay(value: number);
  39525. /**
  39526. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  39527. */
  39528. static get DoubleClickDelay(): number;
  39529. static set DoubleClickDelay(value: number);
  39530. /** If you need to check double click without raising a single click at first click, enable this flag */
  39531. static get ExclusiveDoubleClickMode(): boolean;
  39532. static set ExclusiveDoubleClickMode(value: boolean);
  39533. /** @hidden */
  39534. _mirroredCameraPosition: Nullable<Vector3>;
  39535. /**
  39536. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  39537. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  39538. */
  39539. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  39540. /**
  39541. * Observable event triggered each time an keyboard event is received from the hosting window
  39542. */
  39543. onKeyboardObservable: Observable<KeyboardInfo>;
  39544. private _useRightHandedSystem;
  39545. /**
  39546. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  39547. */
  39548. set useRightHandedSystem(value: boolean);
  39549. get useRightHandedSystem(): boolean;
  39550. private _timeAccumulator;
  39551. private _currentStepId;
  39552. private _currentInternalStep;
  39553. /**
  39554. * Sets the step Id used by deterministic lock step
  39555. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39556. * @param newStepId defines the step Id
  39557. */
  39558. setStepId(newStepId: number): void;
  39559. /**
  39560. * Gets the step Id used by deterministic lock step
  39561. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39562. * @returns the step Id
  39563. */
  39564. getStepId(): number;
  39565. /**
  39566. * Gets the internal step used by deterministic lock step
  39567. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39568. * @returns the internal step
  39569. */
  39570. getInternalStep(): number;
  39571. private _fogEnabled;
  39572. /**
  39573. * Gets or sets a boolean indicating if fog is enabled on this scene
  39574. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39575. * (Default is true)
  39576. */
  39577. set fogEnabled(value: boolean);
  39578. get fogEnabled(): boolean;
  39579. private _fogMode;
  39580. /**
  39581. * Gets or sets the fog mode to use
  39582. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39583. * | mode | value |
  39584. * | --- | --- |
  39585. * | FOGMODE_NONE | 0 |
  39586. * | FOGMODE_EXP | 1 |
  39587. * | FOGMODE_EXP2 | 2 |
  39588. * | FOGMODE_LINEAR | 3 |
  39589. */
  39590. set fogMode(value: number);
  39591. get fogMode(): number;
  39592. /**
  39593. * Gets or sets the fog color to use
  39594. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39595. * (Default is Color3(0.2, 0.2, 0.3))
  39596. */
  39597. fogColor: Color3;
  39598. /**
  39599. * Gets or sets the fog density to use
  39600. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39601. * (Default is 0.1)
  39602. */
  39603. fogDensity: number;
  39604. /**
  39605. * Gets or sets the fog start distance to use
  39606. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39607. * (Default is 0)
  39608. */
  39609. fogStart: number;
  39610. /**
  39611. * Gets or sets the fog end distance to use
  39612. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39613. * (Default is 1000)
  39614. */
  39615. fogEnd: number;
  39616. /**
  39617. * Flag indicating that the frame buffer binding is handled by another component
  39618. */
  39619. prePass: boolean;
  39620. private _shadowsEnabled;
  39621. /**
  39622. * Gets or sets a boolean indicating if shadows are enabled on this scene
  39623. */
  39624. set shadowsEnabled(value: boolean);
  39625. get shadowsEnabled(): boolean;
  39626. private _lightsEnabled;
  39627. /**
  39628. * Gets or sets a boolean indicating if lights are enabled on this scene
  39629. */
  39630. set lightsEnabled(value: boolean);
  39631. get lightsEnabled(): boolean;
  39632. /** All of the active cameras added to this scene. */
  39633. activeCameras: Camera[];
  39634. /** @hidden */
  39635. _activeCamera: Nullable<Camera>;
  39636. /** Gets or sets the current active camera */
  39637. get activeCamera(): Nullable<Camera>;
  39638. set activeCamera(value: Nullable<Camera>);
  39639. private _defaultMaterial;
  39640. /** The default material used on meshes when no material is affected */
  39641. get defaultMaterial(): Material;
  39642. /** The default material used on meshes when no material is affected */
  39643. set defaultMaterial(value: Material);
  39644. private _texturesEnabled;
  39645. /**
  39646. * Gets or sets a boolean indicating if textures are enabled on this scene
  39647. */
  39648. set texturesEnabled(value: boolean);
  39649. get texturesEnabled(): boolean;
  39650. /**
  39651. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  39652. */
  39653. physicsEnabled: boolean;
  39654. /**
  39655. * Gets or sets a boolean indicating if particles are enabled on this scene
  39656. */
  39657. particlesEnabled: boolean;
  39658. /**
  39659. * Gets or sets a boolean indicating if sprites are enabled on this scene
  39660. */
  39661. spritesEnabled: boolean;
  39662. private _skeletonsEnabled;
  39663. /**
  39664. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  39665. */
  39666. set skeletonsEnabled(value: boolean);
  39667. get skeletonsEnabled(): boolean;
  39668. /**
  39669. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  39670. */
  39671. lensFlaresEnabled: boolean;
  39672. /**
  39673. * Gets or sets a boolean indicating if collisions are enabled on this scene
  39674. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39675. */
  39676. collisionsEnabled: boolean;
  39677. private _collisionCoordinator;
  39678. /** @hidden */
  39679. get collisionCoordinator(): ICollisionCoordinator;
  39680. /**
  39681. * Defines the gravity applied to this scene (used only for collisions)
  39682. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39683. */
  39684. gravity: Vector3;
  39685. /**
  39686. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  39687. */
  39688. postProcessesEnabled: boolean;
  39689. /**
  39690. * The list of postprocesses added to the scene
  39691. */
  39692. postProcesses: PostProcess[];
  39693. /**
  39694. * Gets the current postprocess manager
  39695. */
  39696. postProcessManager: PostProcessManager;
  39697. /**
  39698. * Gets or sets a boolean indicating if render targets are enabled on this scene
  39699. */
  39700. renderTargetsEnabled: boolean;
  39701. /**
  39702. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  39703. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  39704. */
  39705. dumpNextRenderTargets: boolean;
  39706. /**
  39707. * The list of user defined render targets added to the scene
  39708. */
  39709. customRenderTargets: RenderTargetTexture[];
  39710. /**
  39711. * Defines if texture loading must be delayed
  39712. * If true, textures will only be loaded when they need to be rendered
  39713. */
  39714. useDelayedTextureLoading: boolean;
  39715. /**
  39716. * Gets the list of meshes imported to the scene through SceneLoader
  39717. */
  39718. importedMeshesFiles: String[];
  39719. /**
  39720. * Gets or sets a boolean indicating if probes are enabled on this scene
  39721. */
  39722. probesEnabled: boolean;
  39723. /**
  39724. * Gets or sets the current offline provider to use to store scene data
  39725. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  39726. */
  39727. offlineProvider: IOfflineProvider;
  39728. /**
  39729. * Gets or sets the action manager associated with the scene
  39730. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  39731. */
  39732. actionManager: AbstractActionManager;
  39733. private _meshesForIntersections;
  39734. /**
  39735. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  39736. */
  39737. proceduralTexturesEnabled: boolean;
  39738. private _engine;
  39739. private _totalVertices;
  39740. /** @hidden */
  39741. _activeIndices: PerfCounter;
  39742. /** @hidden */
  39743. _activeParticles: PerfCounter;
  39744. /** @hidden */
  39745. _activeBones: PerfCounter;
  39746. private _animationRatio;
  39747. /** @hidden */
  39748. _animationTimeLast: number;
  39749. /** @hidden */
  39750. _animationTime: number;
  39751. /**
  39752. * Gets or sets a general scale for animation speed
  39753. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  39754. */
  39755. animationTimeScale: number;
  39756. /** @hidden */
  39757. _cachedMaterial: Nullable<Material>;
  39758. /** @hidden */
  39759. _cachedEffect: Nullable<Effect>;
  39760. /** @hidden */
  39761. _cachedVisibility: Nullable<number>;
  39762. private _renderId;
  39763. private _frameId;
  39764. private _executeWhenReadyTimeoutId;
  39765. private _intermediateRendering;
  39766. private _viewUpdateFlag;
  39767. private _projectionUpdateFlag;
  39768. /** @hidden */
  39769. _toBeDisposed: Nullable<IDisposable>[];
  39770. private _activeRequests;
  39771. /** @hidden */
  39772. _pendingData: any[];
  39773. private _isDisposed;
  39774. /**
  39775. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  39776. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  39777. */
  39778. dispatchAllSubMeshesOfActiveMeshes: boolean;
  39779. private _activeMeshes;
  39780. private _processedMaterials;
  39781. private _renderTargets;
  39782. /** @hidden */
  39783. _activeParticleSystems: SmartArray<IParticleSystem>;
  39784. private _activeSkeletons;
  39785. private _softwareSkinnedMeshes;
  39786. private _renderingManager;
  39787. /** @hidden */
  39788. _activeAnimatables: Animatable[];
  39789. private _transformMatrix;
  39790. private _sceneUbo;
  39791. /** @hidden */
  39792. _viewMatrix: Matrix;
  39793. private _projectionMatrix;
  39794. /** @hidden */
  39795. _forcedViewPosition: Nullable<Vector3>;
  39796. /** @hidden */
  39797. _frustumPlanes: Plane[];
  39798. /**
  39799. * Gets the list of frustum planes (built from the active camera)
  39800. */
  39801. get frustumPlanes(): Plane[];
  39802. /**
  39803. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  39804. * This is useful if there are more lights that the maximum simulteanous authorized
  39805. */
  39806. requireLightSorting: boolean;
  39807. /** @hidden */
  39808. readonly useMaterialMeshMap: boolean;
  39809. /** @hidden */
  39810. readonly useClonedMeshMap: boolean;
  39811. private _externalData;
  39812. private _uid;
  39813. /**
  39814. * @hidden
  39815. * Backing store of defined scene components.
  39816. */
  39817. _components: ISceneComponent[];
  39818. /**
  39819. * @hidden
  39820. * Backing store of defined scene components.
  39821. */
  39822. _serializableComponents: ISceneSerializableComponent[];
  39823. /**
  39824. * List of components to register on the next registration step.
  39825. */
  39826. private _transientComponents;
  39827. /**
  39828. * Registers the transient components if needed.
  39829. */
  39830. private _registerTransientComponents;
  39831. /**
  39832. * @hidden
  39833. * Add a component to the scene.
  39834. * Note that the ccomponent could be registered on th next frame if this is called after
  39835. * the register component stage.
  39836. * @param component Defines the component to add to the scene
  39837. */
  39838. _addComponent(component: ISceneComponent): void;
  39839. /**
  39840. * @hidden
  39841. * Gets a component from the scene.
  39842. * @param name defines the name of the component to retrieve
  39843. * @returns the component or null if not present
  39844. */
  39845. _getComponent(name: string): Nullable<ISceneComponent>;
  39846. /**
  39847. * @hidden
  39848. * Defines the actions happening before camera updates.
  39849. */
  39850. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  39851. /**
  39852. * @hidden
  39853. * Defines the actions happening before clear the canvas.
  39854. */
  39855. _beforeClearStage: Stage<SimpleStageAction>;
  39856. /**
  39857. * @hidden
  39858. * Defines the actions when collecting render targets for the frame.
  39859. */
  39860. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  39861. /**
  39862. * @hidden
  39863. * Defines the actions happening for one camera in the frame.
  39864. */
  39865. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  39866. /**
  39867. * @hidden
  39868. * Defines the actions happening during the per mesh ready checks.
  39869. */
  39870. _isReadyForMeshStage: Stage<MeshStageAction>;
  39871. /**
  39872. * @hidden
  39873. * Defines the actions happening before evaluate active mesh checks.
  39874. */
  39875. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  39876. /**
  39877. * @hidden
  39878. * Defines the actions happening during the evaluate sub mesh checks.
  39879. */
  39880. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  39881. /**
  39882. * @hidden
  39883. * Defines the actions happening during the active mesh stage.
  39884. */
  39885. _activeMeshStage: Stage<ActiveMeshStageAction>;
  39886. /**
  39887. * @hidden
  39888. * Defines the actions happening during the per camera render target step.
  39889. */
  39890. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  39891. /**
  39892. * @hidden
  39893. * Defines the actions happening just before the active camera is drawing.
  39894. */
  39895. _beforeCameraDrawStage: Stage<CameraStageAction>;
  39896. /**
  39897. * @hidden
  39898. * Defines the actions happening just before a render target is drawing.
  39899. */
  39900. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  39901. /**
  39902. * @hidden
  39903. * Defines the actions happening just before a rendering group is drawing.
  39904. */
  39905. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  39906. /**
  39907. * @hidden
  39908. * Defines the actions happening just before a mesh is drawing.
  39909. */
  39910. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  39911. /**
  39912. * @hidden
  39913. * Defines the actions happening just after a mesh has been drawn.
  39914. */
  39915. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  39916. /**
  39917. * @hidden
  39918. * Defines the actions happening just after a rendering group has been drawn.
  39919. */
  39920. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  39921. /**
  39922. * @hidden
  39923. * Defines the actions happening just after the active camera has been drawn.
  39924. */
  39925. _afterCameraDrawStage: Stage<CameraStageAction>;
  39926. /**
  39927. * @hidden
  39928. * Defines the actions happening just after a render target has been drawn.
  39929. */
  39930. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  39931. /**
  39932. * @hidden
  39933. * Defines the actions happening just after rendering all cameras and computing intersections.
  39934. */
  39935. _afterRenderStage: Stage<SimpleStageAction>;
  39936. /**
  39937. * @hidden
  39938. * Defines the actions happening when a pointer move event happens.
  39939. */
  39940. _pointerMoveStage: Stage<PointerMoveStageAction>;
  39941. /**
  39942. * @hidden
  39943. * Defines the actions happening when a pointer down event happens.
  39944. */
  39945. _pointerDownStage: Stage<PointerUpDownStageAction>;
  39946. /**
  39947. * @hidden
  39948. * Defines the actions happening when a pointer up event happens.
  39949. */
  39950. _pointerUpStage: Stage<PointerUpDownStageAction>;
  39951. /**
  39952. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  39953. */
  39954. private geometriesByUniqueId;
  39955. /**
  39956. * Creates a new Scene
  39957. * @param engine defines the engine to use to render this scene
  39958. * @param options defines the scene options
  39959. */
  39960. constructor(engine: Engine, options?: SceneOptions);
  39961. /**
  39962. * Gets a string idenfifying the name of the class
  39963. * @returns "Scene" string
  39964. */
  39965. getClassName(): string;
  39966. private _defaultMeshCandidates;
  39967. /**
  39968. * @hidden
  39969. */
  39970. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  39971. private _defaultSubMeshCandidates;
  39972. /**
  39973. * @hidden
  39974. */
  39975. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  39976. /**
  39977. * Sets the default candidate providers for the scene.
  39978. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  39979. * and getCollidingSubMeshCandidates to their default function
  39980. */
  39981. setDefaultCandidateProviders(): void;
  39982. /**
  39983. * Gets the mesh that is currently under the pointer
  39984. */
  39985. get meshUnderPointer(): Nullable<AbstractMesh>;
  39986. /**
  39987. * Gets or sets the current on-screen X position of the pointer
  39988. */
  39989. get pointerX(): number;
  39990. set pointerX(value: number);
  39991. /**
  39992. * Gets or sets the current on-screen Y position of the pointer
  39993. */
  39994. get pointerY(): number;
  39995. set pointerY(value: number);
  39996. /**
  39997. * Gets the cached material (ie. the latest rendered one)
  39998. * @returns the cached material
  39999. */
  40000. getCachedMaterial(): Nullable<Material>;
  40001. /**
  40002. * Gets the cached effect (ie. the latest rendered one)
  40003. * @returns the cached effect
  40004. */
  40005. getCachedEffect(): Nullable<Effect>;
  40006. /**
  40007. * Gets the cached visibility state (ie. the latest rendered one)
  40008. * @returns the cached visibility state
  40009. */
  40010. getCachedVisibility(): Nullable<number>;
  40011. /**
  40012. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40013. * @param material defines the current material
  40014. * @param effect defines the current effect
  40015. * @param visibility defines the current visibility state
  40016. * @returns true if one parameter is not cached
  40017. */
  40018. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40019. /**
  40020. * Gets the engine associated with the scene
  40021. * @returns an Engine
  40022. */
  40023. getEngine(): Engine;
  40024. /**
  40025. * Gets the total number of vertices rendered per frame
  40026. * @returns the total number of vertices rendered per frame
  40027. */
  40028. getTotalVertices(): number;
  40029. /**
  40030. * Gets the performance counter for total vertices
  40031. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40032. */
  40033. get totalVerticesPerfCounter(): PerfCounter;
  40034. /**
  40035. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40036. * @returns the total number of active indices rendered per frame
  40037. */
  40038. getActiveIndices(): number;
  40039. /**
  40040. * Gets the performance counter for active indices
  40041. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40042. */
  40043. get totalActiveIndicesPerfCounter(): PerfCounter;
  40044. /**
  40045. * Gets the total number of active particles rendered per frame
  40046. * @returns the total number of active particles rendered per frame
  40047. */
  40048. getActiveParticles(): number;
  40049. /**
  40050. * Gets the performance counter for active particles
  40051. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40052. */
  40053. get activeParticlesPerfCounter(): PerfCounter;
  40054. /**
  40055. * Gets the total number of active bones rendered per frame
  40056. * @returns the total number of active bones rendered per frame
  40057. */
  40058. getActiveBones(): number;
  40059. /**
  40060. * Gets the performance counter for active bones
  40061. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40062. */
  40063. get activeBonesPerfCounter(): PerfCounter;
  40064. /**
  40065. * Gets the array of active meshes
  40066. * @returns an array of AbstractMesh
  40067. */
  40068. getActiveMeshes(): SmartArray<AbstractMesh>;
  40069. /**
  40070. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40071. * @returns a number
  40072. */
  40073. getAnimationRatio(): number;
  40074. /**
  40075. * Gets an unique Id for the current render phase
  40076. * @returns a number
  40077. */
  40078. getRenderId(): number;
  40079. /**
  40080. * Gets an unique Id for the current frame
  40081. * @returns a number
  40082. */
  40083. getFrameId(): number;
  40084. /** Call this function if you want to manually increment the render Id*/
  40085. incrementRenderId(): void;
  40086. private _createUbo;
  40087. /**
  40088. * Use this method to simulate a pointer move on a mesh
  40089. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40090. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40091. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40092. * @returns the current scene
  40093. */
  40094. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40095. /**
  40096. * Use this method to simulate a pointer down on a mesh
  40097. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40098. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40099. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40100. * @returns the current scene
  40101. */
  40102. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40103. /**
  40104. * Use this method to simulate a pointer up on a mesh
  40105. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40106. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40107. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40108. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40109. * @returns the current scene
  40110. */
  40111. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40112. /**
  40113. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40114. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40115. * @returns true if the pointer was captured
  40116. */
  40117. isPointerCaptured(pointerId?: number): boolean;
  40118. /**
  40119. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40120. * @param attachUp defines if you want to attach events to pointerup
  40121. * @param attachDown defines if you want to attach events to pointerdown
  40122. * @param attachMove defines if you want to attach events to pointermove
  40123. */
  40124. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40125. /** Detaches all event handlers*/
  40126. detachControl(): void;
  40127. /**
  40128. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40129. * Delay loaded resources are not taking in account
  40130. * @return true if all required resources are ready
  40131. */
  40132. isReady(): boolean;
  40133. /** Resets all cached information relative to material (including effect and visibility) */
  40134. resetCachedMaterial(): void;
  40135. /**
  40136. * Registers a function to be called before every frame render
  40137. * @param func defines the function to register
  40138. */
  40139. registerBeforeRender(func: () => void): void;
  40140. /**
  40141. * Unregisters a function called before every frame render
  40142. * @param func defines the function to unregister
  40143. */
  40144. unregisterBeforeRender(func: () => void): void;
  40145. /**
  40146. * Registers a function to be called after every frame render
  40147. * @param func defines the function to register
  40148. */
  40149. registerAfterRender(func: () => void): void;
  40150. /**
  40151. * Unregisters a function called after every frame render
  40152. * @param func defines the function to unregister
  40153. */
  40154. unregisterAfterRender(func: () => void): void;
  40155. private _executeOnceBeforeRender;
  40156. /**
  40157. * The provided function will run before render once and will be disposed afterwards.
  40158. * A timeout delay can be provided so that the function will be executed in N ms.
  40159. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40160. * @param func The function to be executed.
  40161. * @param timeout optional delay in ms
  40162. */
  40163. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40164. /** @hidden */
  40165. _addPendingData(data: any): void;
  40166. /** @hidden */
  40167. _removePendingData(data: any): void;
  40168. /**
  40169. * Returns the number of items waiting to be loaded
  40170. * @returns the number of items waiting to be loaded
  40171. */
  40172. getWaitingItemsCount(): number;
  40173. /**
  40174. * Returns a boolean indicating if the scene is still loading data
  40175. */
  40176. get isLoading(): boolean;
  40177. /**
  40178. * Registers a function to be executed when the scene is ready
  40179. * @param {Function} func - the function to be executed
  40180. */
  40181. executeWhenReady(func: () => void): void;
  40182. /**
  40183. * Returns a promise that resolves when the scene is ready
  40184. * @returns A promise that resolves when the scene is ready
  40185. */
  40186. whenReadyAsync(): Promise<void>;
  40187. /** @hidden */
  40188. _checkIsReady(): void;
  40189. /**
  40190. * Gets all animatable attached to the scene
  40191. */
  40192. get animatables(): Animatable[];
  40193. /**
  40194. * Resets the last animation time frame.
  40195. * Useful to override when animations start running when loading a scene for the first time.
  40196. */
  40197. resetLastAnimationTimeFrame(): void;
  40198. /**
  40199. * Gets the current view matrix
  40200. * @returns a Matrix
  40201. */
  40202. getViewMatrix(): Matrix;
  40203. /**
  40204. * Gets the current projection matrix
  40205. * @returns a Matrix
  40206. */
  40207. getProjectionMatrix(): Matrix;
  40208. /**
  40209. * Gets the current transform matrix
  40210. * @returns a Matrix made of View * Projection
  40211. */
  40212. getTransformMatrix(): Matrix;
  40213. /**
  40214. * Sets the current transform matrix
  40215. * @param viewL defines the View matrix to use
  40216. * @param projectionL defines the Projection matrix to use
  40217. * @param viewR defines the right View matrix to use (if provided)
  40218. * @param projectionR defines the right Projection matrix to use (if provided)
  40219. */
  40220. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40221. /**
  40222. * Gets the uniform buffer used to store scene data
  40223. * @returns a UniformBuffer
  40224. */
  40225. getSceneUniformBuffer(): UniformBuffer;
  40226. /**
  40227. * Gets an unique (relatively to the current scene) Id
  40228. * @returns an unique number for the scene
  40229. */
  40230. getUniqueId(): number;
  40231. /**
  40232. * Add a mesh to the list of scene's meshes
  40233. * @param newMesh defines the mesh to add
  40234. * @param recursive if all child meshes should also be added to the scene
  40235. */
  40236. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40237. /**
  40238. * Remove a mesh for the list of scene's meshes
  40239. * @param toRemove defines the mesh to remove
  40240. * @param recursive if all child meshes should also be removed from the scene
  40241. * @returns the index where the mesh was in the mesh list
  40242. */
  40243. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40244. /**
  40245. * Add a transform node to the list of scene's transform nodes
  40246. * @param newTransformNode defines the transform node to add
  40247. */
  40248. addTransformNode(newTransformNode: TransformNode): void;
  40249. /**
  40250. * Remove a transform node for the list of scene's transform nodes
  40251. * @param toRemove defines the transform node to remove
  40252. * @returns the index where the transform node was in the transform node list
  40253. */
  40254. removeTransformNode(toRemove: TransformNode): number;
  40255. /**
  40256. * Remove a skeleton for the list of scene's skeletons
  40257. * @param toRemove defines the skeleton to remove
  40258. * @returns the index where the skeleton was in the skeleton list
  40259. */
  40260. removeSkeleton(toRemove: Skeleton): number;
  40261. /**
  40262. * Remove a morph target for the list of scene's morph targets
  40263. * @param toRemove defines the morph target to remove
  40264. * @returns the index where the morph target was in the morph target list
  40265. */
  40266. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40267. /**
  40268. * Remove a light for the list of scene's lights
  40269. * @param toRemove defines the light to remove
  40270. * @returns the index where the light was in the light list
  40271. */
  40272. removeLight(toRemove: Light): number;
  40273. /**
  40274. * Remove a camera for the list of scene's cameras
  40275. * @param toRemove defines the camera to remove
  40276. * @returns the index where the camera was in the camera list
  40277. */
  40278. removeCamera(toRemove: Camera): number;
  40279. /**
  40280. * Remove a particle system for the list of scene's particle systems
  40281. * @param toRemove defines the particle system to remove
  40282. * @returns the index where the particle system was in the particle system list
  40283. */
  40284. removeParticleSystem(toRemove: IParticleSystem): number;
  40285. /**
  40286. * Remove a animation for the list of scene's animations
  40287. * @param toRemove defines the animation to remove
  40288. * @returns the index where the animation was in the animation list
  40289. */
  40290. removeAnimation(toRemove: Animation): number;
  40291. /**
  40292. * Will stop the animation of the given target
  40293. * @param target - the target
  40294. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40295. * @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)
  40296. */
  40297. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40298. /**
  40299. * Removes the given animation group from this scene.
  40300. * @param toRemove The animation group to remove
  40301. * @returns The index of the removed animation group
  40302. */
  40303. removeAnimationGroup(toRemove: AnimationGroup): number;
  40304. /**
  40305. * Removes the given multi-material from this scene.
  40306. * @param toRemove The multi-material to remove
  40307. * @returns The index of the removed multi-material
  40308. */
  40309. removeMultiMaterial(toRemove: MultiMaterial): number;
  40310. /**
  40311. * Removes the given material from this scene.
  40312. * @param toRemove The material to remove
  40313. * @returns The index of the removed material
  40314. */
  40315. removeMaterial(toRemove: Material): number;
  40316. /**
  40317. * Removes the given action manager from this scene.
  40318. * @param toRemove The action manager to remove
  40319. * @returns The index of the removed action manager
  40320. */
  40321. removeActionManager(toRemove: AbstractActionManager): number;
  40322. /**
  40323. * Removes the given texture from this scene.
  40324. * @param toRemove The texture to remove
  40325. * @returns The index of the removed texture
  40326. */
  40327. removeTexture(toRemove: BaseTexture): number;
  40328. /**
  40329. * Adds the given light to this scene
  40330. * @param newLight The light to add
  40331. */
  40332. addLight(newLight: Light): void;
  40333. /**
  40334. * Sorts the list list based on light priorities
  40335. */
  40336. sortLightsByPriority(): void;
  40337. /**
  40338. * Adds the given camera to this scene
  40339. * @param newCamera The camera to add
  40340. */
  40341. addCamera(newCamera: Camera): void;
  40342. /**
  40343. * Adds the given skeleton to this scene
  40344. * @param newSkeleton The skeleton to add
  40345. */
  40346. addSkeleton(newSkeleton: Skeleton): void;
  40347. /**
  40348. * Adds the given particle system to this scene
  40349. * @param newParticleSystem The particle system to add
  40350. */
  40351. addParticleSystem(newParticleSystem: IParticleSystem): void;
  40352. /**
  40353. * Adds the given animation to this scene
  40354. * @param newAnimation The animation to add
  40355. */
  40356. addAnimation(newAnimation: Animation): void;
  40357. /**
  40358. * Adds the given animation group to this scene.
  40359. * @param newAnimationGroup The animation group to add
  40360. */
  40361. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  40362. /**
  40363. * Adds the given multi-material to this scene
  40364. * @param newMultiMaterial The multi-material to add
  40365. */
  40366. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  40367. /**
  40368. * Adds the given material to this scene
  40369. * @param newMaterial The material to add
  40370. */
  40371. addMaterial(newMaterial: Material): void;
  40372. /**
  40373. * Adds the given morph target to this scene
  40374. * @param newMorphTargetManager The morph target to add
  40375. */
  40376. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  40377. /**
  40378. * Adds the given geometry to this scene
  40379. * @param newGeometry The geometry to add
  40380. */
  40381. addGeometry(newGeometry: Geometry): void;
  40382. /**
  40383. * Adds the given action manager to this scene
  40384. * @param newActionManager The action manager to add
  40385. */
  40386. addActionManager(newActionManager: AbstractActionManager): void;
  40387. /**
  40388. * Adds the given texture to this scene.
  40389. * @param newTexture The texture to add
  40390. */
  40391. addTexture(newTexture: BaseTexture): void;
  40392. /**
  40393. * Switch active camera
  40394. * @param newCamera defines the new active camera
  40395. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  40396. */
  40397. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  40398. /**
  40399. * sets the active camera of the scene using its ID
  40400. * @param id defines the camera's ID
  40401. * @return the new active camera or null if none found.
  40402. */
  40403. setActiveCameraByID(id: string): Nullable<Camera>;
  40404. /**
  40405. * sets the active camera of the scene using its name
  40406. * @param name defines the camera's name
  40407. * @returns the new active camera or null if none found.
  40408. */
  40409. setActiveCameraByName(name: string): Nullable<Camera>;
  40410. /**
  40411. * get an animation group using its name
  40412. * @param name defines the material's name
  40413. * @return the animation group or null if none found.
  40414. */
  40415. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  40416. /**
  40417. * Get a material using its unique id
  40418. * @param uniqueId defines the material's unique id
  40419. * @return the material or null if none found.
  40420. */
  40421. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  40422. /**
  40423. * get a material using its id
  40424. * @param id defines the material's ID
  40425. * @return the material or null if none found.
  40426. */
  40427. getMaterialByID(id: string): Nullable<Material>;
  40428. /**
  40429. * Gets a the last added material using a given id
  40430. * @param id defines the material's ID
  40431. * @return the last material with the given id or null if none found.
  40432. */
  40433. getLastMaterialByID(id: string): Nullable<Material>;
  40434. /**
  40435. * Gets a material using its name
  40436. * @param name defines the material's name
  40437. * @return the material or null if none found.
  40438. */
  40439. getMaterialByName(name: string): Nullable<Material>;
  40440. /**
  40441. * Get a texture using its unique id
  40442. * @param uniqueId defines the texture's unique id
  40443. * @return the texture or null if none found.
  40444. */
  40445. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  40446. /**
  40447. * Gets a camera using its id
  40448. * @param id defines the id to look for
  40449. * @returns the camera or null if not found
  40450. */
  40451. getCameraByID(id: string): Nullable<Camera>;
  40452. /**
  40453. * Gets a camera using its unique id
  40454. * @param uniqueId defines the unique id to look for
  40455. * @returns the camera or null if not found
  40456. */
  40457. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  40458. /**
  40459. * Gets a camera using its name
  40460. * @param name defines the camera's name
  40461. * @return the camera or null if none found.
  40462. */
  40463. getCameraByName(name: string): Nullable<Camera>;
  40464. /**
  40465. * Gets a bone using its id
  40466. * @param id defines the bone's id
  40467. * @return the bone or null if not found
  40468. */
  40469. getBoneByID(id: string): Nullable<Bone>;
  40470. /**
  40471. * Gets a bone using its id
  40472. * @param name defines the bone's name
  40473. * @return the bone or null if not found
  40474. */
  40475. getBoneByName(name: string): Nullable<Bone>;
  40476. /**
  40477. * Gets a light node using its name
  40478. * @param name defines the the light's name
  40479. * @return the light or null if none found.
  40480. */
  40481. getLightByName(name: string): Nullable<Light>;
  40482. /**
  40483. * Gets a light node using its id
  40484. * @param id defines the light's id
  40485. * @return the light or null if none found.
  40486. */
  40487. getLightByID(id: string): Nullable<Light>;
  40488. /**
  40489. * Gets a light node using its scene-generated unique ID
  40490. * @param uniqueId defines the light's unique id
  40491. * @return the light or null if none found.
  40492. */
  40493. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  40494. /**
  40495. * Gets a particle system by id
  40496. * @param id defines the particle system id
  40497. * @return the corresponding system or null if none found
  40498. */
  40499. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  40500. /**
  40501. * Gets a geometry using its ID
  40502. * @param id defines the geometry's id
  40503. * @return the geometry or null if none found.
  40504. */
  40505. getGeometryByID(id: string): Nullable<Geometry>;
  40506. private _getGeometryByUniqueID;
  40507. /**
  40508. * Add a new geometry to this scene
  40509. * @param geometry defines the geometry to be added to the scene.
  40510. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  40511. * @return a boolean defining if the geometry was added or not
  40512. */
  40513. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  40514. /**
  40515. * Removes an existing geometry
  40516. * @param geometry defines the geometry to be removed from the scene
  40517. * @return a boolean defining if the geometry was removed or not
  40518. */
  40519. removeGeometry(geometry: Geometry): boolean;
  40520. /**
  40521. * Gets the list of geometries attached to the scene
  40522. * @returns an array of Geometry
  40523. */
  40524. getGeometries(): Geometry[];
  40525. /**
  40526. * Gets the first added mesh found of a given ID
  40527. * @param id defines the id to search for
  40528. * @return the mesh found or null if not found at all
  40529. */
  40530. getMeshByID(id: string): Nullable<AbstractMesh>;
  40531. /**
  40532. * Gets a list of meshes using their id
  40533. * @param id defines the id to search for
  40534. * @returns a list of meshes
  40535. */
  40536. getMeshesByID(id: string): Array<AbstractMesh>;
  40537. /**
  40538. * Gets the first added transform node found of a given ID
  40539. * @param id defines the id to search for
  40540. * @return the found transform node or null if not found at all.
  40541. */
  40542. getTransformNodeByID(id: string): Nullable<TransformNode>;
  40543. /**
  40544. * Gets a transform node with its auto-generated unique id
  40545. * @param uniqueId efines the unique id to search for
  40546. * @return the found transform node or null if not found at all.
  40547. */
  40548. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  40549. /**
  40550. * Gets a list of transform nodes using their id
  40551. * @param id defines the id to search for
  40552. * @returns a list of transform nodes
  40553. */
  40554. getTransformNodesByID(id: string): Array<TransformNode>;
  40555. /**
  40556. * Gets a mesh with its auto-generated unique id
  40557. * @param uniqueId defines the unique id to search for
  40558. * @return the found mesh or null if not found at all.
  40559. */
  40560. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  40561. /**
  40562. * Gets a the last added mesh using a given id
  40563. * @param id defines the id to search for
  40564. * @return the found mesh or null if not found at all.
  40565. */
  40566. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  40567. /**
  40568. * Gets a the last added node (Mesh, Camera, Light) using a given id
  40569. * @param id defines the id to search for
  40570. * @return the found node or null if not found at all
  40571. */
  40572. getLastEntryByID(id: string): Nullable<Node>;
  40573. /**
  40574. * Gets a node (Mesh, Camera, Light) using a given id
  40575. * @param id defines the id to search for
  40576. * @return the found node or null if not found at all
  40577. */
  40578. getNodeByID(id: string): Nullable<Node>;
  40579. /**
  40580. * Gets a node (Mesh, Camera, Light) using a given name
  40581. * @param name defines the name to search for
  40582. * @return the found node or null if not found at all.
  40583. */
  40584. getNodeByName(name: string): Nullable<Node>;
  40585. /**
  40586. * Gets a mesh using a given name
  40587. * @param name defines the name to search for
  40588. * @return the found mesh or null if not found at all.
  40589. */
  40590. getMeshByName(name: string): Nullable<AbstractMesh>;
  40591. /**
  40592. * Gets a transform node using a given name
  40593. * @param name defines the name to search for
  40594. * @return the found transform node or null if not found at all.
  40595. */
  40596. getTransformNodeByName(name: string): Nullable<TransformNode>;
  40597. /**
  40598. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  40599. * @param id defines the id to search for
  40600. * @return the found skeleton or null if not found at all.
  40601. */
  40602. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  40603. /**
  40604. * Gets a skeleton using a given auto generated unique id
  40605. * @param uniqueId defines the unique id to search for
  40606. * @return the found skeleton or null if not found at all.
  40607. */
  40608. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  40609. /**
  40610. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  40611. * @param id defines the id to search for
  40612. * @return the found skeleton or null if not found at all.
  40613. */
  40614. getSkeletonById(id: string): Nullable<Skeleton>;
  40615. /**
  40616. * Gets a skeleton using a given name
  40617. * @param name defines the name to search for
  40618. * @return the found skeleton or null if not found at all.
  40619. */
  40620. getSkeletonByName(name: string): Nullable<Skeleton>;
  40621. /**
  40622. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  40623. * @param id defines the id to search for
  40624. * @return the found morph target manager or null if not found at all.
  40625. */
  40626. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  40627. /**
  40628. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  40629. * @param id defines the id to search for
  40630. * @return the found morph target or null if not found at all.
  40631. */
  40632. getMorphTargetById(id: string): Nullable<MorphTarget>;
  40633. /**
  40634. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  40635. * @param name defines the name to search for
  40636. * @return the found morph target or null if not found at all.
  40637. */
  40638. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  40639. /**
  40640. * Gets a boolean indicating if the given mesh is active
  40641. * @param mesh defines the mesh to look for
  40642. * @returns true if the mesh is in the active list
  40643. */
  40644. isActiveMesh(mesh: AbstractMesh): boolean;
  40645. /**
  40646. * Return a unique id as a string which can serve as an identifier for the scene
  40647. */
  40648. get uid(): string;
  40649. /**
  40650. * Add an externaly attached data from its key.
  40651. * This method call will fail and return false, if such key already exists.
  40652. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  40653. * @param key the unique key that identifies the data
  40654. * @param data the data object to associate to the key for this Engine instance
  40655. * @return true if no such key were already present and the data was added successfully, false otherwise
  40656. */
  40657. addExternalData<T>(key: string, data: T): boolean;
  40658. /**
  40659. * Get an externaly attached data from its key
  40660. * @param key the unique key that identifies the data
  40661. * @return the associated data, if present (can be null), or undefined if not present
  40662. */
  40663. getExternalData<T>(key: string): Nullable<T>;
  40664. /**
  40665. * Get an externaly attached data from its key, create it using a factory if it's not already present
  40666. * @param key the unique key that identifies the data
  40667. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  40668. * @return the associated data, can be null if the factory returned null.
  40669. */
  40670. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  40671. /**
  40672. * Remove an externaly attached data from the Engine instance
  40673. * @param key the unique key that identifies the data
  40674. * @return true if the data was successfully removed, false if it doesn't exist
  40675. */
  40676. removeExternalData(key: string): boolean;
  40677. private _evaluateSubMesh;
  40678. /**
  40679. * Clear the processed materials smart array preventing retention point in material dispose.
  40680. */
  40681. freeProcessedMaterials(): void;
  40682. private _preventFreeActiveMeshesAndRenderingGroups;
  40683. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  40684. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  40685. * when disposing several meshes in a row or a hierarchy of meshes.
  40686. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  40687. */
  40688. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  40689. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  40690. /**
  40691. * Clear the active meshes smart array preventing retention point in mesh dispose.
  40692. */
  40693. freeActiveMeshes(): void;
  40694. /**
  40695. * Clear the info related to rendering groups preventing retention points during dispose.
  40696. */
  40697. freeRenderingGroups(): void;
  40698. /** @hidden */
  40699. _isInIntermediateRendering(): boolean;
  40700. /**
  40701. * Lambda returning the list of potentially active meshes.
  40702. */
  40703. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  40704. /**
  40705. * Lambda returning the list of potentially active sub meshes.
  40706. */
  40707. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  40708. /**
  40709. * Lambda returning the list of potentially intersecting sub meshes.
  40710. */
  40711. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  40712. /**
  40713. * Lambda returning the list of potentially colliding sub meshes.
  40714. */
  40715. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  40716. private _activeMeshesFrozen;
  40717. private _skipEvaluateActiveMeshesCompletely;
  40718. /**
  40719. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  40720. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  40721. * @returns the current scene
  40722. */
  40723. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  40724. /**
  40725. * Use this function to restart evaluating active meshes on every frame
  40726. * @returns the current scene
  40727. */
  40728. unfreezeActiveMeshes(): Scene;
  40729. private _evaluateActiveMeshes;
  40730. private _activeMesh;
  40731. /**
  40732. * Update the transform matrix to update from the current active camera
  40733. * @param force defines a boolean used to force the update even if cache is up to date
  40734. */
  40735. updateTransformMatrix(force?: boolean): void;
  40736. private _bindFrameBuffer;
  40737. /** @hidden */
  40738. _allowPostProcessClearColor: boolean;
  40739. /** @hidden */
  40740. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  40741. private _processSubCameras;
  40742. private _checkIntersections;
  40743. /** @hidden */
  40744. _advancePhysicsEngineStep(step: number): void;
  40745. /**
  40746. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  40747. */
  40748. getDeterministicFrameTime: () => number;
  40749. /** @hidden */
  40750. _animate(): void;
  40751. /** Execute all animations (for a frame) */
  40752. animate(): void;
  40753. /**
  40754. * Render the scene
  40755. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  40756. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  40757. */
  40758. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  40759. /**
  40760. * Freeze all materials
  40761. * A frozen material will not be updatable but should be faster to render
  40762. */
  40763. freezeMaterials(): void;
  40764. /**
  40765. * Unfreeze all materials
  40766. * A frozen material will not be updatable but should be faster to render
  40767. */
  40768. unfreezeMaterials(): void;
  40769. /**
  40770. * Releases all held ressources
  40771. */
  40772. dispose(): void;
  40773. /**
  40774. * Gets if the scene is already disposed
  40775. */
  40776. get isDisposed(): boolean;
  40777. /**
  40778. * Call this function to reduce memory footprint of the scene.
  40779. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  40780. */
  40781. clearCachedVertexData(): void;
  40782. /**
  40783. * This function will remove the local cached buffer data from texture.
  40784. * It will save memory but will prevent the texture from being rebuilt
  40785. */
  40786. cleanCachedTextureBuffer(): void;
  40787. /**
  40788. * Get the world extend vectors with an optional filter
  40789. *
  40790. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  40791. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  40792. */
  40793. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  40794. min: Vector3;
  40795. max: Vector3;
  40796. };
  40797. /**
  40798. * Creates a ray that can be used to pick in the scene
  40799. * @param x defines the x coordinate of the origin (on-screen)
  40800. * @param y defines the y coordinate of the origin (on-screen)
  40801. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  40802. * @param camera defines the camera to use for the picking
  40803. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  40804. * @returns a Ray
  40805. */
  40806. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  40807. /**
  40808. * Creates a ray that can be used to pick in the scene
  40809. * @param x defines the x coordinate of the origin (on-screen)
  40810. * @param y defines the y coordinate of the origin (on-screen)
  40811. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  40812. * @param result defines the ray where to store the picking ray
  40813. * @param camera defines the camera to use for the picking
  40814. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  40815. * @returns the current scene
  40816. */
  40817. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  40818. /**
  40819. * Creates a ray that can be used to pick in the scene
  40820. * @param x defines the x coordinate of the origin (on-screen)
  40821. * @param y defines the y coordinate of the origin (on-screen)
  40822. * @param camera defines the camera to use for the picking
  40823. * @returns a Ray
  40824. */
  40825. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  40826. /**
  40827. * Creates a ray that can be used to pick in the scene
  40828. * @param x defines the x coordinate of the origin (on-screen)
  40829. * @param y defines the y coordinate of the origin (on-screen)
  40830. * @param result defines the ray where to store the picking ray
  40831. * @param camera defines the camera to use for the picking
  40832. * @returns the current scene
  40833. */
  40834. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  40835. /** Launch a ray to try to pick a mesh in the scene
  40836. * @param x position on screen
  40837. * @param y position on screen
  40838. * @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
  40839. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40840. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40841. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40842. * @returns a PickingInfo
  40843. */
  40844. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  40845. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  40846. * @param x position on screen
  40847. * @param y position on screen
  40848. * @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
  40849. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40850. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40851. * @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)
  40852. */
  40853. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  40854. /** Use the given ray to pick a mesh in the scene
  40855. * @param ray The ray to use to pick meshes
  40856. * @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
  40857. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40858. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40859. * @returns a PickingInfo
  40860. */
  40861. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  40862. /**
  40863. * Launch a ray to try to pick a mesh in the scene
  40864. * @param x X position on screen
  40865. * @param y Y position on screen
  40866. * @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
  40867. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40868. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40869. * @returns an array of PickingInfo
  40870. */
  40871. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40872. /**
  40873. * Launch a ray to try to pick a mesh in the scene
  40874. * @param ray Ray to use
  40875. * @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
  40876. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40877. * @returns an array of PickingInfo
  40878. */
  40879. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40880. /**
  40881. * Force the value of meshUnderPointer
  40882. * @param mesh defines the mesh to use
  40883. */
  40884. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  40885. /**
  40886. * Gets the mesh under the pointer
  40887. * @returns a Mesh or null if no mesh is under the pointer
  40888. */
  40889. getPointerOverMesh(): Nullable<AbstractMesh>;
  40890. /** @hidden */
  40891. _rebuildGeometries(): void;
  40892. /** @hidden */
  40893. _rebuildTextures(): void;
  40894. private _getByTags;
  40895. /**
  40896. * Get a list of meshes by tags
  40897. * @param tagsQuery defines the tags query to use
  40898. * @param forEach defines a predicate used to filter results
  40899. * @returns an array of Mesh
  40900. */
  40901. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  40902. /**
  40903. * Get a list of cameras by tags
  40904. * @param tagsQuery defines the tags query to use
  40905. * @param forEach defines a predicate used to filter results
  40906. * @returns an array of Camera
  40907. */
  40908. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  40909. /**
  40910. * Get a list of lights by tags
  40911. * @param tagsQuery defines the tags query to use
  40912. * @param forEach defines a predicate used to filter results
  40913. * @returns an array of Light
  40914. */
  40915. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  40916. /**
  40917. * Get a list of materials by tags
  40918. * @param tagsQuery defines the tags query to use
  40919. * @param forEach defines a predicate used to filter results
  40920. * @returns an array of Material
  40921. */
  40922. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  40923. /**
  40924. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  40925. * This allowed control for front to back rendering or reversly depending of the special needs.
  40926. *
  40927. * @param renderingGroupId The rendering group id corresponding to its index
  40928. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  40929. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  40930. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  40931. */
  40932. 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;
  40933. /**
  40934. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  40935. *
  40936. * @param renderingGroupId The rendering group id corresponding to its index
  40937. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  40938. * @param depth Automatically clears depth between groups if true and autoClear is true.
  40939. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  40940. */
  40941. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  40942. /**
  40943. * Gets the current auto clear configuration for one rendering group of the rendering
  40944. * manager.
  40945. * @param index the rendering group index to get the information for
  40946. * @returns The auto clear setup for the requested rendering group
  40947. */
  40948. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  40949. private _blockMaterialDirtyMechanism;
  40950. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  40951. get blockMaterialDirtyMechanism(): boolean;
  40952. set blockMaterialDirtyMechanism(value: boolean);
  40953. /**
  40954. * Will flag all materials as dirty to trigger new shader compilation
  40955. * @param flag defines the flag used to specify which material part must be marked as dirty
  40956. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  40957. */
  40958. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  40959. /** @hidden */
  40960. _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;
  40961. /** @hidden */
  40962. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40963. /** @hidden */
  40964. _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;
  40965. /** @hidden */
  40966. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  40967. /** @hidden */
  40968. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  40969. /** @hidden */
  40970. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40971. }
  40972. }
  40973. declare module BABYLON {
  40974. /**
  40975. * Set of assets to keep when moving a scene into an asset container.
  40976. */
  40977. export class KeepAssets extends AbstractScene {
  40978. }
  40979. /**
  40980. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  40981. */
  40982. export class InstantiatedEntries {
  40983. /**
  40984. * List of new root nodes (eg. nodes with no parent)
  40985. */
  40986. rootNodes: TransformNode[];
  40987. /**
  40988. * List of new skeletons
  40989. */
  40990. skeletons: Skeleton[];
  40991. /**
  40992. * List of new animation groups
  40993. */
  40994. animationGroups: AnimationGroup[];
  40995. }
  40996. /**
  40997. * Container with a set of assets that can be added or removed from a scene.
  40998. */
  40999. export class AssetContainer extends AbstractScene {
  41000. private _wasAddedToScene;
  41001. /**
  41002. * The scene the AssetContainer belongs to.
  41003. */
  41004. scene: Scene;
  41005. /**
  41006. * Instantiates an AssetContainer.
  41007. * @param scene The scene the AssetContainer belongs to.
  41008. */
  41009. constructor(scene: Scene);
  41010. /**
  41011. * Instantiate or clone all meshes and add the new ones to the scene.
  41012. * Skeletons and animation groups will all be cloned
  41013. * @param nameFunction defines an optional function used to get new names for clones
  41014. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41015. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41016. */
  41017. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41018. /**
  41019. * Adds all the assets from the container to the scene.
  41020. */
  41021. addAllToScene(): void;
  41022. /**
  41023. * Removes all the assets in the container from the scene
  41024. */
  41025. removeAllFromScene(): void;
  41026. /**
  41027. * Disposes all the assets in the container
  41028. */
  41029. dispose(): void;
  41030. private _moveAssets;
  41031. /**
  41032. * Removes all the assets contained in the scene and adds them to the container.
  41033. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41034. */
  41035. moveAllFromScene(keepAssets?: KeepAssets): void;
  41036. /**
  41037. * 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.
  41038. * @returns the root mesh
  41039. */
  41040. createRootMesh(): Mesh;
  41041. /**
  41042. * Merge animations (direct and animation groups) from this asset container into a scene
  41043. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41044. * @param animatables set of animatables to retarget to a node from the scene
  41045. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41046. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41047. */
  41048. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41049. }
  41050. }
  41051. declare module BABYLON {
  41052. /**
  41053. * Defines how the parser contract is defined.
  41054. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41055. */
  41056. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41057. /**
  41058. * Defines how the individual parser contract is defined.
  41059. * These parser can parse an individual asset
  41060. */
  41061. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41062. /**
  41063. * Base class of the scene acting as a container for the different elements composing a scene.
  41064. * This class is dynamically extended by the different components of the scene increasing
  41065. * flexibility and reducing coupling
  41066. */
  41067. export abstract class AbstractScene {
  41068. /**
  41069. * Stores the list of available parsers in the application.
  41070. */
  41071. private static _BabylonFileParsers;
  41072. /**
  41073. * Stores the list of available individual parsers in the application.
  41074. */
  41075. private static _IndividualBabylonFileParsers;
  41076. /**
  41077. * Adds a parser in the list of available ones
  41078. * @param name Defines the name of the parser
  41079. * @param parser Defines the parser to add
  41080. */
  41081. static AddParser(name: string, parser: BabylonFileParser): void;
  41082. /**
  41083. * Gets a general parser from the list of avaialble ones
  41084. * @param name Defines the name of the parser
  41085. * @returns the requested parser or null
  41086. */
  41087. static GetParser(name: string): Nullable<BabylonFileParser>;
  41088. /**
  41089. * Adds n individual parser in the list of available ones
  41090. * @param name Defines the name of the parser
  41091. * @param parser Defines the parser to add
  41092. */
  41093. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41094. /**
  41095. * Gets an individual parser from the list of avaialble ones
  41096. * @param name Defines the name of the parser
  41097. * @returns the requested parser or null
  41098. */
  41099. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41100. /**
  41101. * Parser json data and populate both a scene and its associated container object
  41102. * @param jsonData Defines the data to parse
  41103. * @param scene Defines the scene to parse the data for
  41104. * @param container Defines the container attached to the parsing sequence
  41105. * @param rootUrl Defines the root url of the data
  41106. */
  41107. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41108. /**
  41109. * Gets the list of root nodes (ie. nodes with no parent)
  41110. */
  41111. rootNodes: Node[];
  41112. /** All of the cameras added to this scene
  41113. * @see https://doc.babylonjs.com/babylon101/cameras
  41114. */
  41115. cameras: Camera[];
  41116. /**
  41117. * All of the lights added to this scene
  41118. * @see https://doc.babylonjs.com/babylon101/lights
  41119. */
  41120. lights: Light[];
  41121. /**
  41122. * All of the (abstract) meshes added to this scene
  41123. */
  41124. meshes: AbstractMesh[];
  41125. /**
  41126. * The list of skeletons added to the scene
  41127. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41128. */
  41129. skeletons: Skeleton[];
  41130. /**
  41131. * All of the particle systems added to this scene
  41132. * @see https://doc.babylonjs.com/babylon101/particles
  41133. */
  41134. particleSystems: IParticleSystem[];
  41135. /**
  41136. * Gets a list of Animations associated with the scene
  41137. */
  41138. animations: Animation[];
  41139. /**
  41140. * All of the animation groups added to this scene
  41141. * @see https://doc.babylonjs.com/how_to/group
  41142. */
  41143. animationGroups: AnimationGroup[];
  41144. /**
  41145. * All of the multi-materials added to this scene
  41146. * @see https://doc.babylonjs.com/how_to/multi_materials
  41147. */
  41148. multiMaterials: MultiMaterial[];
  41149. /**
  41150. * All of the materials added to this scene
  41151. * In the context of a Scene, it is not supposed to be modified manually.
  41152. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41153. * Note also that the order of the Material within the array is not significant and might change.
  41154. * @see https://doc.babylonjs.com/babylon101/materials
  41155. */
  41156. materials: Material[];
  41157. /**
  41158. * The list of morph target managers added to the scene
  41159. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41160. */
  41161. morphTargetManagers: MorphTargetManager[];
  41162. /**
  41163. * The list of geometries used in the scene.
  41164. */
  41165. geometries: Geometry[];
  41166. /**
  41167. * All of the tranform nodes added to this scene
  41168. * In the context of a Scene, it is not supposed to be modified manually.
  41169. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41170. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41171. * @see https://doc.babylonjs.com/how_to/transformnode
  41172. */
  41173. transformNodes: TransformNode[];
  41174. /**
  41175. * ActionManagers available on the scene.
  41176. */
  41177. actionManagers: AbstractActionManager[];
  41178. /**
  41179. * Textures to keep.
  41180. */
  41181. textures: BaseTexture[];
  41182. /**
  41183. * Environment texture for the scene
  41184. */
  41185. environmentTexture: Nullable<BaseTexture>;
  41186. /**
  41187. * @returns all meshes, lights, cameras, transformNodes and bones
  41188. */
  41189. getNodes(): Array<Node>;
  41190. }
  41191. }
  41192. declare module BABYLON {
  41193. /**
  41194. * Interface used to define options for Sound class
  41195. */
  41196. export interface ISoundOptions {
  41197. /**
  41198. * Does the sound autoplay once loaded.
  41199. */
  41200. autoplay?: boolean;
  41201. /**
  41202. * Does the sound loop after it finishes playing once.
  41203. */
  41204. loop?: boolean;
  41205. /**
  41206. * Sound's volume
  41207. */
  41208. volume?: number;
  41209. /**
  41210. * Is it a spatial sound?
  41211. */
  41212. spatialSound?: boolean;
  41213. /**
  41214. * Maximum distance to hear that sound
  41215. */
  41216. maxDistance?: number;
  41217. /**
  41218. * Uses user defined attenuation function
  41219. */
  41220. useCustomAttenuation?: boolean;
  41221. /**
  41222. * Define the roll off factor of spatial sounds.
  41223. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41224. */
  41225. rolloffFactor?: number;
  41226. /**
  41227. * Define the reference distance the sound should be heard perfectly.
  41228. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41229. */
  41230. refDistance?: number;
  41231. /**
  41232. * Define the distance attenuation model the sound will follow.
  41233. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41234. */
  41235. distanceModel?: string;
  41236. /**
  41237. * Defines the playback speed (1 by default)
  41238. */
  41239. playbackRate?: number;
  41240. /**
  41241. * Defines if the sound is from a streaming source
  41242. */
  41243. streaming?: boolean;
  41244. /**
  41245. * Defines an optional length (in seconds) inside the sound file
  41246. */
  41247. length?: number;
  41248. /**
  41249. * Defines an optional offset (in seconds) inside the sound file
  41250. */
  41251. offset?: number;
  41252. /**
  41253. * If true, URLs will not be required to state the audio file codec to use.
  41254. */
  41255. skipCodecCheck?: boolean;
  41256. }
  41257. /**
  41258. * Defines a sound that can be played in the application.
  41259. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41260. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41261. */
  41262. export class Sound {
  41263. /**
  41264. * The name of the sound in the scene.
  41265. */
  41266. name: string;
  41267. /**
  41268. * Does the sound autoplay once loaded.
  41269. */
  41270. autoplay: boolean;
  41271. /**
  41272. * Does the sound loop after it finishes playing once.
  41273. */
  41274. loop: boolean;
  41275. /**
  41276. * Does the sound use a custom attenuation curve to simulate the falloff
  41277. * happening when the source gets further away from the camera.
  41278. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41279. */
  41280. useCustomAttenuation: boolean;
  41281. /**
  41282. * The sound track id this sound belongs to.
  41283. */
  41284. soundTrackId: number;
  41285. /**
  41286. * Is this sound currently played.
  41287. */
  41288. isPlaying: boolean;
  41289. /**
  41290. * Is this sound currently paused.
  41291. */
  41292. isPaused: boolean;
  41293. /**
  41294. * Does this sound enables spatial sound.
  41295. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41296. */
  41297. spatialSound: boolean;
  41298. /**
  41299. * Define the reference distance the sound should be heard perfectly.
  41300. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41301. */
  41302. refDistance: number;
  41303. /**
  41304. * Define the roll off factor of spatial sounds.
  41305. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41306. */
  41307. rolloffFactor: number;
  41308. /**
  41309. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  41310. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41311. */
  41312. maxDistance: number;
  41313. /**
  41314. * Define the distance attenuation model the sound will follow.
  41315. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41316. */
  41317. distanceModel: string;
  41318. /**
  41319. * @hidden
  41320. * Back Compat
  41321. **/
  41322. onended: () => any;
  41323. /**
  41324. * Gets or sets an object used to store user defined information for the sound.
  41325. */
  41326. metadata: any;
  41327. /**
  41328. * Observable event when the current playing sound finishes.
  41329. */
  41330. onEndedObservable: Observable<Sound>;
  41331. private _panningModel;
  41332. private _playbackRate;
  41333. private _streaming;
  41334. private _startTime;
  41335. private _startOffset;
  41336. private _position;
  41337. /** @hidden */
  41338. _positionInEmitterSpace: boolean;
  41339. private _localDirection;
  41340. private _volume;
  41341. private _isReadyToPlay;
  41342. private _isDirectional;
  41343. private _readyToPlayCallback;
  41344. private _audioBuffer;
  41345. private _soundSource;
  41346. private _streamingSource;
  41347. private _soundPanner;
  41348. private _soundGain;
  41349. private _inputAudioNode;
  41350. private _outputAudioNode;
  41351. private _coneInnerAngle;
  41352. private _coneOuterAngle;
  41353. private _coneOuterGain;
  41354. private _scene;
  41355. private _connectedTransformNode;
  41356. private _customAttenuationFunction;
  41357. private _registerFunc;
  41358. private _isOutputConnected;
  41359. private _htmlAudioElement;
  41360. private _urlType;
  41361. private _length?;
  41362. private _offset?;
  41363. /** @hidden */
  41364. static _SceneComponentInitialization: (scene: Scene) => void;
  41365. /**
  41366. * Create a sound and attach it to a scene
  41367. * @param name Name of your sound
  41368. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  41369. * @param scene defines the scene the sound belongs to
  41370. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  41371. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  41372. */
  41373. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  41374. /**
  41375. * Release the sound and its associated resources
  41376. */
  41377. dispose(): void;
  41378. /**
  41379. * Gets if the sounds is ready to be played or not.
  41380. * @returns true if ready, otherwise false
  41381. */
  41382. isReady(): boolean;
  41383. private _soundLoaded;
  41384. /**
  41385. * Sets the data of the sound from an audiobuffer
  41386. * @param audioBuffer The audioBuffer containing the data
  41387. */
  41388. setAudioBuffer(audioBuffer: AudioBuffer): void;
  41389. /**
  41390. * Updates the current sounds options such as maxdistance, loop...
  41391. * @param options A JSON object containing values named as the object properties
  41392. */
  41393. updateOptions(options: ISoundOptions): void;
  41394. private _createSpatialParameters;
  41395. private _updateSpatialParameters;
  41396. /**
  41397. * Switch the panning model to HRTF:
  41398. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41399. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41400. */
  41401. switchPanningModelToHRTF(): void;
  41402. /**
  41403. * Switch the panning model to Equal Power:
  41404. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41405. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41406. */
  41407. switchPanningModelToEqualPower(): void;
  41408. private _switchPanningModel;
  41409. /**
  41410. * Connect this sound to a sound track audio node like gain...
  41411. * @param soundTrackAudioNode the sound track audio node to connect to
  41412. */
  41413. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  41414. /**
  41415. * Transform this sound into a directional source
  41416. * @param coneInnerAngle Size of the inner cone in degree
  41417. * @param coneOuterAngle Size of the outer cone in degree
  41418. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  41419. */
  41420. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  41421. /**
  41422. * Gets or sets the inner angle for the directional cone.
  41423. */
  41424. get directionalConeInnerAngle(): number;
  41425. /**
  41426. * Gets or sets the inner angle for the directional cone.
  41427. */
  41428. set directionalConeInnerAngle(value: number);
  41429. /**
  41430. * Gets or sets the outer angle for the directional cone.
  41431. */
  41432. get directionalConeOuterAngle(): number;
  41433. /**
  41434. * Gets or sets the outer angle for the directional cone.
  41435. */
  41436. set directionalConeOuterAngle(value: number);
  41437. /**
  41438. * Sets the position of the emitter if spatial sound is enabled
  41439. * @param newPosition Defines the new posisiton
  41440. */
  41441. setPosition(newPosition: Vector3): void;
  41442. /**
  41443. * Sets the local direction of the emitter if spatial sound is enabled
  41444. * @param newLocalDirection Defines the new local direction
  41445. */
  41446. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  41447. private _updateDirection;
  41448. /** @hidden */
  41449. updateDistanceFromListener(): void;
  41450. /**
  41451. * Sets a new custom attenuation function for the sound.
  41452. * @param callback Defines the function used for the attenuation
  41453. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41454. */
  41455. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  41456. /**
  41457. * Play the sound
  41458. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  41459. * @param offset (optional) Start the sound at a specific time in seconds
  41460. * @param length (optional) Sound duration (in seconds)
  41461. */
  41462. play(time?: number, offset?: number, length?: number): void;
  41463. private _onended;
  41464. /**
  41465. * Stop the sound
  41466. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  41467. */
  41468. stop(time?: number): void;
  41469. /**
  41470. * Put the sound in pause
  41471. */
  41472. pause(): void;
  41473. /**
  41474. * Sets a dedicated volume for this sounds
  41475. * @param newVolume Define the new volume of the sound
  41476. * @param time Define time for gradual change to new volume
  41477. */
  41478. setVolume(newVolume: number, time?: number): void;
  41479. /**
  41480. * Set the sound play back rate
  41481. * @param newPlaybackRate Define the playback rate the sound should be played at
  41482. */
  41483. setPlaybackRate(newPlaybackRate: number): void;
  41484. /**
  41485. * Gets the volume of the sound.
  41486. * @returns the volume of the sound
  41487. */
  41488. getVolume(): number;
  41489. /**
  41490. * Attach the sound to a dedicated mesh
  41491. * @param transformNode The transform node to connect the sound with
  41492. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41493. */
  41494. attachToMesh(transformNode: TransformNode): void;
  41495. /**
  41496. * Detach the sound from the previously attached mesh
  41497. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41498. */
  41499. detachFromMesh(): void;
  41500. private _onRegisterAfterWorldMatrixUpdate;
  41501. /**
  41502. * Clone the current sound in the scene.
  41503. * @returns the new sound clone
  41504. */
  41505. clone(): Nullable<Sound>;
  41506. /**
  41507. * Gets the current underlying audio buffer containing the data
  41508. * @returns the audio buffer
  41509. */
  41510. getAudioBuffer(): Nullable<AudioBuffer>;
  41511. /**
  41512. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  41513. * @returns the source node
  41514. */
  41515. getSoundSource(): Nullable<AudioBufferSourceNode>;
  41516. /**
  41517. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  41518. * @returns the gain node
  41519. */
  41520. getSoundGain(): Nullable<GainNode>;
  41521. /**
  41522. * Serializes the Sound in a JSON representation
  41523. * @returns the JSON representation of the sound
  41524. */
  41525. serialize(): any;
  41526. /**
  41527. * Parse a JSON representation of a sound to innstantiate in a given scene
  41528. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  41529. * @param scene Define the scene the new parsed sound should be created in
  41530. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  41531. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  41532. * @returns the newly parsed sound
  41533. */
  41534. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  41535. }
  41536. }
  41537. declare module BABYLON {
  41538. /**
  41539. * This defines an action helpful to play a defined sound on a triggered action.
  41540. */
  41541. export class PlaySoundAction extends Action {
  41542. private _sound;
  41543. /**
  41544. * Instantiate the action
  41545. * @param triggerOptions defines the trigger options
  41546. * @param sound defines the sound to play
  41547. * @param condition defines the trigger related conditions
  41548. */
  41549. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41550. /** @hidden */
  41551. _prepare(): void;
  41552. /**
  41553. * Execute the action and play the sound.
  41554. */
  41555. execute(): void;
  41556. /**
  41557. * Serializes the actions and its related information.
  41558. * @param parent defines the object to serialize in
  41559. * @returns the serialized object
  41560. */
  41561. serialize(parent: any): any;
  41562. }
  41563. /**
  41564. * This defines an action helpful to stop a defined sound on a triggered action.
  41565. */
  41566. export class StopSoundAction extends Action {
  41567. private _sound;
  41568. /**
  41569. * Instantiate the action
  41570. * @param triggerOptions defines the trigger options
  41571. * @param sound defines the sound to stop
  41572. * @param condition defines the trigger related conditions
  41573. */
  41574. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41575. /** @hidden */
  41576. _prepare(): void;
  41577. /**
  41578. * Execute the action and stop the sound.
  41579. */
  41580. execute(): void;
  41581. /**
  41582. * Serializes the actions and its related information.
  41583. * @param parent defines the object to serialize in
  41584. * @returns the serialized object
  41585. */
  41586. serialize(parent: any): any;
  41587. }
  41588. }
  41589. declare module BABYLON {
  41590. /**
  41591. * This defines an action responsible to change the value of a property
  41592. * by interpolating between its current value and the newly set one once triggered.
  41593. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41594. */
  41595. export class InterpolateValueAction extends Action {
  41596. /**
  41597. * Defines the path of the property where the value should be interpolated
  41598. */
  41599. propertyPath: string;
  41600. /**
  41601. * Defines the target value at the end of the interpolation.
  41602. */
  41603. value: any;
  41604. /**
  41605. * Defines the time it will take for the property to interpolate to the value.
  41606. */
  41607. duration: number;
  41608. /**
  41609. * Defines if the other scene animations should be stopped when the action has been triggered
  41610. */
  41611. stopOtherAnimations?: boolean;
  41612. /**
  41613. * Defines a callback raised once the interpolation animation has been done.
  41614. */
  41615. onInterpolationDone?: () => void;
  41616. /**
  41617. * Observable triggered once the interpolation animation has been done.
  41618. */
  41619. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  41620. private _target;
  41621. private _effectiveTarget;
  41622. private _property;
  41623. /**
  41624. * Instantiate the action
  41625. * @param triggerOptions defines the trigger options
  41626. * @param target defines the object containing the value to interpolate
  41627. * @param propertyPath defines the path to the property in the target object
  41628. * @param value defines the target value at the end of the interpolation
  41629. * @param duration deines the time it will take for the property to interpolate to the value.
  41630. * @param condition defines the trigger related conditions
  41631. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  41632. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  41633. */
  41634. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  41635. /** @hidden */
  41636. _prepare(): void;
  41637. /**
  41638. * Execute the action starts the value interpolation.
  41639. */
  41640. execute(): void;
  41641. /**
  41642. * Serializes the actions and its related information.
  41643. * @param parent defines the object to serialize in
  41644. * @returns the serialized object
  41645. */
  41646. serialize(parent: any): any;
  41647. }
  41648. }
  41649. declare module BABYLON {
  41650. /**
  41651. * Options allowed during the creation of a sound track.
  41652. */
  41653. export interface ISoundTrackOptions {
  41654. /**
  41655. * The volume the sound track should take during creation
  41656. */
  41657. volume?: number;
  41658. /**
  41659. * Define if the sound track is the main sound track of the scene
  41660. */
  41661. mainTrack?: boolean;
  41662. }
  41663. /**
  41664. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  41665. * It will be also used in a future release to apply effects on a specific track.
  41666. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  41667. */
  41668. export class SoundTrack {
  41669. /**
  41670. * The unique identifier of the sound track in the scene.
  41671. */
  41672. id: number;
  41673. /**
  41674. * The list of sounds included in the sound track.
  41675. */
  41676. soundCollection: Array<Sound>;
  41677. private _outputAudioNode;
  41678. private _scene;
  41679. private _connectedAnalyser;
  41680. private _options;
  41681. private _isInitialized;
  41682. /**
  41683. * Creates a new sound track.
  41684. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  41685. * @param scene Define the scene the sound track belongs to
  41686. * @param options
  41687. */
  41688. constructor(scene: Scene, options?: ISoundTrackOptions);
  41689. private _initializeSoundTrackAudioGraph;
  41690. /**
  41691. * Release the sound track and its associated resources
  41692. */
  41693. dispose(): void;
  41694. /**
  41695. * Adds a sound to this sound track
  41696. * @param sound define the cound to add
  41697. * @ignoreNaming
  41698. */
  41699. AddSound(sound: Sound): void;
  41700. /**
  41701. * Removes a sound to this sound track
  41702. * @param sound define the cound to remove
  41703. * @ignoreNaming
  41704. */
  41705. RemoveSound(sound: Sound): void;
  41706. /**
  41707. * Set a global volume for the full sound track.
  41708. * @param newVolume Define the new volume of the sound track
  41709. */
  41710. setVolume(newVolume: number): void;
  41711. /**
  41712. * Switch the panning model to HRTF:
  41713. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41714. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41715. */
  41716. switchPanningModelToHRTF(): void;
  41717. /**
  41718. * Switch the panning model to Equal Power:
  41719. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41720. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41721. */
  41722. switchPanningModelToEqualPower(): void;
  41723. /**
  41724. * Connect the sound track to an audio analyser allowing some amazing
  41725. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41726. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41727. * @param analyser The analyser to connect to the engine
  41728. */
  41729. connectToAnalyser(analyser: Analyser): void;
  41730. }
  41731. }
  41732. declare module BABYLON {
  41733. interface AbstractScene {
  41734. /**
  41735. * The list of sounds used in the scene.
  41736. */
  41737. sounds: Nullable<Array<Sound>>;
  41738. }
  41739. interface Scene {
  41740. /**
  41741. * @hidden
  41742. * Backing field
  41743. */
  41744. _mainSoundTrack: SoundTrack;
  41745. /**
  41746. * The main sound track played by the scene.
  41747. * It cotains your primary collection of sounds.
  41748. */
  41749. mainSoundTrack: SoundTrack;
  41750. /**
  41751. * The list of sound tracks added to the scene
  41752. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41753. */
  41754. soundTracks: Nullable<Array<SoundTrack>>;
  41755. /**
  41756. * Gets a sound using a given name
  41757. * @param name defines the name to search for
  41758. * @return the found sound or null if not found at all.
  41759. */
  41760. getSoundByName(name: string): Nullable<Sound>;
  41761. /**
  41762. * Gets or sets if audio support is enabled
  41763. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41764. */
  41765. audioEnabled: boolean;
  41766. /**
  41767. * Gets or sets if audio will be output to headphones
  41768. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41769. */
  41770. headphone: boolean;
  41771. /**
  41772. * Gets or sets custom audio listener position provider
  41773. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41774. */
  41775. audioListenerPositionProvider: Nullable<() => Vector3>;
  41776. /**
  41777. * Gets or sets a refresh rate when using 3D audio positioning
  41778. */
  41779. audioPositioningRefreshRate: number;
  41780. }
  41781. /**
  41782. * Defines the sound scene component responsible to manage any sounds
  41783. * in a given scene.
  41784. */
  41785. export class AudioSceneComponent implements ISceneSerializableComponent {
  41786. /**
  41787. * The component name helpfull to identify the component in the list of scene components.
  41788. */
  41789. readonly name: string;
  41790. /**
  41791. * The scene the component belongs to.
  41792. */
  41793. scene: Scene;
  41794. private _audioEnabled;
  41795. /**
  41796. * Gets whether audio is enabled or not.
  41797. * Please use related enable/disable method to switch state.
  41798. */
  41799. get audioEnabled(): boolean;
  41800. private _headphone;
  41801. /**
  41802. * Gets whether audio is outputing to headphone or not.
  41803. * Please use the according Switch methods to change output.
  41804. */
  41805. get headphone(): boolean;
  41806. /**
  41807. * Gets or sets a refresh rate when using 3D audio positioning
  41808. */
  41809. audioPositioningRefreshRate: number;
  41810. private _audioListenerPositionProvider;
  41811. /**
  41812. * Gets the current audio listener position provider
  41813. */
  41814. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  41815. /**
  41816. * Sets a custom listener position for all sounds in the scene
  41817. * By default, this is the position of the first active camera
  41818. */
  41819. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  41820. /**
  41821. * Creates a new instance of the component for the given scene
  41822. * @param scene Defines the scene to register the component in
  41823. */
  41824. constructor(scene: Scene);
  41825. /**
  41826. * Registers the component in a given scene
  41827. */
  41828. register(): void;
  41829. /**
  41830. * Rebuilds the elements related to this component in case of
  41831. * context lost for instance.
  41832. */
  41833. rebuild(): void;
  41834. /**
  41835. * Serializes the component data to the specified json object
  41836. * @param serializationObject The object to serialize to
  41837. */
  41838. serialize(serializationObject: any): void;
  41839. /**
  41840. * Adds all the elements from the container to the scene
  41841. * @param container the container holding the elements
  41842. */
  41843. addFromContainer(container: AbstractScene): void;
  41844. /**
  41845. * Removes all the elements in the container from the scene
  41846. * @param container contains the elements to remove
  41847. * @param dispose if the removed element should be disposed (default: false)
  41848. */
  41849. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  41850. /**
  41851. * Disposes the component and the associated ressources.
  41852. */
  41853. dispose(): void;
  41854. /**
  41855. * Disables audio in the associated scene.
  41856. */
  41857. disableAudio(): void;
  41858. /**
  41859. * Enables audio in the associated scene.
  41860. */
  41861. enableAudio(): void;
  41862. /**
  41863. * Switch audio to headphone output.
  41864. */
  41865. switchAudioModeForHeadphones(): void;
  41866. /**
  41867. * Switch audio to normal speakers.
  41868. */
  41869. switchAudioModeForNormalSpeakers(): void;
  41870. private _cachedCameraDirection;
  41871. private _cachedCameraPosition;
  41872. private _lastCheck;
  41873. private _afterRender;
  41874. }
  41875. }
  41876. declare module BABYLON {
  41877. /**
  41878. * Wraps one or more Sound objects and selects one with random weight for playback.
  41879. */
  41880. export class WeightedSound {
  41881. /** When true a Sound will be selected and played when the current playing Sound completes. */
  41882. loop: boolean;
  41883. private _coneInnerAngle;
  41884. private _coneOuterAngle;
  41885. private _volume;
  41886. /** A Sound is currently playing. */
  41887. isPlaying: boolean;
  41888. /** A Sound is currently paused. */
  41889. isPaused: boolean;
  41890. private _sounds;
  41891. private _weights;
  41892. private _currentIndex?;
  41893. /**
  41894. * Creates a new WeightedSound from the list of sounds given.
  41895. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  41896. * @param sounds Array of Sounds that will be selected from.
  41897. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  41898. */
  41899. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  41900. /**
  41901. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  41902. */
  41903. get directionalConeInnerAngle(): number;
  41904. /**
  41905. * The size of cone in degress for a directional sound in which there will be no attenuation.
  41906. */
  41907. set directionalConeInnerAngle(value: number);
  41908. /**
  41909. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  41910. * Listener angles between innerAngle and outerAngle will falloff linearly.
  41911. */
  41912. get directionalConeOuterAngle(): number;
  41913. /**
  41914. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  41915. * Listener angles between innerAngle and outerAngle will falloff linearly.
  41916. */
  41917. set directionalConeOuterAngle(value: number);
  41918. /**
  41919. * Playback volume.
  41920. */
  41921. get volume(): number;
  41922. /**
  41923. * Playback volume.
  41924. */
  41925. set volume(value: number);
  41926. private _onended;
  41927. /**
  41928. * Suspend playback
  41929. */
  41930. pause(): void;
  41931. /**
  41932. * Stop playback
  41933. */
  41934. stop(): void;
  41935. /**
  41936. * Start playback.
  41937. * @param startOffset Position the clip head at a specific time in seconds.
  41938. */
  41939. play(startOffset?: number): void;
  41940. }
  41941. }
  41942. declare module BABYLON {
  41943. /**
  41944. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  41945. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41946. */
  41947. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  41948. /**
  41949. * Gets the name of the behavior.
  41950. */
  41951. get name(): string;
  41952. /**
  41953. * The easing function used by animations
  41954. */
  41955. static EasingFunction: BackEase;
  41956. /**
  41957. * The easing mode used by animations
  41958. */
  41959. static EasingMode: number;
  41960. /**
  41961. * The duration of the animation, in milliseconds
  41962. */
  41963. transitionDuration: number;
  41964. /**
  41965. * Length of the distance animated by the transition when lower radius is reached
  41966. */
  41967. lowerRadiusTransitionRange: number;
  41968. /**
  41969. * Length of the distance animated by the transition when upper radius is reached
  41970. */
  41971. upperRadiusTransitionRange: number;
  41972. private _autoTransitionRange;
  41973. /**
  41974. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  41975. */
  41976. get autoTransitionRange(): boolean;
  41977. /**
  41978. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  41979. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  41980. */
  41981. set autoTransitionRange(value: boolean);
  41982. private _attachedCamera;
  41983. private _onAfterCheckInputsObserver;
  41984. private _onMeshTargetChangedObserver;
  41985. /**
  41986. * Initializes the behavior.
  41987. */
  41988. init(): void;
  41989. /**
  41990. * Attaches the behavior to its arc rotate camera.
  41991. * @param camera Defines the camera to attach the behavior to
  41992. */
  41993. attach(camera: ArcRotateCamera): void;
  41994. /**
  41995. * Detaches the behavior from its current arc rotate camera.
  41996. */
  41997. detach(): void;
  41998. private _radiusIsAnimating;
  41999. private _radiusBounceTransition;
  42000. private _animatables;
  42001. private _cachedWheelPrecision;
  42002. /**
  42003. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42004. * @param radiusLimit The limit to check against.
  42005. * @return Bool to indicate if at limit.
  42006. */
  42007. private _isRadiusAtLimit;
  42008. /**
  42009. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42010. * @param radiusDelta The delta by which to animate to. Can be negative.
  42011. */
  42012. private _applyBoundRadiusAnimation;
  42013. /**
  42014. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42015. */
  42016. protected _clearAnimationLocks(): void;
  42017. /**
  42018. * Stops and removes all animations that have been applied to the camera
  42019. */
  42020. stopAllAnimations(): void;
  42021. }
  42022. }
  42023. declare module BABYLON {
  42024. /**
  42025. * 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.
  42026. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42027. */
  42028. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42029. /**
  42030. * Gets the name of the behavior.
  42031. */
  42032. get name(): string;
  42033. private _mode;
  42034. private _radiusScale;
  42035. private _positionScale;
  42036. private _defaultElevation;
  42037. private _elevationReturnTime;
  42038. private _elevationReturnWaitTime;
  42039. private _zoomStopsAnimation;
  42040. private _framingTime;
  42041. /**
  42042. * The easing function used by animations
  42043. */
  42044. static EasingFunction: ExponentialEase;
  42045. /**
  42046. * The easing mode used by animations
  42047. */
  42048. static EasingMode: number;
  42049. /**
  42050. * Sets the current mode used by the behavior
  42051. */
  42052. set mode(mode: number);
  42053. /**
  42054. * Gets current mode used by the behavior.
  42055. */
  42056. get mode(): number;
  42057. /**
  42058. * Sets the scale applied to the radius (1 by default)
  42059. */
  42060. set radiusScale(radius: number);
  42061. /**
  42062. * Gets the scale applied to the radius
  42063. */
  42064. get radiusScale(): number;
  42065. /**
  42066. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42067. */
  42068. set positionScale(scale: number);
  42069. /**
  42070. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42071. */
  42072. get positionScale(): number;
  42073. /**
  42074. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42075. * behaviour is triggered, in radians.
  42076. */
  42077. set defaultElevation(elevation: number);
  42078. /**
  42079. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42080. * behaviour is triggered, in radians.
  42081. */
  42082. get defaultElevation(): number;
  42083. /**
  42084. * Sets the time (in milliseconds) taken to return to the default beta position.
  42085. * Negative value indicates camera should not return to default.
  42086. */
  42087. set elevationReturnTime(speed: number);
  42088. /**
  42089. * Gets the time (in milliseconds) taken to return to the default beta position.
  42090. * Negative value indicates camera should not return to default.
  42091. */
  42092. get elevationReturnTime(): number;
  42093. /**
  42094. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42095. */
  42096. set elevationReturnWaitTime(time: number);
  42097. /**
  42098. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42099. */
  42100. get elevationReturnWaitTime(): number;
  42101. /**
  42102. * Sets the flag that indicates if user zooming should stop animation.
  42103. */
  42104. set zoomStopsAnimation(flag: boolean);
  42105. /**
  42106. * Gets the flag that indicates if user zooming should stop animation.
  42107. */
  42108. get zoomStopsAnimation(): boolean;
  42109. /**
  42110. * Sets the transition time when framing the mesh, in milliseconds
  42111. */
  42112. set framingTime(time: number);
  42113. /**
  42114. * Gets the transition time when framing the mesh, in milliseconds
  42115. */
  42116. get framingTime(): number;
  42117. /**
  42118. * Define if the behavior should automatically change the configured
  42119. * camera limits and sensibilities.
  42120. */
  42121. autoCorrectCameraLimitsAndSensibility: boolean;
  42122. private _onPrePointerObservableObserver;
  42123. private _onAfterCheckInputsObserver;
  42124. private _onMeshTargetChangedObserver;
  42125. private _attachedCamera;
  42126. private _isPointerDown;
  42127. private _lastInteractionTime;
  42128. /**
  42129. * Initializes the behavior.
  42130. */
  42131. init(): void;
  42132. /**
  42133. * Attaches the behavior to its arc rotate camera.
  42134. * @param camera Defines the camera to attach the behavior to
  42135. */
  42136. attach(camera: ArcRotateCamera): void;
  42137. /**
  42138. * Detaches the behavior from its current arc rotate camera.
  42139. */
  42140. detach(): void;
  42141. private _animatables;
  42142. private _betaIsAnimating;
  42143. private _betaTransition;
  42144. private _radiusTransition;
  42145. private _vectorTransition;
  42146. /**
  42147. * Targets the given mesh and updates zoom level accordingly.
  42148. * @param mesh The mesh to target.
  42149. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42150. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42151. */
  42152. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42153. /**
  42154. * Targets the given mesh with its children and updates zoom level accordingly.
  42155. * @param mesh The mesh to target.
  42156. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42157. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42158. */
  42159. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42160. /**
  42161. * Targets the given meshes with their children and updates zoom level accordingly.
  42162. * @param meshes The mesh to target.
  42163. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42164. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42165. */
  42166. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42167. /**
  42168. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42169. * @param minimumWorld Determines the smaller position of the bounding box extend
  42170. * @param maximumWorld Determines the bigger position of the bounding box extend
  42171. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42172. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42173. */
  42174. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42175. /**
  42176. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42177. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42178. * frustum width.
  42179. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42180. * to fully enclose the mesh in the viewing frustum.
  42181. */
  42182. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42183. /**
  42184. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42185. * is automatically returned to its default position (expected to be above ground plane).
  42186. */
  42187. private _maintainCameraAboveGround;
  42188. /**
  42189. * Returns the frustum slope based on the canvas ratio and camera FOV
  42190. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42191. */
  42192. private _getFrustumSlope;
  42193. /**
  42194. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42195. */
  42196. private _clearAnimationLocks;
  42197. /**
  42198. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42199. */
  42200. private _applyUserInteraction;
  42201. /**
  42202. * Stops and removes all animations that have been applied to the camera
  42203. */
  42204. stopAllAnimations(): void;
  42205. /**
  42206. * Gets a value indicating if the user is moving the camera
  42207. */
  42208. get isUserIsMoving(): boolean;
  42209. /**
  42210. * The camera can move all the way towards the mesh.
  42211. */
  42212. static IgnoreBoundsSizeMode: number;
  42213. /**
  42214. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42215. */
  42216. static FitFrustumSidesMode: number;
  42217. }
  42218. }
  42219. declare module BABYLON {
  42220. /**
  42221. * Base class for Camera Pointer Inputs.
  42222. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42223. * for example usage.
  42224. */
  42225. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42226. /**
  42227. * Defines the camera the input is attached to.
  42228. */
  42229. abstract camera: Camera;
  42230. /**
  42231. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42232. */
  42233. protected _altKey: boolean;
  42234. protected _ctrlKey: boolean;
  42235. protected _metaKey: boolean;
  42236. protected _shiftKey: boolean;
  42237. /**
  42238. * Which mouse buttons were pressed at time of last mouse event.
  42239. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  42240. */
  42241. protected _buttonsPressed: number;
  42242. /**
  42243. * Defines the buttons associated with the input to handle camera move.
  42244. */
  42245. buttons: number[];
  42246. /**
  42247. * Attach the input controls to a specific dom element to get the input from.
  42248. * @param element Defines the element the controls should be listened from
  42249. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42250. */
  42251. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42252. /**
  42253. * Detach the current controls from the specified dom element.
  42254. * @param element Defines the element to stop listening the inputs from
  42255. */
  42256. detachControl(element: Nullable<HTMLElement>): void;
  42257. /**
  42258. * Gets the class name of the current input.
  42259. * @returns the class name
  42260. */
  42261. getClassName(): string;
  42262. /**
  42263. * Get the friendly name associated with the input class.
  42264. * @returns the input friendly name
  42265. */
  42266. getSimpleName(): string;
  42267. /**
  42268. * Called on pointer POINTERDOUBLETAP event.
  42269. * Override this method to provide functionality on POINTERDOUBLETAP event.
  42270. */
  42271. protected onDoubleTap(type: string): void;
  42272. /**
  42273. * Called on pointer POINTERMOVE event if only a single touch is active.
  42274. * Override this method to provide functionality.
  42275. */
  42276. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42277. /**
  42278. * Called on pointer POINTERMOVE event if multiple touches are active.
  42279. * Override this method to provide functionality.
  42280. */
  42281. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42282. /**
  42283. * Called on JS contextmenu event.
  42284. * Override this method to provide functionality.
  42285. */
  42286. protected onContextMenu(evt: PointerEvent): void;
  42287. /**
  42288. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42289. * press.
  42290. * Override this method to provide functionality.
  42291. */
  42292. protected onButtonDown(evt: PointerEvent): void;
  42293. /**
  42294. * Called each time a new POINTERUP event occurs. Ie, for each button
  42295. * release.
  42296. * Override this method to provide functionality.
  42297. */
  42298. protected onButtonUp(evt: PointerEvent): void;
  42299. /**
  42300. * Called when window becomes inactive.
  42301. * Override this method to provide functionality.
  42302. */
  42303. protected onLostFocus(): void;
  42304. private _pointerInput;
  42305. private _observer;
  42306. private _onLostFocus;
  42307. private pointA;
  42308. private pointB;
  42309. }
  42310. }
  42311. declare module BABYLON {
  42312. /**
  42313. * Manage the pointers inputs to control an arc rotate camera.
  42314. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42315. */
  42316. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  42317. /**
  42318. * Defines the camera the input is attached to.
  42319. */
  42320. camera: ArcRotateCamera;
  42321. /**
  42322. * Gets the class name of the current input.
  42323. * @returns the class name
  42324. */
  42325. getClassName(): string;
  42326. /**
  42327. * Defines the buttons associated with the input to handle camera move.
  42328. */
  42329. buttons: number[];
  42330. /**
  42331. * Defines the pointer angular sensibility along the X axis or how fast is
  42332. * the camera rotating.
  42333. */
  42334. angularSensibilityX: number;
  42335. /**
  42336. * Defines the pointer angular sensibility along the Y axis or how fast is
  42337. * the camera rotating.
  42338. */
  42339. angularSensibilityY: number;
  42340. /**
  42341. * Defines the pointer pinch precision or how fast is the camera zooming.
  42342. */
  42343. pinchPrecision: number;
  42344. /**
  42345. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42346. * from 0.
  42347. * It defines the percentage of current camera.radius to use as delta when
  42348. * pinch zoom is used.
  42349. */
  42350. pinchDeltaPercentage: number;
  42351. /**
  42352. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42353. * that any object in the plane at the camera's target point will scale
  42354. * perfectly with finger motion.
  42355. * Overrides pinchDeltaPercentage and pinchPrecision.
  42356. */
  42357. useNaturalPinchZoom: boolean;
  42358. /**
  42359. * Defines the pointer panning sensibility or how fast is the camera moving.
  42360. */
  42361. panningSensibility: number;
  42362. /**
  42363. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  42364. */
  42365. multiTouchPanning: boolean;
  42366. /**
  42367. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  42368. * zoom (pinch) through multitouch.
  42369. */
  42370. multiTouchPanAndZoom: boolean;
  42371. /**
  42372. * Revers pinch action direction.
  42373. */
  42374. pinchInwards: boolean;
  42375. private _isPanClick;
  42376. private _twoFingerActivityCount;
  42377. private _isPinching;
  42378. /**
  42379. * Called on pointer POINTERMOVE event if only a single touch is active.
  42380. */
  42381. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42382. /**
  42383. * Called on pointer POINTERDOUBLETAP event.
  42384. */
  42385. protected onDoubleTap(type: string): void;
  42386. /**
  42387. * Called on pointer POINTERMOVE event if multiple touches are active.
  42388. */
  42389. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42390. /**
  42391. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42392. * press.
  42393. */
  42394. protected onButtonDown(evt: PointerEvent): void;
  42395. /**
  42396. * Called each time a new POINTERUP event occurs. Ie, for each button
  42397. * release.
  42398. */
  42399. protected onButtonUp(evt: PointerEvent): void;
  42400. /**
  42401. * Called when window becomes inactive.
  42402. */
  42403. protected onLostFocus(): void;
  42404. }
  42405. }
  42406. declare module BABYLON {
  42407. /**
  42408. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  42409. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42410. */
  42411. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  42412. /**
  42413. * Defines the camera the input is attached to.
  42414. */
  42415. camera: ArcRotateCamera;
  42416. /**
  42417. * Defines the list of key codes associated with the up action (increase alpha)
  42418. */
  42419. keysUp: number[];
  42420. /**
  42421. * Defines the list of key codes associated with the down action (decrease alpha)
  42422. */
  42423. keysDown: number[];
  42424. /**
  42425. * Defines the list of key codes associated with the left action (increase beta)
  42426. */
  42427. keysLeft: number[];
  42428. /**
  42429. * Defines the list of key codes associated with the right action (decrease beta)
  42430. */
  42431. keysRight: number[];
  42432. /**
  42433. * Defines the list of key codes associated with the reset action.
  42434. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  42435. */
  42436. keysReset: number[];
  42437. /**
  42438. * Defines the panning sensibility of the inputs.
  42439. * (How fast is the camera panning)
  42440. */
  42441. panningSensibility: number;
  42442. /**
  42443. * Defines the zooming sensibility of the inputs.
  42444. * (How fast is the camera zooming)
  42445. */
  42446. zoomingSensibility: number;
  42447. /**
  42448. * Defines whether maintaining the alt key down switch the movement mode from
  42449. * orientation to zoom.
  42450. */
  42451. useAltToZoom: boolean;
  42452. /**
  42453. * Rotation speed of the camera
  42454. */
  42455. angularSpeed: number;
  42456. private _keys;
  42457. private _ctrlPressed;
  42458. private _altPressed;
  42459. private _onCanvasBlurObserver;
  42460. private _onKeyboardObserver;
  42461. private _engine;
  42462. private _scene;
  42463. /**
  42464. * Attach the input controls to a specific dom element to get the input from.
  42465. * @param element Defines the element the controls should be listened from
  42466. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42467. */
  42468. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42469. /**
  42470. * Detach the current controls from the specified dom element.
  42471. * @param element Defines the element to stop listening the inputs from
  42472. */
  42473. detachControl(element: Nullable<HTMLElement>): void;
  42474. /**
  42475. * Update the current camera state depending on the inputs that have been used this frame.
  42476. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42477. */
  42478. checkInputs(): void;
  42479. /**
  42480. * Gets the class name of the current intput.
  42481. * @returns the class name
  42482. */
  42483. getClassName(): string;
  42484. /**
  42485. * Get the friendly name associated with the input class.
  42486. * @returns the input friendly name
  42487. */
  42488. getSimpleName(): string;
  42489. }
  42490. }
  42491. declare module BABYLON {
  42492. /**
  42493. * Manage the mouse wheel inputs to control an arc rotate camera.
  42494. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42495. */
  42496. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  42497. /**
  42498. * Defines the camera the input is attached to.
  42499. */
  42500. camera: ArcRotateCamera;
  42501. /**
  42502. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42503. */
  42504. wheelPrecision: number;
  42505. /**
  42506. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  42507. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  42508. */
  42509. wheelDeltaPercentage: number;
  42510. private _wheel;
  42511. private _observer;
  42512. private computeDeltaFromMouseWheelLegacyEvent;
  42513. /**
  42514. * Attach the input controls to a specific dom element to get the input from.
  42515. * @param element Defines the element the controls should be listened from
  42516. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42517. */
  42518. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42519. /**
  42520. * Detach the current controls from the specified dom element.
  42521. * @param element Defines the element to stop listening the inputs from
  42522. */
  42523. detachControl(element: Nullable<HTMLElement>): void;
  42524. /**
  42525. * Gets the class name of the current intput.
  42526. * @returns the class name
  42527. */
  42528. getClassName(): string;
  42529. /**
  42530. * Get the friendly name associated with the input class.
  42531. * @returns the input friendly name
  42532. */
  42533. getSimpleName(): string;
  42534. }
  42535. }
  42536. declare module BABYLON {
  42537. /**
  42538. * Default Inputs manager for the ArcRotateCamera.
  42539. * It groups all the default supported inputs for ease of use.
  42540. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42541. */
  42542. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  42543. /**
  42544. * Instantiates a new ArcRotateCameraInputsManager.
  42545. * @param camera Defines the camera the inputs belong to
  42546. */
  42547. constructor(camera: ArcRotateCamera);
  42548. /**
  42549. * Add mouse wheel input support to the input manager.
  42550. * @returns the current input manager
  42551. */
  42552. addMouseWheel(): ArcRotateCameraInputsManager;
  42553. /**
  42554. * Add pointers input support to the input manager.
  42555. * @returns the current input manager
  42556. */
  42557. addPointers(): ArcRotateCameraInputsManager;
  42558. /**
  42559. * Add keyboard input support to the input manager.
  42560. * @returns the current input manager
  42561. */
  42562. addKeyboard(): ArcRotateCameraInputsManager;
  42563. }
  42564. }
  42565. declare module BABYLON {
  42566. /**
  42567. * This represents an orbital type of camera.
  42568. *
  42569. * 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.
  42570. * 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.
  42571. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  42572. */
  42573. export class ArcRotateCamera extends TargetCamera {
  42574. /**
  42575. * Defines the rotation angle of the camera along the longitudinal axis.
  42576. */
  42577. alpha: number;
  42578. /**
  42579. * Defines the rotation angle of the camera along the latitudinal axis.
  42580. */
  42581. beta: number;
  42582. /**
  42583. * Defines the radius of the camera from it s target point.
  42584. */
  42585. radius: number;
  42586. protected _target: Vector3;
  42587. protected _targetHost: Nullable<AbstractMesh>;
  42588. /**
  42589. * Defines the target point of the camera.
  42590. * The camera looks towards it form the radius distance.
  42591. */
  42592. get target(): Vector3;
  42593. set target(value: Vector3);
  42594. /**
  42595. * Define the current local position of the camera in the scene
  42596. */
  42597. get position(): Vector3;
  42598. set position(newPosition: Vector3);
  42599. protected _upVector: Vector3;
  42600. protected _upToYMatrix: Matrix;
  42601. protected _YToUpMatrix: Matrix;
  42602. /**
  42603. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  42604. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  42605. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  42606. */
  42607. set upVector(vec: Vector3);
  42608. get upVector(): Vector3;
  42609. /**
  42610. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  42611. */
  42612. setMatUp(): void;
  42613. /**
  42614. * Current inertia value on the longitudinal axis.
  42615. * The bigger this number the longer it will take for the camera to stop.
  42616. */
  42617. inertialAlphaOffset: number;
  42618. /**
  42619. * Current inertia value on the latitudinal axis.
  42620. * The bigger this number the longer it will take for the camera to stop.
  42621. */
  42622. inertialBetaOffset: number;
  42623. /**
  42624. * Current inertia value on the radius axis.
  42625. * The bigger this number the longer it will take for the camera to stop.
  42626. */
  42627. inertialRadiusOffset: number;
  42628. /**
  42629. * Minimum allowed angle on the longitudinal axis.
  42630. * This can help limiting how the Camera is able to move in the scene.
  42631. */
  42632. lowerAlphaLimit: Nullable<number>;
  42633. /**
  42634. * Maximum allowed angle on the longitudinal axis.
  42635. * This can help limiting how the Camera is able to move in the scene.
  42636. */
  42637. upperAlphaLimit: Nullable<number>;
  42638. /**
  42639. * Minimum allowed angle on the latitudinal axis.
  42640. * This can help limiting how the Camera is able to move in the scene.
  42641. */
  42642. lowerBetaLimit: number;
  42643. /**
  42644. * Maximum allowed angle on the latitudinal axis.
  42645. * This can help limiting how the Camera is able to move in the scene.
  42646. */
  42647. upperBetaLimit: number;
  42648. /**
  42649. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  42650. * This can help limiting how the Camera is able to move in the scene.
  42651. */
  42652. lowerRadiusLimit: Nullable<number>;
  42653. /**
  42654. * Maximum allowed distance of the camera to the target (The camera can not get further).
  42655. * This can help limiting how the Camera is able to move in the scene.
  42656. */
  42657. upperRadiusLimit: Nullable<number>;
  42658. /**
  42659. * Defines the current inertia value used during panning of the camera along the X axis.
  42660. */
  42661. inertialPanningX: number;
  42662. /**
  42663. * Defines the current inertia value used during panning of the camera along the Y axis.
  42664. */
  42665. inertialPanningY: number;
  42666. /**
  42667. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  42668. * Basically if your fingers moves away from more than this distance you will be considered
  42669. * in pinch mode.
  42670. */
  42671. pinchToPanMaxDistance: number;
  42672. /**
  42673. * Defines the maximum distance the camera can pan.
  42674. * This could help keeping the cammera always in your scene.
  42675. */
  42676. panningDistanceLimit: Nullable<number>;
  42677. /**
  42678. * Defines the target of the camera before paning.
  42679. */
  42680. panningOriginTarget: Vector3;
  42681. /**
  42682. * Defines the value of the inertia used during panning.
  42683. * 0 would mean stop inertia and one would mean no decelleration at all.
  42684. */
  42685. panningInertia: number;
  42686. /**
  42687. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  42688. */
  42689. get angularSensibilityX(): number;
  42690. set angularSensibilityX(value: number);
  42691. /**
  42692. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  42693. */
  42694. get angularSensibilityY(): number;
  42695. set angularSensibilityY(value: number);
  42696. /**
  42697. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  42698. */
  42699. get pinchPrecision(): number;
  42700. set pinchPrecision(value: number);
  42701. /**
  42702. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  42703. * It will be used instead of pinchDeltaPrecision if different from 0.
  42704. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42705. */
  42706. get pinchDeltaPercentage(): number;
  42707. set pinchDeltaPercentage(value: number);
  42708. /**
  42709. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  42710. * and pinch delta percentage.
  42711. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42712. * that any object in the plane at the camera's target point will scale
  42713. * perfectly with finger motion.
  42714. */
  42715. get useNaturalPinchZoom(): boolean;
  42716. set useNaturalPinchZoom(value: boolean);
  42717. /**
  42718. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  42719. */
  42720. get panningSensibility(): number;
  42721. set panningSensibility(value: number);
  42722. /**
  42723. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  42724. */
  42725. get keysUp(): number[];
  42726. set keysUp(value: number[]);
  42727. /**
  42728. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  42729. */
  42730. get keysDown(): number[];
  42731. set keysDown(value: number[]);
  42732. /**
  42733. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  42734. */
  42735. get keysLeft(): number[];
  42736. set keysLeft(value: number[]);
  42737. /**
  42738. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  42739. */
  42740. get keysRight(): number[];
  42741. set keysRight(value: number[]);
  42742. /**
  42743. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42744. */
  42745. get wheelPrecision(): number;
  42746. set wheelPrecision(value: number);
  42747. /**
  42748. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  42749. * It will be used instead of pinchDeltaPrecision if different from 0.
  42750. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42751. */
  42752. get wheelDeltaPercentage(): number;
  42753. set wheelDeltaPercentage(value: number);
  42754. /**
  42755. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  42756. */
  42757. zoomOnFactor: number;
  42758. /**
  42759. * Defines a screen offset for the camera position.
  42760. */
  42761. targetScreenOffset: Vector2;
  42762. /**
  42763. * Allows the camera to be completely reversed.
  42764. * If false the camera can not arrive upside down.
  42765. */
  42766. allowUpsideDown: boolean;
  42767. /**
  42768. * Define if double tap/click is used to restore the previously saved state of the camera.
  42769. */
  42770. useInputToRestoreState: boolean;
  42771. /** @hidden */
  42772. _viewMatrix: Matrix;
  42773. /** @hidden */
  42774. _useCtrlForPanning: boolean;
  42775. /** @hidden */
  42776. _panningMouseButton: number;
  42777. /**
  42778. * Defines the input associated to the camera.
  42779. */
  42780. inputs: ArcRotateCameraInputsManager;
  42781. /** @hidden */
  42782. _reset: () => void;
  42783. /**
  42784. * Defines the allowed panning axis.
  42785. */
  42786. panningAxis: Vector3;
  42787. protected _localDirection: Vector3;
  42788. protected _transformedDirection: Vector3;
  42789. private _bouncingBehavior;
  42790. /**
  42791. * Gets the bouncing behavior of the camera if it has been enabled.
  42792. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42793. */
  42794. get bouncingBehavior(): Nullable<BouncingBehavior>;
  42795. /**
  42796. * Defines if the bouncing behavior of the camera is enabled on the camera.
  42797. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42798. */
  42799. get useBouncingBehavior(): boolean;
  42800. set useBouncingBehavior(value: boolean);
  42801. private _framingBehavior;
  42802. /**
  42803. * Gets the framing behavior of the camera if it has been enabled.
  42804. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42805. */
  42806. get framingBehavior(): Nullable<FramingBehavior>;
  42807. /**
  42808. * Defines if the framing behavior of the camera is enabled on the camera.
  42809. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42810. */
  42811. get useFramingBehavior(): boolean;
  42812. set useFramingBehavior(value: boolean);
  42813. private _autoRotationBehavior;
  42814. /**
  42815. * Gets the auto rotation behavior of the camera if it has been enabled.
  42816. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42817. */
  42818. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  42819. /**
  42820. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  42821. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42822. */
  42823. get useAutoRotationBehavior(): boolean;
  42824. set useAutoRotationBehavior(value: boolean);
  42825. /**
  42826. * Observable triggered when the mesh target has been changed on the camera.
  42827. */
  42828. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  42829. /**
  42830. * Event raised when the camera is colliding with a mesh.
  42831. */
  42832. onCollide: (collidedMesh: AbstractMesh) => void;
  42833. /**
  42834. * Defines whether the camera should check collision with the objects oh the scene.
  42835. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  42836. */
  42837. checkCollisions: boolean;
  42838. /**
  42839. * Defines the collision radius of the camera.
  42840. * This simulates a sphere around the camera.
  42841. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  42842. */
  42843. collisionRadius: Vector3;
  42844. protected _collider: Collider;
  42845. protected _previousPosition: Vector3;
  42846. protected _collisionVelocity: Vector3;
  42847. protected _newPosition: Vector3;
  42848. protected _previousAlpha: number;
  42849. protected _previousBeta: number;
  42850. protected _previousRadius: number;
  42851. protected _collisionTriggered: boolean;
  42852. protected _targetBoundingCenter: Nullable<Vector3>;
  42853. private _computationVector;
  42854. /**
  42855. * Instantiates a new ArcRotateCamera in a given scene
  42856. * @param name Defines the name of the camera
  42857. * @param alpha Defines the camera rotation along the logitudinal axis
  42858. * @param beta Defines the camera rotation along the latitudinal axis
  42859. * @param radius Defines the camera distance from its target
  42860. * @param target Defines the camera target
  42861. * @param scene Defines the scene the camera belongs to
  42862. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  42863. */
  42864. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  42865. /** @hidden */
  42866. _initCache(): void;
  42867. /** @hidden */
  42868. _updateCache(ignoreParentClass?: boolean): void;
  42869. protected _getTargetPosition(): Vector3;
  42870. private _storedAlpha;
  42871. private _storedBeta;
  42872. private _storedRadius;
  42873. private _storedTarget;
  42874. private _storedTargetScreenOffset;
  42875. /**
  42876. * Stores the current state of the camera (alpha, beta, radius and target)
  42877. * @returns the camera itself
  42878. */
  42879. storeState(): Camera;
  42880. /**
  42881. * @hidden
  42882. * Restored camera state. You must call storeState() first
  42883. */
  42884. _restoreStateValues(): boolean;
  42885. /** @hidden */
  42886. _isSynchronizedViewMatrix(): boolean;
  42887. /**
  42888. * Attached controls to the current camera.
  42889. * @param element Defines the element the controls should be listened from
  42890. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42891. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  42892. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  42893. */
  42894. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  42895. /**
  42896. * Detach the current controls from the camera.
  42897. * The camera will stop reacting to inputs.
  42898. * @param element Defines the element to stop listening the inputs from
  42899. */
  42900. detachControl(element: HTMLElement): void;
  42901. /** @hidden */
  42902. _checkInputs(): void;
  42903. protected _checkLimits(): void;
  42904. /**
  42905. * Rebuilds angles (alpha, beta) and radius from the give position and target
  42906. */
  42907. rebuildAnglesAndRadius(): void;
  42908. /**
  42909. * Use a position to define the current camera related information like alpha, beta and radius
  42910. * @param position Defines the position to set the camera at
  42911. */
  42912. setPosition(position: Vector3): void;
  42913. /**
  42914. * Defines the target the camera should look at.
  42915. * This will automatically adapt alpha beta and radius to fit within the new target.
  42916. * @param target Defines the new target as a Vector or a mesh
  42917. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  42918. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  42919. */
  42920. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  42921. /** @hidden */
  42922. _getViewMatrix(): Matrix;
  42923. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  42924. /**
  42925. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  42926. * @param meshes Defines the mesh to zoom on
  42927. * @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)
  42928. */
  42929. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  42930. /**
  42931. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  42932. * The target will be changed but the radius
  42933. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  42934. * @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)
  42935. */
  42936. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  42937. min: Vector3;
  42938. max: Vector3;
  42939. distance: number;
  42940. }, doNotUpdateMaxZ?: boolean): void;
  42941. /**
  42942. * @override
  42943. * Override Camera.createRigCamera
  42944. */
  42945. createRigCamera(name: string, cameraIndex: number): Camera;
  42946. /**
  42947. * @hidden
  42948. * @override
  42949. * Override Camera._updateRigCameras
  42950. */
  42951. _updateRigCameras(): void;
  42952. /**
  42953. * Destroy the camera and release the current resources hold by it.
  42954. */
  42955. dispose(): void;
  42956. /**
  42957. * Gets the current object class name.
  42958. * @return the class name
  42959. */
  42960. getClassName(): string;
  42961. }
  42962. }
  42963. declare module BABYLON {
  42964. /**
  42965. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  42966. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42967. */
  42968. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  42969. /**
  42970. * Gets the name of the behavior.
  42971. */
  42972. get name(): string;
  42973. private _zoomStopsAnimation;
  42974. private _idleRotationSpeed;
  42975. private _idleRotationWaitTime;
  42976. private _idleRotationSpinupTime;
  42977. /**
  42978. * Sets the flag that indicates if user zooming should stop animation.
  42979. */
  42980. set zoomStopsAnimation(flag: boolean);
  42981. /**
  42982. * Gets the flag that indicates if user zooming should stop animation.
  42983. */
  42984. get zoomStopsAnimation(): boolean;
  42985. /**
  42986. * Sets the default speed at which the camera rotates around the model.
  42987. */
  42988. set idleRotationSpeed(speed: number);
  42989. /**
  42990. * Gets the default speed at which the camera rotates around the model.
  42991. */
  42992. get idleRotationSpeed(): number;
  42993. /**
  42994. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  42995. */
  42996. set idleRotationWaitTime(time: number);
  42997. /**
  42998. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  42999. */
  43000. get idleRotationWaitTime(): number;
  43001. /**
  43002. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43003. */
  43004. set idleRotationSpinupTime(time: number);
  43005. /**
  43006. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43007. */
  43008. get idleRotationSpinupTime(): number;
  43009. /**
  43010. * Gets a value indicating if the camera is currently rotating because of this behavior
  43011. */
  43012. get rotationInProgress(): boolean;
  43013. private _onPrePointerObservableObserver;
  43014. private _onAfterCheckInputsObserver;
  43015. private _attachedCamera;
  43016. private _isPointerDown;
  43017. private _lastFrameTime;
  43018. private _lastInteractionTime;
  43019. private _cameraRotationSpeed;
  43020. /**
  43021. * Initializes the behavior.
  43022. */
  43023. init(): void;
  43024. /**
  43025. * Attaches the behavior to its arc rotate camera.
  43026. * @param camera Defines the camera to attach the behavior to
  43027. */
  43028. attach(camera: ArcRotateCamera): void;
  43029. /**
  43030. * Detaches the behavior from its current arc rotate camera.
  43031. */
  43032. detach(): void;
  43033. /**
  43034. * Returns true if user is scrolling.
  43035. * @return true if user is scrolling.
  43036. */
  43037. private _userIsZooming;
  43038. private _lastFrameRadius;
  43039. private _shouldAnimationStopForInteraction;
  43040. /**
  43041. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43042. */
  43043. private _applyUserInteraction;
  43044. private _userIsMoving;
  43045. }
  43046. }
  43047. declare module BABYLON {
  43048. /**
  43049. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43050. */
  43051. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43052. private ui;
  43053. /**
  43054. * The name of the behavior
  43055. */
  43056. name: string;
  43057. /**
  43058. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43059. */
  43060. distanceAwayFromFace: number;
  43061. /**
  43062. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43063. */
  43064. distanceAwayFromBottomOfFace: number;
  43065. private _faceVectors;
  43066. private _target;
  43067. private _scene;
  43068. private _onRenderObserver;
  43069. private _tmpMatrix;
  43070. private _tmpVector;
  43071. /**
  43072. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43073. * @param ui The transform node that should be attched to the mesh
  43074. */
  43075. constructor(ui: TransformNode);
  43076. /**
  43077. * Initializes the behavior
  43078. */
  43079. init(): void;
  43080. private _closestFace;
  43081. private _zeroVector;
  43082. private _lookAtTmpMatrix;
  43083. private _lookAtToRef;
  43084. /**
  43085. * Attaches the AttachToBoxBehavior to the passed in mesh
  43086. * @param target The mesh that the specified node will be attached to
  43087. */
  43088. attach(target: Mesh): void;
  43089. /**
  43090. * Detaches the behavior from the mesh
  43091. */
  43092. detach(): void;
  43093. }
  43094. }
  43095. declare module BABYLON {
  43096. /**
  43097. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43098. */
  43099. export class FadeInOutBehavior implements Behavior<Mesh> {
  43100. /**
  43101. * Time in milliseconds to delay before fading in (Default: 0)
  43102. */
  43103. delay: number;
  43104. /**
  43105. * Time in milliseconds for the mesh to fade in (Default: 300)
  43106. */
  43107. fadeInTime: number;
  43108. private _millisecondsPerFrame;
  43109. private _hovered;
  43110. private _hoverValue;
  43111. private _ownerNode;
  43112. /**
  43113. * Instatiates the FadeInOutBehavior
  43114. */
  43115. constructor();
  43116. /**
  43117. * The name of the behavior
  43118. */
  43119. get name(): string;
  43120. /**
  43121. * Initializes the behavior
  43122. */
  43123. init(): void;
  43124. /**
  43125. * Attaches the fade behavior on the passed in mesh
  43126. * @param ownerNode The mesh that will be faded in/out once attached
  43127. */
  43128. attach(ownerNode: Mesh): void;
  43129. /**
  43130. * Detaches the behavior from the mesh
  43131. */
  43132. detach(): void;
  43133. /**
  43134. * Triggers the mesh to begin fading in or out
  43135. * @param value if the object should fade in or out (true to fade in)
  43136. */
  43137. fadeIn(value: boolean): void;
  43138. private _update;
  43139. private _setAllVisibility;
  43140. }
  43141. }
  43142. declare module BABYLON {
  43143. /**
  43144. * Class containing a set of static utilities functions for managing Pivots
  43145. * @hidden
  43146. */
  43147. export class PivotTools {
  43148. private static _PivotCached;
  43149. private static _OldPivotPoint;
  43150. private static _PivotTranslation;
  43151. private static _PivotTmpVector;
  43152. /** @hidden */
  43153. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43154. /** @hidden */
  43155. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43156. }
  43157. }
  43158. declare module BABYLON {
  43159. /**
  43160. * Class containing static functions to help procedurally build meshes
  43161. */
  43162. export class PlaneBuilder {
  43163. /**
  43164. * Creates a plane mesh
  43165. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43166. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43167. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43168. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43169. * * 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
  43170. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43171. * @param name defines the name of the mesh
  43172. * @param options defines the options used to create the mesh
  43173. * @param scene defines the hosting scene
  43174. * @returns the plane mesh
  43175. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43176. */
  43177. static CreatePlane(name: string, options: {
  43178. size?: number;
  43179. width?: number;
  43180. height?: number;
  43181. sideOrientation?: number;
  43182. frontUVs?: Vector4;
  43183. backUVs?: Vector4;
  43184. updatable?: boolean;
  43185. sourcePlane?: Plane;
  43186. }, scene?: Nullable<Scene>): Mesh;
  43187. }
  43188. }
  43189. declare module BABYLON {
  43190. /**
  43191. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  43192. */
  43193. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  43194. private static _AnyMouseID;
  43195. /**
  43196. * Abstract mesh the behavior is set on
  43197. */
  43198. attachedNode: AbstractMesh;
  43199. private _dragPlane;
  43200. private _scene;
  43201. private _pointerObserver;
  43202. private _beforeRenderObserver;
  43203. private static _planeScene;
  43204. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  43205. /**
  43206. * 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)
  43207. */
  43208. maxDragAngle: number;
  43209. /**
  43210. * @hidden
  43211. */
  43212. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  43213. /**
  43214. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43215. */
  43216. currentDraggingPointerID: number;
  43217. /**
  43218. * The last position where the pointer hit the drag plane in world space
  43219. */
  43220. lastDragPosition: Vector3;
  43221. /**
  43222. * If the behavior is currently in a dragging state
  43223. */
  43224. dragging: boolean;
  43225. /**
  43226. * 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)
  43227. */
  43228. dragDeltaRatio: number;
  43229. /**
  43230. * If the drag plane orientation should be updated during the dragging (Default: true)
  43231. */
  43232. updateDragPlane: boolean;
  43233. private _debugMode;
  43234. private _moving;
  43235. /**
  43236. * Fires each time the attached mesh is dragged with the pointer
  43237. * * delta between last drag position and current drag position in world space
  43238. * * dragDistance along the drag axis
  43239. * * dragPlaneNormal normal of the current drag plane used during the drag
  43240. * * dragPlanePoint in world space where the drag intersects the drag plane
  43241. */
  43242. onDragObservable: Observable<{
  43243. delta: Vector3;
  43244. dragPlanePoint: Vector3;
  43245. dragPlaneNormal: Vector3;
  43246. dragDistance: number;
  43247. pointerId: number;
  43248. }>;
  43249. /**
  43250. * Fires each time a drag begins (eg. mouse down on mesh)
  43251. */
  43252. onDragStartObservable: Observable<{
  43253. dragPlanePoint: Vector3;
  43254. pointerId: number;
  43255. }>;
  43256. /**
  43257. * Fires each time a drag ends (eg. mouse release after drag)
  43258. */
  43259. onDragEndObservable: Observable<{
  43260. dragPlanePoint: Vector3;
  43261. pointerId: number;
  43262. }>;
  43263. /**
  43264. * If the attached mesh should be moved when dragged
  43265. */
  43266. moveAttached: boolean;
  43267. /**
  43268. * If the drag behavior will react to drag events (Default: true)
  43269. */
  43270. enabled: boolean;
  43271. /**
  43272. * If pointer events should start and release the drag (Default: true)
  43273. */
  43274. startAndReleaseDragOnPointerEvents: boolean;
  43275. /**
  43276. * If camera controls should be detached during the drag
  43277. */
  43278. detachCameraControls: boolean;
  43279. /**
  43280. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  43281. */
  43282. useObjectOrientationForDragging: boolean;
  43283. private _options;
  43284. /**
  43285. * Gets the options used by the behavior
  43286. */
  43287. get options(): {
  43288. dragAxis?: Vector3;
  43289. dragPlaneNormal?: Vector3;
  43290. };
  43291. /**
  43292. * Sets the options used by the behavior
  43293. */
  43294. set options(options: {
  43295. dragAxis?: Vector3;
  43296. dragPlaneNormal?: Vector3;
  43297. });
  43298. /**
  43299. * Creates a pointer drag behavior that can be attached to a mesh
  43300. * @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)
  43301. */
  43302. constructor(options?: {
  43303. dragAxis?: Vector3;
  43304. dragPlaneNormal?: Vector3;
  43305. });
  43306. /**
  43307. * Predicate to determine if it is valid to move the object to a new position when it is moved
  43308. */
  43309. validateDrag: (targetPosition: Vector3) => boolean;
  43310. /**
  43311. * The name of the behavior
  43312. */
  43313. get name(): string;
  43314. /**
  43315. * Initializes the behavior
  43316. */
  43317. init(): void;
  43318. private _tmpVector;
  43319. private _alternatePickedPoint;
  43320. private _worldDragAxis;
  43321. private _targetPosition;
  43322. private _attachedElement;
  43323. /**
  43324. * Attaches the drag behavior the passed in mesh
  43325. * @param ownerNode The mesh that will be dragged around once attached
  43326. * @param predicate Predicate to use for pick filtering
  43327. */
  43328. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  43329. /**
  43330. * Force relase the drag action by code.
  43331. */
  43332. releaseDrag(): void;
  43333. private _startDragRay;
  43334. private _lastPointerRay;
  43335. /**
  43336. * Simulates the start of a pointer drag event on the behavior
  43337. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  43338. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  43339. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  43340. */
  43341. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43342. private _startDrag;
  43343. private _dragDelta;
  43344. private _moveDrag;
  43345. private _pickWithRayOnDragPlane;
  43346. private _pointA;
  43347. private _pointC;
  43348. private _localAxis;
  43349. private _lookAt;
  43350. private _updateDragPlanePosition;
  43351. /**
  43352. * Detaches the behavior from the mesh
  43353. */
  43354. detach(): void;
  43355. }
  43356. }
  43357. declare module BABYLON {
  43358. /**
  43359. * A behavior that when attached to a mesh will allow the mesh to be scaled
  43360. */
  43361. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  43362. private _dragBehaviorA;
  43363. private _dragBehaviorB;
  43364. private _startDistance;
  43365. private _initialScale;
  43366. private _targetScale;
  43367. private _ownerNode;
  43368. private _sceneRenderObserver;
  43369. /**
  43370. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  43371. */
  43372. constructor();
  43373. /**
  43374. * The name of the behavior
  43375. */
  43376. get name(): string;
  43377. /**
  43378. * Initializes the behavior
  43379. */
  43380. init(): void;
  43381. private _getCurrentDistance;
  43382. /**
  43383. * Attaches the scale behavior the passed in mesh
  43384. * @param ownerNode The mesh that will be scaled around once attached
  43385. */
  43386. attach(ownerNode: Mesh): void;
  43387. /**
  43388. * Detaches the behavior from the mesh
  43389. */
  43390. detach(): void;
  43391. }
  43392. }
  43393. declare module BABYLON {
  43394. /**
  43395. * 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
  43396. */
  43397. export class SixDofDragBehavior implements Behavior<Mesh> {
  43398. private static _virtualScene;
  43399. private _ownerNode;
  43400. private _sceneRenderObserver;
  43401. private _scene;
  43402. private _targetPosition;
  43403. private _virtualOriginMesh;
  43404. private _virtualDragMesh;
  43405. private _pointerObserver;
  43406. private _moving;
  43407. private _startingOrientation;
  43408. private _attachedElement;
  43409. /**
  43410. * 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)
  43411. */
  43412. private zDragFactor;
  43413. /**
  43414. * If the object should rotate to face the drag origin
  43415. */
  43416. rotateDraggedObject: boolean;
  43417. /**
  43418. * If the behavior is currently in a dragging state
  43419. */
  43420. dragging: boolean;
  43421. /**
  43422. * 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)
  43423. */
  43424. dragDeltaRatio: number;
  43425. /**
  43426. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43427. */
  43428. currentDraggingPointerID: number;
  43429. /**
  43430. * If camera controls should be detached during the drag
  43431. */
  43432. detachCameraControls: boolean;
  43433. /**
  43434. * Fires each time a drag starts
  43435. */
  43436. onDragStartObservable: Observable<{}>;
  43437. /**
  43438. * Fires each time a drag ends (eg. mouse release after drag)
  43439. */
  43440. onDragEndObservable: Observable<{}>;
  43441. /**
  43442. * 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
  43443. */
  43444. constructor();
  43445. /**
  43446. * The name of the behavior
  43447. */
  43448. get name(): string;
  43449. /**
  43450. * Initializes the behavior
  43451. */
  43452. init(): void;
  43453. /**
  43454. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  43455. */
  43456. private get _pointerCamera();
  43457. /**
  43458. * Attaches the scale behavior the passed in mesh
  43459. * @param ownerNode The mesh that will be scaled around once attached
  43460. */
  43461. attach(ownerNode: Mesh): void;
  43462. /**
  43463. * Detaches the behavior from the mesh
  43464. */
  43465. detach(): void;
  43466. }
  43467. }
  43468. declare module BABYLON {
  43469. /**
  43470. * Class used to apply inverse kinematics to bones
  43471. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  43472. */
  43473. export class BoneIKController {
  43474. private static _tmpVecs;
  43475. private static _tmpQuat;
  43476. private static _tmpMats;
  43477. /**
  43478. * Gets or sets the target mesh
  43479. */
  43480. targetMesh: AbstractMesh;
  43481. /** Gets or sets the mesh used as pole */
  43482. poleTargetMesh: AbstractMesh;
  43483. /**
  43484. * Gets or sets the bone used as pole
  43485. */
  43486. poleTargetBone: Nullable<Bone>;
  43487. /**
  43488. * Gets or sets the target position
  43489. */
  43490. targetPosition: Vector3;
  43491. /**
  43492. * Gets or sets the pole target position
  43493. */
  43494. poleTargetPosition: Vector3;
  43495. /**
  43496. * Gets or sets the pole target local offset
  43497. */
  43498. poleTargetLocalOffset: Vector3;
  43499. /**
  43500. * Gets or sets the pole angle
  43501. */
  43502. poleAngle: number;
  43503. /**
  43504. * Gets or sets the mesh associated with the controller
  43505. */
  43506. mesh: AbstractMesh;
  43507. /**
  43508. * 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)
  43509. */
  43510. slerpAmount: number;
  43511. private _bone1Quat;
  43512. private _bone1Mat;
  43513. private _bone2Ang;
  43514. private _bone1;
  43515. private _bone2;
  43516. private _bone1Length;
  43517. private _bone2Length;
  43518. private _maxAngle;
  43519. private _maxReach;
  43520. private _rightHandedSystem;
  43521. private _bendAxis;
  43522. private _slerping;
  43523. private _adjustRoll;
  43524. /**
  43525. * Gets or sets maximum allowed angle
  43526. */
  43527. get maxAngle(): number;
  43528. set maxAngle(value: number);
  43529. /**
  43530. * Creates a new BoneIKController
  43531. * @param mesh defines the mesh to control
  43532. * @param bone defines the bone to control
  43533. * @param options defines options to set up the controller
  43534. */
  43535. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  43536. targetMesh?: AbstractMesh;
  43537. poleTargetMesh?: AbstractMesh;
  43538. poleTargetBone?: Bone;
  43539. poleTargetLocalOffset?: Vector3;
  43540. poleAngle?: number;
  43541. bendAxis?: Vector3;
  43542. maxAngle?: number;
  43543. slerpAmount?: number;
  43544. });
  43545. private _setMaxAngle;
  43546. /**
  43547. * Force the controller to update the bones
  43548. */
  43549. update(): void;
  43550. }
  43551. }
  43552. declare module BABYLON {
  43553. /**
  43554. * Class used to make a bone look toward a point in space
  43555. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  43556. */
  43557. export class BoneLookController {
  43558. private static _tmpVecs;
  43559. private static _tmpQuat;
  43560. private static _tmpMats;
  43561. /**
  43562. * The target Vector3 that the bone will look at
  43563. */
  43564. target: Vector3;
  43565. /**
  43566. * The mesh that the bone is attached to
  43567. */
  43568. mesh: AbstractMesh;
  43569. /**
  43570. * The bone that will be looking to the target
  43571. */
  43572. bone: Bone;
  43573. /**
  43574. * The up axis of the coordinate system that is used when the bone is rotated
  43575. */
  43576. upAxis: Vector3;
  43577. /**
  43578. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  43579. */
  43580. upAxisSpace: Space;
  43581. /**
  43582. * Used to make an adjustment to the yaw of the bone
  43583. */
  43584. adjustYaw: number;
  43585. /**
  43586. * Used to make an adjustment to the pitch of the bone
  43587. */
  43588. adjustPitch: number;
  43589. /**
  43590. * Used to make an adjustment to the roll of the bone
  43591. */
  43592. adjustRoll: number;
  43593. /**
  43594. * 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)
  43595. */
  43596. slerpAmount: number;
  43597. private _minYaw;
  43598. private _maxYaw;
  43599. private _minPitch;
  43600. private _maxPitch;
  43601. private _minYawSin;
  43602. private _minYawCos;
  43603. private _maxYawSin;
  43604. private _maxYawCos;
  43605. private _midYawConstraint;
  43606. private _minPitchTan;
  43607. private _maxPitchTan;
  43608. private _boneQuat;
  43609. private _slerping;
  43610. private _transformYawPitch;
  43611. private _transformYawPitchInv;
  43612. private _firstFrameSkipped;
  43613. private _yawRange;
  43614. private _fowardAxis;
  43615. /**
  43616. * Gets or sets the minimum yaw angle that the bone can look to
  43617. */
  43618. get minYaw(): number;
  43619. set minYaw(value: number);
  43620. /**
  43621. * Gets or sets the maximum yaw angle that the bone can look to
  43622. */
  43623. get maxYaw(): number;
  43624. set maxYaw(value: number);
  43625. /**
  43626. * Gets or sets the minimum pitch angle that the bone can look to
  43627. */
  43628. get minPitch(): number;
  43629. set minPitch(value: number);
  43630. /**
  43631. * Gets or sets the maximum pitch angle that the bone can look to
  43632. */
  43633. get maxPitch(): number;
  43634. set maxPitch(value: number);
  43635. /**
  43636. * Create a BoneLookController
  43637. * @param mesh the mesh that the bone belongs to
  43638. * @param bone the bone that will be looking to the target
  43639. * @param target the target Vector3 to look at
  43640. * @param options optional settings:
  43641. * * maxYaw: the maximum angle the bone will yaw to
  43642. * * minYaw: the minimum angle the bone will yaw to
  43643. * * maxPitch: the maximum angle the bone will pitch to
  43644. * * minPitch: the minimum angle the bone will yaw to
  43645. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  43646. * * upAxis: the up axis of the coordinate system
  43647. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  43648. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  43649. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  43650. * * adjustYaw: used to make an adjustment to the yaw of the bone
  43651. * * adjustPitch: used to make an adjustment to the pitch of the bone
  43652. * * adjustRoll: used to make an adjustment to the roll of the bone
  43653. **/
  43654. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  43655. maxYaw?: number;
  43656. minYaw?: number;
  43657. maxPitch?: number;
  43658. minPitch?: number;
  43659. slerpAmount?: number;
  43660. upAxis?: Vector3;
  43661. upAxisSpace?: Space;
  43662. yawAxis?: Vector3;
  43663. pitchAxis?: Vector3;
  43664. adjustYaw?: number;
  43665. adjustPitch?: number;
  43666. adjustRoll?: number;
  43667. });
  43668. /**
  43669. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  43670. */
  43671. update(): void;
  43672. private _getAngleDiff;
  43673. private _getAngleBetween;
  43674. private _isAngleBetween;
  43675. }
  43676. }
  43677. declare module BABYLON {
  43678. /**
  43679. * Manage the gamepad inputs to control an arc rotate camera.
  43680. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43681. */
  43682. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  43683. /**
  43684. * Defines the camera the input is attached to.
  43685. */
  43686. camera: ArcRotateCamera;
  43687. /**
  43688. * Defines the gamepad the input is gathering event from.
  43689. */
  43690. gamepad: Nullable<Gamepad>;
  43691. /**
  43692. * Defines the gamepad rotation sensiblity.
  43693. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43694. */
  43695. gamepadRotationSensibility: number;
  43696. /**
  43697. * Defines the gamepad move sensiblity.
  43698. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43699. */
  43700. gamepadMoveSensibility: number;
  43701. private _yAxisScale;
  43702. /**
  43703. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  43704. */
  43705. get invertYAxis(): boolean;
  43706. set invertYAxis(value: boolean);
  43707. private _onGamepadConnectedObserver;
  43708. private _onGamepadDisconnectedObserver;
  43709. /**
  43710. * Attach the input controls to a specific dom element to get the input from.
  43711. * @param element Defines the element the controls should be listened from
  43712. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43713. */
  43714. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43715. /**
  43716. * Detach the current controls from the specified dom element.
  43717. * @param element Defines the element to stop listening the inputs from
  43718. */
  43719. detachControl(element: Nullable<HTMLElement>): void;
  43720. /**
  43721. * Update the current camera state depending on the inputs that have been used this frame.
  43722. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43723. */
  43724. checkInputs(): void;
  43725. /**
  43726. * Gets the class name of the current intput.
  43727. * @returns the class name
  43728. */
  43729. getClassName(): string;
  43730. /**
  43731. * Get the friendly name associated with the input class.
  43732. * @returns the input friendly name
  43733. */
  43734. getSimpleName(): string;
  43735. }
  43736. }
  43737. declare module BABYLON {
  43738. interface ArcRotateCameraInputsManager {
  43739. /**
  43740. * Add orientation input support to the input manager.
  43741. * @returns the current input manager
  43742. */
  43743. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  43744. }
  43745. /**
  43746. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  43747. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43748. */
  43749. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  43750. /**
  43751. * Defines the camera the input is attached to.
  43752. */
  43753. camera: ArcRotateCamera;
  43754. /**
  43755. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  43756. */
  43757. alphaCorrection: number;
  43758. /**
  43759. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  43760. */
  43761. gammaCorrection: number;
  43762. private _alpha;
  43763. private _gamma;
  43764. private _dirty;
  43765. private _deviceOrientationHandler;
  43766. /**
  43767. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  43768. */
  43769. constructor();
  43770. /**
  43771. * Attach the input controls to a specific dom element to get the input from.
  43772. * @param element Defines the element the controls should be listened from
  43773. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43774. */
  43775. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43776. /** @hidden */
  43777. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  43778. /**
  43779. * Update the current camera state depending on the inputs that have been used this frame.
  43780. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43781. */
  43782. checkInputs(): void;
  43783. /**
  43784. * Detach the current controls from the specified dom element.
  43785. * @param element Defines the element to stop listening the inputs from
  43786. */
  43787. detachControl(element: Nullable<HTMLElement>): void;
  43788. /**
  43789. * Gets the class name of the current intput.
  43790. * @returns the class name
  43791. */
  43792. getClassName(): string;
  43793. /**
  43794. * Get the friendly name associated with the input class.
  43795. * @returns the input friendly name
  43796. */
  43797. getSimpleName(): string;
  43798. }
  43799. }
  43800. declare module BABYLON {
  43801. /**
  43802. * Listen to mouse events to control the camera.
  43803. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43804. */
  43805. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  43806. /**
  43807. * Defines the camera the input is attached to.
  43808. */
  43809. camera: FlyCamera;
  43810. /**
  43811. * Defines if touch is enabled. (Default is true.)
  43812. */
  43813. touchEnabled: boolean;
  43814. /**
  43815. * Defines the buttons associated with the input to handle camera rotation.
  43816. */
  43817. buttons: number[];
  43818. /**
  43819. * Assign buttons for Yaw control.
  43820. */
  43821. buttonsYaw: number[];
  43822. /**
  43823. * Assign buttons for Pitch control.
  43824. */
  43825. buttonsPitch: number[];
  43826. /**
  43827. * Assign buttons for Roll control.
  43828. */
  43829. buttonsRoll: number[];
  43830. /**
  43831. * Detect if any button is being pressed while mouse is moved.
  43832. * -1 = Mouse locked.
  43833. * 0 = Left button.
  43834. * 1 = Middle Button.
  43835. * 2 = Right Button.
  43836. */
  43837. activeButton: number;
  43838. /**
  43839. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  43840. * Higher values reduce its sensitivity.
  43841. */
  43842. angularSensibility: number;
  43843. private _mousemoveCallback;
  43844. private _observer;
  43845. private _rollObserver;
  43846. private previousPosition;
  43847. private noPreventDefault;
  43848. private element;
  43849. /**
  43850. * Listen to mouse events to control the camera.
  43851. * @param touchEnabled Define if touch is enabled. (Default is true.)
  43852. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43853. */
  43854. constructor(touchEnabled?: boolean);
  43855. /**
  43856. * Attach the mouse control to the HTML DOM element.
  43857. * @param element Defines the element that listens to the input events.
  43858. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  43859. */
  43860. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43861. /**
  43862. * Detach the current controls from the specified dom element.
  43863. * @param element Defines the element to stop listening the inputs from
  43864. */
  43865. detachControl(element: Nullable<HTMLElement>): void;
  43866. /**
  43867. * Gets the class name of the current input.
  43868. * @returns the class name.
  43869. */
  43870. getClassName(): string;
  43871. /**
  43872. * Get the friendly name associated with the input class.
  43873. * @returns the input's friendly name.
  43874. */
  43875. getSimpleName(): string;
  43876. private _pointerInput;
  43877. private _onMouseMove;
  43878. /**
  43879. * Rotate camera by mouse offset.
  43880. */
  43881. private rotateCamera;
  43882. }
  43883. }
  43884. declare module BABYLON {
  43885. /**
  43886. * Default Inputs manager for the FlyCamera.
  43887. * It groups all the default supported inputs for ease of use.
  43888. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43889. */
  43890. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  43891. /**
  43892. * Instantiates a new FlyCameraInputsManager.
  43893. * @param camera Defines the camera the inputs belong to.
  43894. */
  43895. constructor(camera: FlyCamera);
  43896. /**
  43897. * Add keyboard input support to the input manager.
  43898. * @returns the new FlyCameraKeyboardMoveInput().
  43899. */
  43900. addKeyboard(): FlyCameraInputsManager;
  43901. /**
  43902. * Add mouse input support to the input manager.
  43903. * @param touchEnabled Enable touch screen support.
  43904. * @returns the new FlyCameraMouseInput().
  43905. */
  43906. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  43907. }
  43908. }
  43909. declare module BABYLON {
  43910. /**
  43911. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43912. * such as in a 3D Space Shooter or a Flight Simulator.
  43913. */
  43914. export class FlyCamera extends TargetCamera {
  43915. /**
  43916. * Define the collision ellipsoid of the camera.
  43917. * This is helpful for simulating a camera body, like a player's body.
  43918. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43919. */
  43920. ellipsoid: Vector3;
  43921. /**
  43922. * Define an offset for the position of the ellipsoid around the camera.
  43923. * This can be helpful if the camera is attached away from the player's body center,
  43924. * such as at its head.
  43925. */
  43926. ellipsoidOffset: Vector3;
  43927. /**
  43928. * Enable or disable collisions of the camera with the rest of the scene objects.
  43929. */
  43930. checkCollisions: boolean;
  43931. /**
  43932. * Enable or disable gravity on the camera.
  43933. */
  43934. applyGravity: boolean;
  43935. /**
  43936. * Define the current direction the camera is moving to.
  43937. */
  43938. cameraDirection: Vector3;
  43939. /**
  43940. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  43941. * This overrides and empties cameraRotation.
  43942. */
  43943. rotationQuaternion: Quaternion;
  43944. /**
  43945. * Track Roll to maintain the wanted Rolling when looking around.
  43946. */
  43947. _trackRoll: number;
  43948. /**
  43949. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  43950. */
  43951. rollCorrect: number;
  43952. /**
  43953. * Mimic a banked turn, Rolling the camera when Yawing.
  43954. * It's recommended to use rollCorrect = 10 for faster banking correction.
  43955. */
  43956. bankedTurn: boolean;
  43957. /**
  43958. * Limit in radians for how much Roll banking will add. (Default: 90°)
  43959. */
  43960. bankedTurnLimit: number;
  43961. /**
  43962. * Value of 0 disables the banked Roll.
  43963. * Value of 1 is equal to the Yaw angle in radians.
  43964. */
  43965. bankedTurnMultiplier: number;
  43966. /**
  43967. * The inputs manager loads all the input sources, such as keyboard and mouse.
  43968. */
  43969. inputs: FlyCameraInputsManager;
  43970. /**
  43971. * Gets the input sensibility for mouse input.
  43972. * Higher values reduce sensitivity.
  43973. */
  43974. get angularSensibility(): number;
  43975. /**
  43976. * Sets the input sensibility for a mouse input.
  43977. * Higher values reduce sensitivity.
  43978. */
  43979. set angularSensibility(value: number);
  43980. /**
  43981. * Get the keys for camera movement forward.
  43982. */
  43983. get keysForward(): number[];
  43984. /**
  43985. * Set the keys for camera movement forward.
  43986. */
  43987. set keysForward(value: number[]);
  43988. /**
  43989. * Get the keys for camera movement backward.
  43990. */
  43991. get keysBackward(): number[];
  43992. set keysBackward(value: number[]);
  43993. /**
  43994. * Get the keys for camera movement up.
  43995. */
  43996. get keysUp(): number[];
  43997. /**
  43998. * Set the keys for camera movement up.
  43999. */
  44000. set keysUp(value: number[]);
  44001. /**
  44002. * Get the keys for camera movement down.
  44003. */
  44004. get keysDown(): number[];
  44005. /**
  44006. * Set the keys for camera movement down.
  44007. */
  44008. set keysDown(value: number[]);
  44009. /**
  44010. * Get the keys for camera movement left.
  44011. */
  44012. get keysLeft(): number[];
  44013. /**
  44014. * Set the keys for camera movement left.
  44015. */
  44016. set keysLeft(value: number[]);
  44017. /**
  44018. * Set the keys for camera movement right.
  44019. */
  44020. get keysRight(): number[];
  44021. /**
  44022. * Set the keys for camera movement right.
  44023. */
  44024. set keysRight(value: number[]);
  44025. /**
  44026. * Event raised when the camera collides with a mesh in the scene.
  44027. */
  44028. onCollide: (collidedMesh: AbstractMesh) => void;
  44029. private _collider;
  44030. private _needMoveForGravity;
  44031. private _oldPosition;
  44032. private _diffPosition;
  44033. private _newPosition;
  44034. /** @hidden */
  44035. _localDirection: Vector3;
  44036. /** @hidden */
  44037. _transformedDirection: Vector3;
  44038. /**
  44039. * Instantiates a FlyCamera.
  44040. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44041. * such as in a 3D Space Shooter or a Flight Simulator.
  44042. * @param name Define the name of the camera in the scene.
  44043. * @param position Define the starting position of the camera in the scene.
  44044. * @param scene Define the scene the camera belongs to.
  44045. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44046. */
  44047. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44048. /**
  44049. * Attach a control to the HTML DOM element.
  44050. * @param element Defines the element that listens to the input events.
  44051. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44052. */
  44053. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44054. /**
  44055. * Detach a control from the HTML DOM element.
  44056. * The camera will stop reacting to that input.
  44057. * @param element Defines the element that listens to the input events.
  44058. */
  44059. detachControl(element: HTMLElement): void;
  44060. private _collisionMask;
  44061. /**
  44062. * Get the mask that the camera ignores in collision events.
  44063. */
  44064. get collisionMask(): number;
  44065. /**
  44066. * Set the mask that the camera ignores in collision events.
  44067. */
  44068. set collisionMask(mask: number);
  44069. /** @hidden */
  44070. _collideWithWorld(displacement: Vector3): void;
  44071. /** @hidden */
  44072. private _onCollisionPositionChange;
  44073. /** @hidden */
  44074. _checkInputs(): void;
  44075. /** @hidden */
  44076. _decideIfNeedsToMove(): boolean;
  44077. /** @hidden */
  44078. _updatePosition(): void;
  44079. /**
  44080. * Restore the Roll to its target value at the rate specified.
  44081. * @param rate - Higher means slower restoring.
  44082. * @hidden
  44083. */
  44084. restoreRoll(rate: number): void;
  44085. /**
  44086. * Destroy the camera and release the current resources held by it.
  44087. */
  44088. dispose(): void;
  44089. /**
  44090. * Get the current object class name.
  44091. * @returns the class name.
  44092. */
  44093. getClassName(): string;
  44094. }
  44095. }
  44096. declare module BABYLON {
  44097. /**
  44098. * Listen to keyboard events to control the camera.
  44099. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44100. */
  44101. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44102. /**
  44103. * Defines the camera the input is attached to.
  44104. */
  44105. camera: FlyCamera;
  44106. /**
  44107. * The list of keyboard keys used to control the forward move of the camera.
  44108. */
  44109. keysForward: number[];
  44110. /**
  44111. * The list of keyboard keys used to control the backward move of the camera.
  44112. */
  44113. keysBackward: number[];
  44114. /**
  44115. * The list of keyboard keys used to control the forward move of the camera.
  44116. */
  44117. keysUp: number[];
  44118. /**
  44119. * The list of keyboard keys used to control the backward move of the camera.
  44120. */
  44121. keysDown: number[];
  44122. /**
  44123. * The list of keyboard keys used to control the right strafe move of the camera.
  44124. */
  44125. keysRight: number[];
  44126. /**
  44127. * The list of keyboard keys used to control the left strafe move of the camera.
  44128. */
  44129. keysLeft: number[];
  44130. private _keys;
  44131. private _onCanvasBlurObserver;
  44132. private _onKeyboardObserver;
  44133. private _engine;
  44134. private _scene;
  44135. /**
  44136. * Attach the input controls to a specific dom element to get the input from.
  44137. * @param element Defines the element the controls should be listened from
  44138. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44139. */
  44140. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44141. /**
  44142. * Detach the current controls from the specified dom element.
  44143. * @param element Defines the element to stop listening the inputs from
  44144. */
  44145. detachControl(element: Nullable<HTMLElement>): void;
  44146. /**
  44147. * Gets the class name of the current intput.
  44148. * @returns the class name
  44149. */
  44150. getClassName(): string;
  44151. /** @hidden */
  44152. _onLostFocus(e: FocusEvent): void;
  44153. /**
  44154. * Get the friendly name associated with the input class.
  44155. * @returns the input friendly name
  44156. */
  44157. getSimpleName(): string;
  44158. /**
  44159. * Update the current camera state depending on the inputs that have been used this frame.
  44160. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44161. */
  44162. checkInputs(): void;
  44163. }
  44164. }
  44165. declare module BABYLON {
  44166. /**
  44167. * Manage the mouse wheel inputs to control a follow camera.
  44168. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44169. */
  44170. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  44171. /**
  44172. * Defines the camera the input is attached to.
  44173. */
  44174. camera: FollowCamera;
  44175. /**
  44176. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  44177. */
  44178. axisControlRadius: boolean;
  44179. /**
  44180. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  44181. */
  44182. axisControlHeight: boolean;
  44183. /**
  44184. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  44185. */
  44186. axisControlRotation: boolean;
  44187. /**
  44188. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  44189. * relation to mouseWheel events.
  44190. */
  44191. wheelPrecision: number;
  44192. /**
  44193. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44194. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44195. */
  44196. wheelDeltaPercentage: number;
  44197. private _wheel;
  44198. private _observer;
  44199. /**
  44200. * Attach the input controls to a specific dom element to get the input from.
  44201. * @param element Defines the element the controls should be listened from
  44202. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44203. */
  44204. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44205. /**
  44206. * Detach the current controls from the specified dom element.
  44207. * @param element Defines the element to stop listening the inputs from
  44208. */
  44209. detachControl(element: Nullable<HTMLElement>): void;
  44210. /**
  44211. * Gets the class name of the current intput.
  44212. * @returns the class name
  44213. */
  44214. getClassName(): string;
  44215. /**
  44216. * Get the friendly name associated with the input class.
  44217. * @returns the input friendly name
  44218. */
  44219. getSimpleName(): string;
  44220. }
  44221. }
  44222. declare module BABYLON {
  44223. /**
  44224. * Manage the pointers inputs to control an follow camera.
  44225. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44226. */
  44227. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  44228. /**
  44229. * Defines the camera the input is attached to.
  44230. */
  44231. camera: FollowCamera;
  44232. /**
  44233. * Gets the class name of the current input.
  44234. * @returns the class name
  44235. */
  44236. getClassName(): string;
  44237. /**
  44238. * Defines the pointer angular sensibility along the X axis or how fast is
  44239. * the camera rotating.
  44240. * A negative number will reverse the axis direction.
  44241. */
  44242. angularSensibilityX: number;
  44243. /**
  44244. * Defines the pointer angular sensibility along the Y axis or how fast is
  44245. * the camera rotating.
  44246. * A negative number will reverse the axis direction.
  44247. */
  44248. angularSensibilityY: number;
  44249. /**
  44250. * Defines the pointer pinch precision or how fast is the camera zooming.
  44251. * A negative number will reverse the axis direction.
  44252. */
  44253. pinchPrecision: number;
  44254. /**
  44255. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44256. * from 0.
  44257. * It defines the percentage of current camera.radius to use as delta when
  44258. * pinch zoom is used.
  44259. */
  44260. pinchDeltaPercentage: number;
  44261. /**
  44262. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  44263. */
  44264. axisXControlRadius: boolean;
  44265. /**
  44266. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  44267. */
  44268. axisXControlHeight: boolean;
  44269. /**
  44270. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  44271. */
  44272. axisXControlRotation: boolean;
  44273. /**
  44274. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  44275. */
  44276. axisYControlRadius: boolean;
  44277. /**
  44278. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  44279. */
  44280. axisYControlHeight: boolean;
  44281. /**
  44282. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  44283. */
  44284. axisYControlRotation: boolean;
  44285. /**
  44286. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  44287. */
  44288. axisPinchControlRadius: boolean;
  44289. /**
  44290. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  44291. */
  44292. axisPinchControlHeight: boolean;
  44293. /**
  44294. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  44295. */
  44296. axisPinchControlRotation: boolean;
  44297. /**
  44298. * Log error messages if basic misconfiguration has occurred.
  44299. */
  44300. warningEnable: boolean;
  44301. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44302. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44303. private _warningCounter;
  44304. private _warning;
  44305. }
  44306. }
  44307. declare module BABYLON {
  44308. /**
  44309. * Default Inputs manager for the FollowCamera.
  44310. * It groups all the default supported inputs for ease of use.
  44311. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44312. */
  44313. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  44314. /**
  44315. * Instantiates a new FollowCameraInputsManager.
  44316. * @param camera Defines the camera the inputs belong to
  44317. */
  44318. constructor(camera: FollowCamera);
  44319. /**
  44320. * Add keyboard input support to the input manager.
  44321. * @returns the current input manager
  44322. */
  44323. addKeyboard(): FollowCameraInputsManager;
  44324. /**
  44325. * Add mouse wheel input support to the input manager.
  44326. * @returns the current input manager
  44327. */
  44328. addMouseWheel(): FollowCameraInputsManager;
  44329. /**
  44330. * Add pointers input support to the input manager.
  44331. * @returns the current input manager
  44332. */
  44333. addPointers(): FollowCameraInputsManager;
  44334. /**
  44335. * Add orientation input support to the input manager.
  44336. * @returns the current input manager
  44337. */
  44338. addVRDeviceOrientation(): FollowCameraInputsManager;
  44339. }
  44340. }
  44341. declare module BABYLON {
  44342. /**
  44343. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  44344. * an arc rotate version arcFollowCamera are available.
  44345. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44346. */
  44347. export class FollowCamera extends TargetCamera {
  44348. /**
  44349. * Distance the follow camera should follow an object at
  44350. */
  44351. radius: number;
  44352. /**
  44353. * Minimum allowed distance of the camera to the axis of rotation
  44354. * (The camera can not get closer).
  44355. * This can help limiting how the Camera is able to move in the scene.
  44356. */
  44357. lowerRadiusLimit: Nullable<number>;
  44358. /**
  44359. * Maximum allowed distance of the camera to the axis of rotation
  44360. * (The camera can not get further).
  44361. * This can help limiting how the Camera is able to move in the scene.
  44362. */
  44363. upperRadiusLimit: Nullable<number>;
  44364. /**
  44365. * Define a rotation offset between the camera and the object it follows
  44366. */
  44367. rotationOffset: number;
  44368. /**
  44369. * Minimum allowed angle to camera position relative to target object.
  44370. * This can help limiting how the Camera is able to move in the scene.
  44371. */
  44372. lowerRotationOffsetLimit: Nullable<number>;
  44373. /**
  44374. * Maximum allowed angle to camera position relative to target object.
  44375. * This can help limiting how the Camera is able to move in the scene.
  44376. */
  44377. upperRotationOffsetLimit: Nullable<number>;
  44378. /**
  44379. * Define a height offset between the camera and the object it follows.
  44380. * It can help following an object from the top (like a car chaing a plane)
  44381. */
  44382. heightOffset: number;
  44383. /**
  44384. * Minimum allowed height of camera position relative to target object.
  44385. * This can help limiting how the Camera is able to move in the scene.
  44386. */
  44387. lowerHeightOffsetLimit: Nullable<number>;
  44388. /**
  44389. * Maximum allowed height of camera position relative to target object.
  44390. * This can help limiting how the Camera is able to move in the scene.
  44391. */
  44392. upperHeightOffsetLimit: Nullable<number>;
  44393. /**
  44394. * Define how fast the camera can accelerate to follow it s target.
  44395. */
  44396. cameraAcceleration: number;
  44397. /**
  44398. * Define the speed limit of the camera following an object.
  44399. */
  44400. maxCameraSpeed: number;
  44401. /**
  44402. * Define the target of the camera.
  44403. */
  44404. lockedTarget: Nullable<AbstractMesh>;
  44405. /**
  44406. * Defines the input associated with the camera.
  44407. */
  44408. inputs: FollowCameraInputsManager;
  44409. /**
  44410. * Instantiates the follow camera.
  44411. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44412. * @param name Define the name of the camera in the scene
  44413. * @param position Define the position of the camera
  44414. * @param scene Define the scene the camera belong to
  44415. * @param lockedTarget Define the target of the camera
  44416. */
  44417. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  44418. private _follow;
  44419. /**
  44420. * Attached controls to the current camera.
  44421. * @param element Defines the element the controls should be listened from
  44422. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44423. */
  44424. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44425. /**
  44426. * Detach the current controls from the camera.
  44427. * The camera will stop reacting to inputs.
  44428. * @param element Defines the element to stop listening the inputs from
  44429. */
  44430. detachControl(element: HTMLElement): void;
  44431. /** @hidden */
  44432. _checkInputs(): void;
  44433. private _checkLimits;
  44434. /**
  44435. * Gets the camera class name.
  44436. * @returns the class name
  44437. */
  44438. getClassName(): string;
  44439. }
  44440. /**
  44441. * Arc Rotate version of the follow camera.
  44442. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  44443. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44444. */
  44445. export class ArcFollowCamera extends TargetCamera {
  44446. /** The longitudinal angle of the camera */
  44447. alpha: number;
  44448. /** The latitudinal angle of the camera */
  44449. beta: number;
  44450. /** The radius of the camera from its target */
  44451. radius: number;
  44452. /** Define the camera target (the mesh it should follow) */
  44453. target: Nullable<AbstractMesh>;
  44454. private _cartesianCoordinates;
  44455. /**
  44456. * Instantiates a new ArcFollowCamera
  44457. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44458. * @param name Define the name of the camera
  44459. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  44460. * @param beta Define the rotation angle of the camera around the elevation axis
  44461. * @param radius Define the radius of the camera from its target point
  44462. * @param target Define the target of the camera
  44463. * @param scene Define the scene the camera belongs to
  44464. */
  44465. constructor(name: string,
  44466. /** The longitudinal angle of the camera */
  44467. alpha: number,
  44468. /** The latitudinal angle of the camera */
  44469. beta: number,
  44470. /** The radius of the camera from its target */
  44471. radius: number,
  44472. /** Define the camera target (the mesh it should follow) */
  44473. target: Nullable<AbstractMesh>, scene: Scene);
  44474. private _follow;
  44475. /** @hidden */
  44476. _checkInputs(): void;
  44477. /**
  44478. * Returns the class name of the object.
  44479. * It is mostly used internally for serialization purposes.
  44480. */
  44481. getClassName(): string;
  44482. }
  44483. }
  44484. declare module BABYLON {
  44485. /**
  44486. * Manage the keyboard inputs to control the movement of a follow camera.
  44487. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44488. */
  44489. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  44490. /**
  44491. * Defines the camera the input is attached to.
  44492. */
  44493. camera: FollowCamera;
  44494. /**
  44495. * Defines the list of key codes associated with the up action (increase heightOffset)
  44496. */
  44497. keysHeightOffsetIncr: number[];
  44498. /**
  44499. * Defines the list of key codes associated with the down action (decrease heightOffset)
  44500. */
  44501. keysHeightOffsetDecr: number[];
  44502. /**
  44503. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  44504. */
  44505. keysHeightOffsetModifierAlt: boolean;
  44506. /**
  44507. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  44508. */
  44509. keysHeightOffsetModifierCtrl: boolean;
  44510. /**
  44511. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  44512. */
  44513. keysHeightOffsetModifierShift: boolean;
  44514. /**
  44515. * Defines the list of key codes associated with the left action (increase rotationOffset)
  44516. */
  44517. keysRotationOffsetIncr: number[];
  44518. /**
  44519. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  44520. */
  44521. keysRotationOffsetDecr: number[];
  44522. /**
  44523. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  44524. */
  44525. keysRotationOffsetModifierAlt: boolean;
  44526. /**
  44527. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  44528. */
  44529. keysRotationOffsetModifierCtrl: boolean;
  44530. /**
  44531. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  44532. */
  44533. keysRotationOffsetModifierShift: boolean;
  44534. /**
  44535. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  44536. */
  44537. keysRadiusIncr: number[];
  44538. /**
  44539. * Defines the list of key codes associated with the zoom-out action (increase radius)
  44540. */
  44541. keysRadiusDecr: number[];
  44542. /**
  44543. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  44544. */
  44545. keysRadiusModifierAlt: boolean;
  44546. /**
  44547. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  44548. */
  44549. keysRadiusModifierCtrl: boolean;
  44550. /**
  44551. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  44552. */
  44553. keysRadiusModifierShift: boolean;
  44554. /**
  44555. * Defines the rate of change of heightOffset.
  44556. */
  44557. heightSensibility: number;
  44558. /**
  44559. * Defines the rate of change of rotationOffset.
  44560. */
  44561. rotationSensibility: number;
  44562. /**
  44563. * Defines the rate of change of radius.
  44564. */
  44565. radiusSensibility: number;
  44566. private _keys;
  44567. private _ctrlPressed;
  44568. private _altPressed;
  44569. private _shiftPressed;
  44570. private _onCanvasBlurObserver;
  44571. private _onKeyboardObserver;
  44572. private _engine;
  44573. private _scene;
  44574. /**
  44575. * Attach the input controls to a specific dom element to get the input from.
  44576. * @param element Defines the element the controls should be listened from
  44577. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44578. */
  44579. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44580. /**
  44581. * Detach the current controls from the specified dom element.
  44582. * @param element Defines the element to stop listening the inputs from
  44583. */
  44584. detachControl(element: Nullable<HTMLElement>): void;
  44585. /**
  44586. * Update the current camera state depending on the inputs that have been used this frame.
  44587. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44588. */
  44589. checkInputs(): void;
  44590. /**
  44591. * Gets the class name of the current input.
  44592. * @returns the class name
  44593. */
  44594. getClassName(): string;
  44595. /**
  44596. * Get the friendly name associated with the input class.
  44597. * @returns the input friendly name
  44598. */
  44599. getSimpleName(): string;
  44600. /**
  44601. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44602. * allow modification of the heightOffset value.
  44603. */
  44604. private _modifierHeightOffset;
  44605. /**
  44606. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44607. * allow modification of the rotationOffset value.
  44608. */
  44609. private _modifierRotationOffset;
  44610. /**
  44611. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44612. * allow modification of the radius value.
  44613. */
  44614. private _modifierRadius;
  44615. }
  44616. }
  44617. declare module BABYLON {
  44618. interface FreeCameraInputsManager {
  44619. /**
  44620. * @hidden
  44621. */
  44622. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  44623. /**
  44624. * Add orientation input support to the input manager.
  44625. * @returns the current input manager
  44626. */
  44627. addDeviceOrientation(): FreeCameraInputsManager;
  44628. }
  44629. /**
  44630. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  44631. * Screen rotation is taken into account.
  44632. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44633. */
  44634. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  44635. private _camera;
  44636. private _screenOrientationAngle;
  44637. private _constantTranform;
  44638. private _screenQuaternion;
  44639. private _alpha;
  44640. private _beta;
  44641. private _gamma;
  44642. /**
  44643. * Can be used to detect if a device orientation sensor is available on a device
  44644. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  44645. * @returns a promise that will resolve on orientation change
  44646. */
  44647. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  44648. /**
  44649. * @hidden
  44650. */
  44651. _onDeviceOrientationChangedObservable: Observable<void>;
  44652. /**
  44653. * Instantiates a new input
  44654. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44655. */
  44656. constructor();
  44657. /**
  44658. * Define the camera controlled by the input.
  44659. */
  44660. get camera(): FreeCamera;
  44661. set camera(camera: FreeCamera);
  44662. /**
  44663. * Attach the input controls to a specific dom element to get the input from.
  44664. * @param element Defines the element the controls should be listened from
  44665. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44666. */
  44667. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44668. private _orientationChanged;
  44669. private _deviceOrientation;
  44670. /**
  44671. * Detach the current controls from the specified dom element.
  44672. * @param element Defines the element to stop listening the inputs from
  44673. */
  44674. detachControl(element: Nullable<HTMLElement>): void;
  44675. /**
  44676. * Update the current camera state depending on the inputs that have been used this frame.
  44677. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44678. */
  44679. checkInputs(): void;
  44680. /**
  44681. * Gets the class name of the current intput.
  44682. * @returns the class name
  44683. */
  44684. getClassName(): string;
  44685. /**
  44686. * Get the friendly name associated with the input class.
  44687. * @returns the input friendly name
  44688. */
  44689. getSimpleName(): string;
  44690. }
  44691. }
  44692. declare module BABYLON {
  44693. /**
  44694. * Manage the gamepad inputs to control a free camera.
  44695. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44696. */
  44697. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  44698. /**
  44699. * Define the camera the input is attached to.
  44700. */
  44701. camera: FreeCamera;
  44702. /**
  44703. * Define the Gamepad controlling the input
  44704. */
  44705. gamepad: Nullable<Gamepad>;
  44706. /**
  44707. * Defines the gamepad rotation sensiblity.
  44708. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44709. */
  44710. gamepadAngularSensibility: number;
  44711. /**
  44712. * Defines the gamepad move sensiblity.
  44713. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44714. */
  44715. gamepadMoveSensibility: number;
  44716. private _yAxisScale;
  44717. /**
  44718. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44719. */
  44720. get invertYAxis(): boolean;
  44721. set invertYAxis(value: boolean);
  44722. private _onGamepadConnectedObserver;
  44723. private _onGamepadDisconnectedObserver;
  44724. private _cameraTransform;
  44725. private _deltaTransform;
  44726. private _vector3;
  44727. private _vector2;
  44728. /**
  44729. * Attach the input controls to a specific dom element to get the input from.
  44730. * @param element Defines the element the controls should be listened from
  44731. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44732. */
  44733. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44734. /**
  44735. * Detach the current controls from the specified dom element.
  44736. * @param element Defines the element to stop listening the inputs from
  44737. */
  44738. detachControl(element: Nullable<HTMLElement>): void;
  44739. /**
  44740. * Update the current camera state depending on the inputs that have been used this frame.
  44741. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44742. */
  44743. checkInputs(): void;
  44744. /**
  44745. * Gets the class name of the current intput.
  44746. * @returns the class name
  44747. */
  44748. getClassName(): string;
  44749. /**
  44750. * Get the friendly name associated with the input class.
  44751. * @returns the input friendly name
  44752. */
  44753. getSimpleName(): string;
  44754. }
  44755. }
  44756. declare module BABYLON {
  44757. /**
  44758. * Defines the potential axis of a Joystick
  44759. */
  44760. export enum JoystickAxis {
  44761. /** X axis */
  44762. X = 0,
  44763. /** Y axis */
  44764. Y = 1,
  44765. /** Z axis */
  44766. Z = 2
  44767. }
  44768. /**
  44769. * Represents the different customization options available
  44770. * for VirtualJoystick
  44771. */
  44772. interface VirtualJoystickCustomizations {
  44773. /**
  44774. * Size of the joystick's puck
  44775. */
  44776. puckSize: number;
  44777. /**
  44778. * Size of the joystick's container
  44779. */
  44780. containerSize: number;
  44781. /**
  44782. * Color of the joystick && puck
  44783. */
  44784. color: string;
  44785. /**
  44786. * Image URL for the joystick's puck
  44787. */
  44788. puckImage?: string;
  44789. /**
  44790. * Image URL for the joystick's container
  44791. */
  44792. containerImage?: string;
  44793. /**
  44794. * Defines the unmoving position of the joystick container
  44795. */
  44796. position?: {
  44797. x: number;
  44798. y: number;
  44799. };
  44800. /**
  44801. * Defines whether or not the joystick container is always visible
  44802. */
  44803. alwaysVisible: boolean;
  44804. /**
  44805. * Defines whether or not to limit the movement of the puck to the joystick's container
  44806. */
  44807. limitToContainer: boolean;
  44808. }
  44809. /**
  44810. * Class used to define virtual joystick (used in touch mode)
  44811. */
  44812. export class VirtualJoystick {
  44813. /**
  44814. * Gets or sets a boolean indicating that left and right values must be inverted
  44815. */
  44816. reverseLeftRight: boolean;
  44817. /**
  44818. * Gets or sets a boolean indicating that up and down values must be inverted
  44819. */
  44820. reverseUpDown: boolean;
  44821. /**
  44822. * Gets the offset value for the position (ie. the change of the position value)
  44823. */
  44824. deltaPosition: Vector3;
  44825. /**
  44826. * Gets a boolean indicating if the virtual joystick was pressed
  44827. */
  44828. pressed: boolean;
  44829. /**
  44830. * Canvas the virtual joystick will render onto, default z-index of this is 5
  44831. */
  44832. static Canvas: Nullable<HTMLCanvasElement>;
  44833. /**
  44834. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  44835. */
  44836. limitToContainer: boolean;
  44837. private static _globalJoystickIndex;
  44838. private static _alwaysVisibleSticks;
  44839. private static vjCanvasContext;
  44840. private static vjCanvasWidth;
  44841. private static vjCanvasHeight;
  44842. private static halfWidth;
  44843. private static _GetDefaultOptions;
  44844. private _action;
  44845. private _axisTargetedByLeftAndRight;
  44846. private _axisTargetedByUpAndDown;
  44847. private _joystickSensibility;
  44848. private _inversedSensibility;
  44849. private _joystickPointerID;
  44850. private _joystickColor;
  44851. private _joystickPointerPos;
  44852. private _joystickPreviousPointerPos;
  44853. private _joystickPointerStartPos;
  44854. private _deltaJoystickVector;
  44855. private _leftJoystick;
  44856. private _touches;
  44857. private _joystickPosition;
  44858. private _alwaysVisible;
  44859. private _puckImage;
  44860. private _containerImage;
  44861. private _joystickPuckSize;
  44862. private _joystickContainerSize;
  44863. private _clearPuckSize;
  44864. private _clearContainerSize;
  44865. private _clearPuckSizeOffset;
  44866. private _clearContainerSizeOffset;
  44867. private _onPointerDownHandlerRef;
  44868. private _onPointerMoveHandlerRef;
  44869. private _onPointerUpHandlerRef;
  44870. private _onResize;
  44871. /**
  44872. * Creates a new virtual joystick
  44873. * @param leftJoystick defines that the joystick is for left hand (false by default)
  44874. * @param customizations Defines the options we want to customize the VirtualJoystick
  44875. */
  44876. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  44877. /**
  44878. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  44879. * @param newJoystickSensibility defines the new sensibility
  44880. */
  44881. setJoystickSensibility(newJoystickSensibility: number): void;
  44882. private _onPointerDown;
  44883. private _onPointerMove;
  44884. private _onPointerUp;
  44885. /**
  44886. * Change the color of the virtual joystick
  44887. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  44888. */
  44889. setJoystickColor(newColor: string): void;
  44890. /**
  44891. * Size of the joystick's container
  44892. */
  44893. set containerSize(newSize: number);
  44894. get containerSize(): number;
  44895. /**
  44896. * Size of the joystick's puck
  44897. */
  44898. set puckSize(newSize: number);
  44899. get puckSize(): number;
  44900. /**
  44901. * Clears the set position of the joystick
  44902. */
  44903. clearPosition(): void;
  44904. /**
  44905. * Defines whether or not the joystick container is always visible
  44906. */
  44907. set alwaysVisible(value: boolean);
  44908. get alwaysVisible(): boolean;
  44909. /**
  44910. * Sets the constant position of the Joystick container
  44911. * @param x X axis coordinate
  44912. * @param y Y axis coordinate
  44913. */
  44914. setPosition(x: number, y: number): void;
  44915. /**
  44916. * Defines a callback to call when the joystick is touched
  44917. * @param action defines the callback
  44918. */
  44919. setActionOnTouch(action: () => any): void;
  44920. /**
  44921. * Defines which axis you'd like to control for left & right
  44922. * @param axis defines the axis to use
  44923. */
  44924. setAxisForLeftRight(axis: JoystickAxis): void;
  44925. /**
  44926. * Defines which axis you'd like to control for up & down
  44927. * @param axis defines the axis to use
  44928. */
  44929. setAxisForUpDown(axis: JoystickAxis): void;
  44930. /**
  44931. * Clears the canvas from the previous puck / container draw
  44932. */
  44933. private _clearPreviousDraw;
  44934. /**
  44935. * Loads `urlPath` to be used for the container's image
  44936. * @param urlPath defines the urlPath of an image to use
  44937. */
  44938. setContainerImage(urlPath: string): void;
  44939. /**
  44940. * Loads `urlPath` to be used for the puck's image
  44941. * @param urlPath defines the urlPath of an image to use
  44942. */
  44943. setPuckImage(urlPath: string): void;
  44944. /**
  44945. * Draws the Virtual Joystick's container
  44946. */
  44947. private _drawContainer;
  44948. /**
  44949. * Draws the Virtual Joystick's puck
  44950. */
  44951. private _drawPuck;
  44952. private _drawVirtualJoystick;
  44953. /**
  44954. * Release internal HTML canvas
  44955. */
  44956. releaseCanvas(): void;
  44957. }
  44958. }
  44959. declare module BABYLON {
  44960. interface FreeCameraInputsManager {
  44961. /**
  44962. * Add virtual joystick input support to the input manager.
  44963. * @returns the current input manager
  44964. */
  44965. addVirtualJoystick(): FreeCameraInputsManager;
  44966. }
  44967. /**
  44968. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  44969. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44970. */
  44971. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  44972. /**
  44973. * Defines the camera the input is attached to.
  44974. */
  44975. camera: FreeCamera;
  44976. private _leftjoystick;
  44977. private _rightjoystick;
  44978. /**
  44979. * Gets the left stick of the virtual joystick.
  44980. * @returns The virtual Joystick
  44981. */
  44982. getLeftJoystick(): VirtualJoystick;
  44983. /**
  44984. * Gets the right stick of the virtual joystick.
  44985. * @returns The virtual Joystick
  44986. */
  44987. getRightJoystick(): VirtualJoystick;
  44988. /**
  44989. * Update the current camera state depending on the inputs that have been used this frame.
  44990. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44991. */
  44992. checkInputs(): void;
  44993. /**
  44994. * Attach the input controls to a specific dom element to get the input from.
  44995. * @param element Defines the element the controls should be listened from
  44996. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44997. */
  44998. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44999. /**
  45000. * Detach the current controls from the specified dom element.
  45001. * @param element Defines the element to stop listening the inputs from
  45002. */
  45003. detachControl(element: Nullable<HTMLElement>): void;
  45004. /**
  45005. * Gets the class name of the current intput.
  45006. * @returns the class name
  45007. */
  45008. getClassName(): string;
  45009. /**
  45010. * Get the friendly name associated with the input class.
  45011. * @returns the input friendly name
  45012. */
  45013. getSimpleName(): string;
  45014. }
  45015. }
  45016. declare module BABYLON {
  45017. /**
  45018. * This represents a FPS type of camera controlled by touch.
  45019. * This is like a universal camera minus the Gamepad controls.
  45020. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45021. */
  45022. export class TouchCamera extends FreeCamera {
  45023. /**
  45024. * Defines the touch sensibility for rotation.
  45025. * The higher the faster.
  45026. */
  45027. get touchAngularSensibility(): number;
  45028. set touchAngularSensibility(value: number);
  45029. /**
  45030. * Defines the touch sensibility for move.
  45031. * The higher the faster.
  45032. */
  45033. get touchMoveSensibility(): number;
  45034. set touchMoveSensibility(value: number);
  45035. /**
  45036. * Instantiates a new touch camera.
  45037. * This represents a FPS type of camera controlled by touch.
  45038. * This is like a universal camera minus the Gamepad controls.
  45039. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45040. * @param name Define the name of the camera in the scene
  45041. * @param position Define the start position of the camera in the scene
  45042. * @param scene Define the scene the camera belongs to
  45043. */
  45044. constructor(name: string, position: Vector3, scene: Scene);
  45045. /**
  45046. * Gets the current object class name.
  45047. * @return the class name
  45048. */
  45049. getClassName(): string;
  45050. /** @hidden */
  45051. _setupInputs(): void;
  45052. }
  45053. }
  45054. declare module BABYLON {
  45055. /**
  45056. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45057. * being tilted forward or back and left or right.
  45058. */
  45059. export class DeviceOrientationCamera extends FreeCamera {
  45060. private _initialQuaternion;
  45061. private _quaternionCache;
  45062. private _tmpDragQuaternion;
  45063. private _disablePointerInputWhenUsingDeviceOrientation;
  45064. /**
  45065. * Creates a new device orientation camera
  45066. * @param name The name of the camera
  45067. * @param position The start position camera
  45068. * @param scene The scene the camera belongs to
  45069. */
  45070. constructor(name: string, position: Vector3, scene: Scene);
  45071. /**
  45072. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  45073. */
  45074. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  45075. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  45076. private _dragFactor;
  45077. /**
  45078. * Enabled turning on the y axis when the orientation sensor is active
  45079. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  45080. */
  45081. enableHorizontalDragging(dragFactor?: number): void;
  45082. /**
  45083. * Gets the current instance class name ("DeviceOrientationCamera").
  45084. * This helps avoiding instanceof at run time.
  45085. * @returns the class name
  45086. */
  45087. getClassName(): string;
  45088. /**
  45089. * @hidden
  45090. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  45091. */
  45092. _checkInputs(): void;
  45093. /**
  45094. * Reset the camera to its default orientation on the specified axis only.
  45095. * @param axis The axis to reset
  45096. */
  45097. resetToCurrentRotation(axis?: Axis): void;
  45098. }
  45099. }
  45100. declare module BABYLON {
  45101. /**
  45102. * Defines supported buttons for XBox360 compatible gamepads
  45103. */
  45104. export enum Xbox360Button {
  45105. /** A */
  45106. A = 0,
  45107. /** B */
  45108. B = 1,
  45109. /** X */
  45110. X = 2,
  45111. /** Y */
  45112. Y = 3,
  45113. /** Left button */
  45114. LB = 4,
  45115. /** Right button */
  45116. RB = 5,
  45117. /** Back */
  45118. Back = 8,
  45119. /** Start */
  45120. Start = 9,
  45121. /** Left stick */
  45122. LeftStick = 10,
  45123. /** Right stick */
  45124. RightStick = 11
  45125. }
  45126. /** Defines values for XBox360 DPad */
  45127. export enum Xbox360Dpad {
  45128. /** Up */
  45129. Up = 12,
  45130. /** Down */
  45131. Down = 13,
  45132. /** Left */
  45133. Left = 14,
  45134. /** Right */
  45135. Right = 15
  45136. }
  45137. /**
  45138. * Defines a XBox360 gamepad
  45139. */
  45140. export class Xbox360Pad extends Gamepad {
  45141. private _leftTrigger;
  45142. private _rightTrigger;
  45143. private _onlefttriggerchanged;
  45144. private _onrighttriggerchanged;
  45145. private _onbuttondown;
  45146. private _onbuttonup;
  45147. private _ondpaddown;
  45148. private _ondpadup;
  45149. /** Observable raised when a button is pressed */
  45150. onButtonDownObservable: Observable<Xbox360Button>;
  45151. /** Observable raised when a button is released */
  45152. onButtonUpObservable: Observable<Xbox360Button>;
  45153. /** Observable raised when a pad is pressed */
  45154. onPadDownObservable: Observable<Xbox360Dpad>;
  45155. /** Observable raised when a pad is released */
  45156. onPadUpObservable: Observable<Xbox360Dpad>;
  45157. private _buttonA;
  45158. private _buttonB;
  45159. private _buttonX;
  45160. private _buttonY;
  45161. private _buttonBack;
  45162. private _buttonStart;
  45163. private _buttonLB;
  45164. private _buttonRB;
  45165. private _buttonLeftStick;
  45166. private _buttonRightStick;
  45167. private _dPadUp;
  45168. private _dPadDown;
  45169. private _dPadLeft;
  45170. private _dPadRight;
  45171. private _isXboxOnePad;
  45172. /**
  45173. * Creates a new XBox360 gamepad object
  45174. * @param id defines the id of this gamepad
  45175. * @param index defines its index
  45176. * @param gamepad defines the internal HTML gamepad object
  45177. * @param xboxOne defines if it is a XBox One gamepad
  45178. */
  45179. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  45180. /**
  45181. * Defines the callback to call when left trigger is pressed
  45182. * @param callback defines the callback to use
  45183. */
  45184. onlefttriggerchanged(callback: (value: number) => void): void;
  45185. /**
  45186. * Defines the callback to call when right trigger is pressed
  45187. * @param callback defines the callback to use
  45188. */
  45189. onrighttriggerchanged(callback: (value: number) => void): void;
  45190. /**
  45191. * Gets the left trigger value
  45192. */
  45193. get leftTrigger(): number;
  45194. /**
  45195. * Sets the left trigger value
  45196. */
  45197. set leftTrigger(newValue: number);
  45198. /**
  45199. * Gets the right trigger value
  45200. */
  45201. get rightTrigger(): number;
  45202. /**
  45203. * Sets the right trigger value
  45204. */
  45205. set rightTrigger(newValue: number);
  45206. /**
  45207. * Defines the callback to call when a button is pressed
  45208. * @param callback defines the callback to use
  45209. */
  45210. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  45211. /**
  45212. * Defines the callback to call when a button is released
  45213. * @param callback defines the callback to use
  45214. */
  45215. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  45216. /**
  45217. * Defines the callback to call when a pad is pressed
  45218. * @param callback defines the callback to use
  45219. */
  45220. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  45221. /**
  45222. * Defines the callback to call when a pad is released
  45223. * @param callback defines the callback to use
  45224. */
  45225. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  45226. private _setButtonValue;
  45227. private _setDPadValue;
  45228. /**
  45229. * Gets the value of the `A` button
  45230. */
  45231. get buttonA(): number;
  45232. /**
  45233. * Sets the value of the `A` button
  45234. */
  45235. set buttonA(value: number);
  45236. /**
  45237. * Gets the value of the `B` button
  45238. */
  45239. get buttonB(): number;
  45240. /**
  45241. * Sets the value of the `B` button
  45242. */
  45243. set buttonB(value: number);
  45244. /**
  45245. * Gets the value of the `X` button
  45246. */
  45247. get buttonX(): number;
  45248. /**
  45249. * Sets the value of the `X` button
  45250. */
  45251. set buttonX(value: number);
  45252. /**
  45253. * Gets the value of the `Y` button
  45254. */
  45255. get buttonY(): number;
  45256. /**
  45257. * Sets the value of the `Y` button
  45258. */
  45259. set buttonY(value: number);
  45260. /**
  45261. * Gets the value of the `Start` button
  45262. */
  45263. get buttonStart(): number;
  45264. /**
  45265. * Sets the value of the `Start` button
  45266. */
  45267. set buttonStart(value: number);
  45268. /**
  45269. * Gets the value of the `Back` button
  45270. */
  45271. get buttonBack(): number;
  45272. /**
  45273. * Sets the value of the `Back` button
  45274. */
  45275. set buttonBack(value: number);
  45276. /**
  45277. * Gets the value of the `Left` button
  45278. */
  45279. get buttonLB(): number;
  45280. /**
  45281. * Sets the value of the `Left` button
  45282. */
  45283. set buttonLB(value: number);
  45284. /**
  45285. * Gets the value of the `Right` button
  45286. */
  45287. get buttonRB(): number;
  45288. /**
  45289. * Sets the value of the `Right` button
  45290. */
  45291. set buttonRB(value: number);
  45292. /**
  45293. * Gets the value of the Left joystick
  45294. */
  45295. get buttonLeftStick(): number;
  45296. /**
  45297. * Sets the value of the Left joystick
  45298. */
  45299. set buttonLeftStick(value: number);
  45300. /**
  45301. * Gets the value of the Right joystick
  45302. */
  45303. get buttonRightStick(): number;
  45304. /**
  45305. * Sets the value of the Right joystick
  45306. */
  45307. set buttonRightStick(value: number);
  45308. /**
  45309. * Gets the value of D-pad up
  45310. */
  45311. get dPadUp(): number;
  45312. /**
  45313. * Sets the value of D-pad up
  45314. */
  45315. set dPadUp(value: number);
  45316. /**
  45317. * Gets the value of D-pad down
  45318. */
  45319. get dPadDown(): number;
  45320. /**
  45321. * Sets the value of D-pad down
  45322. */
  45323. set dPadDown(value: number);
  45324. /**
  45325. * Gets the value of D-pad left
  45326. */
  45327. get dPadLeft(): number;
  45328. /**
  45329. * Sets the value of D-pad left
  45330. */
  45331. set dPadLeft(value: number);
  45332. /**
  45333. * Gets the value of D-pad right
  45334. */
  45335. get dPadRight(): number;
  45336. /**
  45337. * Sets the value of D-pad right
  45338. */
  45339. set dPadRight(value: number);
  45340. /**
  45341. * Force the gamepad to synchronize with device values
  45342. */
  45343. update(): void;
  45344. /**
  45345. * Disposes the gamepad
  45346. */
  45347. dispose(): void;
  45348. }
  45349. }
  45350. declare module BABYLON {
  45351. /**
  45352. * Defines supported buttons for DualShock compatible gamepads
  45353. */
  45354. export enum DualShockButton {
  45355. /** Cross */
  45356. Cross = 0,
  45357. /** Circle */
  45358. Circle = 1,
  45359. /** Square */
  45360. Square = 2,
  45361. /** Triangle */
  45362. Triangle = 3,
  45363. /** L1 */
  45364. L1 = 4,
  45365. /** R1 */
  45366. R1 = 5,
  45367. /** Share */
  45368. Share = 8,
  45369. /** Options */
  45370. Options = 9,
  45371. /** Left stick */
  45372. LeftStick = 10,
  45373. /** Right stick */
  45374. RightStick = 11
  45375. }
  45376. /** Defines values for DualShock DPad */
  45377. export enum DualShockDpad {
  45378. /** Up */
  45379. Up = 12,
  45380. /** Down */
  45381. Down = 13,
  45382. /** Left */
  45383. Left = 14,
  45384. /** Right */
  45385. Right = 15
  45386. }
  45387. /**
  45388. * Defines a DualShock gamepad
  45389. */
  45390. export class DualShockPad extends Gamepad {
  45391. private _leftTrigger;
  45392. private _rightTrigger;
  45393. private _onlefttriggerchanged;
  45394. private _onrighttriggerchanged;
  45395. private _onbuttondown;
  45396. private _onbuttonup;
  45397. private _ondpaddown;
  45398. private _ondpadup;
  45399. /** Observable raised when a button is pressed */
  45400. onButtonDownObservable: Observable<DualShockButton>;
  45401. /** Observable raised when a button is released */
  45402. onButtonUpObservable: Observable<DualShockButton>;
  45403. /** Observable raised when a pad is pressed */
  45404. onPadDownObservable: Observable<DualShockDpad>;
  45405. /** Observable raised when a pad is released */
  45406. onPadUpObservable: Observable<DualShockDpad>;
  45407. private _buttonCross;
  45408. private _buttonCircle;
  45409. private _buttonSquare;
  45410. private _buttonTriangle;
  45411. private _buttonShare;
  45412. private _buttonOptions;
  45413. private _buttonL1;
  45414. private _buttonR1;
  45415. private _buttonLeftStick;
  45416. private _buttonRightStick;
  45417. private _dPadUp;
  45418. private _dPadDown;
  45419. private _dPadLeft;
  45420. private _dPadRight;
  45421. /**
  45422. * Creates a new DualShock gamepad object
  45423. * @param id defines the id of this gamepad
  45424. * @param index defines its index
  45425. * @param gamepad defines the internal HTML gamepad object
  45426. */
  45427. constructor(id: string, index: number, gamepad: any);
  45428. /**
  45429. * Defines the callback to call when left trigger is pressed
  45430. * @param callback defines the callback to use
  45431. */
  45432. onlefttriggerchanged(callback: (value: number) => void): void;
  45433. /**
  45434. * Defines the callback to call when right trigger is pressed
  45435. * @param callback defines the callback to use
  45436. */
  45437. onrighttriggerchanged(callback: (value: number) => void): void;
  45438. /**
  45439. * Gets the left trigger value
  45440. */
  45441. get leftTrigger(): number;
  45442. /**
  45443. * Sets the left trigger value
  45444. */
  45445. set leftTrigger(newValue: number);
  45446. /**
  45447. * Gets the right trigger value
  45448. */
  45449. get rightTrigger(): number;
  45450. /**
  45451. * Sets the right trigger value
  45452. */
  45453. set rightTrigger(newValue: number);
  45454. /**
  45455. * Defines the callback to call when a button is pressed
  45456. * @param callback defines the callback to use
  45457. */
  45458. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  45459. /**
  45460. * Defines the callback to call when a button is released
  45461. * @param callback defines the callback to use
  45462. */
  45463. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  45464. /**
  45465. * Defines the callback to call when a pad is pressed
  45466. * @param callback defines the callback to use
  45467. */
  45468. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  45469. /**
  45470. * Defines the callback to call when a pad is released
  45471. * @param callback defines the callback to use
  45472. */
  45473. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  45474. private _setButtonValue;
  45475. private _setDPadValue;
  45476. /**
  45477. * Gets the value of the `Cross` button
  45478. */
  45479. get buttonCross(): number;
  45480. /**
  45481. * Sets the value of the `Cross` button
  45482. */
  45483. set buttonCross(value: number);
  45484. /**
  45485. * Gets the value of the `Circle` button
  45486. */
  45487. get buttonCircle(): number;
  45488. /**
  45489. * Sets the value of the `Circle` button
  45490. */
  45491. set buttonCircle(value: number);
  45492. /**
  45493. * Gets the value of the `Square` button
  45494. */
  45495. get buttonSquare(): number;
  45496. /**
  45497. * Sets the value of the `Square` button
  45498. */
  45499. set buttonSquare(value: number);
  45500. /**
  45501. * Gets the value of the `Triangle` button
  45502. */
  45503. get buttonTriangle(): number;
  45504. /**
  45505. * Sets the value of the `Triangle` button
  45506. */
  45507. set buttonTriangle(value: number);
  45508. /**
  45509. * Gets the value of the `Options` button
  45510. */
  45511. get buttonOptions(): number;
  45512. /**
  45513. * Sets the value of the `Options` button
  45514. */
  45515. set buttonOptions(value: number);
  45516. /**
  45517. * Gets the value of the `Share` button
  45518. */
  45519. get buttonShare(): number;
  45520. /**
  45521. * Sets the value of the `Share` button
  45522. */
  45523. set buttonShare(value: number);
  45524. /**
  45525. * Gets the value of the `L1` button
  45526. */
  45527. get buttonL1(): number;
  45528. /**
  45529. * Sets the value of the `L1` button
  45530. */
  45531. set buttonL1(value: number);
  45532. /**
  45533. * Gets the value of the `R1` button
  45534. */
  45535. get buttonR1(): number;
  45536. /**
  45537. * Sets the value of the `R1` button
  45538. */
  45539. set buttonR1(value: number);
  45540. /**
  45541. * Gets the value of the Left joystick
  45542. */
  45543. get buttonLeftStick(): number;
  45544. /**
  45545. * Sets the value of the Left joystick
  45546. */
  45547. set buttonLeftStick(value: number);
  45548. /**
  45549. * Gets the value of the Right joystick
  45550. */
  45551. get buttonRightStick(): number;
  45552. /**
  45553. * Sets the value of the Right joystick
  45554. */
  45555. set buttonRightStick(value: number);
  45556. /**
  45557. * Gets the value of D-pad up
  45558. */
  45559. get dPadUp(): number;
  45560. /**
  45561. * Sets the value of D-pad up
  45562. */
  45563. set dPadUp(value: number);
  45564. /**
  45565. * Gets the value of D-pad down
  45566. */
  45567. get dPadDown(): number;
  45568. /**
  45569. * Sets the value of D-pad down
  45570. */
  45571. set dPadDown(value: number);
  45572. /**
  45573. * Gets the value of D-pad left
  45574. */
  45575. get dPadLeft(): number;
  45576. /**
  45577. * Sets the value of D-pad left
  45578. */
  45579. set dPadLeft(value: number);
  45580. /**
  45581. * Gets the value of D-pad right
  45582. */
  45583. get dPadRight(): number;
  45584. /**
  45585. * Sets the value of D-pad right
  45586. */
  45587. set dPadRight(value: number);
  45588. /**
  45589. * Force the gamepad to synchronize with device values
  45590. */
  45591. update(): void;
  45592. /**
  45593. * Disposes the gamepad
  45594. */
  45595. dispose(): void;
  45596. }
  45597. }
  45598. declare module BABYLON {
  45599. /**
  45600. * Manager for handling gamepads
  45601. */
  45602. export class GamepadManager {
  45603. private _scene?;
  45604. private _babylonGamepads;
  45605. private _oneGamepadConnected;
  45606. /** @hidden */
  45607. _isMonitoring: boolean;
  45608. private _gamepadEventSupported;
  45609. private _gamepadSupport?;
  45610. /**
  45611. * observable to be triggered when the gamepad controller has been connected
  45612. */
  45613. onGamepadConnectedObservable: Observable<Gamepad>;
  45614. /**
  45615. * observable to be triggered when the gamepad controller has been disconnected
  45616. */
  45617. onGamepadDisconnectedObservable: Observable<Gamepad>;
  45618. private _onGamepadConnectedEvent;
  45619. private _onGamepadDisconnectedEvent;
  45620. /**
  45621. * Initializes the gamepad manager
  45622. * @param _scene BabylonJS scene
  45623. */
  45624. constructor(_scene?: Scene | undefined);
  45625. /**
  45626. * The gamepads in the game pad manager
  45627. */
  45628. get gamepads(): Gamepad[];
  45629. /**
  45630. * Get the gamepad controllers based on type
  45631. * @param type The type of gamepad controller
  45632. * @returns Nullable gamepad
  45633. */
  45634. getGamepadByType(type?: number): Nullable<Gamepad>;
  45635. /**
  45636. * Disposes the gamepad manager
  45637. */
  45638. dispose(): void;
  45639. private _addNewGamepad;
  45640. private _startMonitoringGamepads;
  45641. private _stopMonitoringGamepads;
  45642. /** @hidden */
  45643. _checkGamepadsStatus(): void;
  45644. private _updateGamepadObjects;
  45645. }
  45646. }
  45647. declare module BABYLON {
  45648. interface Scene {
  45649. /** @hidden */
  45650. _gamepadManager: Nullable<GamepadManager>;
  45651. /**
  45652. * Gets the gamepad manager associated with the scene
  45653. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  45654. */
  45655. gamepadManager: GamepadManager;
  45656. }
  45657. /**
  45658. * Interface representing a free camera inputs manager
  45659. */
  45660. interface FreeCameraInputsManager {
  45661. /**
  45662. * Adds gamepad input support to the FreeCameraInputsManager.
  45663. * @returns the FreeCameraInputsManager
  45664. */
  45665. addGamepad(): FreeCameraInputsManager;
  45666. }
  45667. /**
  45668. * Interface representing an arc rotate camera inputs manager
  45669. */
  45670. interface ArcRotateCameraInputsManager {
  45671. /**
  45672. * Adds gamepad input support to the ArcRotateCamera InputManager.
  45673. * @returns the camera inputs manager
  45674. */
  45675. addGamepad(): ArcRotateCameraInputsManager;
  45676. }
  45677. /**
  45678. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  45679. */
  45680. export class GamepadSystemSceneComponent implements ISceneComponent {
  45681. /**
  45682. * The component name helpfull to identify the component in the list of scene components.
  45683. */
  45684. readonly name: string;
  45685. /**
  45686. * The scene the component belongs to.
  45687. */
  45688. scene: Scene;
  45689. /**
  45690. * Creates a new instance of the component for the given scene
  45691. * @param scene Defines the scene to register the component in
  45692. */
  45693. constructor(scene: Scene);
  45694. /**
  45695. * Registers the component in a given scene
  45696. */
  45697. register(): void;
  45698. /**
  45699. * Rebuilds the elements related to this component in case of
  45700. * context lost for instance.
  45701. */
  45702. rebuild(): void;
  45703. /**
  45704. * Disposes the component and the associated ressources
  45705. */
  45706. dispose(): void;
  45707. private _beforeCameraUpdate;
  45708. }
  45709. }
  45710. declare module BABYLON {
  45711. /**
  45712. * 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,
  45713. * which still works and will still be found in many Playgrounds.
  45714. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45715. */
  45716. export class UniversalCamera extends TouchCamera {
  45717. /**
  45718. * Defines the gamepad rotation sensiblity.
  45719. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45720. */
  45721. get gamepadAngularSensibility(): number;
  45722. set gamepadAngularSensibility(value: number);
  45723. /**
  45724. * Defines the gamepad move sensiblity.
  45725. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45726. */
  45727. get gamepadMoveSensibility(): number;
  45728. set gamepadMoveSensibility(value: number);
  45729. /**
  45730. * 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,
  45731. * which still works and will still be found in many Playgrounds.
  45732. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45733. * @param name Define the name of the camera in the scene
  45734. * @param position Define the start position of the camera in the scene
  45735. * @param scene Define the scene the camera belongs to
  45736. */
  45737. constructor(name: string, position: Vector3, scene: Scene);
  45738. /**
  45739. * Gets the current object class name.
  45740. * @return the class name
  45741. */
  45742. getClassName(): string;
  45743. }
  45744. }
  45745. declare module BABYLON {
  45746. /**
  45747. * This represents a FPS type of camera. This is only here for back compat purpose.
  45748. * Please use the UniversalCamera instead as both are identical.
  45749. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45750. */
  45751. export class GamepadCamera extends UniversalCamera {
  45752. /**
  45753. * Instantiates a new Gamepad Camera
  45754. * This represents a FPS type of camera. This is only here for back compat purpose.
  45755. * Please use the UniversalCamera instead as both are identical.
  45756. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45757. * @param name Define the name of the camera in the scene
  45758. * @param position Define the start position of the camera in the scene
  45759. * @param scene Define the scene the camera belongs to
  45760. */
  45761. constructor(name: string, position: Vector3, scene: Scene);
  45762. /**
  45763. * Gets the current object class name.
  45764. * @return the class name
  45765. */
  45766. getClassName(): string;
  45767. }
  45768. }
  45769. declare module BABYLON {
  45770. /** @hidden */
  45771. export var passPixelShader: {
  45772. name: string;
  45773. shader: string;
  45774. };
  45775. }
  45776. declare module BABYLON {
  45777. /** @hidden */
  45778. export var passCubePixelShader: {
  45779. name: string;
  45780. shader: string;
  45781. };
  45782. }
  45783. declare module BABYLON {
  45784. /**
  45785. * PassPostProcess which produces an output the same as it's input
  45786. */
  45787. export class PassPostProcess extends PostProcess {
  45788. /**
  45789. * Creates the PassPostProcess
  45790. * @param name The name of the effect.
  45791. * @param options The required width/height ratio to downsize to before computing the render pass.
  45792. * @param camera The camera to apply the render pass to.
  45793. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  45794. * @param engine The engine which the post process will be applied. (default: current engine)
  45795. * @param reusable If the post process can be reused on the same frame. (default: false)
  45796. * @param textureType The type of texture to be used when performing the post processing.
  45797. * @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)
  45798. */
  45799. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  45800. }
  45801. /**
  45802. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  45803. */
  45804. export class PassCubePostProcess extends PostProcess {
  45805. private _face;
  45806. /**
  45807. * Gets or sets the cube face to display.
  45808. * * 0 is +X
  45809. * * 1 is -X
  45810. * * 2 is +Y
  45811. * * 3 is -Y
  45812. * * 4 is +Z
  45813. * * 5 is -Z
  45814. */
  45815. get face(): number;
  45816. set face(value: number);
  45817. /**
  45818. * Creates the PassCubePostProcess
  45819. * @param name The name of the effect.
  45820. * @param options The required width/height ratio to downsize to before computing the render pass.
  45821. * @param camera The camera to apply the render pass to.
  45822. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  45823. * @param engine The engine which the post process will be applied. (default: current engine)
  45824. * @param reusable If the post process can be reused on the same frame. (default: false)
  45825. * @param textureType The type of texture to be used when performing the post processing.
  45826. * @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)
  45827. */
  45828. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  45829. }
  45830. }
  45831. declare module BABYLON {
  45832. /** @hidden */
  45833. export var anaglyphPixelShader: {
  45834. name: string;
  45835. shader: string;
  45836. };
  45837. }
  45838. declare module BABYLON {
  45839. /**
  45840. * Postprocess used to generate anaglyphic rendering
  45841. */
  45842. export class AnaglyphPostProcess extends PostProcess {
  45843. private _passedProcess;
  45844. /**
  45845. * Creates a new AnaglyphPostProcess
  45846. * @param name defines postprocess name
  45847. * @param options defines creation options or target ratio scale
  45848. * @param rigCameras defines cameras using this postprocess
  45849. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  45850. * @param engine defines hosting engine
  45851. * @param reusable defines if the postprocess will be reused multiple times per frame
  45852. */
  45853. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  45854. }
  45855. }
  45856. declare module BABYLON {
  45857. /**
  45858. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  45859. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45860. */
  45861. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  45862. /**
  45863. * Creates a new AnaglyphArcRotateCamera
  45864. * @param name defines camera name
  45865. * @param alpha defines alpha angle (in radians)
  45866. * @param beta defines beta angle (in radians)
  45867. * @param radius defines radius
  45868. * @param target defines camera target
  45869. * @param interaxialDistance defines distance between each color axis
  45870. * @param scene defines the hosting scene
  45871. */
  45872. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  45873. /**
  45874. * Gets camera class name
  45875. * @returns AnaglyphArcRotateCamera
  45876. */
  45877. getClassName(): string;
  45878. }
  45879. }
  45880. declare module BABYLON {
  45881. /**
  45882. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  45883. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45884. */
  45885. export class AnaglyphFreeCamera extends FreeCamera {
  45886. /**
  45887. * Creates a new AnaglyphFreeCamera
  45888. * @param name defines camera name
  45889. * @param position defines initial position
  45890. * @param interaxialDistance defines distance between each color axis
  45891. * @param scene defines the hosting scene
  45892. */
  45893. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45894. /**
  45895. * Gets camera class name
  45896. * @returns AnaglyphFreeCamera
  45897. */
  45898. getClassName(): string;
  45899. }
  45900. }
  45901. declare module BABYLON {
  45902. /**
  45903. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  45904. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45905. */
  45906. export class AnaglyphGamepadCamera extends GamepadCamera {
  45907. /**
  45908. * Creates a new AnaglyphGamepadCamera
  45909. * @param name defines camera name
  45910. * @param position defines initial position
  45911. * @param interaxialDistance defines distance between each color axis
  45912. * @param scene defines the hosting scene
  45913. */
  45914. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45915. /**
  45916. * Gets camera class name
  45917. * @returns AnaglyphGamepadCamera
  45918. */
  45919. getClassName(): string;
  45920. }
  45921. }
  45922. declare module BABYLON {
  45923. /**
  45924. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  45925. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45926. */
  45927. export class AnaglyphUniversalCamera extends UniversalCamera {
  45928. /**
  45929. * Creates a new AnaglyphUniversalCamera
  45930. * @param name defines camera name
  45931. * @param position defines initial position
  45932. * @param interaxialDistance defines distance between each color axis
  45933. * @param scene defines the hosting scene
  45934. */
  45935. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45936. /**
  45937. * Gets camera class name
  45938. * @returns AnaglyphUniversalCamera
  45939. */
  45940. getClassName(): string;
  45941. }
  45942. }
  45943. declare module BABYLON {
  45944. /**
  45945. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  45946. * @see https://doc.babylonjs.com/features/cameras
  45947. */
  45948. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  45949. /**
  45950. * Creates a new StereoscopicArcRotateCamera
  45951. * @param name defines camera name
  45952. * @param alpha defines alpha angle (in radians)
  45953. * @param beta defines beta angle (in radians)
  45954. * @param radius defines radius
  45955. * @param target defines camera target
  45956. * @param interaxialDistance defines distance between each color axis
  45957. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45958. * @param scene defines the hosting scene
  45959. */
  45960. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45961. /**
  45962. * Gets camera class name
  45963. * @returns StereoscopicArcRotateCamera
  45964. */
  45965. getClassName(): string;
  45966. }
  45967. }
  45968. declare module BABYLON {
  45969. /**
  45970. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  45971. * @see https://doc.babylonjs.com/features/cameras
  45972. */
  45973. export class StereoscopicFreeCamera extends FreeCamera {
  45974. /**
  45975. * Creates a new StereoscopicFreeCamera
  45976. * @param name defines camera name
  45977. * @param position defines initial position
  45978. * @param interaxialDistance defines distance between each color axis
  45979. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45980. * @param scene defines the hosting scene
  45981. */
  45982. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45983. /**
  45984. * Gets camera class name
  45985. * @returns StereoscopicFreeCamera
  45986. */
  45987. getClassName(): string;
  45988. }
  45989. }
  45990. declare module BABYLON {
  45991. /**
  45992. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  45993. * @see https://doc.babylonjs.com/features/cameras
  45994. */
  45995. export class StereoscopicGamepadCamera extends GamepadCamera {
  45996. /**
  45997. * Creates a new StereoscopicGamepadCamera
  45998. * @param name defines camera name
  45999. * @param position defines initial position
  46000. * @param interaxialDistance defines distance between each color axis
  46001. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46002. * @param scene defines the hosting scene
  46003. */
  46004. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46005. /**
  46006. * Gets camera class name
  46007. * @returns StereoscopicGamepadCamera
  46008. */
  46009. getClassName(): string;
  46010. }
  46011. }
  46012. declare module BABYLON {
  46013. /**
  46014. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  46015. * @see https://doc.babylonjs.com/features/cameras
  46016. */
  46017. export class StereoscopicUniversalCamera extends UniversalCamera {
  46018. /**
  46019. * Creates a new StereoscopicUniversalCamera
  46020. * @param name defines camera name
  46021. * @param position defines initial position
  46022. * @param interaxialDistance defines distance between each color axis
  46023. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46024. * @param scene defines the hosting scene
  46025. */
  46026. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46027. /**
  46028. * Gets camera class name
  46029. * @returns StereoscopicUniversalCamera
  46030. */
  46031. getClassName(): string;
  46032. }
  46033. }
  46034. declare module BABYLON {
  46035. /**
  46036. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  46037. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46038. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46039. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46040. */
  46041. export class VirtualJoysticksCamera extends FreeCamera {
  46042. /**
  46043. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  46044. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46045. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46046. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46047. * @param name Define the name of the camera in the scene
  46048. * @param position Define the start position of the camera in the scene
  46049. * @param scene Define the scene the camera belongs to
  46050. */
  46051. constructor(name: string, position: Vector3, scene: Scene);
  46052. /**
  46053. * Gets the current object class name.
  46054. * @return the class name
  46055. */
  46056. getClassName(): string;
  46057. }
  46058. }
  46059. declare module BABYLON {
  46060. /**
  46061. * This represents all the required metrics to create a VR camera.
  46062. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  46063. */
  46064. export class VRCameraMetrics {
  46065. /**
  46066. * Define the horizontal resolution off the screen.
  46067. */
  46068. hResolution: number;
  46069. /**
  46070. * Define the vertical resolution off the screen.
  46071. */
  46072. vResolution: number;
  46073. /**
  46074. * Define the horizontal screen size.
  46075. */
  46076. hScreenSize: number;
  46077. /**
  46078. * Define the vertical screen size.
  46079. */
  46080. vScreenSize: number;
  46081. /**
  46082. * Define the vertical screen center position.
  46083. */
  46084. vScreenCenter: number;
  46085. /**
  46086. * Define the distance of the eyes to the screen.
  46087. */
  46088. eyeToScreenDistance: number;
  46089. /**
  46090. * Define the distance between both lenses
  46091. */
  46092. lensSeparationDistance: number;
  46093. /**
  46094. * Define the distance between both viewer's eyes.
  46095. */
  46096. interpupillaryDistance: number;
  46097. /**
  46098. * Define the distortion factor of the VR postprocess.
  46099. * Please, touch with care.
  46100. */
  46101. distortionK: number[];
  46102. /**
  46103. * Define the chromatic aberration correction factors for the VR post process.
  46104. */
  46105. chromaAbCorrection: number[];
  46106. /**
  46107. * Define the scale factor of the post process.
  46108. * The smaller the better but the slower.
  46109. */
  46110. postProcessScaleFactor: number;
  46111. /**
  46112. * Define an offset for the lens center.
  46113. */
  46114. lensCenterOffset: number;
  46115. /**
  46116. * Define if the current vr camera should compensate the distortion of the lense or not.
  46117. */
  46118. compensateDistortion: boolean;
  46119. /**
  46120. * Defines if multiview should be enabled when rendering (Default: false)
  46121. */
  46122. multiviewEnabled: boolean;
  46123. /**
  46124. * Gets the rendering aspect ratio based on the provided resolutions.
  46125. */
  46126. get aspectRatio(): number;
  46127. /**
  46128. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  46129. */
  46130. get aspectRatioFov(): number;
  46131. /**
  46132. * @hidden
  46133. */
  46134. get leftHMatrix(): Matrix;
  46135. /**
  46136. * @hidden
  46137. */
  46138. get rightHMatrix(): Matrix;
  46139. /**
  46140. * @hidden
  46141. */
  46142. get leftPreViewMatrix(): Matrix;
  46143. /**
  46144. * @hidden
  46145. */
  46146. get rightPreViewMatrix(): Matrix;
  46147. /**
  46148. * Get the default VRMetrics based on the most generic setup.
  46149. * @returns the default vr metrics
  46150. */
  46151. static GetDefault(): VRCameraMetrics;
  46152. }
  46153. }
  46154. declare module BABYLON {
  46155. /** @hidden */
  46156. export var vrDistortionCorrectionPixelShader: {
  46157. name: string;
  46158. shader: string;
  46159. };
  46160. }
  46161. declare module BABYLON {
  46162. /**
  46163. * VRDistortionCorrectionPostProcess used for mobile VR
  46164. */
  46165. export class VRDistortionCorrectionPostProcess extends PostProcess {
  46166. private _isRightEye;
  46167. private _distortionFactors;
  46168. private _postProcessScaleFactor;
  46169. private _lensCenterOffset;
  46170. private _scaleIn;
  46171. private _scaleFactor;
  46172. private _lensCenter;
  46173. /**
  46174. * Initializes the VRDistortionCorrectionPostProcess
  46175. * @param name The name of the effect.
  46176. * @param camera The camera to apply the render pass to.
  46177. * @param isRightEye If this is for the right eye distortion
  46178. * @param vrMetrics All the required metrics for the VR camera
  46179. */
  46180. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  46181. }
  46182. }
  46183. declare module BABYLON {
  46184. /**
  46185. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  46186. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46187. */
  46188. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  46189. /**
  46190. * Creates a new VRDeviceOrientationArcRotateCamera
  46191. * @param name defines camera name
  46192. * @param alpha defines the camera rotation along the logitudinal axis
  46193. * @param beta defines the camera rotation along the latitudinal axis
  46194. * @param radius defines the camera distance from its target
  46195. * @param target defines the camera target
  46196. * @param scene defines the scene the camera belongs to
  46197. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46198. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46199. */
  46200. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46201. /**
  46202. * Gets camera class name
  46203. * @returns VRDeviceOrientationArcRotateCamera
  46204. */
  46205. getClassName(): string;
  46206. }
  46207. }
  46208. declare module BABYLON {
  46209. /**
  46210. * Camera used to simulate VR rendering (based on FreeCamera)
  46211. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46212. */
  46213. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  46214. /**
  46215. * Creates a new VRDeviceOrientationFreeCamera
  46216. * @param name defines camera name
  46217. * @param position defines the start position of the camera
  46218. * @param scene defines the scene the camera belongs to
  46219. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46220. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46221. */
  46222. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46223. /**
  46224. * Gets camera class name
  46225. * @returns VRDeviceOrientationFreeCamera
  46226. */
  46227. getClassName(): string;
  46228. }
  46229. }
  46230. declare module BABYLON {
  46231. /**
  46232. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  46233. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46234. */
  46235. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  46236. /**
  46237. * Creates a new VRDeviceOrientationGamepadCamera
  46238. * @param name defines camera name
  46239. * @param position defines the start position of the camera
  46240. * @param scene defines the scene the camera belongs to
  46241. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46242. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46243. */
  46244. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46245. /**
  46246. * Gets camera class name
  46247. * @returns VRDeviceOrientationGamepadCamera
  46248. */
  46249. getClassName(): string;
  46250. }
  46251. }
  46252. declare module BABYLON {
  46253. /**
  46254. * A class extending Texture allowing drawing on a texture
  46255. * @see https://doc.babylonjs.com/how_to/dynamictexture
  46256. */
  46257. export class DynamicTexture extends Texture {
  46258. private _generateMipMaps;
  46259. private _canvas;
  46260. private _context;
  46261. /**
  46262. * Creates a DynamicTexture
  46263. * @param name defines the name of the texture
  46264. * @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
  46265. * @param scene defines the scene where you want the texture
  46266. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46267. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  46268. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  46269. */
  46270. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46271. /**
  46272. * Get the current class name of the texture useful for serialization or dynamic coding.
  46273. * @returns "DynamicTexture"
  46274. */
  46275. getClassName(): string;
  46276. /**
  46277. * Gets the current state of canRescale
  46278. */
  46279. get canRescale(): boolean;
  46280. private _recreate;
  46281. /**
  46282. * Scales the texture
  46283. * @param ratio the scale factor to apply to both width and height
  46284. */
  46285. scale(ratio: number): void;
  46286. /**
  46287. * Resizes the texture
  46288. * @param width the new width
  46289. * @param height the new height
  46290. */
  46291. scaleTo(width: number, height: number): void;
  46292. /**
  46293. * Gets the context of the canvas used by the texture
  46294. * @returns the canvas context of the dynamic texture
  46295. */
  46296. getContext(): CanvasRenderingContext2D;
  46297. /**
  46298. * Clears the texture
  46299. */
  46300. clear(): void;
  46301. /**
  46302. * Updates the texture
  46303. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46304. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46305. */
  46306. update(invertY?: boolean, premulAlpha?: boolean): void;
  46307. /**
  46308. * Draws text onto the texture
  46309. * @param text defines the text to be drawn
  46310. * @param x defines the placement of the text from the left
  46311. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46312. * @param font defines the font to be used with font-style, font-size, font-name
  46313. * @param color defines the color used for the text
  46314. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46315. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46316. * @param update defines whether texture is immediately update (default is true)
  46317. */
  46318. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  46319. /**
  46320. * Clones the texture
  46321. * @returns the clone of the texture.
  46322. */
  46323. clone(): DynamicTexture;
  46324. /**
  46325. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  46326. * @returns a serialized dynamic texture object
  46327. */
  46328. serialize(): any;
  46329. private _IsCanvasElement;
  46330. /** @hidden */
  46331. _rebuild(): void;
  46332. }
  46333. }
  46334. declare module BABYLON {
  46335. /**
  46336. * Class containing static functions to help procedurally build meshes
  46337. */
  46338. export class GroundBuilder {
  46339. /**
  46340. * Creates a ground mesh
  46341. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  46342. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  46343. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46344. * @param name defines the name of the mesh
  46345. * @param options defines the options used to create the mesh
  46346. * @param scene defines the hosting scene
  46347. * @returns the ground mesh
  46348. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  46349. */
  46350. static CreateGround(name: string, options: {
  46351. width?: number;
  46352. height?: number;
  46353. subdivisions?: number;
  46354. subdivisionsX?: number;
  46355. subdivisionsY?: number;
  46356. updatable?: boolean;
  46357. }, scene: any): Mesh;
  46358. /**
  46359. * Creates a tiled ground mesh
  46360. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  46361. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  46362. * * 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
  46363. * * 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
  46364. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46365. * @param name defines the name of the mesh
  46366. * @param options defines the options used to create the mesh
  46367. * @param scene defines the hosting scene
  46368. * @returns the tiled ground mesh
  46369. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  46370. */
  46371. static CreateTiledGround(name: string, options: {
  46372. xmin: number;
  46373. zmin: number;
  46374. xmax: number;
  46375. zmax: number;
  46376. subdivisions?: {
  46377. w: number;
  46378. h: number;
  46379. };
  46380. precision?: {
  46381. w: number;
  46382. h: number;
  46383. };
  46384. updatable?: boolean;
  46385. }, scene?: Nullable<Scene>): Mesh;
  46386. /**
  46387. * Creates a ground mesh from a height map
  46388. * * The parameter `url` sets the URL of the height map image resource.
  46389. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  46390. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  46391. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  46392. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  46393. * * 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.
  46394. * * 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).
  46395. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  46396. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46397. * @param name defines the name of the mesh
  46398. * @param url defines the url to the height map
  46399. * @param options defines the options used to create the mesh
  46400. * @param scene defines the hosting scene
  46401. * @returns the ground mesh
  46402. * @see https://doc.babylonjs.com/babylon101/height_map
  46403. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  46404. */
  46405. static CreateGroundFromHeightMap(name: string, url: string, options: {
  46406. width?: number;
  46407. height?: number;
  46408. subdivisions?: number;
  46409. minHeight?: number;
  46410. maxHeight?: number;
  46411. colorFilter?: Color3;
  46412. alphaFilter?: number;
  46413. updatable?: boolean;
  46414. onReady?: (mesh: GroundMesh) => void;
  46415. }, scene?: Nullable<Scene>): GroundMesh;
  46416. }
  46417. }
  46418. declare module BABYLON {
  46419. /**
  46420. * Class containing static functions to help procedurally build meshes
  46421. */
  46422. export class TorusBuilder {
  46423. /**
  46424. * Creates a torus mesh
  46425. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  46426. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  46427. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  46428. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46429. * * 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
  46430. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46431. * @param name defines the name of the mesh
  46432. * @param options defines the options used to create the mesh
  46433. * @param scene defines the hosting scene
  46434. * @returns the torus mesh
  46435. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  46436. */
  46437. static CreateTorus(name: string, options: {
  46438. diameter?: number;
  46439. thickness?: number;
  46440. tessellation?: number;
  46441. updatable?: boolean;
  46442. sideOrientation?: number;
  46443. frontUVs?: Vector4;
  46444. backUVs?: Vector4;
  46445. }, scene: any): Mesh;
  46446. }
  46447. }
  46448. declare module BABYLON {
  46449. /**
  46450. * Class containing static functions to help procedurally build meshes
  46451. */
  46452. export class CylinderBuilder {
  46453. /**
  46454. * Creates a cylinder or a cone mesh
  46455. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  46456. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  46457. * * 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.
  46458. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  46459. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  46460. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  46461. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  46462. * * 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).
  46463. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  46464. * * 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).
  46465. * * 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
  46466. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  46467. * * 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
  46468. * * 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.
  46469. * * If `enclose` is false, a ring surface is one element.
  46470. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  46471. * * 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
  46472. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46473. * * 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
  46474. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46475. * @param name defines the name of the mesh
  46476. * @param options defines the options used to create the mesh
  46477. * @param scene defines the hosting scene
  46478. * @returns the cylinder mesh
  46479. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  46480. */
  46481. static CreateCylinder(name: string, options: {
  46482. height?: number;
  46483. diameterTop?: number;
  46484. diameterBottom?: number;
  46485. diameter?: number;
  46486. tessellation?: number;
  46487. subdivisions?: number;
  46488. arc?: number;
  46489. faceColors?: Color4[];
  46490. faceUV?: Vector4[];
  46491. updatable?: boolean;
  46492. hasRings?: boolean;
  46493. enclose?: boolean;
  46494. cap?: number;
  46495. sideOrientation?: number;
  46496. frontUVs?: Vector4;
  46497. backUVs?: Vector4;
  46498. }, scene: any): Mesh;
  46499. }
  46500. }
  46501. declare module BABYLON {
  46502. /**
  46503. * States of the webXR experience
  46504. */
  46505. export enum WebXRState {
  46506. /**
  46507. * Transitioning to being in XR mode
  46508. */
  46509. ENTERING_XR = 0,
  46510. /**
  46511. * Transitioning to non XR mode
  46512. */
  46513. EXITING_XR = 1,
  46514. /**
  46515. * In XR mode and presenting
  46516. */
  46517. IN_XR = 2,
  46518. /**
  46519. * Not entered XR mode
  46520. */
  46521. NOT_IN_XR = 3
  46522. }
  46523. /**
  46524. * Abstraction of the XR render target
  46525. */
  46526. export interface WebXRRenderTarget extends IDisposable {
  46527. /**
  46528. * xrpresent context of the canvas which can be used to display/mirror xr content
  46529. */
  46530. canvasContext: WebGLRenderingContext;
  46531. /**
  46532. * xr layer for the canvas
  46533. */
  46534. xrLayer: Nullable<XRWebGLLayer>;
  46535. /**
  46536. * Initializes the xr layer for the session
  46537. * @param xrSession xr session
  46538. * @returns a promise that will resolve once the XR Layer has been created
  46539. */
  46540. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46541. }
  46542. }
  46543. declare module BABYLON {
  46544. /**
  46545. * COnfiguration object for WebXR output canvas
  46546. */
  46547. export class WebXRManagedOutputCanvasOptions {
  46548. /**
  46549. * An optional canvas in case you wish to create it yourself and provide it here.
  46550. * If not provided, a new canvas will be created
  46551. */
  46552. canvasElement?: HTMLCanvasElement;
  46553. /**
  46554. * Options for this XR Layer output
  46555. */
  46556. canvasOptions?: XRWebGLLayerOptions;
  46557. /**
  46558. * CSS styling for a newly created canvas (if not provided)
  46559. */
  46560. newCanvasCssStyle?: string;
  46561. /**
  46562. * Get the default values of the configuration object
  46563. * @returns default values of this configuration object
  46564. */
  46565. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  46566. }
  46567. /**
  46568. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  46569. */
  46570. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  46571. private _options;
  46572. private _canvas;
  46573. private _engine;
  46574. private _originalCanvasSize;
  46575. /**
  46576. * Rendering context of the canvas which can be used to display/mirror xr content
  46577. */
  46578. canvasContext: WebGLRenderingContext;
  46579. /**
  46580. * xr layer for the canvas
  46581. */
  46582. xrLayer: Nullable<XRWebGLLayer>;
  46583. /**
  46584. * Obseervers registered here will be triggered when the xr layer was initialized
  46585. */
  46586. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  46587. /**
  46588. * Initializes the canvas to be added/removed upon entering/exiting xr
  46589. * @param _xrSessionManager The XR Session manager
  46590. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  46591. */
  46592. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  46593. /**
  46594. * Disposes of the object
  46595. */
  46596. dispose(): void;
  46597. /**
  46598. * Initializes the xr layer for the session
  46599. * @param xrSession xr session
  46600. * @returns a promise that will resolve once the XR Layer has been created
  46601. */
  46602. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46603. private _addCanvas;
  46604. private _removeCanvas;
  46605. private _setCanvasSize;
  46606. private _setManagedOutputCanvas;
  46607. }
  46608. }
  46609. declare module BABYLON {
  46610. /**
  46611. * Manages an XRSession to work with Babylon's engine
  46612. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  46613. */
  46614. export class WebXRSessionManager implements IDisposable {
  46615. /** The scene which the session should be created for */
  46616. scene: Scene;
  46617. private _referenceSpace;
  46618. private _rttProvider;
  46619. private _sessionEnded;
  46620. private _xrNavigator;
  46621. private baseLayer;
  46622. /**
  46623. * The base reference space from which the session started. good if you want to reset your
  46624. * reference space
  46625. */
  46626. baseReferenceSpace: XRReferenceSpace;
  46627. /**
  46628. * Current XR frame
  46629. */
  46630. currentFrame: Nullable<XRFrame>;
  46631. /** WebXR timestamp updated every frame */
  46632. currentTimestamp: number;
  46633. /**
  46634. * Used just in case of a failure to initialize an immersive session.
  46635. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  46636. */
  46637. defaultHeightCompensation: number;
  46638. /**
  46639. * Fires every time a new xrFrame arrives which can be used to update the camera
  46640. */
  46641. onXRFrameObservable: Observable<XRFrame>;
  46642. /**
  46643. * Fires when the reference space changed
  46644. */
  46645. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  46646. /**
  46647. * Fires when the xr session is ended either by the device or manually done
  46648. */
  46649. onXRSessionEnded: Observable<any>;
  46650. /**
  46651. * Fires when the xr session is ended either by the device or manually done
  46652. */
  46653. onXRSessionInit: Observable<XRSession>;
  46654. /**
  46655. * Underlying xr session
  46656. */
  46657. session: XRSession;
  46658. /**
  46659. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  46660. * or get the offset the player is currently at.
  46661. */
  46662. viewerReferenceSpace: XRReferenceSpace;
  46663. /**
  46664. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  46665. * @param scene The scene which the session should be created for
  46666. */
  46667. constructor(
  46668. /** The scene which the session should be created for */
  46669. scene: Scene);
  46670. /**
  46671. * The current reference space used in this session. This reference space can constantly change!
  46672. * It is mainly used to offset the camera's position.
  46673. */
  46674. get referenceSpace(): XRReferenceSpace;
  46675. /**
  46676. * Set a new reference space and triggers the observable
  46677. */
  46678. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  46679. /**
  46680. * Disposes of the session manager
  46681. */
  46682. dispose(): void;
  46683. /**
  46684. * Stops the xrSession and restores the render loop
  46685. * @returns Promise which resolves after it exits XR
  46686. */
  46687. exitXRAsync(): Promise<void>;
  46688. /**
  46689. * Gets the correct render target texture to be rendered this frame for this eye
  46690. * @param eye the eye for which to get the render target
  46691. * @returns the render target for the specified eye
  46692. */
  46693. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  46694. /**
  46695. * Creates a WebXRRenderTarget object for the XR session
  46696. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  46697. * @param options optional options to provide when creating a new render target
  46698. * @returns a WebXR render target to which the session can render
  46699. */
  46700. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  46701. /**
  46702. * Initializes the manager
  46703. * After initialization enterXR can be called to start an XR session
  46704. * @returns Promise which resolves after it is initialized
  46705. */
  46706. initializeAsync(): Promise<void>;
  46707. /**
  46708. * Initializes an xr session
  46709. * @param xrSessionMode mode to initialize
  46710. * @param xrSessionInit defines optional and required values to pass to the session builder
  46711. * @returns a promise which will resolve once the session has been initialized
  46712. */
  46713. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  46714. /**
  46715. * Checks if a session would be supported for the creation options specified
  46716. * @param sessionMode session mode to check if supported eg. immersive-vr
  46717. * @returns A Promise that resolves to true if supported and false if not
  46718. */
  46719. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46720. /**
  46721. * Resets the reference space to the one started the session
  46722. */
  46723. resetReferenceSpace(): void;
  46724. /**
  46725. * Starts rendering to the xr layer
  46726. */
  46727. runXRRenderLoop(): void;
  46728. /**
  46729. * Sets the reference space on the xr session
  46730. * @param referenceSpaceType space to set
  46731. * @returns a promise that will resolve once the reference space has been set
  46732. */
  46733. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  46734. /**
  46735. * Updates the render state of the session
  46736. * @param state state to set
  46737. * @returns a promise that resolves once the render state has been updated
  46738. */
  46739. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  46740. /**
  46741. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  46742. * @param sessionMode defines the session to test
  46743. * @returns a promise with boolean as final value
  46744. */
  46745. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46746. private _createRenderTargetTexture;
  46747. }
  46748. }
  46749. declare module BABYLON {
  46750. /**
  46751. * WebXR Camera which holds the views for the xrSession
  46752. * @see https://doc.babylonjs.com/how_to/webxr_camera
  46753. */
  46754. export class WebXRCamera extends FreeCamera {
  46755. private _xrSessionManager;
  46756. private _firstFrame;
  46757. private _referenceQuaternion;
  46758. private _referencedPosition;
  46759. private _xrInvPositionCache;
  46760. private _xrInvQuaternionCache;
  46761. /**
  46762. * Should position compensation execute on first frame.
  46763. * This is used when copying the position from a native (non XR) camera
  46764. */
  46765. compensateOnFirstFrame: boolean;
  46766. /**
  46767. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  46768. * @param name the name of the camera
  46769. * @param scene the scene to add the camera to
  46770. * @param _xrSessionManager a constructed xr session manager
  46771. */
  46772. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  46773. /**
  46774. * Return the user's height, unrelated to the current ground.
  46775. * This will be the y position of this camera, when ground level is 0.
  46776. */
  46777. get realWorldHeight(): number;
  46778. /** @hidden */
  46779. _updateForDualEyeDebugging(): void;
  46780. /**
  46781. * Sets this camera's transformation based on a non-vr camera
  46782. * @param otherCamera the non-vr camera to copy the transformation from
  46783. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  46784. */
  46785. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  46786. /**
  46787. * Gets the current instance class name ("WebXRCamera").
  46788. * @returns the class name
  46789. */
  46790. getClassName(): string;
  46791. private _rotate180;
  46792. private _updateFromXRSession;
  46793. private _updateNumberOfRigCameras;
  46794. private _updateReferenceSpace;
  46795. private _updateReferenceSpaceOffset;
  46796. }
  46797. }
  46798. declare module BABYLON {
  46799. /**
  46800. * Defining the interface required for a (webxr) feature
  46801. */
  46802. export interface IWebXRFeature extends IDisposable {
  46803. /**
  46804. * Is this feature attached
  46805. */
  46806. attached: boolean;
  46807. /**
  46808. * Should auto-attach be disabled?
  46809. */
  46810. disableAutoAttach: boolean;
  46811. /**
  46812. * Attach the feature to the session
  46813. * Will usually be called by the features manager
  46814. *
  46815. * @param force should attachment be forced (even when already attached)
  46816. * @returns true if successful.
  46817. */
  46818. attach(force?: boolean): boolean;
  46819. /**
  46820. * Detach the feature from the session
  46821. * Will usually be called by the features manager
  46822. *
  46823. * @returns true if successful.
  46824. */
  46825. detach(): boolean;
  46826. }
  46827. /**
  46828. * A list of the currently available features without referencing them
  46829. */
  46830. export class WebXRFeatureName {
  46831. /**
  46832. * The name of the anchor system feature
  46833. */
  46834. static ANCHOR_SYSTEM: string;
  46835. /**
  46836. * The name of the background remover feature
  46837. */
  46838. static BACKGROUND_REMOVER: string;
  46839. /**
  46840. * The name of the hit test feature
  46841. */
  46842. static HIT_TEST: string;
  46843. /**
  46844. * physics impostors for xr controllers feature
  46845. */
  46846. static PHYSICS_CONTROLLERS: string;
  46847. /**
  46848. * The name of the plane detection feature
  46849. */
  46850. static PLANE_DETECTION: string;
  46851. /**
  46852. * The name of the pointer selection feature
  46853. */
  46854. static POINTER_SELECTION: string;
  46855. /**
  46856. * The name of the teleportation feature
  46857. */
  46858. static TELEPORTATION: string;
  46859. }
  46860. /**
  46861. * Defining the constructor of a feature. Used to register the modules.
  46862. */
  46863. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  46864. /**
  46865. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  46866. * It is mainly used in AR sessions.
  46867. *
  46868. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  46869. */
  46870. export class WebXRFeaturesManager implements IDisposable {
  46871. private _xrSessionManager;
  46872. private static readonly _AvailableFeatures;
  46873. private _features;
  46874. /**
  46875. * constructs a new features manages.
  46876. *
  46877. * @param _xrSessionManager an instance of WebXRSessionManager
  46878. */
  46879. constructor(_xrSessionManager: WebXRSessionManager);
  46880. /**
  46881. * Used to register a module. After calling this function a developer can use this feature in the scene.
  46882. * Mainly used internally.
  46883. *
  46884. * @param featureName the name of the feature to register
  46885. * @param constructorFunction the function used to construct the module
  46886. * @param version the (babylon) version of the module
  46887. * @param stable is that a stable version of this module
  46888. */
  46889. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  46890. /**
  46891. * Returns a constructor of a specific feature.
  46892. *
  46893. * @param featureName the name of the feature to construct
  46894. * @param version the version of the feature to load
  46895. * @param xrSessionManager the xrSessionManager. Used to construct the module
  46896. * @param options optional options provided to the module.
  46897. * @returns a function that, when called, will return a new instance of this feature
  46898. */
  46899. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  46900. /**
  46901. * Can be used to return the list of features currently registered
  46902. *
  46903. * @returns an Array of available features
  46904. */
  46905. static GetAvailableFeatures(): string[];
  46906. /**
  46907. * Gets the versions available for a specific feature
  46908. * @param featureName the name of the feature
  46909. * @returns an array with the available versions
  46910. */
  46911. static GetAvailableVersions(featureName: string): string[];
  46912. /**
  46913. * Return the latest unstable version of this feature
  46914. * @param featureName the name of the feature to search
  46915. * @returns the version number. if not found will return -1
  46916. */
  46917. static GetLatestVersionOfFeature(featureName: string): number;
  46918. /**
  46919. * Return the latest stable version of this feature
  46920. * @param featureName the name of the feature to search
  46921. * @returns the version number. if not found will return -1
  46922. */
  46923. static GetStableVersionOfFeature(featureName: string): number;
  46924. /**
  46925. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  46926. * Can be used during a session to start a feature
  46927. * @param featureName the name of feature to attach
  46928. */
  46929. attachFeature(featureName: string): void;
  46930. /**
  46931. * Can be used inside a session or when the session ends to detach a specific feature
  46932. * @param featureName the name of the feature to detach
  46933. */
  46934. detachFeature(featureName: string): void;
  46935. /**
  46936. * Used to disable an already-enabled feature
  46937. * The feature will be disposed and will be recreated once enabled.
  46938. * @param featureName the feature to disable
  46939. * @returns true if disable was successful
  46940. */
  46941. disableFeature(featureName: string | {
  46942. Name: string;
  46943. }): boolean;
  46944. /**
  46945. * dispose this features manager
  46946. */
  46947. dispose(): void;
  46948. /**
  46949. * 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.
  46950. * 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.
  46951. *
  46952. * @param featureName the name of the feature to load or the class of the feature
  46953. * @param version optional version to load. if not provided the latest version will be enabled
  46954. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  46955. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  46956. * @returns a new constructed feature or throws an error if feature not found.
  46957. */
  46958. enableFeature(featureName: string | {
  46959. Name: string;
  46960. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  46961. /**
  46962. * get the implementation of an enabled feature.
  46963. * @param featureName the name of the feature to load
  46964. * @returns the feature class, if found
  46965. */
  46966. getEnabledFeature(featureName: string): IWebXRFeature;
  46967. /**
  46968. * Get the list of enabled features
  46969. * @returns an array of enabled features
  46970. */
  46971. getEnabledFeatures(): string[];
  46972. }
  46973. }
  46974. declare module BABYLON {
  46975. /**
  46976. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  46977. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  46978. */
  46979. export class WebXRExperienceHelper implements IDisposable {
  46980. private scene;
  46981. private _nonVRCamera;
  46982. private _originalSceneAutoClear;
  46983. private _supported;
  46984. /**
  46985. * Camera used to render xr content
  46986. */
  46987. camera: WebXRCamera;
  46988. /** A features manager for this xr session */
  46989. featuresManager: WebXRFeaturesManager;
  46990. /**
  46991. * Observers registered here will be triggered after the camera's initial transformation is set
  46992. * This can be used to set a different ground level or an extra rotation.
  46993. *
  46994. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  46995. * to the position set after this observable is done executing.
  46996. */
  46997. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  46998. /**
  46999. * Fires when the state of the experience helper has changed
  47000. */
  47001. onStateChangedObservable: Observable<WebXRState>;
  47002. /** Session manager used to keep track of xr session */
  47003. sessionManager: WebXRSessionManager;
  47004. /**
  47005. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  47006. */
  47007. state: WebXRState;
  47008. /**
  47009. * Creates a WebXRExperienceHelper
  47010. * @param scene The scene the helper should be created in
  47011. */
  47012. private constructor();
  47013. /**
  47014. * Creates the experience helper
  47015. * @param scene the scene to attach the experience helper to
  47016. * @returns a promise for the experience helper
  47017. */
  47018. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  47019. /**
  47020. * Disposes of the experience helper
  47021. */
  47022. dispose(): void;
  47023. /**
  47024. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  47025. * @param sessionMode options for the XR session
  47026. * @param referenceSpaceType frame of reference of the XR session
  47027. * @param renderTarget the output canvas that will be used to enter XR mode
  47028. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  47029. * @returns promise that resolves after xr mode has entered
  47030. */
  47031. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  47032. /**
  47033. * Exits XR mode and returns the scene to its original state
  47034. * @returns promise that resolves after xr mode has exited
  47035. */
  47036. exitXRAsync(): Promise<void>;
  47037. private _nonXRToXRCamera;
  47038. private _setState;
  47039. }
  47040. }
  47041. declare module BABYLON {
  47042. /**
  47043. * X-Y values for axes in WebXR
  47044. */
  47045. export interface IWebXRMotionControllerAxesValue {
  47046. /**
  47047. * The value of the x axis
  47048. */
  47049. x: number;
  47050. /**
  47051. * The value of the y-axis
  47052. */
  47053. y: number;
  47054. }
  47055. /**
  47056. * changed / previous values for the values of this component
  47057. */
  47058. export interface IWebXRMotionControllerComponentChangesValues<T> {
  47059. /**
  47060. * current (this frame) value
  47061. */
  47062. current: T;
  47063. /**
  47064. * previous (last change) value
  47065. */
  47066. previous: T;
  47067. }
  47068. /**
  47069. * Represents changes in the component between current frame and last values recorded
  47070. */
  47071. export interface IWebXRMotionControllerComponentChanges {
  47072. /**
  47073. * will be populated with previous and current values if axes changed
  47074. */
  47075. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  47076. /**
  47077. * will be populated with previous and current values if pressed changed
  47078. */
  47079. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47080. /**
  47081. * will be populated with previous and current values if touched changed
  47082. */
  47083. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47084. /**
  47085. * will be populated with previous and current values if value changed
  47086. */
  47087. value?: IWebXRMotionControllerComponentChangesValues<number>;
  47088. }
  47089. /**
  47090. * This class represents a single component (for example button or thumbstick) of a motion controller
  47091. */
  47092. export class WebXRControllerComponent implements IDisposable {
  47093. /**
  47094. * the id of this component
  47095. */
  47096. id: string;
  47097. /**
  47098. * the type of the component
  47099. */
  47100. type: MotionControllerComponentType;
  47101. private _buttonIndex;
  47102. private _axesIndices;
  47103. private _axes;
  47104. private _changes;
  47105. private _currentValue;
  47106. private _hasChanges;
  47107. private _pressed;
  47108. private _touched;
  47109. /**
  47110. * button component type
  47111. */
  47112. static BUTTON_TYPE: MotionControllerComponentType;
  47113. /**
  47114. * squeeze component type
  47115. */
  47116. static SQUEEZE_TYPE: MotionControllerComponentType;
  47117. /**
  47118. * Thumbstick component type
  47119. */
  47120. static THUMBSTICK_TYPE: MotionControllerComponentType;
  47121. /**
  47122. * Touchpad component type
  47123. */
  47124. static TOUCHPAD_TYPE: MotionControllerComponentType;
  47125. /**
  47126. * trigger component type
  47127. */
  47128. static TRIGGER_TYPE: MotionControllerComponentType;
  47129. /**
  47130. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  47131. * the axes data changes
  47132. */
  47133. onAxisValueChangedObservable: Observable<{
  47134. x: number;
  47135. y: number;
  47136. }>;
  47137. /**
  47138. * Observers registered here will be triggered when the state of a button changes
  47139. * State change is either pressed / touched / value
  47140. */
  47141. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  47142. /**
  47143. * Creates a new component for a motion controller.
  47144. * It is created by the motion controller itself
  47145. *
  47146. * @param id the id of this component
  47147. * @param type the type of the component
  47148. * @param _buttonIndex index in the buttons array of the gamepad
  47149. * @param _axesIndices indices of the values in the axes array of the gamepad
  47150. */
  47151. constructor(
  47152. /**
  47153. * the id of this component
  47154. */
  47155. id: string,
  47156. /**
  47157. * the type of the component
  47158. */
  47159. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  47160. /**
  47161. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  47162. */
  47163. get axes(): IWebXRMotionControllerAxesValue;
  47164. /**
  47165. * Get the changes. Elements will be populated only if they changed with their previous and current value
  47166. */
  47167. get changes(): IWebXRMotionControllerComponentChanges;
  47168. /**
  47169. * Return whether or not the component changed the last frame
  47170. */
  47171. get hasChanges(): boolean;
  47172. /**
  47173. * is the button currently pressed
  47174. */
  47175. get pressed(): boolean;
  47176. /**
  47177. * is the button currently touched
  47178. */
  47179. get touched(): boolean;
  47180. /**
  47181. * Get the current value of this component
  47182. */
  47183. get value(): number;
  47184. /**
  47185. * Dispose this component
  47186. */
  47187. dispose(): void;
  47188. /**
  47189. * Are there axes correlating to this component
  47190. * @return true is axes data is available
  47191. */
  47192. isAxes(): boolean;
  47193. /**
  47194. * Is this component a button (hence - pressable)
  47195. * @returns true if can be pressed
  47196. */
  47197. isButton(): boolean;
  47198. /**
  47199. * update this component using the gamepad object it is in. Called on every frame
  47200. * @param nativeController the native gamepad controller object
  47201. */
  47202. update(nativeController: IMinimalMotionControllerObject): void;
  47203. }
  47204. }
  47205. declare module BABYLON {
  47206. /**
  47207. * Interface used to represent data loading progression
  47208. */
  47209. export interface ISceneLoaderProgressEvent {
  47210. /**
  47211. * Defines if data length to load can be evaluated
  47212. */
  47213. readonly lengthComputable: boolean;
  47214. /**
  47215. * Defines the loaded data length
  47216. */
  47217. readonly loaded: number;
  47218. /**
  47219. * Defines the data length to load
  47220. */
  47221. readonly total: number;
  47222. }
  47223. /**
  47224. * Interface used by SceneLoader plugins to define supported file extensions
  47225. */
  47226. export interface ISceneLoaderPluginExtensions {
  47227. /**
  47228. * Defines the list of supported extensions
  47229. */
  47230. [extension: string]: {
  47231. isBinary: boolean;
  47232. };
  47233. }
  47234. /**
  47235. * Interface used by SceneLoader plugin factory
  47236. */
  47237. export interface ISceneLoaderPluginFactory {
  47238. /**
  47239. * Defines the name of the factory
  47240. */
  47241. name: string;
  47242. /**
  47243. * Function called to create a new plugin
  47244. * @return the new plugin
  47245. */
  47246. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  47247. /**
  47248. * The callback that returns true if the data can be directly loaded.
  47249. * @param data string containing the file data
  47250. * @returns if the data can be loaded directly
  47251. */
  47252. canDirectLoad?(data: string): boolean;
  47253. }
  47254. /**
  47255. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  47256. */
  47257. export interface ISceneLoaderPluginBase {
  47258. /**
  47259. * The friendly name of this plugin.
  47260. */
  47261. name: string;
  47262. /**
  47263. * The file extensions supported by this plugin.
  47264. */
  47265. extensions: string | ISceneLoaderPluginExtensions;
  47266. /**
  47267. * The callback called when loading from a url.
  47268. * @param scene scene loading this url
  47269. * @param url url to load
  47270. * @param onSuccess callback called when the file successfully loads
  47271. * @param onProgress callback called while file is loading (if the server supports this mode)
  47272. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  47273. * @param onError callback called when the file fails to load
  47274. * @returns a file request object
  47275. */
  47276. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47277. /**
  47278. * The callback called when loading from a file object.
  47279. * @param scene scene loading this file
  47280. * @param file defines the file to load
  47281. * @param onSuccess defines the callback to call when data is loaded
  47282. * @param onProgress defines the callback to call during loading process
  47283. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  47284. * @param onError defines the callback to call when an error occurs
  47285. * @returns a file request object
  47286. */
  47287. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47288. /**
  47289. * The callback that returns true if the data can be directly loaded.
  47290. * @param data string containing the file data
  47291. * @returns if the data can be loaded directly
  47292. */
  47293. canDirectLoad?(data: string): boolean;
  47294. /**
  47295. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  47296. * @param scene scene loading this data
  47297. * @param data string containing the data
  47298. * @returns data to pass to the plugin
  47299. */
  47300. directLoad?(scene: Scene, data: string): any;
  47301. /**
  47302. * The callback that allows custom handling of the root url based on the response url.
  47303. * @param rootUrl the original root url
  47304. * @param responseURL the response url if available
  47305. * @returns the new root url
  47306. */
  47307. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  47308. }
  47309. /**
  47310. * Interface used to define a SceneLoader plugin
  47311. */
  47312. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  47313. /**
  47314. * Import meshes into a scene.
  47315. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47316. * @param scene The scene to import into
  47317. * @param data The data to import
  47318. * @param rootUrl The root url for scene and resources
  47319. * @param meshes The meshes array to import into
  47320. * @param particleSystems The particle systems array to import into
  47321. * @param skeletons The skeletons array to import into
  47322. * @param onError The callback when import fails
  47323. * @returns True if successful or false otherwise
  47324. */
  47325. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  47326. /**
  47327. * Load into a scene.
  47328. * @param scene The scene to load into
  47329. * @param data The data to import
  47330. * @param rootUrl The root url for scene and resources
  47331. * @param onError The callback when import fails
  47332. * @returns True if successful or false otherwise
  47333. */
  47334. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  47335. /**
  47336. * Load into an asset container.
  47337. * @param scene The scene to load into
  47338. * @param data The data to import
  47339. * @param rootUrl The root url for scene and resources
  47340. * @param onError The callback when import fails
  47341. * @returns The loaded asset container
  47342. */
  47343. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  47344. }
  47345. /**
  47346. * Interface used to define an async SceneLoader plugin
  47347. */
  47348. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  47349. /**
  47350. * Import meshes into a scene.
  47351. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47352. * @param scene The scene to import into
  47353. * @param data The data to import
  47354. * @param rootUrl The root url for scene and resources
  47355. * @param onProgress The callback when the load progresses
  47356. * @param fileName Defines the name of the file to load
  47357. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  47358. */
  47359. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  47360. meshes: AbstractMesh[];
  47361. particleSystems: IParticleSystem[];
  47362. skeletons: Skeleton[];
  47363. animationGroups: AnimationGroup[];
  47364. }>;
  47365. /**
  47366. * Load into a scene.
  47367. * @param scene The scene to load into
  47368. * @param data The data to import
  47369. * @param rootUrl The root url for scene and resources
  47370. * @param onProgress The callback when the load progresses
  47371. * @param fileName Defines the name of the file to load
  47372. * @returns Nothing
  47373. */
  47374. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  47375. /**
  47376. * Load into an asset container.
  47377. * @param scene The scene to load into
  47378. * @param data The data to import
  47379. * @param rootUrl The root url for scene and resources
  47380. * @param onProgress The callback when the load progresses
  47381. * @param fileName Defines the name of the file to load
  47382. * @returns The loaded asset container
  47383. */
  47384. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  47385. }
  47386. /**
  47387. * Mode that determines how to handle old animation groups before loading new ones.
  47388. */
  47389. export enum SceneLoaderAnimationGroupLoadingMode {
  47390. /**
  47391. * Reset all old animations to initial state then dispose them.
  47392. */
  47393. Clean = 0,
  47394. /**
  47395. * Stop all old animations.
  47396. */
  47397. Stop = 1,
  47398. /**
  47399. * Restart old animations from first frame.
  47400. */
  47401. Sync = 2,
  47402. /**
  47403. * Old animations remains untouched.
  47404. */
  47405. NoSync = 3
  47406. }
  47407. /**
  47408. * Class used to load scene from various file formats using registered plugins
  47409. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  47410. */
  47411. export class SceneLoader {
  47412. /**
  47413. * No logging while loading
  47414. */
  47415. static readonly NO_LOGGING: number;
  47416. /**
  47417. * Minimal logging while loading
  47418. */
  47419. static readonly MINIMAL_LOGGING: number;
  47420. /**
  47421. * Summary logging while loading
  47422. */
  47423. static readonly SUMMARY_LOGGING: number;
  47424. /**
  47425. * Detailled logging while loading
  47426. */
  47427. static readonly DETAILED_LOGGING: number;
  47428. /**
  47429. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  47430. */
  47431. static get ForceFullSceneLoadingForIncremental(): boolean;
  47432. static set ForceFullSceneLoadingForIncremental(value: boolean);
  47433. /**
  47434. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  47435. */
  47436. static get ShowLoadingScreen(): boolean;
  47437. static set ShowLoadingScreen(value: boolean);
  47438. /**
  47439. * Defines the current logging level (while loading the scene)
  47440. * @ignorenaming
  47441. */
  47442. static get loggingLevel(): number;
  47443. static set loggingLevel(value: number);
  47444. /**
  47445. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  47446. */
  47447. static get CleanBoneMatrixWeights(): boolean;
  47448. static set CleanBoneMatrixWeights(value: boolean);
  47449. /**
  47450. * Event raised when a plugin is used to load a scene
  47451. */
  47452. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  47453. private static _registeredPlugins;
  47454. private static _showingLoadingScreen;
  47455. private static _getDefaultPlugin;
  47456. private static _getPluginForExtension;
  47457. private static _getPluginForDirectLoad;
  47458. private static _getPluginForFilename;
  47459. private static _getDirectLoad;
  47460. private static _loadData;
  47461. private static _getFileInfo;
  47462. /**
  47463. * Gets a plugin that can load the given extension
  47464. * @param extension defines the extension to load
  47465. * @returns a plugin or null if none works
  47466. */
  47467. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47468. /**
  47469. * Gets a boolean indicating that the given extension can be loaded
  47470. * @param extension defines the extension to load
  47471. * @returns true if the extension is supported
  47472. */
  47473. static IsPluginForExtensionAvailable(extension: string): boolean;
  47474. /**
  47475. * Adds a new plugin to the list of registered plugins
  47476. * @param plugin defines the plugin to add
  47477. */
  47478. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  47479. /**
  47480. * Import meshes into a scene
  47481. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47482. * @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)
  47483. * @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)
  47484. * @param scene the instance of BABYLON.Scene to append to
  47485. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  47486. * @param onProgress a callback with a progress event for each file being loaded
  47487. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47488. * @param pluginExtension the extension used to determine the plugin
  47489. * @returns The loaded plugin
  47490. */
  47491. 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>;
  47492. /**
  47493. * Import meshes into a scene
  47494. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47495. * @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)
  47496. * @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)
  47497. * @param scene the instance of BABYLON.Scene to append to
  47498. * @param onProgress a callback with a progress event for each file being loaded
  47499. * @param pluginExtension the extension used to determine the plugin
  47500. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  47501. */
  47502. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  47503. meshes: AbstractMesh[];
  47504. particleSystems: IParticleSystem[];
  47505. skeletons: Skeleton[];
  47506. animationGroups: AnimationGroup[];
  47507. }>;
  47508. /**
  47509. * Load a scene
  47510. * @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)
  47511. * @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)
  47512. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47513. * @param onSuccess a callback with the scene when import succeeds
  47514. * @param onProgress a callback with a progress event for each file being loaded
  47515. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47516. * @param pluginExtension the extension used to determine the plugin
  47517. * @returns The loaded plugin
  47518. */
  47519. 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>;
  47520. /**
  47521. * Load a scene
  47522. * @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)
  47523. * @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)
  47524. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47525. * @param onProgress a callback with a progress event for each file being loaded
  47526. * @param pluginExtension the extension used to determine the plugin
  47527. * @returns The loaded scene
  47528. */
  47529. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47530. /**
  47531. * Append a scene
  47532. * @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)
  47533. * @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)
  47534. * @param scene is the instance of BABYLON.Scene to append to
  47535. * @param onSuccess a callback with the scene when import succeeds
  47536. * @param onProgress a callback with a progress event for each file being loaded
  47537. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47538. * @param pluginExtension the extension used to determine the plugin
  47539. * @returns The loaded plugin
  47540. */
  47541. 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>;
  47542. /**
  47543. * Append a scene
  47544. * @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)
  47545. * @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)
  47546. * @param scene is the instance of BABYLON.Scene to append to
  47547. * @param onProgress a callback with a progress event for each file being loaded
  47548. * @param pluginExtension the extension used to determine the plugin
  47549. * @returns The given scene
  47550. */
  47551. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47552. /**
  47553. * Load a scene into an asset container
  47554. * @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)
  47555. * @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)
  47556. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47557. * @param onSuccess a callback with the scene when import succeeds
  47558. * @param onProgress a callback with a progress event for each file being loaded
  47559. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47560. * @param pluginExtension the extension used to determine the plugin
  47561. * @returns The loaded plugin
  47562. */
  47563. 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>;
  47564. /**
  47565. * Load a scene into an asset container
  47566. * @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)
  47567. * @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)
  47568. * @param scene is the instance of Scene to append to
  47569. * @param onProgress a callback with a progress event for each file being loaded
  47570. * @param pluginExtension the extension used to determine the plugin
  47571. * @returns The loaded asset container
  47572. */
  47573. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  47574. /**
  47575. * Import animations from a file into a scene
  47576. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  47577. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  47578. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47579. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47580. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47581. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47582. * @param onSuccess a callback with the scene when import succeeds
  47583. * @param onProgress a callback with a progress event for each file being loaded
  47584. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47585. * @param pluginExtension the extension used to determine the plugin
  47586. */
  47587. 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;
  47588. /**
  47589. * Import animations from a file into a scene
  47590. * @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)
  47591. * @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)
  47592. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47593. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47594. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47595. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47596. * @param onSuccess a callback with the scene when import succeeds
  47597. * @param onProgress a callback with a progress event for each file being loaded
  47598. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47599. * @param pluginExtension the extension used to determine the plugin
  47600. * @returns the updated scene with imported animations
  47601. */
  47602. 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>;
  47603. }
  47604. }
  47605. declare module BABYLON {
  47606. /**
  47607. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  47608. */
  47609. export type MotionControllerHandedness = "none" | "left" | "right";
  47610. /**
  47611. * The type of components available in motion controllers.
  47612. * This is not the name of the component.
  47613. */
  47614. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  47615. /**
  47616. * The state of a controller component
  47617. */
  47618. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  47619. /**
  47620. * The schema of motion controller layout.
  47621. * No object will be initialized using this interface
  47622. * This is used just to define the profile.
  47623. */
  47624. export interface IMotionControllerLayout {
  47625. /**
  47626. * Path to load the assets. Usually relative to the base path
  47627. */
  47628. assetPath: string;
  47629. /**
  47630. * Available components (unsorted)
  47631. */
  47632. components: {
  47633. /**
  47634. * A map of component Ids
  47635. */
  47636. [componentId: string]: {
  47637. /**
  47638. * The type of input the component outputs
  47639. */
  47640. type: MotionControllerComponentType;
  47641. /**
  47642. * The indices of this component in the gamepad object
  47643. */
  47644. gamepadIndices: {
  47645. /**
  47646. * Index of button
  47647. */
  47648. button?: number;
  47649. /**
  47650. * If available, index of x-axis
  47651. */
  47652. xAxis?: number;
  47653. /**
  47654. * If available, index of y-axis
  47655. */
  47656. yAxis?: number;
  47657. };
  47658. /**
  47659. * The mesh's root node name
  47660. */
  47661. rootNodeName: string;
  47662. /**
  47663. * Animation definitions for this model
  47664. */
  47665. visualResponses: {
  47666. [stateKey: string]: {
  47667. /**
  47668. * What property will be animated
  47669. */
  47670. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  47671. /**
  47672. * What states influence this visual response
  47673. */
  47674. states: MotionControllerComponentStateType[];
  47675. /**
  47676. * Type of animation - movement or visibility
  47677. */
  47678. valueNodeProperty: "transform" | "visibility";
  47679. /**
  47680. * Base node name to move. Its position will be calculated according to the min and max nodes
  47681. */
  47682. valueNodeName?: string;
  47683. /**
  47684. * Minimum movement node
  47685. */
  47686. minNodeName?: string;
  47687. /**
  47688. * Max movement node
  47689. */
  47690. maxNodeName?: string;
  47691. };
  47692. };
  47693. /**
  47694. * If touch enabled, what is the name of node to display user feedback
  47695. */
  47696. touchPointNodeName?: string;
  47697. };
  47698. };
  47699. /**
  47700. * Is it xr standard mapping or not
  47701. */
  47702. gamepadMapping: "" | "xr-standard";
  47703. /**
  47704. * Base root node of this entire model
  47705. */
  47706. rootNodeName: string;
  47707. /**
  47708. * Defines the main button component id
  47709. */
  47710. selectComponentId: string;
  47711. }
  47712. /**
  47713. * A definition for the layout map in the input profile
  47714. */
  47715. export interface IMotionControllerLayoutMap {
  47716. /**
  47717. * Layouts with handedness type as a key
  47718. */
  47719. [handedness: string]: IMotionControllerLayout;
  47720. }
  47721. /**
  47722. * The XR Input profile schema
  47723. * Profiles can be found here:
  47724. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  47725. */
  47726. export interface IMotionControllerProfile {
  47727. /**
  47728. * fallback profiles for this profileId
  47729. */
  47730. fallbackProfileIds: string[];
  47731. /**
  47732. * The layout map, with handedness as key
  47733. */
  47734. layouts: IMotionControllerLayoutMap;
  47735. /**
  47736. * The id of this profile
  47737. * correlates to the profile(s) in the xrInput.profiles array
  47738. */
  47739. profileId: string;
  47740. }
  47741. /**
  47742. * A helper-interface for the 3 meshes needed for controller button animation
  47743. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  47744. */
  47745. export interface IMotionControllerButtonMeshMap {
  47746. /**
  47747. * the mesh that defines the pressed value mesh position.
  47748. * This is used to find the max-position of this button
  47749. */
  47750. pressedMesh: AbstractMesh;
  47751. /**
  47752. * the mesh that defines the unpressed value mesh position.
  47753. * This is used to find the min (or initial) position of this button
  47754. */
  47755. unpressedMesh: AbstractMesh;
  47756. /**
  47757. * The mesh that will be changed when value changes
  47758. */
  47759. valueMesh: AbstractMesh;
  47760. }
  47761. /**
  47762. * A helper-interface for the 3 meshes needed for controller axis animation.
  47763. * This will be expanded when touchpad animations are fully supported
  47764. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  47765. */
  47766. export interface IMotionControllerMeshMap {
  47767. /**
  47768. * the mesh that defines the maximum value mesh position.
  47769. */
  47770. maxMesh?: AbstractMesh;
  47771. /**
  47772. * the mesh that defines the minimum value mesh position.
  47773. */
  47774. minMesh?: AbstractMesh;
  47775. /**
  47776. * The mesh that will be changed when axis value changes
  47777. */
  47778. valueMesh: AbstractMesh;
  47779. }
  47780. /**
  47781. * The elements needed for change-detection of the gamepad objects in motion controllers
  47782. */
  47783. export interface IMinimalMotionControllerObject {
  47784. /**
  47785. * Available axes of this controller
  47786. */
  47787. axes: number[];
  47788. /**
  47789. * An array of available buttons
  47790. */
  47791. buttons: Array<{
  47792. /**
  47793. * Value of the button/trigger
  47794. */
  47795. value: number;
  47796. /**
  47797. * If the button/trigger is currently touched
  47798. */
  47799. touched: boolean;
  47800. /**
  47801. * If the button/trigger is currently pressed
  47802. */
  47803. pressed: boolean;
  47804. }>;
  47805. /**
  47806. * EXPERIMENTAL haptic support.
  47807. */
  47808. hapticActuators?: Array<{
  47809. pulse: (value: number, duration: number) => Promise<boolean>;
  47810. }>;
  47811. }
  47812. /**
  47813. * An Abstract Motion controller
  47814. * This class receives an xrInput and a profile layout and uses those to initialize the components
  47815. * Each component has an observable to check for changes in value and state
  47816. */
  47817. export abstract class WebXRAbstractMotionController implements IDisposable {
  47818. protected scene: Scene;
  47819. protected layout: IMotionControllerLayout;
  47820. /**
  47821. * The gamepad object correlating to this controller
  47822. */
  47823. gamepadObject: IMinimalMotionControllerObject;
  47824. /**
  47825. * handedness (left/right/none) of this controller
  47826. */
  47827. handedness: MotionControllerHandedness;
  47828. private _initComponent;
  47829. private _modelReady;
  47830. /**
  47831. * A map of components (WebXRControllerComponent) in this motion controller
  47832. * Components have a ComponentType and can also have both button and axis definitions
  47833. */
  47834. readonly components: {
  47835. [id: string]: WebXRControllerComponent;
  47836. };
  47837. /**
  47838. * Disable the model's animation. Can be set at any time.
  47839. */
  47840. disableAnimation: boolean;
  47841. /**
  47842. * Observers registered here will be triggered when the model of this controller is done loading
  47843. */
  47844. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  47845. /**
  47846. * The profile id of this motion controller
  47847. */
  47848. abstract profileId: string;
  47849. /**
  47850. * The root mesh of the model. It is null if the model was not yet initialized
  47851. */
  47852. rootMesh: Nullable<AbstractMesh>;
  47853. /**
  47854. * constructs a new abstract motion controller
  47855. * @param scene the scene to which the model of the controller will be added
  47856. * @param layout The profile layout to load
  47857. * @param gamepadObject The gamepad object correlating to this controller
  47858. * @param handedness handedness (left/right/none) of this controller
  47859. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  47860. */
  47861. constructor(scene: Scene, layout: IMotionControllerLayout,
  47862. /**
  47863. * The gamepad object correlating to this controller
  47864. */
  47865. gamepadObject: IMinimalMotionControllerObject,
  47866. /**
  47867. * handedness (left/right/none) of this controller
  47868. */
  47869. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  47870. /**
  47871. * Dispose this controller, the model mesh and all its components
  47872. */
  47873. dispose(): void;
  47874. /**
  47875. * Returns all components of specific type
  47876. * @param type the type to search for
  47877. * @return an array of components with this type
  47878. */
  47879. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  47880. /**
  47881. * get a component based an its component id as defined in layout.components
  47882. * @param id the id of the component
  47883. * @returns the component correlates to the id or undefined if not found
  47884. */
  47885. getComponent(id: string): WebXRControllerComponent;
  47886. /**
  47887. * Get the list of components available in this motion controller
  47888. * @returns an array of strings correlating to available components
  47889. */
  47890. getComponentIds(): string[];
  47891. /**
  47892. * Get the first component of specific type
  47893. * @param type type of component to find
  47894. * @return a controller component or null if not found
  47895. */
  47896. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  47897. /**
  47898. * Get the main (Select) component of this controller as defined in the layout
  47899. * @returns the main component of this controller
  47900. */
  47901. getMainComponent(): WebXRControllerComponent;
  47902. /**
  47903. * Loads the model correlating to this controller
  47904. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  47905. * @returns A promise fulfilled with the result of the model loading
  47906. */
  47907. loadModel(): Promise<boolean>;
  47908. /**
  47909. * Update this model using the current XRFrame
  47910. * @param xrFrame the current xr frame to use and update the model
  47911. */
  47912. updateFromXRFrame(xrFrame: XRFrame): void;
  47913. /**
  47914. * Backwards compatibility due to a deeply-integrated typo
  47915. */
  47916. get handness(): XREye;
  47917. /**
  47918. * Pulse (vibrate) this controller
  47919. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  47920. * Consecutive calls to this function will cancel the last pulse call
  47921. *
  47922. * @param value the strength of the pulse in 0.0...1.0 range
  47923. * @param duration Duration of the pulse in milliseconds
  47924. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  47925. * @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
  47926. */
  47927. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  47928. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  47929. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  47930. /**
  47931. * Moves the axis on the controller mesh based on its current state
  47932. * @param axis the index of the axis
  47933. * @param axisValue the value of the axis which determines the meshes new position
  47934. * @hidden
  47935. */
  47936. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  47937. /**
  47938. * Update the model itself with the current frame data
  47939. * @param xrFrame the frame to use for updating the model mesh
  47940. */
  47941. protected updateModel(xrFrame: XRFrame): void;
  47942. /**
  47943. * Get the filename and path for this controller's model
  47944. * @returns a map of filename and path
  47945. */
  47946. protected abstract _getFilenameAndPath(): {
  47947. filename: string;
  47948. path: string;
  47949. };
  47950. /**
  47951. * This function is called before the mesh is loaded. It checks for loading constraints.
  47952. * For example, this function can check if the GLB loader is available
  47953. * If this function returns false, the generic controller will be loaded instead
  47954. * @returns Is the client ready to load the mesh
  47955. */
  47956. protected abstract _getModelLoadingConstraints(): boolean;
  47957. /**
  47958. * This function will be called after the model was successfully loaded and can be used
  47959. * for mesh transformations before it is available for the user
  47960. * @param meshes the loaded meshes
  47961. */
  47962. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  47963. /**
  47964. * Set the root mesh for this controller. Important for the WebXR controller class
  47965. * @param meshes the loaded meshes
  47966. */
  47967. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  47968. /**
  47969. * A function executed each frame that updates the mesh (if needed)
  47970. * @param xrFrame the current xrFrame
  47971. */
  47972. protected abstract _updateModel(xrFrame: XRFrame): void;
  47973. private _getGenericFilenameAndPath;
  47974. private _getGenericParentMesh;
  47975. }
  47976. }
  47977. declare module BABYLON {
  47978. /**
  47979. * A generic trigger-only motion controller for WebXR
  47980. */
  47981. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  47982. /**
  47983. * Static version of the profile id of this controller
  47984. */
  47985. static ProfileId: string;
  47986. profileId: string;
  47987. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  47988. protected _getFilenameAndPath(): {
  47989. filename: string;
  47990. path: string;
  47991. };
  47992. protected _getModelLoadingConstraints(): boolean;
  47993. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  47994. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47995. protected _updateModel(): void;
  47996. }
  47997. }
  47998. declare module BABYLON {
  47999. /**
  48000. * Class containing static functions to help procedurally build meshes
  48001. */
  48002. export class SphereBuilder {
  48003. /**
  48004. * Creates a sphere mesh
  48005. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  48006. * * 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`)
  48007. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  48008. * * 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
  48009. * * 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)
  48010. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48011. * * 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
  48012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48013. * @param name defines the name of the mesh
  48014. * @param options defines the options used to create the mesh
  48015. * @param scene defines the hosting scene
  48016. * @returns the sphere mesh
  48017. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  48018. */
  48019. static CreateSphere(name: string, options: {
  48020. segments?: number;
  48021. diameter?: number;
  48022. diameterX?: number;
  48023. diameterY?: number;
  48024. diameterZ?: number;
  48025. arc?: number;
  48026. slice?: number;
  48027. sideOrientation?: number;
  48028. frontUVs?: Vector4;
  48029. backUVs?: Vector4;
  48030. updatable?: boolean;
  48031. }, scene?: Nullable<Scene>): Mesh;
  48032. }
  48033. }
  48034. declare module BABYLON {
  48035. /**
  48036. * A profiled motion controller has its profile loaded from an online repository.
  48037. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  48038. */
  48039. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  48040. private _repositoryUrl;
  48041. private _buttonMeshMapping;
  48042. private _touchDots;
  48043. /**
  48044. * The profile ID of this controller. Will be populated when the controller initializes.
  48045. */
  48046. profileId: string;
  48047. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  48048. dispose(): void;
  48049. protected _getFilenameAndPath(): {
  48050. filename: string;
  48051. path: string;
  48052. };
  48053. protected _getModelLoadingConstraints(): boolean;
  48054. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  48055. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48056. protected _updateModel(_xrFrame: XRFrame): void;
  48057. }
  48058. }
  48059. declare module BABYLON {
  48060. /**
  48061. * A construction function type to create a new controller based on an xrInput object
  48062. */
  48063. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  48064. /**
  48065. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  48066. *
  48067. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  48068. * it should be replaced with auto-loaded controllers.
  48069. *
  48070. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  48071. */
  48072. export class WebXRMotionControllerManager {
  48073. private static _AvailableControllers;
  48074. private static _Fallbacks;
  48075. private static _ProfileLoadingPromises;
  48076. private static _ProfilesList;
  48077. /**
  48078. * The base URL of the online controller repository. Can be changed at any time.
  48079. */
  48080. static BaseRepositoryUrl: string;
  48081. /**
  48082. * Which repository gets priority - local or online
  48083. */
  48084. static PrioritizeOnlineRepository: boolean;
  48085. /**
  48086. * Use the online repository, or use only locally-defined controllers
  48087. */
  48088. static UseOnlineRepository: boolean;
  48089. /**
  48090. * Clear the cache used for profile loading and reload when requested again
  48091. */
  48092. static ClearProfilesCache(): void;
  48093. /**
  48094. * Register the default fallbacks.
  48095. * This function is called automatically when this file is imported.
  48096. */
  48097. static DefaultFallbacks(): void;
  48098. /**
  48099. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  48100. * @param profileId the profile to which a fallback needs to be found
  48101. * @return an array with corresponding fallback profiles
  48102. */
  48103. static FindFallbackWithProfileId(profileId: string): string[];
  48104. /**
  48105. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  48106. * The order of search:
  48107. *
  48108. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  48109. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  48110. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  48111. * 4) return the generic trigger controller if none were found
  48112. *
  48113. * @param xrInput the xrInput to which a new controller is initialized
  48114. * @param scene the scene to which the model will be added
  48115. * @param forceProfile force a certain profile for this controller
  48116. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  48117. */
  48118. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  48119. /**
  48120. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  48121. *
  48122. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  48123. *
  48124. * @param type the profile type to register
  48125. * @param constructFunction the function to be called when loading this profile
  48126. */
  48127. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  48128. /**
  48129. * Register a fallback to a specific profile.
  48130. * @param profileId the profileId that will receive the fallbacks
  48131. * @param fallbacks A list of fallback profiles
  48132. */
  48133. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  48134. /**
  48135. * Will update the list of profiles available in the repository
  48136. * @return a promise that resolves to a map of profiles available online
  48137. */
  48138. static UpdateProfilesList(): Promise<{
  48139. [profile: string]: string;
  48140. }>;
  48141. private static _LoadProfileFromRepository;
  48142. private static _LoadProfilesFromAvailableControllers;
  48143. }
  48144. }
  48145. declare module BABYLON {
  48146. /**
  48147. * Configuration options for the WebXR controller creation
  48148. */
  48149. export interface IWebXRControllerOptions {
  48150. /**
  48151. * Should the controller mesh be animated when a user interacts with it
  48152. * The pressed buttons / thumbstick and touchpad animations will be disabled
  48153. */
  48154. disableMotionControllerAnimation?: boolean;
  48155. /**
  48156. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  48157. */
  48158. doNotLoadControllerMesh?: boolean;
  48159. /**
  48160. * Force a specific controller type for this controller.
  48161. * This can be used when creating your own profile or when testing different controllers
  48162. */
  48163. forceControllerProfile?: string;
  48164. /**
  48165. * Defines a rendering group ID for meshes that will be loaded.
  48166. * This is for the default controllers only.
  48167. */
  48168. renderingGroupId?: number;
  48169. }
  48170. /**
  48171. * Represents an XR controller
  48172. */
  48173. export class WebXRInputSource {
  48174. private _scene;
  48175. /** The underlying input source for the controller */
  48176. inputSource: XRInputSource;
  48177. private _options;
  48178. private _tmpVector;
  48179. private _uniqueId;
  48180. /**
  48181. * 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
  48182. */
  48183. grip?: AbstractMesh;
  48184. /**
  48185. * If available, this is the gamepad object related to this controller.
  48186. * Using this object it is possible to get click events and trackpad changes of the
  48187. * webxr controller that is currently being used.
  48188. */
  48189. motionController?: WebXRAbstractMotionController;
  48190. /**
  48191. * Event that fires when the controller is removed/disposed.
  48192. * The object provided as event data is this controller, after associated assets were disposed.
  48193. * uniqueId is still available.
  48194. */
  48195. onDisposeObservable: Observable<WebXRInputSource>;
  48196. /**
  48197. * Will be triggered when the mesh associated with the motion controller is done loading.
  48198. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  48199. * A shortened version of controller -> motion controller -> on mesh loaded.
  48200. */
  48201. onMeshLoadedObservable: Observable<AbstractMesh>;
  48202. /**
  48203. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  48204. */
  48205. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  48206. /**
  48207. * Pointer which can be used to select objects or attach a visible laser to
  48208. */
  48209. pointer: AbstractMesh;
  48210. /**
  48211. * Creates the input source object
  48212. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  48213. * @param _scene the scene which the controller should be associated to
  48214. * @param inputSource the underlying input source for the controller
  48215. * @param _options options for this controller creation
  48216. */
  48217. constructor(_scene: Scene,
  48218. /** The underlying input source for the controller */
  48219. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  48220. /**
  48221. * Get this controllers unique id
  48222. */
  48223. get uniqueId(): string;
  48224. /**
  48225. * Disposes of the object
  48226. */
  48227. dispose(): void;
  48228. /**
  48229. * Gets a world space ray coming from the pointer or grip
  48230. * @param result the resulting ray
  48231. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  48232. */
  48233. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  48234. /**
  48235. * Updates the controller pose based on the given XRFrame
  48236. * @param xrFrame xr frame to update the pose with
  48237. * @param referenceSpace reference space to use
  48238. */
  48239. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  48240. }
  48241. }
  48242. declare module BABYLON {
  48243. /**
  48244. * The schema for initialization options of the XR Input class
  48245. */
  48246. export interface IWebXRInputOptions {
  48247. /**
  48248. * If set to true no model will be automatically loaded
  48249. */
  48250. doNotLoadControllerMeshes?: boolean;
  48251. /**
  48252. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  48253. * If not found, the xr input profile data will be used.
  48254. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  48255. */
  48256. forceInputProfile?: string;
  48257. /**
  48258. * Do not send a request to the controller repository to load the profile.
  48259. *
  48260. * Instead, use the controllers available in babylon itself.
  48261. */
  48262. disableOnlineControllerRepository?: boolean;
  48263. /**
  48264. * A custom URL for the controllers repository
  48265. */
  48266. customControllersRepositoryURL?: string;
  48267. /**
  48268. * Should the controller model's components not move according to the user input
  48269. */
  48270. disableControllerAnimation?: boolean;
  48271. /**
  48272. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  48273. */
  48274. controllerOptions?: IWebXRControllerOptions;
  48275. }
  48276. /**
  48277. * XR input used to track XR inputs such as controllers/rays
  48278. */
  48279. export class WebXRInput implements IDisposable {
  48280. /**
  48281. * the xr session manager for this session
  48282. */
  48283. xrSessionManager: WebXRSessionManager;
  48284. /**
  48285. * the WebXR camera for this session. Mainly used for teleportation
  48286. */
  48287. xrCamera: WebXRCamera;
  48288. private readonly options;
  48289. /**
  48290. * XR controllers being tracked
  48291. */
  48292. controllers: Array<WebXRInputSource>;
  48293. private _frameObserver;
  48294. private _sessionEndedObserver;
  48295. private _sessionInitObserver;
  48296. /**
  48297. * Event when a controller has been connected/added
  48298. */
  48299. onControllerAddedObservable: Observable<WebXRInputSource>;
  48300. /**
  48301. * Event when a controller has been removed/disconnected
  48302. */
  48303. onControllerRemovedObservable: Observable<WebXRInputSource>;
  48304. /**
  48305. * Initializes the WebXRInput
  48306. * @param xrSessionManager the xr session manager for this session
  48307. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  48308. * @param options = initialization options for this xr input
  48309. */
  48310. constructor(
  48311. /**
  48312. * the xr session manager for this session
  48313. */
  48314. xrSessionManager: WebXRSessionManager,
  48315. /**
  48316. * the WebXR camera for this session. Mainly used for teleportation
  48317. */
  48318. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  48319. private _onInputSourcesChange;
  48320. private _addAndRemoveControllers;
  48321. /**
  48322. * Disposes of the object
  48323. */
  48324. dispose(): void;
  48325. }
  48326. }
  48327. declare module BABYLON {
  48328. /**
  48329. * This is the base class for all WebXR features.
  48330. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  48331. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  48332. */
  48333. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  48334. protected _xrSessionManager: WebXRSessionManager;
  48335. private _attached;
  48336. private _removeOnDetach;
  48337. /**
  48338. * Should auto-attach be disabled?
  48339. */
  48340. disableAutoAttach: boolean;
  48341. /**
  48342. * Construct a new (abstract) WebXR feature
  48343. * @param _xrSessionManager the xr session manager for this feature
  48344. */
  48345. constructor(_xrSessionManager: WebXRSessionManager);
  48346. /**
  48347. * Is this feature attached
  48348. */
  48349. get attached(): boolean;
  48350. /**
  48351. * attach this feature
  48352. *
  48353. * @param force should attachment be forced (even when already attached)
  48354. * @returns true if successful, false is failed or already attached
  48355. */
  48356. attach(force?: boolean): boolean;
  48357. /**
  48358. * detach this feature.
  48359. *
  48360. * @returns true if successful, false if failed or already detached
  48361. */
  48362. detach(): boolean;
  48363. /**
  48364. * Dispose this feature and all of the resources attached
  48365. */
  48366. dispose(): void;
  48367. /**
  48368. * This is used to register callbacks that will automatically be removed when detach is called.
  48369. * @param observable the observable to which the observer will be attached
  48370. * @param callback the callback to register
  48371. */
  48372. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  48373. /**
  48374. * Code in this function will be executed on each xrFrame received from the browser.
  48375. * This function will not execute after the feature is detached.
  48376. * @param _xrFrame the current frame
  48377. */
  48378. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  48379. }
  48380. }
  48381. declare module BABYLON {
  48382. /**
  48383. * Renders a layer on top of an existing scene
  48384. */
  48385. export class UtilityLayerRenderer implements IDisposable {
  48386. /** the original scene that will be rendered on top of */
  48387. originalScene: Scene;
  48388. private _pointerCaptures;
  48389. private _lastPointerEvents;
  48390. private static _DefaultUtilityLayer;
  48391. private static _DefaultKeepDepthUtilityLayer;
  48392. private _sharedGizmoLight;
  48393. private _renderCamera;
  48394. /**
  48395. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  48396. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  48397. * @returns the camera that is used when rendering the utility layer
  48398. */
  48399. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  48400. /**
  48401. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  48402. * @param cam the camera that should be used when rendering the utility layer
  48403. */
  48404. setRenderCamera(cam: Nullable<Camera>): void;
  48405. /**
  48406. * @hidden
  48407. * Light which used by gizmos to get light shading
  48408. */
  48409. _getSharedGizmoLight(): HemisphericLight;
  48410. /**
  48411. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  48412. */
  48413. pickUtilitySceneFirst: boolean;
  48414. /**
  48415. * 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)
  48416. */
  48417. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  48418. /**
  48419. * 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)
  48420. */
  48421. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  48422. /**
  48423. * The scene that is rendered on top of the original scene
  48424. */
  48425. utilityLayerScene: Scene;
  48426. /**
  48427. * If the utility layer should automatically be rendered on top of existing scene
  48428. */
  48429. shouldRender: boolean;
  48430. /**
  48431. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  48432. */
  48433. onlyCheckPointerDownEvents: boolean;
  48434. /**
  48435. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  48436. */
  48437. processAllEvents: boolean;
  48438. /**
  48439. * Observable raised when the pointer move from the utility layer scene to the main scene
  48440. */
  48441. onPointerOutObservable: Observable<number>;
  48442. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  48443. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  48444. private _afterRenderObserver;
  48445. private _sceneDisposeObserver;
  48446. private _originalPointerObserver;
  48447. /**
  48448. * Instantiates a UtilityLayerRenderer
  48449. * @param originalScene the original scene that will be rendered on top of
  48450. * @param handleEvents boolean indicating if the utility layer should handle events
  48451. */
  48452. constructor(
  48453. /** the original scene that will be rendered on top of */
  48454. originalScene: Scene, handleEvents?: boolean);
  48455. private _notifyObservers;
  48456. /**
  48457. * Renders the utility layers scene on top of the original scene
  48458. */
  48459. render(): void;
  48460. /**
  48461. * Disposes of the renderer
  48462. */
  48463. dispose(): void;
  48464. private _updateCamera;
  48465. }
  48466. }
  48467. declare module BABYLON {
  48468. /**
  48469. * Options interface for the pointer selection module
  48470. */
  48471. export interface IWebXRControllerPointerSelectionOptions {
  48472. /**
  48473. * if provided, this scene will be used to render meshes.
  48474. */
  48475. customUtilityLayerScene?: Scene;
  48476. /**
  48477. * 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)
  48478. * If not disabled, the last picked point will be used to execute a pointer up event
  48479. * If disabled, pointer up event will be triggered right after the pointer down event.
  48480. * Used in screen and gaze target ray mode only
  48481. */
  48482. disablePointerUpOnTouchOut: boolean;
  48483. /**
  48484. * For gaze mode (time to select instead of press)
  48485. */
  48486. forceGazeMode: boolean;
  48487. /**
  48488. * 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
  48489. * to start a new countdown to the pointer down event.
  48490. * Defaults to 1.
  48491. */
  48492. gazeModePointerMovedFactor?: number;
  48493. /**
  48494. * Different button type to use instead of the main component
  48495. */
  48496. overrideButtonId?: string;
  48497. /**
  48498. * use this rendering group id for the meshes (optional)
  48499. */
  48500. renderingGroupId?: number;
  48501. /**
  48502. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  48503. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  48504. * 3000 means 3 seconds between pointing at something and selecting it
  48505. */
  48506. timeToSelect?: number;
  48507. /**
  48508. * Should meshes created here be added to a utility layer or the main scene
  48509. */
  48510. useUtilityLayer?: boolean;
  48511. /**
  48512. * the xr input to use with this pointer selection
  48513. */
  48514. xrInput: WebXRInput;
  48515. }
  48516. /**
  48517. * A module that will enable pointer selection for motion controllers of XR Input Sources
  48518. */
  48519. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  48520. private readonly _options;
  48521. private static _idCounter;
  48522. private _attachController;
  48523. private _controllers;
  48524. private _scene;
  48525. private _tmpVectorForPickCompare;
  48526. /**
  48527. * The module's name
  48528. */
  48529. static readonly Name: string;
  48530. /**
  48531. * The (Babylon) version of this module.
  48532. * This is an integer representing the implementation version.
  48533. * This number does not correspond to the WebXR specs version
  48534. */
  48535. static readonly Version: number;
  48536. /**
  48537. * Disable lighting on the laser pointer (so it will always be visible)
  48538. */
  48539. disablePointerLighting: boolean;
  48540. /**
  48541. * Disable lighting on the selection mesh (so it will always be visible)
  48542. */
  48543. disableSelectionMeshLighting: boolean;
  48544. /**
  48545. * Should the laser pointer be displayed
  48546. */
  48547. displayLaserPointer: boolean;
  48548. /**
  48549. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  48550. */
  48551. displaySelectionMesh: boolean;
  48552. /**
  48553. * This color will be set to the laser pointer when selection is triggered
  48554. */
  48555. laserPointerPickedColor: Color3;
  48556. /**
  48557. * Default color of the laser pointer
  48558. */
  48559. laserPointerDefaultColor: Color3;
  48560. /**
  48561. * default color of the selection ring
  48562. */
  48563. selectionMeshDefaultColor: Color3;
  48564. /**
  48565. * This color will be applied to the selection ring when selection is triggered
  48566. */
  48567. selectionMeshPickedColor: Color3;
  48568. /**
  48569. * Optional filter to be used for ray selection. This predicate shares behavior with
  48570. * scene.pointerMovePredicate which takes priority if it is also assigned.
  48571. */
  48572. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48573. /**
  48574. * constructs a new background remover module
  48575. * @param _xrSessionManager the session manager for this module
  48576. * @param _options read-only options to be used in this module
  48577. */
  48578. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  48579. /**
  48580. * attach this feature
  48581. * Will usually be called by the features manager
  48582. *
  48583. * @returns true if successful.
  48584. */
  48585. attach(): boolean;
  48586. /**
  48587. * detach this feature.
  48588. * Will usually be called by the features manager
  48589. *
  48590. * @returns true if successful.
  48591. */
  48592. detach(): boolean;
  48593. /**
  48594. * Will get the mesh under a specific pointer.
  48595. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  48596. * @param controllerId the controllerId to check
  48597. * @returns The mesh under pointer or null if no mesh is under the pointer
  48598. */
  48599. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  48600. /**
  48601. * Get the xr controller that correlates to the pointer id in the pointer event
  48602. *
  48603. * @param id the pointer id to search for
  48604. * @returns the controller that correlates to this id or null if not found
  48605. */
  48606. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  48607. protected _onXRFrame(_xrFrame: XRFrame): void;
  48608. private _attachGazeMode;
  48609. private _attachScreenRayMode;
  48610. private _attachTrackedPointerRayMode;
  48611. private _convertNormalToDirectionOfRay;
  48612. private _detachController;
  48613. private _generateNewMeshPair;
  48614. private _pickingMoved;
  48615. private _updatePointerDistance;
  48616. /** @hidden */
  48617. get lasterPointerDefaultColor(): Color3;
  48618. }
  48619. }
  48620. declare module BABYLON {
  48621. /**
  48622. * Button which can be used to enter a different mode of XR
  48623. */
  48624. export class WebXREnterExitUIButton {
  48625. /** button element */
  48626. element: HTMLElement;
  48627. /** XR initialization options for the button */
  48628. sessionMode: XRSessionMode;
  48629. /** Reference space type */
  48630. referenceSpaceType: XRReferenceSpaceType;
  48631. /**
  48632. * Creates a WebXREnterExitUIButton
  48633. * @param element button element
  48634. * @param sessionMode XR initialization session mode
  48635. * @param referenceSpaceType the type of reference space to be used
  48636. */
  48637. constructor(
  48638. /** button element */
  48639. element: HTMLElement,
  48640. /** XR initialization options for the button */
  48641. sessionMode: XRSessionMode,
  48642. /** Reference space type */
  48643. referenceSpaceType: XRReferenceSpaceType);
  48644. /**
  48645. * Extendable function which can be used to update the button's visuals when the state changes
  48646. * @param activeButton the current active button in the UI
  48647. */
  48648. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  48649. }
  48650. /**
  48651. * Options to create the webXR UI
  48652. */
  48653. export class WebXREnterExitUIOptions {
  48654. /**
  48655. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  48656. */
  48657. customButtons?: Array<WebXREnterExitUIButton>;
  48658. /**
  48659. * A reference space type to use when creating the default button.
  48660. * Default is local-floor
  48661. */
  48662. referenceSpaceType?: XRReferenceSpaceType;
  48663. /**
  48664. * Context to enter xr with
  48665. */
  48666. renderTarget?: Nullable<WebXRRenderTarget>;
  48667. /**
  48668. * A session mode to use when creating the default button.
  48669. * Default is immersive-vr
  48670. */
  48671. sessionMode?: XRSessionMode;
  48672. /**
  48673. * A list of optional features to init the session with
  48674. */
  48675. optionalFeatures?: string[];
  48676. /**
  48677. * A list of optional features to init the session with
  48678. */
  48679. requiredFeatures?: string[];
  48680. }
  48681. /**
  48682. * UI to allow the user to enter/exit XR mode
  48683. */
  48684. export class WebXREnterExitUI implements IDisposable {
  48685. private scene;
  48686. /** version of the options passed to this UI */
  48687. options: WebXREnterExitUIOptions;
  48688. private _activeButton;
  48689. private _buttons;
  48690. private _overlay;
  48691. /**
  48692. * Fired every time the active button is changed.
  48693. *
  48694. * When xr is entered via a button that launches xr that button will be the callback parameter
  48695. *
  48696. * When exiting xr the callback parameter will be null)
  48697. */
  48698. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  48699. /**
  48700. *
  48701. * @param scene babylon scene object to use
  48702. * @param options (read-only) version of the options passed to this UI
  48703. */
  48704. private constructor();
  48705. /**
  48706. * Creates UI to allow the user to enter/exit XR mode
  48707. * @param scene the scene to add the ui to
  48708. * @param helper the xr experience helper to enter/exit xr with
  48709. * @param options options to configure the UI
  48710. * @returns the created ui
  48711. */
  48712. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  48713. /**
  48714. * Disposes of the XR UI component
  48715. */
  48716. dispose(): void;
  48717. private _updateButtons;
  48718. }
  48719. }
  48720. declare module BABYLON {
  48721. /**
  48722. * Class containing static functions to help procedurally build meshes
  48723. */
  48724. export class LinesBuilder {
  48725. /**
  48726. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  48727. * * 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
  48728. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  48729. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  48730. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  48731. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  48732. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  48733. * * 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
  48734. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  48735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48736. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  48737. * @param name defines the name of the new line system
  48738. * @param options defines the options used to create the line system
  48739. * @param scene defines the hosting scene
  48740. * @returns a new line system mesh
  48741. */
  48742. static CreateLineSystem(name: string, options: {
  48743. lines: Vector3[][];
  48744. updatable?: boolean;
  48745. instance?: Nullable<LinesMesh>;
  48746. colors?: Nullable<Color4[][]>;
  48747. useVertexAlpha?: boolean;
  48748. }, scene: Nullable<Scene>): LinesMesh;
  48749. /**
  48750. * Creates a line mesh
  48751. * 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
  48752. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48753. * * The parameter `points` is an array successive Vector3
  48754. * * 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
  48755. * * The optional parameter `colors` is an array of successive Color4, one per line point
  48756. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  48757. * * When updating an instance, remember that only point positions can change, not the number of points
  48758. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48759. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  48760. * @param name defines the name of the new line system
  48761. * @param options defines the options used to create the line system
  48762. * @param scene defines the hosting scene
  48763. * @returns a new line mesh
  48764. */
  48765. static CreateLines(name: string, options: {
  48766. points: Vector3[];
  48767. updatable?: boolean;
  48768. instance?: Nullable<LinesMesh>;
  48769. colors?: Color4[];
  48770. useVertexAlpha?: boolean;
  48771. }, scene?: Nullable<Scene>): LinesMesh;
  48772. /**
  48773. * Creates a dashed line mesh
  48774. * * 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
  48775. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48776. * * The parameter `points` is an array successive Vector3
  48777. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  48778. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  48779. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  48780. * * 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
  48781. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  48782. * * When updating an instance, remember that only point positions can change, not the number of points
  48783. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48784. * @param name defines the name of the mesh
  48785. * @param options defines the options used to create the mesh
  48786. * @param scene defines the hosting scene
  48787. * @returns the dashed line mesh
  48788. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  48789. */
  48790. static CreateDashedLines(name: string, options: {
  48791. points: Vector3[];
  48792. dashSize?: number;
  48793. gapSize?: number;
  48794. dashNb?: number;
  48795. updatable?: boolean;
  48796. instance?: LinesMesh;
  48797. useVertexAlpha?: boolean;
  48798. }, scene?: Nullable<Scene>): LinesMesh;
  48799. }
  48800. }
  48801. declare module BABYLON {
  48802. /**
  48803. * Construction options for a timer
  48804. */
  48805. export interface ITimerOptions<T> {
  48806. /**
  48807. * Time-to-end
  48808. */
  48809. timeout: number;
  48810. /**
  48811. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  48812. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  48813. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  48814. */
  48815. contextObservable: Observable<T>;
  48816. /**
  48817. * Optional parameters when adding an observer to the observable
  48818. */
  48819. observableParameters?: {
  48820. mask?: number;
  48821. insertFirst?: boolean;
  48822. scope?: any;
  48823. };
  48824. /**
  48825. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  48826. */
  48827. breakCondition?: (data?: ITimerData<T>) => boolean;
  48828. /**
  48829. * Will be triggered when the time condition has met
  48830. */
  48831. onEnded?: (data: ITimerData<any>) => void;
  48832. /**
  48833. * Will be triggered when the break condition has met (prematurely ended)
  48834. */
  48835. onAborted?: (data: ITimerData<any>) => void;
  48836. /**
  48837. * Optional function to execute on each tick (or count)
  48838. */
  48839. onTick?: (data: ITimerData<any>) => void;
  48840. }
  48841. /**
  48842. * An interface defining the data sent by the timer
  48843. */
  48844. export interface ITimerData<T> {
  48845. /**
  48846. * When did it start
  48847. */
  48848. startTime: number;
  48849. /**
  48850. * Time now
  48851. */
  48852. currentTime: number;
  48853. /**
  48854. * Time passed since started
  48855. */
  48856. deltaTime: number;
  48857. /**
  48858. * How much is completed, in [0.0...1.0].
  48859. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  48860. */
  48861. completeRate: number;
  48862. /**
  48863. * What the registered observable sent in the last count
  48864. */
  48865. payload: T;
  48866. }
  48867. /**
  48868. * The current state of the timer
  48869. */
  48870. export enum TimerState {
  48871. /**
  48872. * Timer initialized, not yet started
  48873. */
  48874. INIT = 0,
  48875. /**
  48876. * Timer started and counting
  48877. */
  48878. STARTED = 1,
  48879. /**
  48880. * Timer ended (whether aborted or time reached)
  48881. */
  48882. ENDED = 2
  48883. }
  48884. /**
  48885. * A simple version of the timer. Will take options and start the timer immediately after calling it
  48886. *
  48887. * @param options options with which to initialize this timer
  48888. */
  48889. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  48890. /**
  48891. * An advanced implementation of a timer class
  48892. */
  48893. export class AdvancedTimer<T = any> implements IDisposable {
  48894. /**
  48895. * Will notify each time the timer calculates the remaining time
  48896. */
  48897. onEachCountObservable: Observable<ITimerData<T>>;
  48898. /**
  48899. * Will trigger when the timer was aborted due to the break condition
  48900. */
  48901. onTimerAbortedObservable: Observable<ITimerData<T>>;
  48902. /**
  48903. * Will trigger when the timer ended successfully
  48904. */
  48905. onTimerEndedObservable: Observable<ITimerData<T>>;
  48906. /**
  48907. * Will trigger when the timer state has changed
  48908. */
  48909. onStateChangedObservable: Observable<TimerState>;
  48910. private _observer;
  48911. private _contextObservable;
  48912. private _observableParameters;
  48913. private _startTime;
  48914. private _timer;
  48915. private _state;
  48916. private _breakCondition;
  48917. private _timeToEnd;
  48918. private _breakOnNextTick;
  48919. /**
  48920. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  48921. * @param options construction options for this advanced timer
  48922. */
  48923. constructor(options: ITimerOptions<T>);
  48924. /**
  48925. * set a breaking condition for this timer. Default is to never break during count
  48926. * @param predicate the new break condition. Returns true to break, false otherwise
  48927. */
  48928. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  48929. /**
  48930. * Reset ALL associated observables in this advanced timer
  48931. */
  48932. clearObservables(): void;
  48933. /**
  48934. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  48935. *
  48936. * @param timeToEnd how much time to measure until timer ended
  48937. */
  48938. start(timeToEnd?: number): void;
  48939. /**
  48940. * Will force a stop on the next tick.
  48941. */
  48942. stop(): void;
  48943. /**
  48944. * Dispose this timer, clearing all resources
  48945. */
  48946. dispose(): void;
  48947. private _setState;
  48948. private _tick;
  48949. private _stop;
  48950. }
  48951. }
  48952. declare module BABYLON {
  48953. /**
  48954. * The options container for the teleportation module
  48955. */
  48956. export interface IWebXRTeleportationOptions {
  48957. /**
  48958. * if provided, this scene will be used to render meshes.
  48959. */
  48960. customUtilityLayerScene?: Scene;
  48961. /**
  48962. * Values to configure the default target mesh
  48963. */
  48964. defaultTargetMeshOptions?: {
  48965. /**
  48966. * Fill color of the teleportation area
  48967. */
  48968. teleportationFillColor?: string;
  48969. /**
  48970. * Border color for the teleportation area
  48971. */
  48972. teleportationBorderColor?: string;
  48973. /**
  48974. * Disable the mesh's animation sequence
  48975. */
  48976. disableAnimation?: boolean;
  48977. /**
  48978. * Disable lighting on the material or the ring and arrow
  48979. */
  48980. disableLighting?: boolean;
  48981. /**
  48982. * Override the default material of the torus and arrow
  48983. */
  48984. torusArrowMaterial?: Material;
  48985. };
  48986. /**
  48987. * A list of meshes to use as floor meshes.
  48988. * Meshes can be added and removed after initializing the feature using the
  48989. * addFloorMesh and removeFloorMesh functions
  48990. * If empty, rotation will still work
  48991. */
  48992. floorMeshes?: AbstractMesh[];
  48993. /**
  48994. * use this rendering group id for the meshes (optional)
  48995. */
  48996. renderingGroupId?: number;
  48997. /**
  48998. * Should teleportation move only to snap points
  48999. */
  49000. snapPointsOnly?: boolean;
  49001. /**
  49002. * An array of points to which the teleportation will snap to.
  49003. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  49004. */
  49005. snapPositions?: Vector3[];
  49006. /**
  49007. * How close should the teleportation ray be in order to snap to position.
  49008. * Default to 0.8 units (meters)
  49009. */
  49010. snapToPositionRadius?: number;
  49011. /**
  49012. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  49013. * If you want to support rotation, make sure your mesh has a direction indicator.
  49014. *
  49015. * When left untouched, the default mesh will be initialized.
  49016. */
  49017. teleportationTargetMesh?: AbstractMesh;
  49018. /**
  49019. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  49020. */
  49021. timeToTeleport?: number;
  49022. /**
  49023. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  49024. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  49025. */
  49026. useMainComponentOnly?: boolean;
  49027. /**
  49028. * Should meshes created here be added to a utility layer or the main scene
  49029. */
  49030. useUtilityLayer?: boolean;
  49031. /**
  49032. * Babylon XR Input class for controller
  49033. */
  49034. xrInput: WebXRInput;
  49035. }
  49036. /**
  49037. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  49038. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  49039. * the input of the attached controllers.
  49040. */
  49041. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  49042. private _options;
  49043. private _controllers;
  49044. private _currentTeleportationControllerId;
  49045. private _floorMeshes;
  49046. private _quadraticBezierCurve;
  49047. private _selectionFeature;
  49048. private _snapToPositions;
  49049. private _snappedToPoint;
  49050. private _teleportationRingMaterial?;
  49051. private _tmpRay;
  49052. private _tmpVector;
  49053. /**
  49054. * The module's name
  49055. */
  49056. static readonly Name: string;
  49057. /**
  49058. * The (Babylon) version of this module.
  49059. * This is an integer representing the implementation version.
  49060. * This number does not correspond to the webxr specs version
  49061. */
  49062. static readonly Version: number;
  49063. /**
  49064. * Is movement backwards enabled
  49065. */
  49066. backwardsMovementEnabled: boolean;
  49067. /**
  49068. * Distance to travel when moving backwards
  49069. */
  49070. backwardsTeleportationDistance: number;
  49071. /**
  49072. * The distance from the user to the inspection point in the direction of the controller
  49073. * A higher number will allow the user to move further
  49074. * defaults to 5 (meters, in xr units)
  49075. */
  49076. parabolicCheckRadius: number;
  49077. /**
  49078. * Should the module support parabolic ray on top of direct ray
  49079. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  49080. * Very helpful when moving between floors / different heights
  49081. */
  49082. parabolicRayEnabled: boolean;
  49083. /**
  49084. * How much rotation should be applied when rotating right and left
  49085. */
  49086. rotationAngle: number;
  49087. /**
  49088. * Is rotation enabled when moving forward?
  49089. * Disabling this feature will prevent the user from deciding the direction when teleporting
  49090. */
  49091. rotationEnabled: boolean;
  49092. /**
  49093. * constructs a new anchor system
  49094. * @param _xrSessionManager an instance of WebXRSessionManager
  49095. * @param _options configuration object for this feature
  49096. */
  49097. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  49098. /**
  49099. * Get the snapPointsOnly flag
  49100. */
  49101. get snapPointsOnly(): boolean;
  49102. /**
  49103. * Sets the snapPointsOnly flag
  49104. * @param snapToPoints should teleportation be exclusively to snap points
  49105. */
  49106. set snapPointsOnly(snapToPoints: boolean);
  49107. /**
  49108. * Add a new mesh to the floor meshes array
  49109. * @param mesh the mesh to use as floor mesh
  49110. */
  49111. addFloorMesh(mesh: AbstractMesh): void;
  49112. /**
  49113. * Add a new snap-to point to fix teleportation to this position
  49114. * @param newSnapPoint The new Snap-To point
  49115. */
  49116. addSnapPoint(newSnapPoint: Vector3): void;
  49117. attach(): boolean;
  49118. detach(): boolean;
  49119. dispose(): void;
  49120. /**
  49121. * Remove a mesh from the floor meshes array
  49122. * @param mesh the mesh to remove
  49123. */
  49124. removeFloorMesh(mesh: AbstractMesh): void;
  49125. /**
  49126. * Remove a mesh from the floor meshes array using its name
  49127. * @param name the mesh name to remove
  49128. */
  49129. removeFloorMeshByName(name: string): void;
  49130. /**
  49131. * 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
  49132. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  49133. * @returns was the point found and removed or not
  49134. */
  49135. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  49136. /**
  49137. * This function sets a selection feature that will be disabled when
  49138. * the forward ray is shown and will be reattached when hidden.
  49139. * This is used to remove the selection rays when moving.
  49140. * @param selectionFeature the feature to disable when forward movement is enabled
  49141. */
  49142. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  49143. protected _onXRFrame(_xrFrame: XRFrame): void;
  49144. private _attachController;
  49145. private _createDefaultTargetMesh;
  49146. private _detachController;
  49147. private _findClosestSnapPointWithRadius;
  49148. private _setTargetMeshPosition;
  49149. private _setTargetMeshVisibility;
  49150. private _showParabolicPath;
  49151. private _teleportForward;
  49152. }
  49153. }
  49154. declare module BABYLON {
  49155. /**
  49156. * Options for the default xr helper
  49157. */
  49158. export class WebXRDefaultExperienceOptions {
  49159. /**
  49160. * Enable or disable default UI to enter XR
  49161. */
  49162. disableDefaultUI?: boolean;
  49163. /**
  49164. * Should teleportation not initialize. defaults to false.
  49165. */
  49166. disableTeleportation?: boolean;
  49167. /**
  49168. * Floor meshes that will be used for teleport
  49169. */
  49170. floorMeshes?: Array<AbstractMesh>;
  49171. /**
  49172. * If set to true, the first frame will not be used to reset position
  49173. * The first frame is mainly used when copying transformation from the old camera
  49174. * Mainly used in AR
  49175. */
  49176. ignoreNativeCameraTransformation?: boolean;
  49177. /**
  49178. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  49179. */
  49180. inputOptions?: IWebXRInputOptions;
  49181. /**
  49182. * optional configuration for the output canvas
  49183. */
  49184. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  49185. /**
  49186. * optional UI options. This can be used among other to change session mode and reference space type
  49187. */
  49188. uiOptions?: WebXREnterExitUIOptions;
  49189. /**
  49190. * When loading teleportation and pointer select, use stable versions instead of latest.
  49191. */
  49192. useStablePlugins?: boolean;
  49193. /**
  49194. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  49195. */
  49196. renderingGroupId?: number;
  49197. /**
  49198. * A list of optional features to init the session with
  49199. * If set to true, all features we support will be added
  49200. */
  49201. optionalFeatures?: boolean | string[];
  49202. }
  49203. /**
  49204. * Default experience which provides a similar setup to the previous webVRExperience
  49205. */
  49206. export class WebXRDefaultExperience {
  49207. /**
  49208. * Base experience
  49209. */
  49210. baseExperience: WebXRExperienceHelper;
  49211. /**
  49212. * Enables ui for entering/exiting xr
  49213. */
  49214. enterExitUI: WebXREnterExitUI;
  49215. /**
  49216. * Input experience extension
  49217. */
  49218. input: WebXRInput;
  49219. /**
  49220. * Enables laser pointer and selection
  49221. */
  49222. pointerSelection: WebXRControllerPointerSelection;
  49223. /**
  49224. * Default target xr should render to
  49225. */
  49226. renderTarget: WebXRRenderTarget;
  49227. /**
  49228. * Enables teleportation
  49229. */
  49230. teleportation: WebXRMotionControllerTeleportation;
  49231. private constructor();
  49232. /**
  49233. * Creates the default xr experience
  49234. * @param scene scene
  49235. * @param options options for basic configuration
  49236. * @returns resulting WebXRDefaultExperience
  49237. */
  49238. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49239. /**
  49240. * DIsposes of the experience helper
  49241. */
  49242. dispose(): void;
  49243. }
  49244. }
  49245. declare module BABYLON {
  49246. /**
  49247. * Options to modify the vr teleportation behavior.
  49248. */
  49249. export interface VRTeleportationOptions {
  49250. /**
  49251. * The name of the mesh which should be used as the teleportation floor. (default: null)
  49252. */
  49253. floorMeshName?: string;
  49254. /**
  49255. * A list of meshes to be used as the teleportation floor. (default: empty)
  49256. */
  49257. floorMeshes?: Mesh[];
  49258. /**
  49259. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  49260. */
  49261. teleportationMode?: number;
  49262. /**
  49263. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  49264. */
  49265. teleportationTime?: number;
  49266. /**
  49267. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  49268. */
  49269. teleportationSpeed?: number;
  49270. /**
  49271. * The easing function used in the animation or null for Linear. (default CircleEase)
  49272. */
  49273. easingFunction?: EasingFunction;
  49274. }
  49275. /**
  49276. * Options to modify the vr experience helper's behavior.
  49277. */
  49278. export interface VRExperienceHelperOptions extends WebVROptions {
  49279. /**
  49280. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  49281. */
  49282. createDeviceOrientationCamera?: boolean;
  49283. /**
  49284. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  49285. */
  49286. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  49287. /**
  49288. * Uses the main button on the controller to toggle the laser casted. (default: true)
  49289. */
  49290. laserToggle?: boolean;
  49291. /**
  49292. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  49293. */
  49294. floorMeshes?: Mesh[];
  49295. /**
  49296. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  49297. */
  49298. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  49299. /**
  49300. * Defines if WebXR should be used instead of WebVR (if available)
  49301. */
  49302. useXR?: boolean;
  49303. }
  49304. /**
  49305. * Event containing information after VR has been entered
  49306. */
  49307. export class OnAfterEnteringVRObservableEvent {
  49308. /**
  49309. * If entering vr was successful
  49310. */
  49311. success: boolean;
  49312. }
  49313. /**
  49314. * Helps to quickly add VR support to an existing scene.
  49315. * See https://doc.babylonjs.com/how_to/webvr_helper
  49316. */
  49317. export class VRExperienceHelper {
  49318. /** Options to modify the vr experience helper's behavior. */
  49319. webVROptions: VRExperienceHelperOptions;
  49320. private _scene;
  49321. private _position;
  49322. private _btnVR;
  49323. private _btnVRDisplayed;
  49324. private _webVRsupported;
  49325. private _webVRready;
  49326. private _webVRrequesting;
  49327. private _webVRpresenting;
  49328. private _hasEnteredVR;
  49329. private _fullscreenVRpresenting;
  49330. private _inputElement;
  49331. private _webVRCamera;
  49332. private _vrDeviceOrientationCamera;
  49333. private _deviceOrientationCamera;
  49334. private _existingCamera;
  49335. private _onKeyDown;
  49336. private _onVrDisplayPresentChange;
  49337. private _onVRDisplayChanged;
  49338. private _onVRRequestPresentStart;
  49339. private _onVRRequestPresentComplete;
  49340. /**
  49341. * 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)
  49342. */
  49343. enableGazeEvenWhenNoPointerLock: boolean;
  49344. /**
  49345. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  49346. */
  49347. exitVROnDoubleTap: boolean;
  49348. /**
  49349. * Observable raised right before entering VR.
  49350. */
  49351. onEnteringVRObservable: Observable<VRExperienceHelper>;
  49352. /**
  49353. * Observable raised when entering VR has completed.
  49354. */
  49355. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  49356. /**
  49357. * Observable raised when exiting VR.
  49358. */
  49359. onExitingVRObservable: Observable<VRExperienceHelper>;
  49360. /**
  49361. * Observable raised when controller mesh is loaded.
  49362. */
  49363. onControllerMeshLoadedObservable: Observable<WebVRController>;
  49364. /** Return this.onEnteringVRObservable
  49365. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  49366. */
  49367. get onEnteringVR(): Observable<VRExperienceHelper>;
  49368. /** Return this.onExitingVRObservable
  49369. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  49370. */
  49371. get onExitingVR(): Observable<VRExperienceHelper>;
  49372. /** Return this.onControllerMeshLoadedObservable
  49373. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  49374. */
  49375. get onControllerMeshLoaded(): Observable<WebVRController>;
  49376. private _rayLength;
  49377. private _useCustomVRButton;
  49378. private _teleportationRequested;
  49379. private _teleportActive;
  49380. private _floorMeshName;
  49381. private _floorMeshesCollection;
  49382. private _teleportationMode;
  49383. private _teleportationTime;
  49384. private _teleportationSpeed;
  49385. private _teleportationEasing;
  49386. private _rotationAllowed;
  49387. private _teleportBackwardsVector;
  49388. private _teleportationTarget;
  49389. private _isDefaultTeleportationTarget;
  49390. private _postProcessMove;
  49391. private _teleportationFillColor;
  49392. private _teleportationBorderColor;
  49393. private _rotationAngle;
  49394. private _haloCenter;
  49395. private _cameraGazer;
  49396. private _padSensibilityUp;
  49397. private _padSensibilityDown;
  49398. private _leftController;
  49399. private _rightController;
  49400. private _gazeColor;
  49401. private _laserColor;
  49402. private _pickedLaserColor;
  49403. private _pickedGazeColor;
  49404. /**
  49405. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  49406. */
  49407. onNewMeshSelected: Observable<AbstractMesh>;
  49408. /**
  49409. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  49410. * This observable will provide the mesh and the controller used to select the mesh
  49411. */
  49412. onMeshSelectedWithController: Observable<{
  49413. mesh: AbstractMesh;
  49414. controller: WebVRController;
  49415. }>;
  49416. /**
  49417. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  49418. */
  49419. onNewMeshPicked: Observable<PickingInfo>;
  49420. private _circleEase;
  49421. /**
  49422. * Observable raised before camera teleportation
  49423. */
  49424. onBeforeCameraTeleport: Observable<Vector3>;
  49425. /**
  49426. * Observable raised after camera teleportation
  49427. */
  49428. onAfterCameraTeleport: Observable<Vector3>;
  49429. /**
  49430. * Observable raised when current selected mesh gets unselected
  49431. */
  49432. onSelectedMeshUnselected: Observable<AbstractMesh>;
  49433. private _raySelectionPredicate;
  49434. /**
  49435. * To be optionaly changed by user to define custom ray selection
  49436. */
  49437. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49438. /**
  49439. * To be optionaly changed by user to define custom selection logic (after ray selection)
  49440. */
  49441. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49442. /**
  49443. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  49444. */
  49445. teleportationEnabled: boolean;
  49446. private _defaultHeight;
  49447. private _teleportationInitialized;
  49448. private _interactionsEnabled;
  49449. private _interactionsRequested;
  49450. private _displayGaze;
  49451. private _displayLaserPointer;
  49452. /**
  49453. * The mesh used to display where the user is going to teleport.
  49454. */
  49455. get teleportationTarget(): Mesh;
  49456. /**
  49457. * Sets the mesh to be used to display where the user is going to teleport.
  49458. */
  49459. set teleportationTarget(value: Mesh);
  49460. /**
  49461. * 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
  49462. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  49463. * See https://doc.babylonjs.com/resources/baking_transformations
  49464. */
  49465. get gazeTrackerMesh(): Mesh;
  49466. set gazeTrackerMesh(value: Mesh);
  49467. /**
  49468. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  49469. */
  49470. updateGazeTrackerScale: boolean;
  49471. /**
  49472. * If the gaze trackers color should be updated when selecting meshes
  49473. */
  49474. updateGazeTrackerColor: boolean;
  49475. /**
  49476. * If the controller laser color should be updated when selecting meshes
  49477. */
  49478. updateControllerLaserColor: boolean;
  49479. /**
  49480. * The gaze tracking mesh corresponding to the left controller
  49481. */
  49482. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  49483. /**
  49484. * The gaze tracking mesh corresponding to the right controller
  49485. */
  49486. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  49487. /**
  49488. * If the ray of the gaze should be displayed.
  49489. */
  49490. get displayGaze(): boolean;
  49491. /**
  49492. * Sets if the ray of the gaze should be displayed.
  49493. */
  49494. set displayGaze(value: boolean);
  49495. /**
  49496. * If the ray of the LaserPointer should be displayed.
  49497. */
  49498. get displayLaserPointer(): boolean;
  49499. /**
  49500. * Sets if the ray of the LaserPointer should be displayed.
  49501. */
  49502. set displayLaserPointer(value: boolean);
  49503. /**
  49504. * The deviceOrientationCamera used as the camera when not in VR.
  49505. */
  49506. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  49507. /**
  49508. * Based on the current WebVR support, returns the current VR camera used.
  49509. */
  49510. get currentVRCamera(): Nullable<Camera>;
  49511. /**
  49512. * The webVRCamera which is used when in VR.
  49513. */
  49514. get webVRCamera(): WebVRFreeCamera;
  49515. /**
  49516. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  49517. */
  49518. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  49519. /**
  49520. * The html button that is used to trigger entering into VR.
  49521. */
  49522. get vrButton(): Nullable<HTMLButtonElement>;
  49523. private get _teleportationRequestInitiated();
  49524. /**
  49525. * Defines whether or not Pointer lock should be requested when switching to
  49526. * full screen.
  49527. */
  49528. requestPointerLockOnFullScreen: boolean;
  49529. /**
  49530. * If asking to force XR, this will be populated with the default xr experience
  49531. */
  49532. xr: WebXRDefaultExperience;
  49533. /**
  49534. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  49535. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  49536. */
  49537. xrTestDone: boolean;
  49538. /**
  49539. * Instantiates a VRExperienceHelper.
  49540. * Helps to quickly add VR support to an existing scene.
  49541. * @param scene The scene the VRExperienceHelper belongs to.
  49542. * @param webVROptions Options to modify the vr experience helper's behavior.
  49543. */
  49544. constructor(scene: Scene,
  49545. /** Options to modify the vr experience helper's behavior. */
  49546. webVROptions?: VRExperienceHelperOptions);
  49547. private completeVRInit;
  49548. private _onDefaultMeshLoaded;
  49549. private _onResize;
  49550. private _onFullscreenChange;
  49551. /**
  49552. * Gets a value indicating if we are currently in VR mode.
  49553. */
  49554. get isInVRMode(): boolean;
  49555. private onVrDisplayPresentChange;
  49556. private onVRDisplayChanged;
  49557. private moveButtonToBottomRight;
  49558. private displayVRButton;
  49559. private updateButtonVisibility;
  49560. private _cachedAngularSensibility;
  49561. /**
  49562. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  49563. * Otherwise, will use the fullscreen API.
  49564. */
  49565. enterVR(): void;
  49566. /**
  49567. * Attempt to exit VR, or fullscreen.
  49568. */
  49569. exitVR(): void;
  49570. /**
  49571. * The position of the vr experience helper.
  49572. */
  49573. get position(): Vector3;
  49574. /**
  49575. * Sets the position of the vr experience helper.
  49576. */
  49577. set position(value: Vector3);
  49578. /**
  49579. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  49580. */
  49581. enableInteractions(): void;
  49582. private get _noControllerIsActive();
  49583. private beforeRender;
  49584. private _isTeleportationFloor;
  49585. /**
  49586. * Adds a floor mesh to be used for teleportation.
  49587. * @param floorMesh the mesh to be used for teleportation.
  49588. */
  49589. addFloorMesh(floorMesh: Mesh): void;
  49590. /**
  49591. * Removes a floor mesh from being used for teleportation.
  49592. * @param floorMesh the mesh to be removed.
  49593. */
  49594. removeFloorMesh(floorMesh: Mesh): void;
  49595. /**
  49596. * Enables interactions and teleportation using the VR controllers and gaze.
  49597. * @param vrTeleportationOptions options to modify teleportation behavior.
  49598. */
  49599. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  49600. private _onNewGamepadConnected;
  49601. private _tryEnableInteractionOnController;
  49602. private _onNewGamepadDisconnected;
  49603. private _enableInteractionOnController;
  49604. private _checkTeleportWithRay;
  49605. private _checkRotate;
  49606. private _checkTeleportBackwards;
  49607. private _enableTeleportationOnController;
  49608. private _createTeleportationCircles;
  49609. private _displayTeleportationTarget;
  49610. private _hideTeleportationTarget;
  49611. private _rotateCamera;
  49612. private _moveTeleportationSelectorTo;
  49613. private _workingVector;
  49614. private _workingQuaternion;
  49615. private _workingMatrix;
  49616. /**
  49617. * Time Constant Teleportation Mode
  49618. */
  49619. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  49620. /**
  49621. * Speed Constant Teleportation Mode
  49622. */
  49623. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  49624. /**
  49625. * Teleports the users feet to the desired location
  49626. * @param location The location where the user's feet should be placed
  49627. */
  49628. teleportCamera(location: Vector3): void;
  49629. private _convertNormalToDirectionOfRay;
  49630. private _castRayAndSelectObject;
  49631. private _notifySelectedMeshUnselected;
  49632. /**
  49633. * Permanently set new colors for the laser pointer
  49634. * @param color the new laser color
  49635. * @param pickedColor the new laser color when picked mesh detected
  49636. */
  49637. setLaserColor(color: Color3, pickedColor?: Color3): void;
  49638. /**
  49639. * Set lighting enabled / disabled on the laser pointer of both controllers
  49640. * @param enabled should the lighting be enabled on the laser pointer
  49641. */
  49642. setLaserLightingState(enabled?: boolean): void;
  49643. /**
  49644. * Permanently set new colors for the gaze pointer
  49645. * @param color the new gaze color
  49646. * @param pickedColor the new gaze color when picked mesh detected
  49647. */
  49648. setGazeColor(color: Color3, pickedColor?: Color3): void;
  49649. /**
  49650. * Sets the color of the laser ray from the vr controllers.
  49651. * @param color new color for the ray.
  49652. */
  49653. changeLaserColor(color: Color3): void;
  49654. /**
  49655. * Sets the color of the ray from the vr headsets gaze.
  49656. * @param color new color for the ray.
  49657. */
  49658. changeGazeColor(color: Color3): void;
  49659. /**
  49660. * Exits VR and disposes of the vr experience helper
  49661. */
  49662. dispose(): void;
  49663. /**
  49664. * Gets the name of the VRExperienceHelper class
  49665. * @returns "VRExperienceHelper"
  49666. */
  49667. getClassName(): string;
  49668. }
  49669. }
  49670. declare module BABYLON {
  49671. /**
  49672. * Contains an array of blocks representing the octree
  49673. */
  49674. export interface IOctreeContainer<T> {
  49675. /**
  49676. * Blocks within the octree
  49677. */
  49678. blocks: Array<OctreeBlock<T>>;
  49679. }
  49680. /**
  49681. * Class used to store a cell in an octree
  49682. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49683. */
  49684. export class OctreeBlock<T> {
  49685. /**
  49686. * Gets the content of the current block
  49687. */
  49688. entries: T[];
  49689. /**
  49690. * Gets the list of block children
  49691. */
  49692. blocks: Array<OctreeBlock<T>>;
  49693. private _depth;
  49694. private _maxDepth;
  49695. private _capacity;
  49696. private _minPoint;
  49697. private _maxPoint;
  49698. private _boundingVectors;
  49699. private _creationFunc;
  49700. /**
  49701. * Creates a new block
  49702. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  49703. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  49704. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49705. * @param depth defines the current depth of this block in the octree
  49706. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  49707. * @param creationFunc defines a callback to call when an element is added to the block
  49708. */
  49709. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  49710. /**
  49711. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49712. */
  49713. get capacity(): number;
  49714. /**
  49715. * Gets the minimum vector (in world space) of the block's bounding box
  49716. */
  49717. get minPoint(): Vector3;
  49718. /**
  49719. * Gets the maximum vector (in world space) of the block's bounding box
  49720. */
  49721. get maxPoint(): Vector3;
  49722. /**
  49723. * Add a new element to this block
  49724. * @param entry defines the element to add
  49725. */
  49726. addEntry(entry: T): void;
  49727. /**
  49728. * Remove an element from this block
  49729. * @param entry defines the element to remove
  49730. */
  49731. removeEntry(entry: T): void;
  49732. /**
  49733. * Add an array of elements to this block
  49734. * @param entries defines the array of elements to add
  49735. */
  49736. addEntries(entries: T[]): void;
  49737. /**
  49738. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  49739. * @param frustumPlanes defines the frustum planes to test
  49740. * @param selection defines the array to store current content if selection is positive
  49741. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49742. */
  49743. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  49744. /**
  49745. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  49746. * @param sphereCenter defines the bounding sphere center
  49747. * @param sphereRadius defines the bounding sphere radius
  49748. * @param selection defines the array to store current content if selection is positive
  49749. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49750. */
  49751. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  49752. /**
  49753. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  49754. * @param ray defines the ray to test with
  49755. * @param selection defines the array to store current content if selection is positive
  49756. */
  49757. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  49758. /**
  49759. * Subdivide the content into child blocks (this block will then be empty)
  49760. */
  49761. createInnerBlocks(): void;
  49762. /**
  49763. * @hidden
  49764. */
  49765. 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;
  49766. }
  49767. }
  49768. declare module BABYLON {
  49769. /**
  49770. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  49771. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49772. */
  49773. export class Octree<T> {
  49774. /** 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.) */
  49775. maxDepth: number;
  49776. /**
  49777. * Blocks within the octree containing objects
  49778. */
  49779. blocks: Array<OctreeBlock<T>>;
  49780. /**
  49781. * Content stored in the octree
  49782. */
  49783. dynamicContent: T[];
  49784. private _maxBlockCapacity;
  49785. private _selectionContent;
  49786. private _creationFunc;
  49787. /**
  49788. * Creates a octree
  49789. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49790. * @param creationFunc function to be used to instatiate the octree
  49791. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  49792. * @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.)
  49793. */
  49794. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  49795. /** 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.) */
  49796. maxDepth?: number);
  49797. /**
  49798. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  49799. * @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);
  49800. * @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);
  49801. * @param entries meshes to be added to the octree blocks
  49802. */
  49803. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  49804. /**
  49805. * Adds a mesh to the octree
  49806. * @param entry Mesh to add to the octree
  49807. */
  49808. addMesh(entry: T): void;
  49809. /**
  49810. * Remove an element from the octree
  49811. * @param entry defines the element to remove
  49812. */
  49813. removeMesh(entry: T): void;
  49814. /**
  49815. * Selects an array of meshes within the frustum
  49816. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  49817. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  49818. * @returns array of meshes within the frustum
  49819. */
  49820. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  49821. /**
  49822. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  49823. * @param sphereCenter defines the bounding sphere center
  49824. * @param sphereRadius defines the bounding sphere radius
  49825. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49826. * @returns an array of objects that intersect the sphere
  49827. */
  49828. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  49829. /**
  49830. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  49831. * @param ray defines the ray to test with
  49832. * @returns array of intersected objects
  49833. */
  49834. intersectsRay(ray: Ray): SmartArray<T>;
  49835. /**
  49836. * Adds a mesh into the octree block if it intersects the block
  49837. */
  49838. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  49839. /**
  49840. * Adds a submesh into the octree block if it intersects the block
  49841. */
  49842. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  49843. }
  49844. }
  49845. declare module BABYLON {
  49846. interface Scene {
  49847. /**
  49848. * @hidden
  49849. * Backing Filed
  49850. */
  49851. _selectionOctree: Octree<AbstractMesh>;
  49852. /**
  49853. * Gets the octree used to boost mesh selection (picking)
  49854. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49855. */
  49856. selectionOctree: Octree<AbstractMesh>;
  49857. /**
  49858. * Creates or updates the octree used to boost selection (picking)
  49859. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49860. * @param maxCapacity defines the maximum capacity per leaf
  49861. * @param maxDepth defines the maximum depth of the octree
  49862. * @returns an octree of AbstractMesh
  49863. */
  49864. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  49865. }
  49866. interface AbstractMesh {
  49867. /**
  49868. * @hidden
  49869. * Backing Field
  49870. */
  49871. _submeshesOctree: Octree<SubMesh>;
  49872. /**
  49873. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  49874. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  49875. * @param maxCapacity defines the maximum size of each block (64 by default)
  49876. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  49877. * @returns the new octree
  49878. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  49879. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49880. */
  49881. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  49882. }
  49883. /**
  49884. * Defines the octree scene component responsible to manage any octrees
  49885. * in a given scene.
  49886. */
  49887. export class OctreeSceneComponent {
  49888. /**
  49889. * The component name help to identify the component in the list of scene components.
  49890. */
  49891. readonly name: string;
  49892. /**
  49893. * The scene the component belongs to.
  49894. */
  49895. scene: Scene;
  49896. /**
  49897. * Indicates if the meshes have been checked to make sure they are isEnabled()
  49898. */
  49899. readonly checksIsEnabled: boolean;
  49900. /**
  49901. * Creates a new instance of the component for the given scene
  49902. * @param scene Defines the scene to register the component in
  49903. */
  49904. constructor(scene: Scene);
  49905. /**
  49906. * Registers the component in a given scene
  49907. */
  49908. register(): void;
  49909. /**
  49910. * Return the list of active meshes
  49911. * @returns the list of active meshes
  49912. */
  49913. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  49914. /**
  49915. * Return the list of active sub meshes
  49916. * @param mesh The mesh to get the candidates sub meshes from
  49917. * @returns the list of active sub meshes
  49918. */
  49919. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  49920. private _tempRay;
  49921. /**
  49922. * Return the list of sub meshes intersecting with a given local ray
  49923. * @param mesh defines the mesh to find the submesh for
  49924. * @param localRay defines the ray in local space
  49925. * @returns the list of intersecting sub meshes
  49926. */
  49927. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  49928. /**
  49929. * Return the list of sub meshes colliding with a collider
  49930. * @param mesh defines the mesh to find the submesh for
  49931. * @param collider defines the collider to evaluate the collision against
  49932. * @returns the list of colliding sub meshes
  49933. */
  49934. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  49935. /**
  49936. * Rebuilds the elements related to this component in case of
  49937. * context lost for instance.
  49938. */
  49939. rebuild(): void;
  49940. /**
  49941. * Disposes the component and the associated ressources.
  49942. */
  49943. dispose(): void;
  49944. }
  49945. }
  49946. declare module BABYLON {
  49947. /**
  49948. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  49949. */
  49950. export class Gizmo implements IDisposable {
  49951. /** The utility layer the gizmo will be added to */
  49952. gizmoLayer: UtilityLayerRenderer;
  49953. /**
  49954. * The root mesh of the gizmo
  49955. */
  49956. _rootMesh: Mesh;
  49957. private _attachedMesh;
  49958. private _attachedNode;
  49959. /**
  49960. * Ratio for the scale of the gizmo (Default: 1)
  49961. */
  49962. scaleRatio: number;
  49963. /**
  49964. * If a custom mesh has been set (Default: false)
  49965. */
  49966. protected _customMeshSet: boolean;
  49967. /**
  49968. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  49969. * * When set, interactions will be enabled
  49970. */
  49971. get attachedMesh(): Nullable<AbstractMesh>;
  49972. set attachedMesh(value: Nullable<AbstractMesh>);
  49973. /**
  49974. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  49975. * * When set, interactions will be enabled
  49976. */
  49977. get attachedNode(): Nullable<Node>;
  49978. set attachedNode(value: Nullable<Node>);
  49979. /**
  49980. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  49981. * @param mesh The mesh to replace the default mesh of the gizmo
  49982. */
  49983. setCustomMesh(mesh: Mesh): void;
  49984. /**
  49985. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  49986. */
  49987. updateGizmoRotationToMatchAttachedMesh: boolean;
  49988. /**
  49989. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  49990. */
  49991. updateGizmoPositionToMatchAttachedMesh: boolean;
  49992. /**
  49993. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  49994. */
  49995. updateScale: boolean;
  49996. protected _interactionsEnabled: boolean;
  49997. protected _attachedNodeChanged(value: Nullable<Node>): void;
  49998. private _beforeRenderObserver;
  49999. private _tempVector;
  50000. /**
  50001. * Creates a gizmo
  50002. * @param gizmoLayer The utility layer the gizmo will be added to
  50003. */
  50004. constructor(
  50005. /** The utility layer the gizmo will be added to */
  50006. gizmoLayer?: UtilityLayerRenderer);
  50007. /**
  50008. * Updates the gizmo to match the attached mesh's position/rotation
  50009. */
  50010. protected _update(): void;
  50011. /**
  50012. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  50013. * @param value Node, TransformNode or mesh
  50014. */
  50015. protected _matrixChanged(): void;
  50016. /**
  50017. * Disposes of the gizmo
  50018. */
  50019. dispose(): void;
  50020. }
  50021. }
  50022. declare module BABYLON {
  50023. /**
  50024. * Single plane drag gizmo
  50025. */
  50026. export class PlaneDragGizmo extends Gizmo {
  50027. /**
  50028. * Drag behavior responsible for the gizmos dragging interactions
  50029. */
  50030. dragBehavior: PointerDragBehavior;
  50031. private _pointerObserver;
  50032. /**
  50033. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50034. */
  50035. snapDistance: number;
  50036. /**
  50037. * Event that fires each time the gizmo snaps to a new location.
  50038. * * snapDistance is the the change in distance
  50039. */
  50040. onSnapObservable: Observable<{
  50041. snapDistance: number;
  50042. }>;
  50043. private _plane;
  50044. private _coloredMaterial;
  50045. private _hoverMaterial;
  50046. private _isEnabled;
  50047. private _parent;
  50048. /** @hidden */
  50049. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  50050. /** @hidden */
  50051. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50052. /**
  50053. * Creates a PlaneDragGizmo
  50054. * @param gizmoLayer The utility layer the gizmo will be added to
  50055. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  50056. * @param color The color of the gizmo
  50057. */
  50058. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  50059. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50060. /**
  50061. * If the gizmo is enabled
  50062. */
  50063. set isEnabled(value: boolean);
  50064. get isEnabled(): boolean;
  50065. /**
  50066. * Disposes of the gizmo
  50067. */
  50068. dispose(): void;
  50069. }
  50070. }
  50071. declare module BABYLON {
  50072. /**
  50073. * Gizmo that enables dragging a mesh along 3 axis
  50074. */
  50075. export class PositionGizmo extends Gizmo {
  50076. /**
  50077. * Internal gizmo used for interactions on the x axis
  50078. */
  50079. xGizmo: AxisDragGizmo;
  50080. /**
  50081. * Internal gizmo used for interactions on the y axis
  50082. */
  50083. yGizmo: AxisDragGizmo;
  50084. /**
  50085. * Internal gizmo used for interactions on the z axis
  50086. */
  50087. zGizmo: AxisDragGizmo;
  50088. /**
  50089. * Internal gizmo used for interactions on the yz plane
  50090. */
  50091. xPlaneGizmo: PlaneDragGizmo;
  50092. /**
  50093. * Internal gizmo used for interactions on the xz plane
  50094. */
  50095. yPlaneGizmo: PlaneDragGizmo;
  50096. /**
  50097. * Internal gizmo used for interactions on the xy plane
  50098. */
  50099. zPlaneGizmo: PlaneDragGizmo;
  50100. /**
  50101. * private variables
  50102. */
  50103. private _meshAttached;
  50104. private _nodeAttached;
  50105. private _updateGizmoRotationToMatchAttachedMesh;
  50106. private _snapDistance;
  50107. private _scaleRatio;
  50108. /** Fires an event when any of it's sub gizmos are dragged */
  50109. onDragStartObservable: Observable<unknown>;
  50110. /** Fires an event when any of it's sub gizmos are released from dragging */
  50111. onDragEndObservable: Observable<unknown>;
  50112. /**
  50113. * If set to true, planar drag is enabled
  50114. */
  50115. private _planarGizmoEnabled;
  50116. get attachedMesh(): Nullable<AbstractMesh>;
  50117. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50118. get attachedNode(): Nullable<Node>;
  50119. set attachedNode(node: Nullable<Node>);
  50120. /**
  50121. * Creates a PositionGizmo
  50122. * @param gizmoLayer The utility layer the gizmo will be added to
  50123. @param thickness display gizmo axis thickness
  50124. */
  50125. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  50126. /**
  50127. * If the planar drag gizmo is enabled
  50128. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  50129. */
  50130. set planarGizmoEnabled(value: boolean);
  50131. get planarGizmoEnabled(): boolean;
  50132. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50133. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50134. /**
  50135. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50136. */
  50137. set snapDistance(value: number);
  50138. get snapDistance(): number;
  50139. /**
  50140. * Ratio for the scale of the gizmo (Default: 1)
  50141. */
  50142. set scaleRatio(value: number);
  50143. get scaleRatio(): number;
  50144. /**
  50145. * Disposes of the gizmo
  50146. */
  50147. dispose(): void;
  50148. /**
  50149. * CustomMeshes are not supported by this gizmo
  50150. * @param mesh The mesh to replace the default mesh of the gizmo
  50151. */
  50152. setCustomMesh(mesh: Mesh): void;
  50153. }
  50154. }
  50155. declare module BABYLON {
  50156. /**
  50157. * Single axis drag gizmo
  50158. */
  50159. export class AxisDragGizmo extends Gizmo {
  50160. /**
  50161. * Drag behavior responsible for the gizmos dragging interactions
  50162. */
  50163. dragBehavior: PointerDragBehavior;
  50164. private _pointerObserver;
  50165. /**
  50166. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50167. */
  50168. snapDistance: number;
  50169. /**
  50170. * Event that fires each time the gizmo snaps to a new location.
  50171. * * snapDistance is the the change in distance
  50172. */
  50173. onSnapObservable: Observable<{
  50174. snapDistance: number;
  50175. }>;
  50176. private _isEnabled;
  50177. private _parent;
  50178. private _arrow;
  50179. private _coloredMaterial;
  50180. private _hoverMaterial;
  50181. /** @hidden */
  50182. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  50183. /** @hidden */
  50184. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50185. /**
  50186. * Creates an AxisDragGizmo
  50187. * @param gizmoLayer The utility layer the gizmo will be added to
  50188. * @param dragAxis The axis which the gizmo will be able to drag on
  50189. * @param color The color of the gizmo
  50190. * @param thickness display gizmo axis thickness
  50191. */
  50192. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  50193. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50194. /**
  50195. * If the gizmo is enabled
  50196. */
  50197. set isEnabled(value: boolean);
  50198. get isEnabled(): boolean;
  50199. /**
  50200. * Disposes of the gizmo
  50201. */
  50202. dispose(): void;
  50203. }
  50204. }
  50205. declare module BABYLON.Debug {
  50206. /**
  50207. * The Axes viewer will show 3 axes in a specific point in space
  50208. */
  50209. export class AxesViewer {
  50210. private _xAxis;
  50211. private _yAxis;
  50212. private _zAxis;
  50213. private _scaleLinesFactor;
  50214. private _instanced;
  50215. /**
  50216. * Gets the hosting scene
  50217. */
  50218. scene: Scene;
  50219. /**
  50220. * Gets or sets a number used to scale line length
  50221. */
  50222. scaleLines: number;
  50223. /** Gets the node hierarchy used to render x-axis */
  50224. get xAxis(): TransformNode;
  50225. /** Gets the node hierarchy used to render y-axis */
  50226. get yAxis(): TransformNode;
  50227. /** Gets the node hierarchy used to render z-axis */
  50228. get zAxis(): TransformNode;
  50229. /**
  50230. * Creates a new AxesViewer
  50231. * @param scene defines the hosting scene
  50232. * @param scaleLines defines a number used to scale line length (1 by default)
  50233. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  50234. * @param xAxis defines the node hierarchy used to render the x-axis
  50235. * @param yAxis defines the node hierarchy used to render the y-axis
  50236. * @param zAxis defines the node hierarchy used to render the z-axis
  50237. */
  50238. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  50239. /**
  50240. * Force the viewer to update
  50241. * @param position defines the position of the viewer
  50242. * @param xaxis defines the x axis of the viewer
  50243. * @param yaxis defines the y axis of the viewer
  50244. * @param zaxis defines the z axis of the viewer
  50245. */
  50246. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  50247. /**
  50248. * Creates an instance of this axes viewer.
  50249. * @returns a new axes viewer with instanced meshes
  50250. */
  50251. createInstance(): AxesViewer;
  50252. /** Releases resources */
  50253. dispose(): void;
  50254. private static _SetRenderingGroupId;
  50255. }
  50256. }
  50257. declare module BABYLON.Debug {
  50258. /**
  50259. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  50260. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  50261. */
  50262. export class BoneAxesViewer extends AxesViewer {
  50263. /**
  50264. * Gets or sets the target mesh where to display the axes viewer
  50265. */
  50266. mesh: Nullable<Mesh>;
  50267. /**
  50268. * Gets or sets the target bone where to display the axes viewer
  50269. */
  50270. bone: Nullable<Bone>;
  50271. /** Gets current position */
  50272. pos: Vector3;
  50273. /** Gets direction of X axis */
  50274. xaxis: Vector3;
  50275. /** Gets direction of Y axis */
  50276. yaxis: Vector3;
  50277. /** Gets direction of Z axis */
  50278. zaxis: Vector3;
  50279. /**
  50280. * Creates a new BoneAxesViewer
  50281. * @param scene defines the hosting scene
  50282. * @param bone defines the target bone
  50283. * @param mesh defines the target mesh
  50284. * @param scaleLines defines a scaling factor for line length (1 by default)
  50285. */
  50286. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  50287. /**
  50288. * Force the viewer to update
  50289. */
  50290. update(): void;
  50291. /** Releases resources */
  50292. dispose(): void;
  50293. }
  50294. }
  50295. declare module BABYLON {
  50296. /**
  50297. * Interface used to define scene explorer extensibility option
  50298. */
  50299. export interface IExplorerExtensibilityOption {
  50300. /**
  50301. * Define the option label
  50302. */
  50303. label: string;
  50304. /**
  50305. * Defines the action to execute on click
  50306. */
  50307. action: (entity: any) => void;
  50308. }
  50309. /**
  50310. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  50311. */
  50312. export interface IExplorerExtensibilityGroup {
  50313. /**
  50314. * Defines a predicate to test if a given type mut be extended
  50315. */
  50316. predicate: (entity: any) => boolean;
  50317. /**
  50318. * Gets the list of options added to a type
  50319. */
  50320. entries: IExplorerExtensibilityOption[];
  50321. }
  50322. /**
  50323. * Interface used to define the options to use to create the Inspector
  50324. */
  50325. export interface IInspectorOptions {
  50326. /**
  50327. * Display in overlay mode (default: false)
  50328. */
  50329. overlay?: boolean;
  50330. /**
  50331. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  50332. */
  50333. globalRoot?: HTMLElement;
  50334. /**
  50335. * Display the Scene explorer
  50336. */
  50337. showExplorer?: boolean;
  50338. /**
  50339. * Display the property inspector
  50340. */
  50341. showInspector?: boolean;
  50342. /**
  50343. * Display in embed mode (both panes on the right)
  50344. */
  50345. embedMode?: boolean;
  50346. /**
  50347. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  50348. */
  50349. handleResize?: boolean;
  50350. /**
  50351. * Allow the panes to popup (default: true)
  50352. */
  50353. enablePopup?: boolean;
  50354. /**
  50355. * Allow the panes to be closed by users (default: true)
  50356. */
  50357. enableClose?: boolean;
  50358. /**
  50359. * Optional list of extensibility entries
  50360. */
  50361. explorerExtensibility?: IExplorerExtensibilityGroup[];
  50362. /**
  50363. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  50364. */
  50365. inspectorURL?: string;
  50366. /**
  50367. * Optional initial tab (default to DebugLayerTab.Properties)
  50368. */
  50369. initialTab?: DebugLayerTab;
  50370. }
  50371. interface Scene {
  50372. /**
  50373. * @hidden
  50374. * Backing field
  50375. */
  50376. _debugLayer: DebugLayer;
  50377. /**
  50378. * Gets the debug layer (aka Inspector) associated with the scene
  50379. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50380. */
  50381. debugLayer: DebugLayer;
  50382. }
  50383. /**
  50384. * Enum of inspector action tab
  50385. */
  50386. export enum DebugLayerTab {
  50387. /**
  50388. * Properties tag (default)
  50389. */
  50390. Properties = 0,
  50391. /**
  50392. * Debug tab
  50393. */
  50394. Debug = 1,
  50395. /**
  50396. * Statistics tab
  50397. */
  50398. Statistics = 2,
  50399. /**
  50400. * Tools tab
  50401. */
  50402. Tools = 3,
  50403. /**
  50404. * Settings tab
  50405. */
  50406. Settings = 4
  50407. }
  50408. /**
  50409. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50410. * what is happening in your scene
  50411. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50412. */
  50413. export class DebugLayer {
  50414. /**
  50415. * Define the url to get the inspector script from.
  50416. * By default it uses the babylonjs CDN.
  50417. * @ignoreNaming
  50418. */
  50419. static InspectorURL: string;
  50420. private _scene;
  50421. private BJSINSPECTOR;
  50422. private _onPropertyChangedObservable?;
  50423. /**
  50424. * Observable triggered when a property is changed through the inspector.
  50425. */
  50426. get onPropertyChangedObservable(): any;
  50427. /**
  50428. * Instantiates a new debug layer.
  50429. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50430. * what is happening in your scene
  50431. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50432. * @param scene Defines the scene to inspect
  50433. */
  50434. constructor(scene: Scene);
  50435. /** Creates the inspector window. */
  50436. private _createInspector;
  50437. /**
  50438. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  50439. * @param entity defines the entity to select
  50440. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  50441. */
  50442. select(entity: any, lineContainerTitles?: string | string[]): void;
  50443. /** Get the inspector from bundle or global */
  50444. private _getGlobalInspector;
  50445. /**
  50446. * Get if the inspector is visible or not.
  50447. * @returns true if visible otherwise, false
  50448. */
  50449. isVisible(): boolean;
  50450. /**
  50451. * Hide the inspector and close its window.
  50452. */
  50453. hide(): void;
  50454. /**
  50455. * Update the scene in the inspector
  50456. */
  50457. setAsActiveScene(): void;
  50458. /**
  50459. * Launch the debugLayer.
  50460. * @param config Define the configuration of the inspector
  50461. * @return a promise fulfilled when the debug layer is visible
  50462. */
  50463. show(config?: IInspectorOptions): Promise<DebugLayer>;
  50464. }
  50465. }
  50466. declare module BABYLON {
  50467. /**
  50468. * Class containing static functions to help procedurally build meshes
  50469. */
  50470. export class BoxBuilder {
  50471. /**
  50472. * Creates a box mesh
  50473. * * The parameter `size` sets the size (float) of each box side (default 1)
  50474. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50475. * * 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)
  50476. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50477. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50478. * * 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
  50479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50480. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50481. * @param name defines the name of the mesh
  50482. * @param options defines the options used to create the mesh
  50483. * @param scene defines the hosting scene
  50484. * @returns the box mesh
  50485. */
  50486. static CreateBox(name: string, options: {
  50487. size?: number;
  50488. width?: number;
  50489. height?: number;
  50490. depth?: number;
  50491. faceUV?: Vector4[];
  50492. faceColors?: Color4[];
  50493. sideOrientation?: number;
  50494. frontUVs?: Vector4;
  50495. backUVs?: Vector4;
  50496. wrap?: boolean;
  50497. topBaseAt?: number;
  50498. bottomBaseAt?: number;
  50499. updatable?: boolean;
  50500. }, scene?: Nullable<Scene>): Mesh;
  50501. }
  50502. }
  50503. declare module BABYLON.Debug {
  50504. /**
  50505. * Used to show the physics impostor around the specific mesh
  50506. */
  50507. export class PhysicsViewer {
  50508. /** @hidden */
  50509. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  50510. /** @hidden */
  50511. protected _meshes: Array<Nullable<AbstractMesh>>;
  50512. /** @hidden */
  50513. protected _scene: Nullable<Scene>;
  50514. /** @hidden */
  50515. protected _numMeshes: number;
  50516. /** @hidden */
  50517. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  50518. private _renderFunction;
  50519. private _utilityLayer;
  50520. private _debugBoxMesh;
  50521. private _debugSphereMesh;
  50522. private _debugCylinderMesh;
  50523. private _debugMaterial;
  50524. private _debugMeshMeshes;
  50525. /**
  50526. * Creates a new PhysicsViewer
  50527. * @param scene defines the hosting scene
  50528. */
  50529. constructor(scene: Scene);
  50530. /** @hidden */
  50531. protected _updateDebugMeshes(): void;
  50532. /**
  50533. * Renders a specified physic impostor
  50534. * @param impostor defines the impostor to render
  50535. * @param targetMesh defines the mesh represented by the impostor
  50536. * @returns the new debug mesh used to render the impostor
  50537. */
  50538. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  50539. /**
  50540. * Hides a specified physic impostor
  50541. * @param impostor defines the impostor to hide
  50542. */
  50543. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  50544. private _getDebugMaterial;
  50545. private _getDebugBoxMesh;
  50546. private _getDebugSphereMesh;
  50547. private _getDebugCylinderMesh;
  50548. private _getDebugMeshMesh;
  50549. private _getDebugMesh;
  50550. /** Releases all resources */
  50551. dispose(): void;
  50552. }
  50553. }
  50554. declare module BABYLON {
  50555. /**
  50556. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50557. * in order to better appreciate the issue one might have.
  50558. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50559. */
  50560. export class RayHelper {
  50561. /**
  50562. * Defines the ray we are currently tryin to visualize.
  50563. */
  50564. ray: Nullable<Ray>;
  50565. private _renderPoints;
  50566. private _renderLine;
  50567. private _renderFunction;
  50568. private _scene;
  50569. private _updateToMeshFunction;
  50570. private _attachedToMesh;
  50571. private _meshSpaceDirection;
  50572. private _meshSpaceOrigin;
  50573. /**
  50574. * Helper function to create a colored helper in a scene in one line.
  50575. * @param ray Defines the ray we are currently tryin to visualize
  50576. * @param scene Defines the scene the ray is used in
  50577. * @param color Defines the color we want to see the ray in
  50578. * @returns The newly created ray helper.
  50579. */
  50580. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  50581. /**
  50582. * Instantiate a new ray helper.
  50583. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50584. * in order to better appreciate the issue one might have.
  50585. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50586. * @param ray Defines the ray we are currently tryin to visualize
  50587. */
  50588. constructor(ray: Ray);
  50589. /**
  50590. * Shows the ray we are willing to debug.
  50591. * @param scene Defines the scene the ray needs to be rendered in
  50592. * @param color Defines the color the ray needs to be rendered in
  50593. */
  50594. show(scene: Scene, color?: Color3): void;
  50595. /**
  50596. * Hides the ray we are debugging.
  50597. */
  50598. hide(): void;
  50599. private _render;
  50600. /**
  50601. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  50602. * @param mesh Defines the mesh we want the helper attached to
  50603. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  50604. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  50605. * @param length Defines the length of the ray
  50606. */
  50607. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  50608. /**
  50609. * Detach the ray helper from the mesh it has previously been attached to.
  50610. */
  50611. detachFromMesh(): void;
  50612. private _updateToMesh;
  50613. /**
  50614. * Dispose the helper and release its associated resources.
  50615. */
  50616. dispose(): void;
  50617. }
  50618. }
  50619. declare module BABYLON.Debug {
  50620. /**
  50621. * Class used to render a debug view of a given skeleton
  50622. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  50623. */
  50624. export class SkeletonViewer {
  50625. /** defines the skeleton to render */
  50626. skeleton: Skeleton;
  50627. /** defines the mesh attached to the skeleton */
  50628. mesh: AbstractMesh;
  50629. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  50630. autoUpdateBonesMatrices: boolean;
  50631. /** defines the rendering group id to use with the viewer */
  50632. renderingGroupId: number;
  50633. /** Gets or sets the color used to render the skeleton */
  50634. color: Color3;
  50635. private _scene;
  50636. private _debugLines;
  50637. private _debugMesh;
  50638. private _isEnabled;
  50639. private _renderFunction;
  50640. private _utilityLayer;
  50641. /**
  50642. * Returns the mesh used to render the bones
  50643. */
  50644. get debugMesh(): Nullable<LinesMesh>;
  50645. /**
  50646. * Creates a new SkeletonViewer
  50647. * @param skeleton defines the skeleton to render
  50648. * @param mesh defines the mesh attached to the skeleton
  50649. * @param scene defines the hosting scene
  50650. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  50651. * @param renderingGroupId defines the rendering group id to use with the viewer
  50652. */
  50653. constructor(
  50654. /** defines the skeleton to render */
  50655. skeleton: Skeleton,
  50656. /** defines the mesh attached to the skeleton */
  50657. mesh: AbstractMesh, scene: Scene,
  50658. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  50659. autoUpdateBonesMatrices?: boolean,
  50660. /** defines the rendering group id to use with the viewer */
  50661. renderingGroupId?: number);
  50662. /** Gets or sets a boolean indicating if the viewer is enabled */
  50663. set isEnabled(value: boolean);
  50664. get isEnabled(): boolean;
  50665. private _getBonePosition;
  50666. private _getLinesForBonesWithLength;
  50667. private _getLinesForBonesNoLength;
  50668. /** Update the viewer to sync with current skeleton state */
  50669. update(): void;
  50670. /** Release associated resources */
  50671. dispose(): void;
  50672. }
  50673. }
  50674. declare module BABYLON {
  50675. /**
  50676. * Enum for Device Types
  50677. */
  50678. export enum DeviceType {
  50679. /** Generic */
  50680. Generic = 0,
  50681. /** Keyboard */
  50682. Keyboard = 1,
  50683. /** Mouse */
  50684. Mouse = 2,
  50685. /** Touch Pointers */
  50686. Touch = 3,
  50687. /** PS4 Dual Shock */
  50688. DualShock = 4,
  50689. /** Xbox */
  50690. Xbox = 5,
  50691. /** Switch Controller */
  50692. Switch = 6
  50693. }
  50694. /**
  50695. * Enum for All Pointers (Touch/Mouse)
  50696. */
  50697. export enum PointerInput {
  50698. /** Horizontal Axis */
  50699. Horizontal = 0,
  50700. /** Vertical Axis */
  50701. Vertical = 1,
  50702. /** Left Click or Touch */
  50703. LeftClick = 2,
  50704. /** Middle Click */
  50705. MiddleClick = 3,
  50706. /** Right Click */
  50707. RightClick = 4,
  50708. /** Browser Back */
  50709. BrowserBack = 5,
  50710. /** Browser Forward */
  50711. BrowserForward = 6
  50712. }
  50713. /**
  50714. * Enum for Dual Shock Gamepad
  50715. */
  50716. export enum DualShockInput {
  50717. /** Cross */
  50718. Cross = 0,
  50719. /** Circle */
  50720. Circle = 1,
  50721. /** Square */
  50722. Square = 2,
  50723. /** Triangle */
  50724. Triangle = 3,
  50725. /** L1 */
  50726. L1 = 4,
  50727. /** R1 */
  50728. R1 = 5,
  50729. /** L2 */
  50730. L2 = 6,
  50731. /** R2 */
  50732. R2 = 7,
  50733. /** Share */
  50734. Share = 8,
  50735. /** Options */
  50736. Options = 9,
  50737. /** L3 */
  50738. L3 = 10,
  50739. /** R3 */
  50740. R3 = 11,
  50741. /** DPadUp */
  50742. DPadUp = 12,
  50743. /** DPadDown */
  50744. DPadDown = 13,
  50745. /** DPadLeft */
  50746. DPadLeft = 14,
  50747. /** DRight */
  50748. DPadRight = 15,
  50749. /** Home */
  50750. Home = 16,
  50751. /** TouchPad */
  50752. TouchPad = 17,
  50753. /** LStickXAxis */
  50754. LStickXAxis = 18,
  50755. /** LStickYAxis */
  50756. LStickYAxis = 19,
  50757. /** RStickXAxis */
  50758. RStickXAxis = 20,
  50759. /** RStickYAxis */
  50760. RStickYAxis = 21
  50761. }
  50762. /**
  50763. * Enum for Xbox Gamepad
  50764. */
  50765. export enum XboxInput {
  50766. /** A */
  50767. A = 0,
  50768. /** B */
  50769. B = 1,
  50770. /** X */
  50771. X = 2,
  50772. /** Y */
  50773. Y = 3,
  50774. /** LB */
  50775. LB = 4,
  50776. /** RB */
  50777. RB = 5,
  50778. /** LT */
  50779. LT = 6,
  50780. /** RT */
  50781. RT = 7,
  50782. /** Back */
  50783. Back = 8,
  50784. /** Start */
  50785. Start = 9,
  50786. /** LS */
  50787. LS = 10,
  50788. /** RS */
  50789. RS = 11,
  50790. /** DPadUp */
  50791. DPadUp = 12,
  50792. /** DPadDown */
  50793. DPadDown = 13,
  50794. /** DPadLeft */
  50795. DPadLeft = 14,
  50796. /** DRight */
  50797. DPadRight = 15,
  50798. /** Home */
  50799. Home = 16,
  50800. /** LStickXAxis */
  50801. LStickXAxis = 17,
  50802. /** LStickYAxis */
  50803. LStickYAxis = 18,
  50804. /** RStickXAxis */
  50805. RStickXAxis = 19,
  50806. /** RStickYAxis */
  50807. RStickYAxis = 20
  50808. }
  50809. /**
  50810. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  50811. */
  50812. export enum SwitchInput {
  50813. /** B */
  50814. B = 0,
  50815. /** A */
  50816. A = 1,
  50817. /** Y */
  50818. Y = 2,
  50819. /** X */
  50820. X = 3,
  50821. /** L */
  50822. L = 4,
  50823. /** R */
  50824. R = 5,
  50825. /** ZL */
  50826. ZL = 6,
  50827. /** ZR */
  50828. ZR = 7,
  50829. /** Minus */
  50830. Minus = 8,
  50831. /** Plus */
  50832. Plus = 9,
  50833. /** LS */
  50834. LS = 10,
  50835. /** RS */
  50836. RS = 11,
  50837. /** DPadUp */
  50838. DPadUp = 12,
  50839. /** DPadDown */
  50840. DPadDown = 13,
  50841. /** DPadLeft */
  50842. DPadLeft = 14,
  50843. /** DRight */
  50844. DPadRight = 15,
  50845. /** Home */
  50846. Home = 16,
  50847. /** Capture */
  50848. Capture = 17,
  50849. /** LStickXAxis */
  50850. LStickXAxis = 18,
  50851. /** LStickYAxis */
  50852. LStickYAxis = 19,
  50853. /** RStickXAxis */
  50854. RStickXAxis = 20,
  50855. /** RStickYAxis */
  50856. RStickYAxis = 21
  50857. }
  50858. }
  50859. declare module BABYLON {
  50860. /**
  50861. * This class will take all inputs from Keyboard, Pointer, and
  50862. * any Gamepads and provide a polling system that all devices
  50863. * will use. This class assumes that there will only be one
  50864. * pointer device and one keyboard.
  50865. */
  50866. export class DeviceInputSystem implements IDisposable {
  50867. /**
  50868. * Callback to be triggered when a device is connected
  50869. */
  50870. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  50871. /**
  50872. * Callback to be triggered when a device is disconnected
  50873. */
  50874. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  50875. /**
  50876. * Callback to be triggered when event driven input is updated
  50877. */
  50878. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  50879. private _inputs;
  50880. private _gamepads;
  50881. private _keyboardActive;
  50882. private _pointerActive;
  50883. private _elementToAttachTo;
  50884. private _keyboardDownEvent;
  50885. private _keyboardUpEvent;
  50886. private _pointerMoveEvent;
  50887. private _pointerDownEvent;
  50888. private _pointerUpEvent;
  50889. private _gamepadConnectedEvent;
  50890. private _gamepadDisconnectedEvent;
  50891. private static _MAX_KEYCODES;
  50892. private static _MAX_POINTER_INPUTS;
  50893. private constructor();
  50894. /**
  50895. * Creates a new DeviceInputSystem instance
  50896. * @param engine Engine to pull input element from
  50897. * @returns The new instance
  50898. */
  50899. static Create(engine: Engine): DeviceInputSystem;
  50900. /**
  50901. * Checks for current device input value, given an id and input index
  50902. * @param deviceName Id of connected device
  50903. * @param inputIndex Index of device input
  50904. * @returns Current value of input
  50905. */
  50906. /**
  50907. * Checks for current device input value, given an id and input index
  50908. * @param deviceType Enum specifiying device type
  50909. * @param deviceSlot "Slot" or index that device is referenced in
  50910. * @param inputIndex Id of input to be checked
  50911. * @returns Current value of input
  50912. */
  50913. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  50914. /**
  50915. * Dispose of all the eventlisteners
  50916. */
  50917. dispose(): void;
  50918. /**
  50919. * Add device and inputs to device array
  50920. * @param deviceType Enum specifiying device type
  50921. * @param deviceSlot "Slot" or index that device is referenced in
  50922. * @param numberOfInputs Number of input entries to create for given device
  50923. */
  50924. private _registerDevice;
  50925. /**
  50926. * Given a specific device name, remove that device from the device map
  50927. * @param deviceType Enum specifiying device type
  50928. * @param deviceSlot "Slot" or index that device is referenced in
  50929. */
  50930. private _unregisterDevice;
  50931. /**
  50932. * Handle all actions that come from keyboard interaction
  50933. */
  50934. private _handleKeyActions;
  50935. /**
  50936. * Handle all actions that come from pointer interaction
  50937. */
  50938. private _handlePointerActions;
  50939. /**
  50940. * Handle all actions that come from gamepad interaction
  50941. */
  50942. private _handleGamepadActions;
  50943. /**
  50944. * Update all non-event based devices with each frame
  50945. * @param deviceType Enum specifiying device type
  50946. * @param deviceSlot "Slot" or index that device is referenced in
  50947. * @param inputIndex Id of input to be checked
  50948. */
  50949. private _updateDevice;
  50950. /**
  50951. * Gets DeviceType from the device name
  50952. * @param deviceName Name of Device from DeviceInputSystem
  50953. * @returns DeviceType enum value
  50954. */
  50955. private _getGamepadDeviceType;
  50956. }
  50957. }
  50958. declare module BABYLON {
  50959. /**
  50960. * Type to handle enforcement of inputs
  50961. */
  50962. 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;
  50963. }
  50964. declare module BABYLON {
  50965. /**
  50966. * Class that handles all input for a specific device
  50967. */
  50968. export class DeviceSource<T extends DeviceType> {
  50969. /** Type of device */
  50970. readonly deviceType: DeviceType;
  50971. /** "Slot" or index that device is referenced in */
  50972. readonly deviceSlot: number;
  50973. /**
  50974. * Observable to handle device input changes per device
  50975. */
  50976. readonly onInputChangedObservable: Observable<{
  50977. inputIndex: DeviceInput<T>;
  50978. previousState: Nullable<number>;
  50979. currentState: Nullable<number>;
  50980. }>;
  50981. private readonly _deviceInputSystem;
  50982. /**
  50983. * Default Constructor
  50984. * @param deviceInputSystem Reference to DeviceInputSystem
  50985. * @param deviceType Type of device
  50986. * @param deviceSlot "Slot" or index that device is referenced in
  50987. */
  50988. constructor(deviceInputSystem: DeviceInputSystem,
  50989. /** Type of device */
  50990. deviceType: DeviceType,
  50991. /** "Slot" or index that device is referenced in */
  50992. deviceSlot?: number);
  50993. /**
  50994. * Get input for specific input
  50995. * @param inputIndex index of specific input on device
  50996. * @returns Input value from DeviceInputSystem
  50997. */
  50998. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  50999. }
  51000. /**
  51001. * Class to keep track of devices
  51002. */
  51003. export class DeviceSourceManager implements IDisposable {
  51004. /**
  51005. * Observable to be triggered when before a device is connected
  51006. */
  51007. readonly onBeforeDeviceConnectedObservable: Observable<{
  51008. deviceType: DeviceType;
  51009. deviceSlot: number;
  51010. }>;
  51011. /**
  51012. * Observable to be triggered when before a device is disconnected
  51013. */
  51014. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  51015. deviceType: DeviceType;
  51016. deviceSlot: number;
  51017. }>;
  51018. /**
  51019. * Observable to be triggered when after a device is connected
  51020. */
  51021. readonly onAfterDeviceConnectedObservable: Observable<{
  51022. deviceType: DeviceType;
  51023. deviceSlot: number;
  51024. }>;
  51025. /**
  51026. * Observable to be triggered when after a device is disconnected
  51027. */
  51028. readonly onAfterDeviceDisconnectedObservable: Observable<{
  51029. deviceType: DeviceType;
  51030. deviceSlot: number;
  51031. }>;
  51032. private readonly _devices;
  51033. private readonly _firstDevice;
  51034. private readonly _deviceInputSystem;
  51035. /**
  51036. * Default Constructor
  51037. * @param engine engine to pull input element from
  51038. */
  51039. constructor(engine: Engine);
  51040. /**
  51041. * Gets a DeviceSource, given a type and slot
  51042. * @param deviceType Enum specifying device type
  51043. * @param deviceSlot "Slot" or index that device is referenced in
  51044. * @returns DeviceSource object
  51045. */
  51046. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  51047. /**
  51048. * Gets an array of DeviceSource objects for a given device type
  51049. * @param deviceType Enum specifying device type
  51050. * @returns Array of DeviceSource objects
  51051. */
  51052. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  51053. /**
  51054. * Dispose of DeviceInputSystem and other parts
  51055. */
  51056. dispose(): void;
  51057. /**
  51058. * Function to add device name to device list
  51059. * @param deviceType Enum specifying device type
  51060. * @param deviceSlot "Slot" or index that device is referenced in
  51061. */
  51062. private _addDevice;
  51063. /**
  51064. * Function to remove device name to device list
  51065. * @param deviceType Enum specifying device type
  51066. * @param deviceSlot "Slot" or index that device is referenced in
  51067. */
  51068. private _removeDevice;
  51069. /**
  51070. * Updates array storing first connected device of each type
  51071. * @param type Type of Device
  51072. */
  51073. private _updateFirstDevices;
  51074. }
  51075. }
  51076. declare module BABYLON {
  51077. /**
  51078. * Options to create the null engine
  51079. */
  51080. export class NullEngineOptions {
  51081. /**
  51082. * Render width (Default: 512)
  51083. */
  51084. renderWidth: number;
  51085. /**
  51086. * Render height (Default: 256)
  51087. */
  51088. renderHeight: number;
  51089. /**
  51090. * Texture size (Default: 512)
  51091. */
  51092. textureSize: number;
  51093. /**
  51094. * If delta time between frames should be constant
  51095. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51096. */
  51097. deterministicLockstep: boolean;
  51098. /**
  51099. * Maximum about of steps between frames (Default: 4)
  51100. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51101. */
  51102. lockstepMaxSteps: number;
  51103. /**
  51104. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  51105. */
  51106. useHighPrecisionMatrix?: boolean;
  51107. }
  51108. /**
  51109. * The null engine class provides support for headless version of babylon.js.
  51110. * This can be used in server side scenario or for testing purposes
  51111. */
  51112. export class NullEngine extends Engine {
  51113. private _options;
  51114. /**
  51115. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  51116. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51117. * @returns true if engine is in deterministic lock step mode
  51118. */
  51119. isDeterministicLockStep(): boolean;
  51120. /**
  51121. * Gets the max steps when engine is running in deterministic lock step
  51122. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51123. * @returns the max steps
  51124. */
  51125. getLockstepMaxSteps(): number;
  51126. /**
  51127. * Gets the current hardware scaling level.
  51128. * By default the hardware scaling level is computed from the window device ratio.
  51129. * 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.
  51130. * @returns a number indicating the current hardware scaling level
  51131. */
  51132. getHardwareScalingLevel(): number;
  51133. constructor(options?: NullEngineOptions);
  51134. /**
  51135. * Creates a vertex buffer
  51136. * @param vertices the data for the vertex buffer
  51137. * @returns the new WebGL static buffer
  51138. */
  51139. createVertexBuffer(vertices: FloatArray): DataBuffer;
  51140. /**
  51141. * Creates a new index buffer
  51142. * @param indices defines the content of the index buffer
  51143. * @param updatable defines if the index buffer must be updatable
  51144. * @returns a new webGL buffer
  51145. */
  51146. createIndexBuffer(indices: IndicesArray): DataBuffer;
  51147. /**
  51148. * Clear the current render buffer or the current render target (if any is set up)
  51149. * @param color defines the color to use
  51150. * @param backBuffer defines if the back buffer must be cleared
  51151. * @param depth defines if the depth buffer must be cleared
  51152. * @param stencil defines if the stencil buffer must be cleared
  51153. */
  51154. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51155. /**
  51156. * Gets the current render width
  51157. * @param useScreen defines if screen size must be used (or the current render target if any)
  51158. * @returns a number defining the current render width
  51159. */
  51160. getRenderWidth(useScreen?: boolean): number;
  51161. /**
  51162. * Gets the current render height
  51163. * @param useScreen defines if screen size must be used (or the current render target if any)
  51164. * @returns a number defining the current render height
  51165. */
  51166. getRenderHeight(useScreen?: boolean): number;
  51167. /**
  51168. * Set the WebGL's viewport
  51169. * @param viewport defines the viewport element to be used
  51170. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  51171. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  51172. */
  51173. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  51174. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  51175. /**
  51176. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  51177. * @param pipelineContext defines the pipeline context to use
  51178. * @param uniformsNames defines the list of uniform names
  51179. * @returns an array of webGL uniform locations
  51180. */
  51181. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  51182. /**
  51183. * Gets the lsit of active attributes for a given webGL program
  51184. * @param pipelineContext defines the pipeline context to use
  51185. * @param attributesNames defines the list of attribute names to get
  51186. * @returns an array of indices indicating the offset of each attribute
  51187. */
  51188. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51189. /**
  51190. * Binds an effect to the webGL context
  51191. * @param effect defines the effect to bind
  51192. */
  51193. bindSamplers(effect: Effect): void;
  51194. /**
  51195. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  51196. * @param effect defines the effect to activate
  51197. */
  51198. enableEffect(effect: Effect): void;
  51199. /**
  51200. * Set various states to the webGL context
  51201. * @param culling defines backface culling state
  51202. * @param zOffset defines the value to apply to zOffset (0 by default)
  51203. * @param force defines if states must be applied even if cache is up to date
  51204. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  51205. */
  51206. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51207. /**
  51208. * Set the value of an uniform to an array of int32
  51209. * @param uniform defines the webGL uniform location where to store the value
  51210. * @param array defines the array of int32 to store
  51211. */
  51212. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51213. /**
  51214. * Set the value of an uniform to an array of int32 (stored as vec2)
  51215. * @param uniform defines the webGL uniform location where to store the value
  51216. * @param array defines the array of int32 to store
  51217. */
  51218. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51219. /**
  51220. * Set the value of an uniform to an array of int32 (stored as vec3)
  51221. * @param uniform defines the webGL uniform location where to store the value
  51222. * @param array defines the array of int32 to store
  51223. */
  51224. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51225. /**
  51226. * Set the value of an uniform to an array of int32 (stored as vec4)
  51227. * @param uniform defines the webGL uniform location where to store the value
  51228. * @param array defines the array of int32 to store
  51229. */
  51230. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51231. /**
  51232. * Set the value of an uniform to an array of float32
  51233. * @param uniform defines the webGL uniform location where to store the value
  51234. * @param array defines the array of float32 to store
  51235. */
  51236. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51237. /**
  51238. * Set the value of an uniform to an array of float32 (stored as vec2)
  51239. * @param uniform defines the webGL uniform location where to store the value
  51240. * @param array defines the array of float32 to store
  51241. */
  51242. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51243. /**
  51244. * Set the value of an uniform to an array of float32 (stored as vec3)
  51245. * @param uniform defines the webGL uniform location where to store the value
  51246. * @param array defines the array of float32 to store
  51247. */
  51248. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51249. /**
  51250. * Set the value of an uniform to an array of float32 (stored as vec4)
  51251. * @param uniform defines the webGL uniform location where to store the value
  51252. * @param array defines the array of float32 to store
  51253. */
  51254. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51255. /**
  51256. * Set the value of an uniform to an array of number
  51257. * @param uniform defines the webGL uniform location where to store the value
  51258. * @param array defines the array of number to store
  51259. */
  51260. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51261. /**
  51262. * Set the value of an uniform to an array of number (stored as vec2)
  51263. * @param uniform defines the webGL uniform location where to store the value
  51264. * @param array defines the array of number to store
  51265. */
  51266. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51267. /**
  51268. * Set the value of an uniform to an array of number (stored as vec3)
  51269. * @param uniform defines the webGL uniform location where to store the value
  51270. * @param array defines the array of number to store
  51271. */
  51272. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51273. /**
  51274. * Set the value of an uniform to an array of number (stored as vec4)
  51275. * @param uniform defines the webGL uniform location where to store the value
  51276. * @param array defines the array of number to store
  51277. */
  51278. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51279. /**
  51280. * Set the value of an uniform to an array of float32 (stored as matrices)
  51281. * @param uniform defines the webGL uniform location where to store the value
  51282. * @param matrices defines the array of float32 to store
  51283. */
  51284. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  51285. /**
  51286. * Set the value of an uniform to a matrix (3x3)
  51287. * @param uniform defines the webGL uniform location where to store the value
  51288. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  51289. */
  51290. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51291. /**
  51292. * Set the value of an uniform to a matrix (2x2)
  51293. * @param uniform defines the webGL uniform location where to store the value
  51294. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  51295. */
  51296. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51297. /**
  51298. * Set the value of an uniform to a number (float)
  51299. * @param uniform defines the webGL uniform location where to store the value
  51300. * @param value defines the float number to store
  51301. */
  51302. setFloat(uniform: WebGLUniformLocation, value: number): void;
  51303. /**
  51304. * Set the value of an uniform to a vec2
  51305. * @param uniform defines the webGL uniform location where to store the value
  51306. * @param x defines the 1st component of the value
  51307. * @param y defines the 2nd component of the value
  51308. */
  51309. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  51310. /**
  51311. * Set the value of an uniform to a vec3
  51312. * @param uniform defines the webGL uniform location where to store the value
  51313. * @param x defines the 1st component of the value
  51314. * @param y defines the 2nd component of the value
  51315. * @param z defines the 3rd component of the value
  51316. */
  51317. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  51318. /**
  51319. * Set the value of an uniform to a boolean
  51320. * @param uniform defines the webGL uniform location where to store the value
  51321. * @param bool defines the boolean to store
  51322. */
  51323. setBool(uniform: WebGLUniformLocation, bool: number): void;
  51324. /**
  51325. * Set the value of an uniform to a vec4
  51326. * @param uniform defines the webGL uniform location where to store the value
  51327. * @param x defines the 1st component of the value
  51328. * @param y defines the 2nd component of the value
  51329. * @param z defines the 3rd component of the value
  51330. * @param w defines the 4th component of the value
  51331. */
  51332. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  51333. /**
  51334. * Sets the current alpha mode
  51335. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  51336. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  51337. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51338. */
  51339. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  51340. /**
  51341. * Bind webGl buffers directly to the webGL context
  51342. * @param vertexBuffers defines the vertex buffer to bind
  51343. * @param indexBuffer defines the index buffer to bind
  51344. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  51345. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  51346. * @param effect defines the effect associated with the vertex buffer
  51347. */
  51348. bindBuffers(vertexBuffers: {
  51349. [key: string]: VertexBuffer;
  51350. }, indexBuffer: DataBuffer, effect: Effect): void;
  51351. /**
  51352. * Force the entire cache to be cleared
  51353. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  51354. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  51355. */
  51356. wipeCaches(bruteForce?: boolean): void;
  51357. /**
  51358. * Send a draw order
  51359. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  51360. * @param indexStart defines the starting index
  51361. * @param indexCount defines the number of index to draw
  51362. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51363. */
  51364. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  51365. /**
  51366. * Draw a list of indexed primitives
  51367. * @param fillMode defines the primitive to use
  51368. * @param indexStart defines the starting index
  51369. * @param indexCount defines the number of index to draw
  51370. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51371. */
  51372. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  51373. /**
  51374. * Draw a list of unindexed primitives
  51375. * @param fillMode defines the primitive to use
  51376. * @param verticesStart defines the index of first vertex to draw
  51377. * @param verticesCount defines the count of vertices to draw
  51378. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51379. */
  51380. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  51381. /** @hidden */
  51382. _createTexture(): WebGLTexture;
  51383. /** @hidden */
  51384. _releaseTexture(texture: InternalTexture): void;
  51385. /**
  51386. * Usually called from Texture.ts.
  51387. * Passed information to create a WebGLTexture
  51388. * @param urlArg defines a value which contains one of the following:
  51389. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  51390. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  51391. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  51392. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  51393. * @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)
  51394. * @param scene needed for loading to the correct scene
  51395. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  51396. * @param onLoad optional callback to be called upon successful completion
  51397. * @param onError optional callback to be called upon failure
  51398. * @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
  51399. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  51400. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  51401. * @param forcedExtension defines the extension to use to pick the right loader
  51402. * @param mimeType defines an optional mime type
  51403. * @returns a InternalTexture for assignment back into BABYLON.Texture
  51404. */
  51405. 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;
  51406. /**
  51407. * Creates a new render target texture
  51408. * @param size defines the size of the texture
  51409. * @param options defines the options used to create the texture
  51410. * @returns a new render target texture stored in an InternalTexture
  51411. */
  51412. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  51413. /**
  51414. * Update the sampling mode of a given texture
  51415. * @param samplingMode defines the required sampling mode
  51416. * @param texture defines the texture to update
  51417. */
  51418. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  51419. /**
  51420. * Binds the frame buffer to the specified texture.
  51421. * @param texture The texture to render to or null for the default canvas
  51422. * @param faceIndex The face of the texture to render to in case of cube texture
  51423. * @param requiredWidth The width of the target to render to
  51424. * @param requiredHeight The height of the target to render to
  51425. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  51426. * @param lodLevel defines le lod level to bind to the frame buffer
  51427. */
  51428. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  51429. /**
  51430. * Unbind the current render target texture from the webGL context
  51431. * @param texture defines the render target texture to unbind
  51432. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  51433. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  51434. */
  51435. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  51436. /**
  51437. * Creates a dynamic vertex buffer
  51438. * @param vertices the data for the dynamic vertex buffer
  51439. * @returns the new WebGL dynamic buffer
  51440. */
  51441. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  51442. /**
  51443. * Update the content of a dynamic texture
  51444. * @param texture defines the texture to update
  51445. * @param canvas defines the canvas containing the source
  51446. * @param invertY defines if data must be stored with Y axis inverted
  51447. * @param premulAlpha defines if alpha is stored as premultiplied
  51448. * @param format defines the format of the data
  51449. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  51450. */
  51451. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  51452. /**
  51453. * Gets a boolean indicating if all created effects are ready
  51454. * @returns true if all effects are ready
  51455. */
  51456. areAllEffectsReady(): boolean;
  51457. /**
  51458. * @hidden
  51459. * Get the current error code of the webGL context
  51460. * @returns the error code
  51461. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  51462. */
  51463. getError(): number;
  51464. /** @hidden */
  51465. _getUnpackAlignement(): number;
  51466. /** @hidden */
  51467. _unpackFlipY(value: boolean): void;
  51468. /**
  51469. * Update a dynamic index buffer
  51470. * @param indexBuffer defines the target index buffer
  51471. * @param indices defines the data to update
  51472. * @param offset defines the offset in the target index buffer where update should start
  51473. */
  51474. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  51475. /**
  51476. * Updates a dynamic vertex buffer.
  51477. * @param vertexBuffer the vertex buffer to update
  51478. * @param vertices the data used to update the vertex buffer
  51479. * @param byteOffset the byte offset of the data (optional)
  51480. * @param byteLength the byte length of the data (optional)
  51481. */
  51482. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  51483. /** @hidden */
  51484. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  51485. /** @hidden */
  51486. _bindTexture(channel: number, texture: InternalTexture): void;
  51487. protected _deleteBuffer(buffer: WebGLBuffer): void;
  51488. /**
  51489. * 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
  51490. */
  51491. releaseEffects(): void;
  51492. displayLoadingUI(): void;
  51493. hideLoadingUI(): void;
  51494. /** @hidden */
  51495. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51496. /** @hidden */
  51497. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51498. /** @hidden */
  51499. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51500. /** @hidden */
  51501. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  51502. }
  51503. }
  51504. declare module BABYLON {
  51505. /**
  51506. * @hidden
  51507. **/
  51508. export class _TimeToken {
  51509. _startTimeQuery: Nullable<WebGLQuery>;
  51510. _endTimeQuery: Nullable<WebGLQuery>;
  51511. _timeElapsedQuery: Nullable<WebGLQuery>;
  51512. _timeElapsedQueryEnded: boolean;
  51513. }
  51514. }
  51515. declare module BABYLON {
  51516. /** @hidden */
  51517. export class _OcclusionDataStorage {
  51518. /** @hidden */
  51519. occlusionInternalRetryCounter: number;
  51520. /** @hidden */
  51521. isOcclusionQueryInProgress: boolean;
  51522. /** @hidden */
  51523. isOccluded: boolean;
  51524. /** @hidden */
  51525. occlusionRetryCount: number;
  51526. /** @hidden */
  51527. occlusionType: number;
  51528. /** @hidden */
  51529. occlusionQueryAlgorithmType: number;
  51530. }
  51531. interface Engine {
  51532. /**
  51533. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  51534. * @return the new query
  51535. */
  51536. createQuery(): WebGLQuery;
  51537. /**
  51538. * Delete and release a webGL query
  51539. * @param query defines the query to delete
  51540. * @return the current engine
  51541. */
  51542. deleteQuery(query: WebGLQuery): Engine;
  51543. /**
  51544. * Check if a given query has resolved and got its value
  51545. * @param query defines the query to check
  51546. * @returns true if the query got its value
  51547. */
  51548. isQueryResultAvailable(query: WebGLQuery): boolean;
  51549. /**
  51550. * Gets the value of a given query
  51551. * @param query defines the query to check
  51552. * @returns the value of the query
  51553. */
  51554. getQueryResult(query: WebGLQuery): number;
  51555. /**
  51556. * Initiates an occlusion query
  51557. * @param algorithmType defines the algorithm to use
  51558. * @param query defines the query to use
  51559. * @returns the current engine
  51560. * @see https://doc.babylonjs.com/features/occlusionquery
  51561. */
  51562. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  51563. /**
  51564. * Ends an occlusion query
  51565. * @see https://doc.babylonjs.com/features/occlusionquery
  51566. * @param algorithmType defines the algorithm to use
  51567. * @returns the current engine
  51568. */
  51569. endOcclusionQuery(algorithmType: number): Engine;
  51570. /**
  51571. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  51572. * Please note that only one query can be issued at a time
  51573. * @returns a time token used to track the time span
  51574. */
  51575. startTimeQuery(): Nullable<_TimeToken>;
  51576. /**
  51577. * Ends a time query
  51578. * @param token defines the token used to measure the time span
  51579. * @returns the time spent (in ns)
  51580. */
  51581. endTimeQuery(token: _TimeToken): int;
  51582. /** @hidden */
  51583. _currentNonTimestampToken: Nullable<_TimeToken>;
  51584. /** @hidden */
  51585. _createTimeQuery(): WebGLQuery;
  51586. /** @hidden */
  51587. _deleteTimeQuery(query: WebGLQuery): void;
  51588. /** @hidden */
  51589. _getGlAlgorithmType(algorithmType: number): number;
  51590. /** @hidden */
  51591. _getTimeQueryResult(query: WebGLQuery): any;
  51592. /** @hidden */
  51593. _getTimeQueryAvailability(query: WebGLQuery): any;
  51594. }
  51595. interface AbstractMesh {
  51596. /**
  51597. * Backing filed
  51598. * @hidden
  51599. */
  51600. __occlusionDataStorage: _OcclusionDataStorage;
  51601. /**
  51602. * Access property
  51603. * @hidden
  51604. */
  51605. _occlusionDataStorage: _OcclusionDataStorage;
  51606. /**
  51607. * 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.
  51608. * The default value is -1 which means don't break the query and wait till the result
  51609. * @see https://doc.babylonjs.com/features/occlusionquery
  51610. */
  51611. occlusionRetryCount: number;
  51612. /**
  51613. * 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:
  51614. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  51615. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  51616. * * 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.
  51617. * @see https://doc.babylonjs.com/features/occlusionquery
  51618. */
  51619. occlusionType: number;
  51620. /**
  51621. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  51622. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  51623. * * 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.
  51624. * @see https://doc.babylonjs.com/features/occlusionquery
  51625. */
  51626. occlusionQueryAlgorithmType: number;
  51627. /**
  51628. * 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
  51629. * @see https://doc.babylonjs.com/features/occlusionquery
  51630. */
  51631. isOccluded: boolean;
  51632. /**
  51633. * Flag to check the progress status of the query
  51634. * @see https://doc.babylonjs.com/features/occlusionquery
  51635. */
  51636. isOcclusionQueryInProgress: boolean;
  51637. }
  51638. }
  51639. declare module BABYLON {
  51640. /** @hidden */
  51641. export var _forceTransformFeedbackToBundle: boolean;
  51642. interface Engine {
  51643. /**
  51644. * Creates a webGL transform feedback object
  51645. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  51646. * @returns the webGL transform feedback object
  51647. */
  51648. createTransformFeedback(): WebGLTransformFeedback;
  51649. /**
  51650. * Delete a webGL transform feedback object
  51651. * @param value defines the webGL transform feedback object to delete
  51652. */
  51653. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  51654. /**
  51655. * Bind a webGL transform feedback object to the webgl context
  51656. * @param value defines the webGL transform feedback object to bind
  51657. */
  51658. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  51659. /**
  51660. * Begins a transform feedback operation
  51661. * @param usePoints defines if points or triangles must be used
  51662. */
  51663. beginTransformFeedback(usePoints: boolean): void;
  51664. /**
  51665. * Ends a transform feedback operation
  51666. */
  51667. endTransformFeedback(): void;
  51668. /**
  51669. * Specify the varyings to use with transform feedback
  51670. * @param program defines the associated webGL program
  51671. * @param value defines the list of strings representing the varying names
  51672. */
  51673. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  51674. /**
  51675. * Bind a webGL buffer for a transform feedback operation
  51676. * @param value defines the webGL buffer to bind
  51677. */
  51678. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  51679. }
  51680. }
  51681. declare module BABYLON {
  51682. /**
  51683. * Class used to define an additional view for the engine
  51684. * @see https://doc.babylonjs.com/how_to/multi_canvases
  51685. */
  51686. export class EngineView {
  51687. /** Defines the canvas where to render the view */
  51688. target: HTMLCanvasElement;
  51689. /** Defines an optional camera used to render the view (will use active camera else) */
  51690. camera?: Camera;
  51691. }
  51692. interface Engine {
  51693. /**
  51694. * Gets or sets the HTML element to use for attaching events
  51695. */
  51696. inputElement: Nullable<HTMLElement>;
  51697. /**
  51698. * Gets the current engine view
  51699. * @see https://doc.babylonjs.com/how_to/multi_canvases
  51700. */
  51701. activeView: Nullable<EngineView>;
  51702. /** Gets or sets the list of views */
  51703. views: EngineView[];
  51704. /**
  51705. * Register a new child canvas
  51706. * @param canvas defines the canvas to register
  51707. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  51708. * @returns the associated view
  51709. */
  51710. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  51711. /**
  51712. * Remove a registered child canvas
  51713. * @param canvas defines the canvas to remove
  51714. * @returns the current engine
  51715. */
  51716. unRegisterView(canvas: HTMLCanvasElement): Engine;
  51717. }
  51718. }
  51719. declare module BABYLON {
  51720. interface Engine {
  51721. /** @hidden */
  51722. _excludedCompressedTextures: string[];
  51723. /** @hidden */
  51724. _textureFormatInUse: string;
  51725. /**
  51726. * Gets the list of texture formats supported
  51727. */
  51728. readonly texturesSupported: Array<string>;
  51729. /**
  51730. * Gets the texture format in use
  51731. */
  51732. readonly textureFormatInUse: Nullable<string>;
  51733. /**
  51734. * Set the compressed texture extensions or file names to skip.
  51735. *
  51736. * @param skippedFiles defines the list of those texture files you want to skip
  51737. * Example: [".dds", ".env", "myfile.png"]
  51738. */
  51739. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  51740. /**
  51741. * Set the compressed texture format to use, based on the formats you have, and the formats
  51742. * supported by the hardware / browser.
  51743. *
  51744. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  51745. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  51746. * to API arguments needed to compressed textures. This puts the burden on the container
  51747. * generator to house the arcane code for determining these for current & future formats.
  51748. *
  51749. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51750. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51751. *
  51752. * Note: The result of this call is not taken into account when a texture is base64.
  51753. *
  51754. * @param formatsAvailable defines the list of those format families you have created
  51755. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  51756. *
  51757. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  51758. * @returns The extension selected.
  51759. */
  51760. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  51761. }
  51762. }
  51763. declare module BABYLON {
  51764. /**
  51765. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  51766. */
  51767. export interface CubeMapInfo {
  51768. /**
  51769. * The pixel array for the front face.
  51770. * This is stored in format, left to right, up to down format.
  51771. */
  51772. front: Nullable<ArrayBufferView>;
  51773. /**
  51774. * The pixel array for the back face.
  51775. * This is stored in format, left to right, up to down format.
  51776. */
  51777. back: Nullable<ArrayBufferView>;
  51778. /**
  51779. * The pixel array for the left face.
  51780. * This is stored in format, left to right, up to down format.
  51781. */
  51782. left: Nullable<ArrayBufferView>;
  51783. /**
  51784. * The pixel array for the right face.
  51785. * This is stored in format, left to right, up to down format.
  51786. */
  51787. right: Nullable<ArrayBufferView>;
  51788. /**
  51789. * The pixel array for the up face.
  51790. * This is stored in format, left to right, up to down format.
  51791. */
  51792. up: Nullable<ArrayBufferView>;
  51793. /**
  51794. * The pixel array for the down face.
  51795. * This is stored in format, left to right, up to down format.
  51796. */
  51797. down: Nullable<ArrayBufferView>;
  51798. /**
  51799. * The size of the cubemap stored.
  51800. *
  51801. * Each faces will be size * size pixels.
  51802. */
  51803. size: number;
  51804. /**
  51805. * The format of the texture.
  51806. *
  51807. * RGBA, RGB.
  51808. */
  51809. format: number;
  51810. /**
  51811. * The type of the texture data.
  51812. *
  51813. * UNSIGNED_INT, FLOAT.
  51814. */
  51815. type: number;
  51816. /**
  51817. * Specifies whether the texture is in gamma space.
  51818. */
  51819. gammaSpace: boolean;
  51820. }
  51821. /**
  51822. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  51823. */
  51824. export class PanoramaToCubeMapTools {
  51825. private static FACE_LEFT;
  51826. private static FACE_RIGHT;
  51827. private static FACE_FRONT;
  51828. private static FACE_BACK;
  51829. private static FACE_DOWN;
  51830. private static FACE_UP;
  51831. /**
  51832. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  51833. *
  51834. * @param float32Array The source data.
  51835. * @param inputWidth The width of the input panorama.
  51836. * @param inputHeight The height of the input panorama.
  51837. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  51838. * @return The cubemap data
  51839. */
  51840. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  51841. private static CreateCubemapTexture;
  51842. private static CalcProjectionSpherical;
  51843. }
  51844. }
  51845. declare module BABYLON {
  51846. /**
  51847. * Helper class dealing with the extraction of spherical polynomial dataArray
  51848. * from a cube map.
  51849. */
  51850. export class CubeMapToSphericalPolynomialTools {
  51851. private static FileFaces;
  51852. /**
  51853. * Converts a texture to the according Spherical Polynomial data.
  51854. * This extracts the first 3 orders only as they are the only one used in the lighting.
  51855. *
  51856. * @param texture The texture to extract the information from.
  51857. * @return The Spherical Polynomial data.
  51858. */
  51859. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  51860. /**
  51861. * Converts a cubemap to the according Spherical Polynomial data.
  51862. * This extracts the first 3 orders only as they are the only one used in the lighting.
  51863. *
  51864. * @param cubeInfo The Cube map to extract the information from.
  51865. * @return The Spherical Polynomial data.
  51866. */
  51867. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  51868. }
  51869. }
  51870. declare module BABYLON {
  51871. interface BaseTexture {
  51872. /**
  51873. * Get the polynomial representation of the texture data.
  51874. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  51875. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  51876. */
  51877. sphericalPolynomial: Nullable<SphericalPolynomial>;
  51878. }
  51879. }
  51880. declare module BABYLON {
  51881. /** @hidden */
  51882. export var rgbdEncodePixelShader: {
  51883. name: string;
  51884. shader: string;
  51885. };
  51886. }
  51887. declare module BABYLON {
  51888. /** @hidden */
  51889. export var rgbdDecodePixelShader: {
  51890. name: string;
  51891. shader: string;
  51892. };
  51893. }
  51894. declare module BABYLON {
  51895. /**
  51896. * Raw texture data and descriptor sufficient for WebGL texture upload
  51897. */
  51898. export interface EnvironmentTextureInfo {
  51899. /**
  51900. * Version of the environment map
  51901. */
  51902. version: number;
  51903. /**
  51904. * Width of image
  51905. */
  51906. width: number;
  51907. /**
  51908. * Irradiance information stored in the file.
  51909. */
  51910. irradiance: any;
  51911. /**
  51912. * Specular information stored in the file.
  51913. */
  51914. specular: any;
  51915. }
  51916. /**
  51917. * Defines One Image in the file. It requires only the position in the file
  51918. * as well as the length.
  51919. */
  51920. interface BufferImageData {
  51921. /**
  51922. * Length of the image data.
  51923. */
  51924. length: number;
  51925. /**
  51926. * Position of the data from the null terminator delimiting the end of the JSON.
  51927. */
  51928. position: number;
  51929. }
  51930. /**
  51931. * Defines the specular data enclosed in the file.
  51932. * This corresponds to the version 1 of the data.
  51933. */
  51934. export interface EnvironmentTextureSpecularInfoV1 {
  51935. /**
  51936. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  51937. */
  51938. specularDataPosition?: number;
  51939. /**
  51940. * This contains all the images data needed to reconstruct the cubemap.
  51941. */
  51942. mipmaps: Array<BufferImageData>;
  51943. /**
  51944. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  51945. */
  51946. lodGenerationScale: number;
  51947. }
  51948. /**
  51949. * Sets of helpers addressing the serialization and deserialization of environment texture
  51950. * stored in a BabylonJS env file.
  51951. * Those files are usually stored as .env files.
  51952. */
  51953. export class EnvironmentTextureTools {
  51954. /**
  51955. * Magic number identifying the env file.
  51956. */
  51957. private static _MagicBytes;
  51958. /**
  51959. * Gets the environment info from an env file.
  51960. * @param data The array buffer containing the .env bytes.
  51961. * @returns the environment file info (the json header) if successfully parsed.
  51962. */
  51963. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  51964. /**
  51965. * Creates an environment texture from a loaded cube texture.
  51966. * @param texture defines the cube texture to convert in env file
  51967. * @return a promise containing the environment data if succesfull.
  51968. */
  51969. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  51970. /**
  51971. * Creates a JSON representation of the spherical data.
  51972. * @param texture defines the texture containing the polynomials
  51973. * @return the JSON representation of the spherical info
  51974. */
  51975. private static _CreateEnvTextureIrradiance;
  51976. /**
  51977. * Creates the ArrayBufferViews used for initializing environment texture image data.
  51978. * @param data the image data
  51979. * @param info parameters that determine what views will be created for accessing the underlying buffer
  51980. * @return the views described by info providing access to the underlying buffer
  51981. */
  51982. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  51983. /**
  51984. * Uploads the texture info contained in the env file to the GPU.
  51985. * @param texture defines the internal texture to upload to
  51986. * @param data defines the data to load
  51987. * @param info defines the texture info retrieved through the GetEnvInfo method
  51988. * @returns a promise
  51989. */
  51990. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  51991. private static _OnImageReadyAsync;
  51992. /**
  51993. * Uploads the levels of image data to the GPU.
  51994. * @param texture defines the internal texture to upload to
  51995. * @param imageData defines the array buffer views of image data [mipmap][face]
  51996. * @returns a promise
  51997. */
  51998. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  51999. /**
  52000. * Uploads spherical polynomials information to the texture.
  52001. * @param texture defines the texture we are trying to upload the information to
  52002. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  52003. */
  52004. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  52005. /** @hidden */
  52006. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52007. }
  52008. }
  52009. declare module BABYLON {
  52010. /**
  52011. * Class used to inline functions in shader code
  52012. */
  52013. export class ShaderCodeInliner {
  52014. private static readonly _RegexpFindFunctionNameAndType;
  52015. private _sourceCode;
  52016. private _functionDescr;
  52017. private _numMaxIterations;
  52018. /** Gets or sets the token used to mark the functions to inline */
  52019. inlineToken: string;
  52020. /** Gets or sets the debug mode */
  52021. debug: boolean;
  52022. /** Gets the code after the inlining process */
  52023. get code(): string;
  52024. /**
  52025. * Initializes the inliner
  52026. * @param sourceCode shader code source to inline
  52027. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  52028. */
  52029. constructor(sourceCode: string, numMaxIterations?: number);
  52030. /**
  52031. * Start the processing of the shader code
  52032. */
  52033. processCode(): void;
  52034. private _collectFunctions;
  52035. private _processInlining;
  52036. private _extractBetweenMarkers;
  52037. private _skipWhitespaces;
  52038. private _removeComments;
  52039. private _replaceFunctionCallsByCode;
  52040. private _findBackward;
  52041. private _escapeRegExp;
  52042. private _replaceNames;
  52043. }
  52044. }
  52045. declare module BABYLON {
  52046. /**
  52047. * Container for accessors for natively-stored mesh data buffers.
  52048. */
  52049. class NativeDataBuffer extends DataBuffer {
  52050. /**
  52051. * Accessor value used to identify/retrieve a natively-stored index buffer.
  52052. */
  52053. nativeIndexBuffer?: any;
  52054. /**
  52055. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  52056. */
  52057. nativeVertexBuffer?: any;
  52058. }
  52059. /** @hidden */
  52060. class NativeTexture extends InternalTexture {
  52061. getInternalTexture(): InternalTexture;
  52062. getViewCount(): number;
  52063. }
  52064. /** @hidden */
  52065. export class NativeEngine extends Engine {
  52066. private readonly _native;
  52067. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  52068. private readonly INVALID_HANDLE;
  52069. getHardwareScalingLevel(): number;
  52070. constructor();
  52071. dispose(): void;
  52072. /**
  52073. * Can be used to override the current requestAnimationFrame requester.
  52074. * @hidden
  52075. */
  52076. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  52077. /**
  52078. * Override default engine behavior.
  52079. * @param color
  52080. * @param backBuffer
  52081. * @param depth
  52082. * @param stencil
  52083. */
  52084. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  52085. /**
  52086. * Gets host document
  52087. * @returns the host document object
  52088. */
  52089. getHostDocument(): Nullable<Document>;
  52090. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52091. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  52092. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  52093. recordVertexArrayObject(vertexBuffers: {
  52094. [key: string]: VertexBuffer;
  52095. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  52096. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52097. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52098. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52099. /**
  52100. * Draw a list of indexed primitives
  52101. * @param fillMode defines the primitive to use
  52102. * @param indexStart defines the starting index
  52103. * @param indexCount defines the number of index to draw
  52104. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52105. */
  52106. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52107. /**
  52108. * Draw a list of unindexed primitives
  52109. * @param fillMode defines the primitive to use
  52110. * @param verticesStart defines the index of first vertex to draw
  52111. * @param verticesCount defines the count of vertices to draw
  52112. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52113. */
  52114. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52115. createPipelineContext(): IPipelineContext;
  52116. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  52117. /** @hidden */
  52118. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  52119. /** @hidden */
  52120. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  52121. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52122. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52123. protected _setProgram(program: WebGLProgram): void;
  52124. _releaseEffect(effect: Effect): void;
  52125. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  52126. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  52127. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  52128. bindSamplers(effect: Effect): void;
  52129. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  52130. getRenderWidth(useScreen?: boolean): number;
  52131. getRenderHeight(useScreen?: boolean): number;
  52132. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  52133. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52134. /**
  52135. * Set the z offset to apply to current rendering
  52136. * @param value defines the offset to apply
  52137. */
  52138. setZOffset(value: number): void;
  52139. /**
  52140. * Gets the current value of the zOffset
  52141. * @returns the current zOffset state
  52142. */
  52143. getZOffset(): number;
  52144. /**
  52145. * Enable or disable depth buffering
  52146. * @param enable defines the state to set
  52147. */
  52148. setDepthBuffer(enable: boolean): void;
  52149. /**
  52150. * Gets a boolean indicating if depth writing is enabled
  52151. * @returns the current depth writing state
  52152. */
  52153. getDepthWrite(): boolean;
  52154. /**
  52155. * Enable or disable depth writing
  52156. * @param enable defines the state to set
  52157. */
  52158. setDepthWrite(enable: boolean): void;
  52159. /**
  52160. * Enable or disable color writing
  52161. * @param enable defines the state to set
  52162. */
  52163. setColorWrite(enable: boolean): void;
  52164. /**
  52165. * Gets a boolean indicating if color writing is enabled
  52166. * @returns the current color writing state
  52167. */
  52168. getColorWrite(): boolean;
  52169. /**
  52170. * Sets alpha constants used by some alpha blending modes
  52171. * @param r defines the red component
  52172. * @param g defines the green component
  52173. * @param b defines the blue component
  52174. * @param a defines the alpha component
  52175. */
  52176. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  52177. /**
  52178. * Sets the current alpha mode
  52179. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  52180. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52181. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52182. */
  52183. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52184. /**
  52185. * Gets the current alpha mode
  52186. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52187. * @returns the current alpha mode
  52188. */
  52189. getAlphaMode(): number;
  52190. setInt(uniform: WebGLUniformLocation, int: number): void;
  52191. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  52192. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  52193. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  52194. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  52195. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  52196. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  52197. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  52198. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  52199. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  52200. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  52201. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  52202. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  52203. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  52204. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52205. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52206. setFloat(uniform: WebGLUniformLocation, value: number): void;
  52207. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  52208. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  52209. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  52210. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  52211. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  52212. wipeCaches(bruteForce?: boolean): void;
  52213. _createTexture(): WebGLTexture;
  52214. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  52215. /**
  52216. * Usually called from Texture.ts.
  52217. * Passed information to create a WebGLTexture
  52218. * @param url defines a value which contains one of the following:
  52219. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52220. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52221. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52222. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52223. * @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)
  52224. * @param scene needed for loading to the correct scene
  52225. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52226. * @param onLoad optional callback to be called upon successful completion
  52227. * @param onError optional callback to be called upon failure
  52228. * @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
  52229. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52230. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52231. * @param forcedExtension defines the extension to use to pick the right loader
  52232. * @param mimeType defines an optional mime type
  52233. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52234. */
  52235. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  52236. /**
  52237. * Creates a cube texture
  52238. * @param rootUrl defines the url where the files to load is located
  52239. * @param scene defines the current scene
  52240. * @param files defines the list of files to load (1 per face)
  52241. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  52242. * @param onLoad defines an optional callback raised when the texture is loaded
  52243. * @param onError defines an optional callback raised if there is an issue to load the texture
  52244. * @param format defines the format of the data
  52245. * @param forcedExtension defines the extension to use to pick the right loader
  52246. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  52247. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52248. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52249. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  52250. * @returns the cube texture as an InternalTexture
  52251. */
  52252. 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;
  52253. private _getSamplingFilter;
  52254. private static _GetNativeTextureFormat;
  52255. createRenderTargetTexture(size: number | {
  52256. width: number;
  52257. height: number;
  52258. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  52259. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52260. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52261. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52262. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  52263. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  52264. /**
  52265. * Updates a dynamic vertex buffer.
  52266. * @param vertexBuffer the vertex buffer to update
  52267. * @param data the data used to update the vertex buffer
  52268. * @param byteOffset the byte offset of the data (optional)
  52269. * @param byteLength the byte length of the data (optional)
  52270. */
  52271. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  52272. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  52273. private _updateAnisotropicLevel;
  52274. private _getAddressMode;
  52275. /** @hidden */
  52276. _bindTexture(channel: number, texture: InternalTexture): void;
  52277. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  52278. releaseEffects(): void;
  52279. /** @hidden */
  52280. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52281. /** @hidden */
  52282. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52283. /** @hidden */
  52284. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52285. /** @hidden */
  52286. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52287. }
  52288. }
  52289. declare module BABYLON {
  52290. /**
  52291. * Gather the list of clipboard event types as constants.
  52292. */
  52293. export class ClipboardEventTypes {
  52294. /**
  52295. * The clipboard event is fired when a copy command is active (pressed).
  52296. */
  52297. static readonly COPY: number;
  52298. /**
  52299. * The clipboard event is fired when a cut command is active (pressed).
  52300. */
  52301. static readonly CUT: number;
  52302. /**
  52303. * The clipboard event is fired when a paste command is active (pressed).
  52304. */
  52305. static readonly PASTE: number;
  52306. }
  52307. /**
  52308. * This class is used to store clipboard related info for the onClipboardObservable event.
  52309. */
  52310. export class ClipboardInfo {
  52311. /**
  52312. * Defines the type of event (BABYLON.ClipboardEventTypes)
  52313. */
  52314. type: number;
  52315. /**
  52316. * Defines the related dom event
  52317. */
  52318. event: ClipboardEvent;
  52319. /**
  52320. *Creates an instance of ClipboardInfo.
  52321. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  52322. * @param event Defines the related dom event
  52323. */
  52324. constructor(
  52325. /**
  52326. * Defines the type of event (BABYLON.ClipboardEventTypes)
  52327. */
  52328. type: number,
  52329. /**
  52330. * Defines the related dom event
  52331. */
  52332. event: ClipboardEvent);
  52333. /**
  52334. * Get the clipboard event's type from the keycode.
  52335. * @param keyCode Defines the keyCode for the current keyboard event.
  52336. * @return {number}
  52337. */
  52338. static GetTypeFromCharacter(keyCode: number): number;
  52339. }
  52340. }
  52341. declare module BABYLON {
  52342. /**
  52343. * Google Daydream controller
  52344. */
  52345. export class DaydreamController extends WebVRController {
  52346. /**
  52347. * Base Url for the controller model.
  52348. */
  52349. static MODEL_BASE_URL: string;
  52350. /**
  52351. * File name for the controller model.
  52352. */
  52353. static MODEL_FILENAME: string;
  52354. /**
  52355. * Gamepad Id prefix used to identify Daydream Controller.
  52356. */
  52357. static readonly GAMEPAD_ID_PREFIX: string;
  52358. /**
  52359. * Creates a new DaydreamController from a gamepad
  52360. * @param vrGamepad the gamepad that the controller should be created from
  52361. */
  52362. constructor(vrGamepad: any);
  52363. /**
  52364. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52365. * @param scene scene in which to add meshes
  52366. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52367. */
  52368. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52369. /**
  52370. * Called once for each button that changed state since the last frame
  52371. * @param buttonIdx Which button index changed
  52372. * @param state New state of the button
  52373. * @param changes Which properties on the state changed since last frame
  52374. */
  52375. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52376. }
  52377. }
  52378. declare module BABYLON {
  52379. /**
  52380. * Gear VR Controller
  52381. */
  52382. export class GearVRController extends WebVRController {
  52383. /**
  52384. * Base Url for the controller model.
  52385. */
  52386. static MODEL_BASE_URL: string;
  52387. /**
  52388. * File name for the controller model.
  52389. */
  52390. static MODEL_FILENAME: string;
  52391. /**
  52392. * Gamepad Id prefix used to identify this controller.
  52393. */
  52394. static readonly GAMEPAD_ID_PREFIX: string;
  52395. private readonly _buttonIndexToObservableNameMap;
  52396. /**
  52397. * Creates a new GearVRController from a gamepad
  52398. * @param vrGamepad the gamepad that the controller should be created from
  52399. */
  52400. constructor(vrGamepad: any);
  52401. /**
  52402. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52403. * @param scene scene in which to add meshes
  52404. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52405. */
  52406. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52407. /**
  52408. * Called once for each button that changed state since the last frame
  52409. * @param buttonIdx Which button index changed
  52410. * @param state New state of the button
  52411. * @param changes Which properties on the state changed since last frame
  52412. */
  52413. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52414. }
  52415. }
  52416. declare module BABYLON {
  52417. /**
  52418. * Generic Controller
  52419. */
  52420. export class GenericController extends WebVRController {
  52421. /**
  52422. * Base Url for the controller model.
  52423. */
  52424. static readonly MODEL_BASE_URL: string;
  52425. /**
  52426. * File name for the controller model.
  52427. */
  52428. static readonly MODEL_FILENAME: string;
  52429. /**
  52430. * Creates a new GenericController from a gamepad
  52431. * @param vrGamepad the gamepad that the controller should be created from
  52432. */
  52433. constructor(vrGamepad: any);
  52434. /**
  52435. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52436. * @param scene scene in which to add meshes
  52437. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52438. */
  52439. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52440. /**
  52441. * Called once for each button that changed state since the last frame
  52442. * @param buttonIdx Which button index changed
  52443. * @param state New state of the button
  52444. * @param changes Which properties on the state changed since last frame
  52445. */
  52446. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52447. }
  52448. }
  52449. declare module BABYLON {
  52450. /**
  52451. * Oculus Touch Controller
  52452. */
  52453. export class OculusTouchController extends WebVRController {
  52454. /**
  52455. * Base Url for the controller model.
  52456. */
  52457. static MODEL_BASE_URL: string;
  52458. /**
  52459. * File name for the left controller model.
  52460. */
  52461. static MODEL_LEFT_FILENAME: string;
  52462. /**
  52463. * File name for the right controller model.
  52464. */
  52465. static MODEL_RIGHT_FILENAME: string;
  52466. /**
  52467. * Base Url for the Quest controller model.
  52468. */
  52469. static QUEST_MODEL_BASE_URL: string;
  52470. /**
  52471. * @hidden
  52472. * If the controllers are running on a device that needs the updated Quest controller models
  52473. */
  52474. static _IsQuest: boolean;
  52475. /**
  52476. * Fired when the secondary trigger on this controller is modified
  52477. */
  52478. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  52479. /**
  52480. * Fired when the thumb rest on this controller is modified
  52481. */
  52482. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  52483. /**
  52484. * Creates a new OculusTouchController from a gamepad
  52485. * @param vrGamepad the gamepad that the controller should be created from
  52486. */
  52487. constructor(vrGamepad: any);
  52488. /**
  52489. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52490. * @param scene scene in which to add meshes
  52491. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52492. */
  52493. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52494. /**
  52495. * Fired when the A button on this controller is modified
  52496. */
  52497. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52498. /**
  52499. * Fired when the B button on this controller is modified
  52500. */
  52501. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52502. /**
  52503. * Fired when the X button on this controller is modified
  52504. */
  52505. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52506. /**
  52507. * Fired when the Y button on this controller is modified
  52508. */
  52509. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52510. /**
  52511. * Called once for each button that changed state since the last frame
  52512. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  52513. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  52514. * 2) secondary trigger (same)
  52515. * 3) A (right) X (left), touch, pressed = value
  52516. * 4) B / Y
  52517. * 5) thumb rest
  52518. * @param buttonIdx Which button index changed
  52519. * @param state New state of the button
  52520. * @param changes Which properties on the state changed since last frame
  52521. */
  52522. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52523. }
  52524. }
  52525. declare module BABYLON {
  52526. /**
  52527. * Vive Controller
  52528. */
  52529. export class ViveController extends WebVRController {
  52530. /**
  52531. * Base Url for the controller model.
  52532. */
  52533. static MODEL_BASE_URL: string;
  52534. /**
  52535. * File name for the controller model.
  52536. */
  52537. static MODEL_FILENAME: string;
  52538. /**
  52539. * Creates a new ViveController from a gamepad
  52540. * @param vrGamepad the gamepad that the controller should be created from
  52541. */
  52542. constructor(vrGamepad: any);
  52543. /**
  52544. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52545. * @param scene scene in which to add meshes
  52546. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52547. */
  52548. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52549. /**
  52550. * Fired when the left button on this controller is modified
  52551. */
  52552. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52553. /**
  52554. * Fired when the right button on this controller is modified
  52555. */
  52556. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52557. /**
  52558. * Fired when the menu button on this controller is modified
  52559. */
  52560. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52561. /**
  52562. * Called once for each button that changed state since the last frame
  52563. * Vive mapping:
  52564. * 0: touchpad
  52565. * 1: trigger
  52566. * 2: left AND right buttons
  52567. * 3: menu button
  52568. * @param buttonIdx Which button index changed
  52569. * @param state New state of the button
  52570. * @param changes Which properties on the state changed since last frame
  52571. */
  52572. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52573. }
  52574. }
  52575. declare module BABYLON {
  52576. /**
  52577. * Defines the WindowsMotionController object that the state of the windows motion controller
  52578. */
  52579. export class WindowsMotionController extends WebVRController {
  52580. /**
  52581. * The base url used to load the left and right controller models
  52582. */
  52583. static MODEL_BASE_URL: string;
  52584. /**
  52585. * The name of the left controller model file
  52586. */
  52587. static MODEL_LEFT_FILENAME: string;
  52588. /**
  52589. * The name of the right controller model file
  52590. */
  52591. static MODEL_RIGHT_FILENAME: string;
  52592. /**
  52593. * The controller name prefix for this controller type
  52594. */
  52595. static readonly GAMEPAD_ID_PREFIX: string;
  52596. /**
  52597. * The controller id pattern for this controller type
  52598. */
  52599. private static readonly GAMEPAD_ID_PATTERN;
  52600. private _loadedMeshInfo;
  52601. protected readonly _mapping: {
  52602. buttons: string[];
  52603. buttonMeshNames: {
  52604. trigger: string;
  52605. menu: string;
  52606. grip: string;
  52607. thumbstick: string;
  52608. trackpad: string;
  52609. };
  52610. buttonObservableNames: {
  52611. trigger: string;
  52612. menu: string;
  52613. grip: string;
  52614. thumbstick: string;
  52615. trackpad: string;
  52616. };
  52617. axisMeshNames: string[];
  52618. pointingPoseMeshName: string;
  52619. };
  52620. /**
  52621. * Fired when the trackpad on this controller is clicked
  52622. */
  52623. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  52624. /**
  52625. * Fired when the trackpad on this controller is modified
  52626. */
  52627. onTrackpadValuesChangedObservable: Observable<StickValues>;
  52628. /**
  52629. * The current x and y values of this controller's trackpad
  52630. */
  52631. trackpad: StickValues;
  52632. /**
  52633. * Creates a new WindowsMotionController from a gamepad
  52634. * @param vrGamepad the gamepad that the controller should be created from
  52635. */
  52636. constructor(vrGamepad: any);
  52637. /**
  52638. * Fired when the trigger on this controller is modified
  52639. */
  52640. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52641. /**
  52642. * Fired when the menu button on this controller is modified
  52643. */
  52644. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52645. /**
  52646. * Fired when the grip button on this controller is modified
  52647. */
  52648. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52649. /**
  52650. * Fired when the thumbstick button on this controller is modified
  52651. */
  52652. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52653. /**
  52654. * Fired when the touchpad button on this controller is modified
  52655. */
  52656. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52657. /**
  52658. * Fired when the touchpad values on this controller are modified
  52659. */
  52660. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  52661. protected _updateTrackpad(): void;
  52662. /**
  52663. * Called once per frame by the engine.
  52664. */
  52665. update(): void;
  52666. /**
  52667. * Called once for each button that changed state since the last frame
  52668. * @param buttonIdx Which button index changed
  52669. * @param state New state of the button
  52670. * @param changes Which properties on the state changed since last frame
  52671. */
  52672. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52673. /**
  52674. * Moves the buttons on the controller mesh based on their current state
  52675. * @param buttonName the name of the button to move
  52676. * @param buttonValue the value of the button which determines the buttons new position
  52677. */
  52678. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  52679. /**
  52680. * Moves the axis on the controller mesh based on its current state
  52681. * @param axis the index of the axis
  52682. * @param axisValue the value of the axis which determines the meshes new position
  52683. * @hidden
  52684. */
  52685. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  52686. /**
  52687. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52688. * @param scene scene in which to add meshes
  52689. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52690. */
  52691. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  52692. /**
  52693. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  52694. * can be transformed by button presses and axes values, based on this._mapping.
  52695. *
  52696. * @param scene scene in which the meshes exist
  52697. * @param meshes list of meshes that make up the controller model to process
  52698. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  52699. */
  52700. private processModel;
  52701. private createMeshInfo;
  52702. /**
  52703. * Gets the ray of the controller in the direction the controller is pointing
  52704. * @param length the length the resulting ray should be
  52705. * @returns a ray in the direction the controller is pointing
  52706. */
  52707. getForwardRay(length?: number): Ray;
  52708. /**
  52709. * Disposes of the controller
  52710. */
  52711. dispose(): void;
  52712. }
  52713. /**
  52714. * This class represents a new windows motion controller in XR.
  52715. */
  52716. export class XRWindowsMotionController extends WindowsMotionController {
  52717. /**
  52718. * Changing the original WIndowsMotionController mapping to fir the new mapping
  52719. */
  52720. protected readonly _mapping: {
  52721. buttons: string[];
  52722. buttonMeshNames: {
  52723. trigger: string;
  52724. menu: string;
  52725. grip: string;
  52726. thumbstick: string;
  52727. trackpad: string;
  52728. };
  52729. buttonObservableNames: {
  52730. trigger: string;
  52731. menu: string;
  52732. grip: string;
  52733. thumbstick: string;
  52734. trackpad: string;
  52735. };
  52736. axisMeshNames: string[];
  52737. pointingPoseMeshName: string;
  52738. };
  52739. /**
  52740. * Construct a new XR-Based windows motion controller
  52741. *
  52742. * @param gamepadInfo the gamepad object from the browser
  52743. */
  52744. constructor(gamepadInfo: any);
  52745. /**
  52746. * holds the thumbstick values (X,Y)
  52747. */
  52748. thumbstickValues: StickValues;
  52749. /**
  52750. * Fired when the thumbstick on this controller is clicked
  52751. */
  52752. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  52753. /**
  52754. * Fired when the thumbstick on this controller is modified
  52755. */
  52756. onThumbstickValuesChangedObservable: Observable<StickValues>;
  52757. /**
  52758. * Fired when the touchpad button on this controller is modified
  52759. */
  52760. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  52761. /**
  52762. * Fired when the touchpad values on this controller are modified
  52763. */
  52764. onTrackpadValuesChangedObservable: Observable<StickValues>;
  52765. /**
  52766. * Fired when the thumbstick button on this controller is modified
  52767. * here to prevent breaking changes
  52768. */
  52769. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52770. /**
  52771. * updating the thumbstick(!) and not the trackpad.
  52772. * This is named this way due to the difference between WebVR and XR and to avoid
  52773. * changing the parent class.
  52774. */
  52775. protected _updateTrackpad(): void;
  52776. /**
  52777. * Disposes the class with joy
  52778. */
  52779. dispose(): void;
  52780. }
  52781. }
  52782. declare module BABYLON {
  52783. /**
  52784. * Class containing static functions to help procedurally build meshes
  52785. */
  52786. export class PolyhedronBuilder {
  52787. /**
  52788. * Creates a polyhedron mesh
  52789. * * 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
  52790. * * The parameter `size` (positive float, default 1) sets the polygon size
  52791. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  52792. * * 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`
  52793. * * 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
  52794. * * 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)`)
  52795. * * 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
  52796. * * 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
  52797. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52798. * * 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
  52799. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52800. * @param name defines the name of the mesh
  52801. * @param options defines the options used to create the mesh
  52802. * @param scene defines the hosting scene
  52803. * @returns the polyhedron mesh
  52804. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  52805. */
  52806. static CreatePolyhedron(name: string, options: {
  52807. type?: number;
  52808. size?: number;
  52809. sizeX?: number;
  52810. sizeY?: number;
  52811. sizeZ?: number;
  52812. custom?: any;
  52813. faceUV?: Vector4[];
  52814. faceColors?: Color4[];
  52815. flat?: boolean;
  52816. updatable?: boolean;
  52817. sideOrientation?: number;
  52818. frontUVs?: Vector4;
  52819. backUVs?: Vector4;
  52820. }, scene?: Nullable<Scene>): Mesh;
  52821. }
  52822. }
  52823. declare module BABYLON {
  52824. /**
  52825. * Gizmo that enables scaling a mesh along 3 axis
  52826. */
  52827. export class ScaleGizmo extends Gizmo {
  52828. /**
  52829. * Internal gizmo used for interactions on the x axis
  52830. */
  52831. xGizmo: AxisScaleGizmo;
  52832. /**
  52833. * Internal gizmo used for interactions on the y axis
  52834. */
  52835. yGizmo: AxisScaleGizmo;
  52836. /**
  52837. * Internal gizmo used for interactions on the z axis
  52838. */
  52839. zGizmo: AxisScaleGizmo;
  52840. /**
  52841. * Internal gizmo used to scale all axis equally
  52842. */
  52843. uniformScaleGizmo: AxisScaleGizmo;
  52844. private _meshAttached;
  52845. private _nodeAttached;
  52846. private _updateGizmoRotationToMatchAttachedMesh;
  52847. private _snapDistance;
  52848. private _scaleRatio;
  52849. private _uniformScalingMesh;
  52850. private _octahedron;
  52851. private _sensitivity;
  52852. /** Fires an event when any of it's sub gizmos are dragged */
  52853. onDragStartObservable: Observable<unknown>;
  52854. /** Fires an event when any of it's sub gizmos are released from dragging */
  52855. onDragEndObservable: Observable<unknown>;
  52856. get attachedMesh(): Nullable<AbstractMesh>;
  52857. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52858. get attachedNode(): Nullable<Node>;
  52859. set attachedNode(node: Nullable<Node>);
  52860. /**
  52861. * Creates a ScaleGizmo
  52862. * @param gizmoLayer The utility layer the gizmo will be added to
  52863. * @param thickness display gizmo axis thickness
  52864. */
  52865. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  52866. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52867. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52868. /**
  52869. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52870. */
  52871. set snapDistance(value: number);
  52872. get snapDistance(): number;
  52873. /**
  52874. * Ratio for the scale of the gizmo (Default: 1)
  52875. */
  52876. set scaleRatio(value: number);
  52877. get scaleRatio(): number;
  52878. /**
  52879. * Sensitivity factor for dragging (Default: 1)
  52880. */
  52881. set sensitivity(value: number);
  52882. get sensitivity(): number;
  52883. /**
  52884. * Disposes of the gizmo
  52885. */
  52886. dispose(): void;
  52887. }
  52888. }
  52889. declare module BABYLON {
  52890. /**
  52891. * Single axis scale gizmo
  52892. */
  52893. export class AxisScaleGizmo extends Gizmo {
  52894. /**
  52895. * Drag behavior responsible for the gizmos dragging interactions
  52896. */
  52897. dragBehavior: PointerDragBehavior;
  52898. private _pointerObserver;
  52899. /**
  52900. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52901. */
  52902. snapDistance: number;
  52903. /**
  52904. * Event that fires each time the gizmo snaps to a new location.
  52905. * * snapDistance is the the change in distance
  52906. */
  52907. onSnapObservable: Observable<{
  52908. snapDistance: number;
  52909. }>;
  52910. /**
  52911. * If the scaling operation should be done on all axis (default: false)
  52912. */
  52913. uniformScaling: boolean;
  52914. /**
  52915. * Custom sensitivity value for the drag strength
  52916. */
  52917. sensitivity: number;
  52918. private _isEnabled;
  52919. private _parent;
  52920. private _arrow;
  52921. private _coloredMaterial;
  52922. private _hoverMaterial;
  52923. /**
  52924. * Creates an AxisScaleGizmo
  52925. * @param gizmoLayer The utility layer the gizmo will be added to
  52926. * @param dragAxis The axis which the gizmo will be able to scale on
  52927. * @param color The color of the gizmo
  52928. * @param thickness display gizmo axis thickness
  52929. */
  52930. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  52931. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52932. /**
  52933. * If the gizmo is enabled
  52934. */
  52935. set isEnabled(value: boolean);
  52936. get isEnabled(): boolean;
  52937. /**
  52938. * Disposes of the gizmo
  52939. */
  52940. dispose(): void;
  52941. /**
  52942. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52943. * @param mesh The mesh to replace the default mesh of the gizmo
  52944. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  52945. */
  52946. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  52947. }
  52948. }
  52949. declare module BABYLON {
  52950. /**
  52951. * Bounding box gizmo
  52952. */
  52953. export class BoundingBoxGizmo extends Gizmo {
  52954. private _lineBoundingBox;
  52955. private _rotateSpheresParent;
  52956. private _scaleBoxesParent;
  52957. private _boundingDimensions;
  52958. private _renderObserver;
  52959. private _pointerObserver;
  52960. private _scaleDragSpeed;
  52961. private _tmpQuaternion;
  52962. private _tmpVector;
  52963. private _tmpRotationMatrix;
  52964. /**
  52965. * 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)
  52966. */
  52967. ignoreChildren: boolean;
  52968. /**
  52969. * 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)
  52970. */
  52971. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  52972. /**
  52973. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  52974. */
  52975. rotationSphereSize: number;
  52976. /**
  52977. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  52978. */
  52979. scaleBoxSize: number;
  52980. /**
  52981. * 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)
  52982. */
  52983. fixedDragMeshScreenSize: boolean;
  52984. /**
  52985. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  52986. */
  52987. fixedDragMeshScreenSizeDistanceFactor: number;
  52988. /**
  52989. * Fired when a rotation sphere or scale box is dragged
  52990. */
  52991. onDragStartObservable: Observable<{}>;
  52992. /**
  52993. * Fired when a scale box is dragged
  52994. */
  52995. onScaleBoxDragObservable: Observable<{}>;
  52996. /**
  52997. * Fired when a scale box drag is ended
  52998. */
  52999. onScaleBoxDragEndObservable: Observable<{}>;
  53000. /**
  53001. * Fired when a rotation sphere is dragged
  53002. */
  53003. onRotationSphereDragObservable: Observable<{}>;
  53004. /**
  53005. * Fired when a rotation sphere drag is ended
  53006. */
  53007. onRotationSphereDragEndObservable: Observable<{}>;
  53008. /**
  53009. * 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)
  53010. */
  53011. scalePivot: Nullable<Vector3>;
  53012. /**
  53013. * Mesh used as a pivot to rotate the attached node
  53014. */
  53015. private _anchorMesh;
  53016. private _existingMeshScale;
  53017. private _dragMesh;
  53018. private pointerDragBehavior;
  53019. private coloredMaterial;
  53020. private hoverColoredMaterial;
  53021. /**
  53022. * Sets the color of the bounding box gizmo
  53023. * @param color the color to set
  53024. */
  53025. setColor(color: Color3): void;
  53026. /**
  53027. * Creates an BoundingBoxGizmo
  53028. * @param gizmoLayer The utility layer the gizmo will be added to
  53029. * @param color The color of the gizmo
  53030. */
  53031. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  53032. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  53033. private _selectNode;
  53034. /**
  53035. * Updates the bounding box information for the Gizmo
  53036. */
  53037. updateBoundingBox(): void;
  53038. private _updateRotationSpheres;
  53039. private _updateScaleBoxes;
  53040. /**
  53041. * Enables rotation on the specified axis and disables rotation on the others
  53042. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  53043. */
  53044. setEnabledRotationAxis(axis: string): void;
  53045. /**
  53046. * Enables/disables scaling
  53047. * @param enable if scaling should be enabled
  53048. * @param homogeneousScaling defines if scaling should only be homogeneous
  53049. */
  53050. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  53051. private _updateDummy;
  53052. /**
  53053. * Enables a pointer drag behavior on the bounding box of the gizmo
  53054. */
  53055. enableDragBehavior(): void;
  53056. /**
  53057. * Disposes of the gizmo
  53058. */
  53059. dispose(): void;
  53060. /**
  53061. * 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)
  53062. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  53063. * @returns the bounding box mesh with the passed in mesh as a child
  53064. */
  53065. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  53066. /**
  53067. * CustomMeshes are not supported by this gizmo
  53068. * @param mesh The mesh to replace the default mesh of the gizmo
  53069. */
  53070. setCustomMesh(mesh: Mesh): void;
  53071. }
  53072. }
  53073. declare module BABYLON {
  53074. /**
  53075. * Single plane rotation gizmo
  53076. */
  53077. export class PlaneRotationGizmo extends Gizmo {
  53078. /**
  53079. * Drag behavior responsible for the gizmos dragging interactions
  53080. */
  53081. dragBehavior: PointerDragBehavior;
  53082. private _pointerObserver;
  53083. /**
  53084. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  53085. */
  53086. snapDistance: number;
  53087. /**
  53088. * Event that fires each time the gizmo snaps to a new location.
  53089. * * snapDistance is the the change in distance
  53090. */
  53091. onSnapObservable: Observable<{
  53092. snapDistance: number;
  53093. }>;
  53094. private _isEnabled;
  53095. private _parent;
  53096. /**
  53097. * Creates a PlaneRotationGizmo
  53098. * @param gizmoLayer The utility layer the gizmo will be added to
  53099. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  53100. * @param color The color of the gizmo
  53101. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53102. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53103. * @param thickness display gizmo axis thickness
  53104. */
  53105. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  53106. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53107. /**
  53108. * If the gizmo is enabled
  53109. */
  53110. set isEnabled(value: boolean);
  53111. get isEnabled(): boolean;
  53112. /**
  53113. * Disposes of the gizmo
  53114. */
  53115. dispose(): void;
  53116. }
  53117. }
  53118. declare module BABYLON {
  53119. /**
  53120. * Gizmo that enables rotating a mesh along 3 axis
  53121. */
  53122. export class RotationGizmo extends Gizmo {
  53123. /**
  53124. * Internal gizmo used for interactions on the x axis
  53125. */
  53126. xGizmo: PlaneRotationGizmo;
  53127. /**
  53128. * Internal gizmo used for interactions on the y axis
  53129. */
  53130. yGizmo: PlaneRotationGizmo;
  53131. /**
  53132. * Internal gizmo used for interactions on the z axis
  53133. */
  53134. zGizmo: PlaneRotationGizmo;
  53135. /** Fires an event when any of it's sub gizmos are dragged */
  53136. onDragStartObservable: Observable<unknown>;
  53137. /** Fires an event when any of it's sub gizmos are released from dragging */
  53138. onDragEndObservable: Observable<unknown>;
  53139. private _meshAttached;
  53140. private _nodeAttached;
  53141. get attachedMesh(): Nullable<AbstractMesh>;
  53142. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53143. get attachedNode(): Nullable<Node>;
  53144. set attachedNode(node: Nullable<Node>);
  53145. /**
  53146. * Creates a RotationGizmo
  53147. * @param gizmoLayer The utility layer the gizmo will be added to
  53148. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53149. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53150. * @param thickness display gizmo axis thickness
  53151. */
  53152. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  53153. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53154. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53155. /**
  53156. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53157. */
  53158. set snapDistance(value: number);
  53159. get snapDistance(): number;
  53160. /**
  53161. * Ratio for the scale of the gizmo (Default: 1)
  53162. */
  53163. set scaleRatio(value: number);
  53164. get scaleRatio(): number;
  53165. /**
  53166. * Disposes of the gizmo
  53167. */
  53168. dispose(): void;
  53169. /**
  53170. * CustomMeshes are not supported by this gizmo
  53171. * @param mesh The mesh to replace the default mesh of the gizmo
  53172. */
  53173. setCustomMesh(mesh: Mesh): void;
  53174. }
  53175. }
  53176. declare module BABYLON {
  53177. /**
  53178. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  53179. */
  53180. export class GizmoManager implements IDisposable {
  53181. private scene;
  53182. /**
  53183. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  53184. */
  53185. gizmos: {
  53186. positionGizmo: Nullable<PositionGizmo>;
  53187. rotationGizmo: Nullable<RotationGizmo>;
  53188. scaleGizmo: Nullable<ScaleGizmo>;
  53189. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  53190. };
  53191. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  53192. clearGizmoOnEmptyPointerEvent: boolean;
  53193. /** Fires an event when the manager is attached to a mesh */
  53194. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  53195. private _gizmosEnabled;
  53196. private _pointerObserver;
  53197. private _attachedMesh;
  53198. private _boundingBoxColor;
  53199. private _defaultUtilityLayer;
  53200. private _defaultKeepDepthUtilityLayer;
  53201. private _thickness;
  53202. /**
  53203. * When bounding box gizmo is enabled, this can be used to track drag/end events
  53204. */
  53205. boundingBoxDragBehavior: SixDofDragBehavior;
  53206. /**
  53207. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  53208. */
  53209. attachableMeshes: Nullable<Array<AbstractMesh>>;
  53210. /**
  53211. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  53212. */
  53213. usePointerToAttachGizmos: boolean;
  53214. /**
  53215. * Utility layer that the bounding box gizmo belongs to
  53216. */
  53217. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  53218. /**
  53219. * Utility layer that all gizmos besides bounding box belong to
  53220. */
  53221. get utilityLayer(): UtilityLayerRenderer;
  53222. /**
  53223. * Instatiates a gizmo manager
  53224. * @param scene the scene to overlay the gizmos on top of
  53225. * @param thickness display gizmo axis thickness
  53226. */
  53227. constructor(scene: Scene, thickness?: number);
  53228. /**
  53229. * Attaches a set of gizmos to the specified mesh
  53230. * @param mesh The mesh the gizmo's should be attached to
  53231. */
  53232. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53233. /**
  53234. * If the position gizmo is enabled
  53235. */
  53236. set positionGizmoEnabled(value: boolean);
  53237. get positionGizmoEnabled(): boolean;
  53238. /**
  53239. * If the rotation gizmo is enabled
  53240. */
  53241. set rotationGizmoEnabled(value: boolean);
  53242. get rotationGizmoEnabled(): boolean;
  53243. /**
  53244. * If the scale gizmo is enabled
  53245. */
  53246. set scaleGizmoEnabled(value: boolean);
  53247. get scaleGizmoEnabled(): boolean;
  53248. /**
  53249. * If the boundingBox gizmo is enabled
  53250. */
  53251. set boundingBoxGizmoEnabled(value: boolean);
  53252. get boundingBoxGizmoEnabled(): boolean;
  53253. /**
  53254. * Disposes of the gizmo manager
  53255. */
  53256. dispose(): void;
  53257. }
  53258. }
  53259. declare module BABYLON {
  53260. /**
  53261. * A directional light is defined by a direction (what a surprise!).
  53262. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  53263. * 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.
  53264. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53265. */
  53266. export class DirectionalLight extends ShadowLight {
  53267. private _shadowFrustumSize;
  53268. /**
  53269. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  53270. */
  53271. get shadowFrustumSize(): number;
  53272. /**
  53273. * Specifies a fix frustum size for the shadow generation.
  53274. */
  53275. set shadowFrustumSize(value: number);
  53276. private _shadowOrthoScale;
  53277. /**
  53278. * Gets the shadow projection scale against the optimal computed one.
  53279. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  53280. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  53281. */
  53282. get shadowOrthoScale(): number;
  53283. /**
  53284. * Sets the shadow projection scale against the optimal computed one.
  53285. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  53286. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  53287. */
  53288. set shadowOrthoScale(value: number);
  53289. /**
  53290. * Automatically compute the projection matrix to best fit (including all the casters)
  53291. * on each frame.
  53292. */
  53293. autoUpdateExtends: boolean;
  53294. /**
  53295. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  53296. * on each frame. autoUpdateExtends must be set to true for this to work
  53297. */
  53298. autoCalcShadowZBounds: boolean;
  53299. private _orthoLeft;
  53300. private _orthoRight;
  53301. private _orthoTop;
  53302. private _orthoBottom;
  53303. /**
  53304. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  53305. * The directional light is emitted from everywhere in the given direction.
  53306. * It can cast shadows.
  53307. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53308. * @param name The friendly name of the light
  53309. * @param direction The direction of the light
  53310. * @param scene The scene the light belongs to
  53311. */
  53312. constructor(name: string, direction: Vector3, scene: Scene);
  53313. /**
  53314. * Returns the string "DirectionalLight".
  53315. * @return The class name
  53316. */
  53317. getClassName(): string;
  53318. /**
  53319. * Returns the integer 1.
  53320. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53321. */
  53322. getTypeID(): number;
  53323. /**
  53324. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  53325. * Returns the DirectionalLight Shadow projection matrix.
  53326. */
  53327. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53328. /**
  53329. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  53330. * Returns the DirectionalLight Shadow projection matrix.
  53331. */
  53332. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  53333. /**
  53334. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  53335. * Returns the DirectionalLight Shadow projection matrix.
  53336. */
  53337. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53338. protected _buildUniformLayout(): void;
  53339. /**
  53340. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  53341. * @param effect The effect to update
  53342. * @param lightIndex The index of the light in the effect to update
  53343. * @returns The directional light
  53344. */
  53345. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  53346. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  53347. /**
  53348. * Gets the minZ used for shadow according to both the scene and the light.
  53349. *
  53350. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  53351. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  53352. * @param activeCamera The camera we are returning the min for
  53353. * @returns the depth min z
  53354. */
  53355. getDepthMinZ(activeCamera: Camera): number;
  53356. /**
  53357. * Gets the maxZ used for shadow according to both the scene and the light.
  53358. *
  53359. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  53360. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  53361. * @param activeCamera The camera we are returning the max for
  53362. * @returns the depth max z
  53363. */
  53364. getDepthMaxZ(activeCamera: Camera): number;
  53365. /**
  53366. * Prepares the list of defines specific to the light type.
  53367. * @param defines the list of defines
  53368. * @param lightIndex defines the index of the light for the effect
  53369. */
  53370. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53371. }
  53372. }
  53373. declare module BABYLON {
  53374. /**
  53375. * Class containing static functions to help procedurally build meshes
  53376. */
  53377. export class HemisphereBuilder {
  53378. /**
  53379. * Creates a hemisphere mesh
  53380. * @param name defines the name of the mesh
  53381. * @param options defines the options used to create the mesh
  53382. * @param scene defines the hosting scene
  53383. * @returns the hemisphere mesh
  53384. */
  53385. static CreateHemisphere(name: string, options: {
  53386. segments?: number;
  53387. diameter?: number;
  53388. sideOrientation?: number;
  53389. }, scene: any): Mesh;
  53390. }
  53391. }
  53392. declare module BABYLON {
  53393. /**
  53394. * A spot light is defined by a position, a direction, an angle, and an exponent.
  53395. * These values define a cone of light starting from the position, emitting toward the direction.
  53396. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  53397. * and the exponent defines the speed of the decay of the light with distance (reach).
  53398. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53399. */
  53400. export class SpotLight extends ShadowLight {
  53401. private _angle;
  53402. private _innerAngle;
  53403. private _cosHalfAngle;
  53404. private _lightAngleScale;
  53405. private _lightAngleOffset;
  53406. /**
  53407. * Gets the cone angle of the spot light in Radians.
  53408. */
  53409. get angle(): number;
  53410. /**
  53411. * Sets the cone angle of the spot light in Radians.
  53412. */
  53413. set angle(value: number);
  53414. /**
  53415. * Only used in gltf falloff mode, this defines the angle where
  53416. * the directional falloff will start before cutting at angle which could be seen
  53417. * as outer angle.
  53418. */
  53419. get innerAngle(): number;
  53420. /**
  53421. * Only used in gltf falloff mode, this defines the angle where
  53422. * the directional falloff will start before cutting at angle which could be seen
  53423. * as outer angle.
  53424. */
  53425. set innerAngle(value: number);
  53426. private _shadowAngleScale;
  53427. /**
  53428. * Allows scaling the angle of the light for shadow generation only.
  53429. */
  53430. get shadowAngleScale(): number;
  53431. /**
  53432. * Allows scaling the angle of the light for shadow generation only.
  53433. */
  53434. set shadowAngleScale(value: number);
  53435. /**
  53436. * The light decay speed with the distance from the emission spot.
  53437. */
  53438. exponent: number;
  53439. private _projectionTextureMatrix;
  53440. /**
  53441. * Allows reading the projecton texture
  53442. */
  53443. get projectionTextureMatrix(): Matrix;
  53444. protected _projectionTextureLightNear: number;
  53445. /**
  53446. * Gets the near clip of the Spotlight for texture projection.
  53447. */
  53448. get projectionTextureLightNear(): number;
  53449. /**
  53450. * Sets the near clip of the Spotlight for texture projection.
  53451. */
  53452. set projectionTextureLightNear(value: number);
  53453. protected _projectionTextureLightFar: number;
  53454. /**
  53455. * Gets the far clip of the Spotlight for texture projection.
  53456. */
  53457. get projectionTextureLightFar(): number;
  53458. /**
  53459. * Sets the far clip of the Spotlight for texture projection.
  53460. */
  53461. set projectionTextureLightFar(value: number);
  53462. protected _projectionTextureUpDirection: Vector3;
  53463. /**
  53464. * Gets the Up vector of the Spotlight for texture projection.
  53465. */
  53466. get projectionTextureUpDirection(): Vector3;
  53467. /**
  53468. * Sets the Up vector of the Spotlight for texture projection.
  53469. */
  53470. set projectionTextureUpDirection(value: Vector3);
  53471. private _projectionTexture;
  53472. /**
  53473. * Gets the projection texture of the light.
  53474. */
  53475. get projectionTexture(): Nullable<BaseTexture>;
  53476. /**
  53477. * Sets the projection texture of the light.
  53478. */
  53479. set projectionTexture(value: Nullable<BaseTexture>);
  53480. private _projectionTextureViewLightDirty;
  53481. private _projectionTextureProjectionLightDirty;
  53482. private _projectionTextureDirty;
  53483. private _projectionTextureViewTargetVector;
  53484. private _projectionTextureViewLightMatrix;
  53485. private _projectionTextureProjectionLightMatrix;
  53486. private _projectionTextureScalingMatrix;
  53487. /**
  53488. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  53489. * It can cast shadows.
  53490. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53491. * @param name The light friendly name
  53492. * @param position The position of the spot light in the scene
  53493. * @param direction The direction of the light in the scene
  53494. * @param angle The cone angle of the light in Radians
  53495. * @param exponent The light decay speed with the distance from the emission spot
  53496. * @param scene The scene the lights belongs to
  53497. */
  53498. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  53499. /**
  53500. * Returns the string "SpotLight".
  53501. * @returns the class name
  53502. */
  53503. getClassName(): string;
  53504. /**
  53505. * Returns the integer 2.
  53506. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53507. */
  53508. getTypeID(): number;
  53509. /**
  53510. * Overrides the direction setter to recompute the projection texture view light Matrix.
  53511. */
  53512. protected _setDirection(value: Vector3): void;
  53513. /**
  53514. * Overrides the position setter to recompute the projection texture view light Matrix.
  53515. */
  53516. protected _setPosition(value: Vector3): void;
  53517. /**
  53518. * 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.
  53519. * Returns the SpotLight.
  53520. */
  53521. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53522. protected _computeProjectionTextureViewLightMatrix(): void;
  53523. protected _computeProjectionTextureProjectionLightMatrix(): void;
  53524. /**
  53525. * Main function for light texture projection matrix computing.
  53526. */
  53527. protected _computeProjectionTextureMatrix(): void;
  53528. protected _buildUniformLayout(): void;
  53529. private _computeAngleValues;
  53530. /**
  53531. * Sets the passed Effect "effect" with the Light textures.
  53532. * @param effect The effect to update
  53533. * @param lightIndex The index of the light in the effect to update
  53534. * @returns The light
  53535. */
  53536. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  53537. /**
  53538. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  53539. * @param effect The effect to update
  53540. * @param lightIndex The index of the light in the effect to update
  53541. * @returns The spot light
  53542. */
  53543. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  53544. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  53545. /**
  53546. * Disposes the light and the associated resources.
  53547. */
  53548. dispose(): void;
  53549. /**
  53550. * Prepares the list of defines specific to the light type.
  53551. * @param defines the list of defines
  53552. * @param lightIndex defines the index of the light for the effect
  53553. */
  53554. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53555. }
  53556. }
  53557. declare module BABYLON {
  53558. /**
  53559. * Gizmo that enables viewing a light
  53560. */
  53561. export class LightGizmo extends Gizmo {
  53562. private _lightMesh;
  53563. private _material;
  53564. private _cachedPosition;
  53565. private _cachedForward;
  53566. private _attachedMeshParent;
  53567. /**
  53568. * Creates a LightGizmo
  53569. * @param gizmoLayer The utility layer the gizmo will be added to
  53570. */
  53571. constructor(gizmoLayer?: UtilityLayerRenderer);
  53572. private _light;
  53573. /**
  53574. * The light that the gizmo is attached to
  53575. */
  53576. set light(light: Nullable<Light>);
  53577. get light(): Nullable<Light>;
  53578. /**
  53579. * Gets the material used to render the light gizmo
  53580. */
  53581. get material(): StandardMaterial;
  53582. /**
  53583. * @hidden
  53584. * Updates the gizmo to match the attached mesh's position/rotation
  53585. */
  53586. protected _update(): void;
  53587. private static _Scale;
  53588. /**
  53589. * Creates the lines for a light mesh
  53590. */
  53591. private static _CreateLightLines;
  53592. /**
  53593. * Disposes of the light gizmo
  53594. */
  53595. dispose(): void;
  53596. private static _CreateHemisphericLightMesh;
  53597. private static _CreatePointLightMesh;
  53598. private static _CreateSpotLightMesh;
  53599. private static _CreateDirectionalLightMesh;
  53600. }
  53601. }
  53602. declare module BABYLON {
  53603. /** @hidden */
  53604. export var backgroundFragmentDeclaration: {
  53605. name: string;
  53606. shader: string;
  53607. };
  53608. }
  53609. declare module BABYLON {
  53610. /** @hidden */
  53611. export var backgroundUboDeclaration: {
  53612. name: string;
  53613. shader: string;
  53614. };
  53615. }
  53616. declare module BABYLON {
  53617. /** @hidden */
  53618. export var backgroundPixelShader: {
  53619. name: string;
  53620. shader: string;
  53621. };
  53622. }
  53623. declare module BABYLON {
  53624. /** @hidden */
  53625. export var backgroundVertexDeclaration: {
  53626. name: string;
  53627. shader: string;
  53628. };
  53629. }
  53630. declare module BABYLON {
  53631. /** @hidden */
  53632. export var backgroundVertexShader: {
  53633. name: string;
  53634. shader: string;
  53635. };
  53636. }
  53637. declare module BABYLON {
  53638. /**
  53639. * Background material used to create an efficient environement around your scene.
  53640. */
  53641. export class BackgroundMaterial extends PushMaterial {
  53642. /**
  53643. * Standard reflectance value at parallel view angle.
  53644. */
  53645. static StandardReflectance0: number;
  53646. /**
  53647. * Standard reflectance value at grazing angle.
  53648. */
  53649. static StandardReflectance90: number;
  53650. protected _primaryColor: Color3;
  53651. /**
  53652. * Key light Color (multiply against the environement texture)
  53653. */
  53654. primaryColor: Color3;
  53655. protected __perceptualColor: Nullable<Color3>;
  53656. /**
  53657. * Experimental Internal Use Only.
  53658. *
  53659. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  53660. * This acts as a helper to set the primary color to a more "human friendly" value.
  53661. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  53662. * output color as close as possible from the chosen value.
  53663. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  53664. * part of lighting setup.)
  53665. */
  53666. get _perceptualColor(): Nullable<Color3>;
  53667. set _perceptualColor(value: Nullable<Color3>);
  53668. protected _primaryColorShadowLevel: float;
  53669. /**
  53670. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  53671. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  53672. */
  53673. get primaryColorShadowLevel(): float;
  53674. set primaryColorShadowLevel(value: float);
  53675. protected _primaryColorHighlightLevel: float;
  53676. /**
  53677. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  53678. * The primary color is used at the level chosen to define what the white area would look.
  53679. */
  53680. get primaryColorHighlightLevel(): float;
  53681. set primaryColorHighlightLevel(value: float);
  53682. protected _reflectionTexture: Nullable<BaseTexture>;
  53683. /**
  53684. * Reflection Texture used in the material.
  53685. * Should be author in a specific way for the best result (refer to the documentation).
  53686. */
  53687. reflectionTexture: Nullable<BaseTexture>;
  53688. protected _reflectionBlur: float;
  53689. /**
  53690. * Reflection Texture level of blur.
  53691. *
  53692. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  53693. * texture twice.
  53694. */
  53695. reflectionBlur: float;
  53696. protected _diffuseTexture: Nullable<BaseTexture>;
  53697. /**
  53698. * Diffuse Texture used in the material.
  53699. * Should be author in a specific way for the best result (refer to the documentation).
  53700. */
  53701. diffuseTexture: Nullable<BaseTexture>;
  53702. protected _shadowLights: Nullable<IShadowLight[]>;
  53703. /**
  53704. * Specify the list of lights casting shadow on the material.
  53705. * All scene shadow lights will be included if null.
  53706. */
  53707. shadowLights: Nullable<IShadowLight[]>;
  53708. protected _shadowLevel: float;
  53709. /**
  53710. * Helps adjusting the shadow to a softer level if required.
  53711. * 0 means black shadows and 1 means no shadows.
  53712. */
  53713. shadowLevel: float;
  53714. protected _sceneCenter: Vector3;
  53715. /**
  53716. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  53717. * It is usually zero but might be interesting to modify according to your setup.
  53718. */
  53719. sceneCenter: Vector3;
  53720. protected _opacityFresnel: boolean;
  53721. /**
  53722. * This helps specifying that the material is falling off to the sky box at grazing angle.
  53723. * This helps ensuring a nice transition when the camera goes under the ground.
  53724. */
  53725. opacityFresnel: boolean;
  53726. protected _reflectionFresnel: boolean;
  53727. /**
  53728. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  53729. * This helps adding a mirror texture on the ground.
  53730. */
  53731. reflectionFresnel: boolean;
  53732. protected _reflectionFalloffDistance: number;
  53733. /**
  53734. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  53735. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  53736. */
  53737. reflectionFalloffDistance: number;
  53738. protected _reflectionAmount: number;
  53739. /**
  53740. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  53741. */
  53742. reflectionAmount: number;
  53743. protected _reflectionReflectance0: number;
  53744. /**
  53745. * This specifies the weight of the reflection at grazing angle.
  53746. */
  53747. reflectionReflectance0: number;
  53748. protected _reflectionReflectance90: number;
  53749. /**
  53750. * This specifies the weight of the reflection at a perpendicular point of view.
  53751. */
  53752. reflectionReflectance90: number;
  53753. /**
  53754. * Sets the reflection reflectance fresnel values according to the default standard
  53755. * empirically know to work well :-)
  53756. */
  53757. set reflectionStandardFresnelWeight(value: number);
  53758. protected _useRGBColor: boolean;
  53759. /**
  53760. * Helps to directly use the maps channels instead of their level.
  53761. */
  53762. useRGBColor: boolean;
  53763. protected _enableNoise: boolean;
  53764. /**
  53765. * This helps reducing the banding effect that could occur on the background.
  53766. */
  53767. enableNoise: boolean;
  53768. /**
  53769. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53770. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  53771. * Recommended to be keep at 1.0 except for special cases.
  53772. */
  53773. get fovMultiplier(): number;
  53774. set fovMultiplier(value: number);
  53775. private _fovMultiplier;
  53776. /**
  53777. * Enable the FOV adjustment feature controlled by fovMultiplier.
  53778. */
  53779. useEquirectangularFOV: boolean;
  53780. private _maxSimultaneousLights;
  53781. /**
  53782. * Number of Simultaneous lights allowed on the material.
  53783. */
  53784. maxSimultaneousLights: int;
  53785. private _shadowOnly;
  53786. /**
  53787. * Make the material only render shadows
  53788. */
  53789. shadowOnly: boolean;
  53790. /**
  53791. * Default configuration related to image processing available in the Background Material.
  53792. */
  53793. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53794. /**
  53795. * Keep track of the image processing observer to allow dispose and replace.
  53796. */
  53797. private _imageProcessingObserver;
  53798. /**
  53799. * Attaches a new image processing configuration to the PBR Material.
  53800. * @param configuration (if null the scene configuration will be use)
  53801. */
  53802. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53803. /**
  53804. * Gets the image processing configuration used either in this material.
  53805. */
  53806. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  53807. /**
  53808. * Sets the Default image processing configuration used either in the this material.
  53809. *
  53810. * If sets to null, the scene one is in use.
  53811. */
  53812. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  53813. /**
  53814. * Gets wether the color curves effect is enabled.
  53815. */
  53816. get cameraColorCurvesEnabled(): boolean;
  53817. /**
  53818. * Sets wether the color curves effect is enabled.
  53819. */
  53820. set cameraColorCurvesEnabled(value: boolean);
  53821. /**
  53822. * Gets wether the color grading effect is enabled.
  53823. */
  53824. get cameraColorGradingEnabled(): boolean;
  53825. /**
  53826. * Gets wether the color grading effect is enabled.
  53827. */
  53828. set cameraColorGradingEnabled(value: boolean);
  53829. /**
  53830. * Gets wether tonemapping is enabled or not.
  53831. */
  53832. get cameraToneMappingEnabled(): boolean;
  53833. /**
  53834. * Sets wether tonemapping is enabled or not
  53835. */
  53836. set cameraToneMappingEnabled(value: boolean);
  53837. /**
  53838. * The camera exposure used on this material.
  53839. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53840. * This corresponds to a photographic exposure.
  53841. */
  53842. get cameraExposure(): float;
  53843. /**
  53844. * The camera exposure used on this material.
  53845. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53846. * This corresponds to a photographic exposure.
  53847. */
  53848. set cameraExposure(value: float);
  53849. /**
  53850. * Gets The camera contrast used on this material.
  53851. */
  53852. get cameraContrast(): float;
  53853. /**
  53854. * Sets The camera contrast used on this material.
  53855. */
  53856. set cameraContrast(value: float);
  53857. /**
  53858. * Gets the Color Grading 2D Lookup Texture.
  53859. */
  53860. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  53861. /**
  53862. * Sets the Color Grading 2D Lookup Texture.
  53863. */
  53864. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  53865. /**
  53866. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53867. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53868. * 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;
  53869. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53870. */
  53871. get cameraColorCurves(): Nullable<ColorCurves>;
  53872. /**
  53873. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53874. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53875. * 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;
  53876. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53877. */
  53878. set cameraColorCurves(value: Nullable<ColorCurves>);
  53879. /**
  53880. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  53881. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  53882. */
  53883. switchToBGR: boolean;
  53884. private _renderTargets;
  53885. private _reflectionControls;
  53886. private _white;
  53887. private _primaryShadowColor;
  53888. private _primaryHighlightColor;
  53889. /**
  53890. * Instantiates a Background Material in the given scene
  53891. * @param name The friendly name of the material
  53892. * @param scene The scene to add the material to
  53893. */
  53894. constructor(name: string, scene: Scene);
  53895. /**
  53896. * Gets a boolean indicating that current material needs to register RTT
  53897. */
  53898. get hasRenderTargetTextures(): boolean;
  53899. /**
  53900. * The entire material has been created in order to prevent overdraw.
  53901. * @returns false
  53902. */
  53903. needAlphaTesting(): boolean;
  53904. /**
  53905. * The entire material has been created in order to prevent overdraw.
  53906. * @returns true if blending is enable
  53907. */
  53908. needAlphaBlending(): boolean;
  53909. /**
  53910. * Checks wether the material is ready to be rendered for a given mesh.
  53911. * @param mesh The mesh to render
  53912. * @param subMesh The submesh to check against
  53913. * @param useInstances Specify wether or not the material is used with instances
  53914. * @returns true if all the dependencies are ready (Textures, Effects...)
  53915. */
  53916. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53917. /**
  53918. * Compute the primary color according to the chosen perceptual color.
  53919. */
  53920. private _computePrimaryColorFromPerceptualColor;
  53921. /**
  53922. * Compute the highlights and shadow colors according to their chosen levels.
  53923. */
  53924. private _computePrimaryColors;
  53925. /**
  53926. * Build the uniform buffer used in the material.
  53927. */
  53928. buildUniformLayout(): void;
  53929. /**
  53930. * Unbind the material.
  53931. */
  53932. unbind(): void;
  53933. /**
  53934. * Bind only the world matrix to the material.
  53935. * @param world The world matrix to bind.
  53936. */
  53937. bindOnlyWorldMatrix(world: Matrix): void;
  53938. /**
  53939. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  53940. * @param world The world matrix to bind.
  53941. * @param subMesh The submesh to bind for.
  53942. */
  53943. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53944. /**
  53945. * Checks to see if a texture is used in the material.
  53946. * @param texture - Base texture to use.
  53947. * @returns - Boolean specifying if a texture is used in the material.
  53948. */
  53949. hasTexture(texture: BaseTexture): boolean;
  53950. /**
  53951. * Dispose the material.
  53952. * @param forceDisposeEffect Force disposal of the associated effect.
  53953. * @param forceDisposeTextures Force disposal of the associated textures.
  53954. */
  53955. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53956. /**
  53957. * Clones the material.
  53958. * @param name The cloned name.
  53959. * @returns The cloned material.
  53960. */
  53961. clone(name: string): BackgroundMaterial;
  53962. /**
  53963. * Serializes the current material to its JSON representation.
  53964. * @returns The JSON representation.
  53965. */
  53966. serialize(): any;
  53967. /**
  53968. * Gets the class name of the material
  53969. * @returns "BackgroundMaterial"
  53970. */
  53971. getClassName(): string;
  53972. /**
  53973. * Parse a JSON input to create back a background material.
  53974. * @param source The JSON data to parse
  53975. * @param scene The scene to create the parsed material in
  53976. * @param rootUrl The root url of the assets the material depends upon
  53977. * @returns the instantiated BackgroundMaterial.
  53978. */
  53979. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  53980. }
  53981. }
  53982. declare module BABYLON {
  53983. /**
  53984. * Represents the different options available during the creation of
  53985. * a Environment helper.
  53986. *
  53987. * This can control the default ground, skybox and image processing setup of your scene.
  53988. */
  53989. export interface IEnvironmentHelperOptions {
  53990. /**
  53991. * Specifies whether or not to create a ground.
  53992. * True by default.
  53993. */
  53994. createGround: boolean;
  53995. /**
  53996. * Specifies the ground size.
  53997. * 15 by default.
  53998. */
  53999. groundSize: number;
  54000. /**
  54001. * The texture used on the ground for the main color.
  54002. * Comes from the BabylonJS CDN by default.
  54003. *
  54004. * Remarks: Can be either a texture or a url.
  54005. */
  54006. groundTexture: string | BaseTexture;
  54007. /**
  54008. * The color mixed in the ground texture by default.
  54009. * BabylonJS clearColor by default.
  54010. */
  54011. groundColor: Color3;
  54012. /**
  54013. * Specifies the ground opacity.
  54014. * 1 by default.
  54015. */
  54016. groundOpacity: number;
  54017. /**
  54018. * Enables the ground to receive shadows.
  54019. * True by default.
  54020. */
  54021. enableGroundShadow: boolean;
  54022. /**
  54023. * Helps preventing the shadow to be fully black on the ground.
  54024. * 0.5 by default.
  54025. */
  54026. groundShadowLevel: number;
  54027. /**
  54028. * Creates a mirror texture attach to the ground.
  54029. * false by default.
  54030. */
  54031. enableGroundMirror: boolean;
  54032. /**
  54033. * Specifies the ground mirror size ratio.
  54034. * 0.3 by default as the default kernel is 64.
  54035. */
  54036. groundMirrorSizeRatio: number;
  54037. /**
  54038. * Specifies the ground mirror blur kernel size.
  54039. * 64 by default.
  54040. */
  54041. groundMirrorBlurKernel: number;
  54042. /**
  54043. * Specifies the ground mirror visibility amount.
  54044. * 1 by default
  54045. */
  54046. groundMirrorAmount: number;
  54047. /**
  54048. * Specifies the ground mirror reflectance weight.
  54049. * This uses the standard weight of the background material to setup the fresnel effect
  54050. * of the mirror.
  54051. * 1 by default.
  54052. */
  54053. groundMirrorFresnelWeight: number;
  54054. /**
  54055. * Specifies the ground mirror Falloff distance.
  54056. * This can helps reducing the size of the reflection.
  54057. * 0 by Default.
  54058. */
  54059. groundMirrorFallOffDistance: number;
  54060. /**
  54061. * Specifies the ground mirror texture type.
  54062. * Unsigned Int by Default.
  54063. */
  54064. groundMirrorTextureType: number;
  54065. /**
  54066. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  54067. * the shown objects.
  54068. */
  54069. groundYBias: number;
  54070. /**
  54071. * Specifies whether or not to create a skybox.
  54072. * True by default.
  54073. */
  54074. createSkybox: boolean;
  54075. /**
  54076. * Specifies the skybox size.
  54077. * 20 by default.
  54078. */
  54079. skyboxSize: number;
  54080. /**
  54081. * The texture used on the skybox for the main color.
  54082. * Comes from the BabylonJS CDN by default.
  54083. *
  54084. * Remarks: Can be either a texture or a url.
  54085. */
  54086. skyboxTexture: string | BaseTexture;
  54087. /**
  54088. * The color mixed in the skybox texture by default.
  54089. * BabylonJS clearColor by default.
  54090. */
  54091. skyboxColor: Color3;
  54092. /**
  54093. * The background rotation around the Y axis of the scene.
  54094. * This helps aligning the key lights of your scene with the background.
  54095. * 0 by default.
  54096. */
  54097. backgroundYRotation: number;
  54098. /**
  54099. * Compute automatically the size of the elements to best fit with the scene.
  54100. */
  54101. sizeAuto: boolean;
  54102. /**
  54103. * Default position of the rootMesh if autoSize is not true.
  54104. */
  54105. rootPosition: Vector3;
  54106. /**
  54107. * Sets up the image processing in the scene.
  54108. * true by default.
  54109. */
  54110. setupImageProcessing: boolean;
  54111. /**
  54112. * The texture used as your environment texture in the scene.
  54113. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  54114. *
  54115. * Remarks: Can be either a texture or a url.
  54116. */
  54117. environmentTexture: string | BaseTexture;
  54118. /**
  54119. * The value of the exposure to apply to the scene.
  54120. * 0.6 by default if setupImageProcessing is true.
  54121. */
  54122. cameraExposure: number;
  54123. /**
  54124. * The value of the contrast to apply to the scene.
  54125. * 1.6 by default if setupImageProcessing is true.
  54126. */
  54127. cameraContrast: number;
  54128. /**
  54129. * Specifies whether or not tonemapping should be enabled in the scene.
  54130. * true by default if setupImageProcessing is true.
  54131. */
  54132. toneMappingEnabled: boolean;
  54133. }
  54134. /**
  54135. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  54136. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  54137. * It also helps with the default setup of your imageProcessing configuration.
  54138. */
  54139. export class EnvironmentHelper {
  54140. /**
  54141. * Default ground texture URL.
  54142. */
  54143. private static _groundTextureCDNUrl;
  54144. /**
  54145. * Default skybox texture URL.
  54146. */
  54147. private static _skyboxTextureCDNUrl;
  54148. /**
  54149. * Default environment texture URL.
  54150. */
  54151. private static _environmentTextureCDNUrl;
  54152. /**
  54153. * Creates the default options for the helper.
  54154. */
  54155. private static _getDefaultOptions;
  54156. private _rootMesh;
  54157. /**
  54158. * Gets the root mesh created by the helper.
  54159. */
  54160. get rootMesh(): Mesh;
  54161. private _skybox;
  54162. /**
  54163. * Gets the skybox created by the helper.
  54164. */
  54165. get skybox(): Nullable<Mesh>;
  54166. private _skyboxTexture;
  54167. /**
  54168. * Gets the skybox texture created by the helper.
  54169. */
  54170. get skyboxTexture(): Nullable<BaseTexture>;
  54171. private _skyboxMaterial;
  54172. /**
  54173. * Gets the skybox material created by the helper.
  54174. */
  54175. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  54176. private _ground;
  54177. /**
  54178. * Gets the ground mesh created by the helper.
  54179. */
  54180. get ground(): Nullable<Mesh>;
  54181. private _groundTexture;
  54182. /**
  54183. * Gets the ground texture created by the helper.
  54184. */
  54185. get groundTexture(): Nullable<BaseTexture>;
  54186. private _groundMirror;
  54187. /**
  54188. * Gets the ground mirror created by the helper.
  54189. */
  54190. get groundMirror(): Nullable<MirrorTexture>;
  54191. /**
  54192. * Gets the ground mirror render list to helps pushing the meshes
  54193. * you wish in the ground reflection.
  54194. */
  54195. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  54196. private _groundMaterial;
  54197. /**
  54198. * Gets the ground material created by the helper.
  54199. */
  54200. get groundMaterial(): Nullable<BackgroundMaterial>;
  54201. /**
  54202. * Stores the creation options.
  54203. */
  54204. private readonly _scene;
  54205. private _options;
  54206. /**
  54207. * This observable will be notified with any error during the creation of the environment,
  54208. * mainly texture creation errors.
  54209. */
  54210. onErrorObservable: Observable<{
  54211. message?: string;
  54212. exception?: any;
  54213. }>;
  54214. /**
  54215. * constructor
  54216. * @param options Defines the options we want to customize the helper
  54217. * @param scene The scene to add the material to
  54218. */
  54219. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  54220. /**
  54221. * Updates the background according to the new options
  54222. * @param options
  54223. */
  54224. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  54225. /**
  54226. * Sets the primary color of all the available elements.
  54227. * @param color the main color to affect to the ground and the background
  54228. */
  54229. setMainColor(color: Color3): void;
  54230. /**
  54231. * Setup the image processing according to the specified options.
  54232. */
  54233. private _setupImageProcessing;
  54234. /**
  54235. * Setup the environment texture according to the specified options.
  54236. */
  54237. private _setupEnvironmentTexture;
  54238. /**
  54239. * Setup the background according to the specified options.
  54240. */
  54241. private _setupBackground;
  54242. /**
  54243. * Get the scene sizes according to the setup.
  54244. */
  54245. private _getSceneSize;
  54246. /**
  54247. * Setup the ground according to the specified options.
  54248. */
  54249. private _setupGround;
  54250. /**
  54251. * Setup the ground material according to the specified options.
  54252. */
  54253. private _setupGroundMaterial;
  54254. /**
  54255. * Setup the ground diffuse texture according to the specified options.
  54256. */
  54257. private _setupGroundDiffuseTexture;
  54258. /**
  54259. * Setup the ground mirror texture according to the specified options.
  54260. */
  54261. private _setupGroundMirrorTexture;
  54262. /**
  54263. * Setup the ground to receive the mirror texture.
  54264. */
  54265. private _setupMirrorInGroundMaterial;
  54266. /**
  54267. * Setup the skybox according to the specified options.
  54268. */
  54269. private _setupSkybox;
  54270. /**
  54271. * Setup the skybox material according to the specified options.
  54272. */
  54273. private _setupSkyboxMaterial;
  54274. /**
  54275. * Setup the skybox reflection texture according to the specified options.
  54276. */
  54277. private _setupSkyboxReflectionTexture;
  54278. private _errorHandler;
  54279. /**
  54280. * Dispose all the elements created by the Helper.
  54281. */
  54282. dispose(): void;
  54283. }
  54284. }
  54285. declare module BABYLON {
  54286. /**
  54287. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  54288. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  54289. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  54290. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54291. */
  54292. export class PhotoDome extends TransformNode {
  54293. /**
  54294. * Define the image as a Monoscopic panoramic 360 image.
  54295. */
  54296. static readonly MODE_MONOSCOPIC: number;
  54297. /**
  54298. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  54299. */
  54300. static readonly MODE_TOPBOTTOM: number;
  54301. /**
  54302. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  54303. */
  54304. static readonly MODE_SIDEBYSIDE: number;
  54305. private _useDirectMapping;
  54306. /**
  54307. * The texture being displayed on the sphere
  54308. */
  54309. protected _photoTexture: Texture;
  54310. /**
  54311. * Gets or sets the texture being displayed on the sphere
  54312. */
  54313. get photoTexture(): Texture;
  54314. set photoTexture(value: Texture);
  54315. /**
  54316. * Observable raised when an error occured while loading the 360 image
  54317. */
  54318. onLoadErrorObservable: Observable<string>;
  54319. /**
  54320. * The skybox material
  54321. */
  54322. protected _material: BackgroundMaterial;
  54323. /**
  54324. * The surface used for the skybox
  54325. */
  54326. protected _mesh: Mesh;
  54327. /**
  54328. * Gets the mesh used for the skybox.
  54329. */
  54330. get mesh(): Mesh;
  54331. /**
  54332. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54333. * Also see the options.resolution property.
  54334. */
  54335. get fovMultiplier(): number;
  54336. set fovMultiplier(value: number);
  54337. private _imageMode;
  54338. /**
  54339. * Gets or set the current video mode for the video. It can be:
  54340. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  54341. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  54342. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  54343. */
  54344. get imageMode(): number;
  54345. set imageMode(value: number);
  54346. /**
  54347. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  54348. * @param name Element's name, child elements will append suffixes for their own names.
  54349. * @param urlsOfPhoto defines the url of the photo to display
  54350. * @param options defines an object containing optional or exposed sub element properties
  54351. * @param onError defines a callback called when an error occured while loading the texture
  54352. */
  54353. constructor(name: string, urlOfPhoto: string, options: {
  54354. resolution?: number;
  54355. size?: number;
  54356. useDirectMapping?: boolean;
  54357. faceForward?: boolean;
  54358. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  54359. private _onBeforeCameraRenderObserver;
  54360. private _changeImageMode;
  54361. /**
  54362. * Releases resources associated with this node.
  54363. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54364. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54365. */
  54366. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  54367. }
  54368. }
  54369. declare module BABYLON {
  54370. /**
  54371. * Class used to host RGBD texture specific utilities
  54372. */
  54373. export class RGBDTextureTools {
  54374. /**
  54375. * Expand the RGBD Texture from RGBD to Half Float if possible.
  54376. * @param texture the texture to expand.
  54377. */
  54378. static ExpandRGBDTexture(texture: Texture): void;
  54379. }
  54380. }
  54381. declare module BABYLON {
  54382. /**
  54383. * Class used to host texture specific utilities
  54384. */
  54385. export class BRDFTextureTools {
  54386. /**
  54387. * Prevents texture cache collision
  54388. */
  54389. private static _instanceNumber;
  54390. /**
  54391. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  54392. * @param scene defines the hosting scene
  54393. * @returns the environment BRDF texture
  54394. */
  54395. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  54396. private static _environmentBRDFBase64Texture;
  54397. }
  54398. }
  54399. declare module BABYLON {
  54400. /**
  54401. * @hidden
  54402. */
  54403. export interface IMaterialClearCoatDefines {
  54404. CLEARCOAT: boolean;
  54405. CLEARCOAT_DEFAULTIOR: boolean;
  54406. CLEARCOAT_TEXTURE: boolean;
  54407. CLEARCOAT_TEXTUREDIRECTUV: number;
  54408. CLEARCOAT_BUMP: boolean;
  54409. CLEARCOAT_BUMPDIRECTUV: number;
  54410. CLEARCOAT_TINT: boolean;
  54411. CLEARCOAT_TINT_TEXTURE: boolean;
  54412. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  54413. /** @hidden */
  54414. _areTexturesDirty: boolean;
  54415. }
  54416. /**
  54417. * Define the code related to the clear coat parameters of the pbr material.
  54418. */
  54419. export class PBRClearCoatConfiguration {
  54420. /**
  54421. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  54422. * The default fits with a polyurethane material.
  54423. */
  54424. private static readonly _DefaultIndexOfRefraction;
  54425. private _isEnabled;
  54426. /**
  54427. * Defines if the clear coat is enabled in the material.
  54428. */
  54429. isEnabled: boolean;
  54430. /**
  54431. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  54432. */
  54433. intensity: number;
  54434. /**
  54435. * Defines the clear coat layer roughness.
  54436. */
  54437. roughness: number;
  54438. private _indexOfRefraction;
  54439. /**
  54440. * Defines the index of refraction of the clear coat.
  54441. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  54442. * The default fits with a polyurethane material.
  54443. * Changing the default value is more performance intensive.
  54444. */
  54445. indexOfRefraction: number;
  54446. private _texture;
  54447. /**
  54448. * Stores the clear coat values in a texture.
  54449. */
  54450. texture: Nullable<BaseTexture>;
  54451. private _bumpTexture;
  54452. /**
  54453. * Define the clear coat specific bump texture.
  54454. */
  54455. bumpTexture: Nullable<BaseTexture>;
  54456. private _isTintEnabled;
  54457. /**
  54458. * Defines if the clear coat tint is enabled in the material.
  54459. */
  54460. isTintEnabled: boolean;
  54461. /**
  54462. * Defines the clear coat tint of the material.
  54463. * This is only use if tint is enabled
  54464. */
  54465. tintColor: Color3;
  54466. /**
  54467. * Defines the distance at which the tint color should be found in the
  54468. * clear coat media.
  54469. * This is only use if tint is enabled
  54470. */
  54471. tintColorAtDistance: number;
  54472. /**
  54473. * Defines the clear coat layer thickness.
  54474. * This is only use if tint is enabled
  54475. */
  54476. tintThickness: number;
  54477. private _tintTexture;
  54478. /**
  54479. * Stores the clear tint values in a texture.
  54480. * rgb is tint
  54481. * a is a thickness factor
  54482. */
  54483. tintTexture: Nullable<BaseTexture>;
  54484. /** @hidden */
  54485. private _internalMarkAllSubMeshesAsTexturesDirty;
  54486. /** @hidden */
  54487. _markAllSubMeshesAsTexturesDirty(): void;
  54488. /**
  54489. * Instantiate a new istance of clear coat configuration.
  54490. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54491. */
  54492. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54493. /**
  54494. * Gets wehter the submesh is ready to be used or not.
  54495. * @param defines the list of "defines" to update.
  54496. * @param scene defines the scene the material belongs to.
  54497. * @param engine defines the engine the material belongs to.
  54498. * @param disableBumpMap defines wether the material disables bump or not.
  54499. * @returns - boolean indicating that the submesh is ready or not.
  54500. */
  54501. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  54502. /**
  54503. * Checks to see if a texture is used in the material.
  54504. * @param defines the list of "defines" to update.
  54505. * @param scene defines the scene to the material belongs to.
  54506. */
  54507. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  54508. /**
  54509. * Binds the material data.
  54510. * @param uniformBuffer defines the Uniform buffer to fill in.
  54511. * @param scene defines the scene the material belongs to.
  54512. * @param engine defines the engine the material belongs to.
  54513. * @param disableBumpMap defines wether the material disables bump or not.
  54514. * @param isFrozen defines wether the material is frozen or not.
  54515. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  54516. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  54517. */
  54518. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  54519. /**
  54520. * Checks to see if a texture is used in the material.
  54521. * @param texture - Base texture to use.
  54522. * @returns - Boolean specifying if a texture is used in the material.
  54523. */
  54524. hasTexture(texture: BaseTexture): boolean;
  54525. /**
  54526. * Returns an array of the actively used textures.
  54527. * @param activeTextures Array of BaseTextures
  54528. */
  54529. getActiveTextures(activeTextures: BaseTexture[]): void;
  54530. /**
  54531. * Returns the animatable textures.
  54532. * @param animatables Array of animatable textures.
  54533. */
  54534. getAnimatables(animatables: IAnimatable[]): void;
  54535. /**
  54536. * Disposes the resources of the material.
  54537. * @param forceDisposeTextures - Forces the disposal of all textures.
  54538. */
  54539. dispose(forceDisposeTextures?: boolean): void;
  54540. /**
  54541. * Get the current class name of the texture useful for serialization or dynamic coding.
  54542. * @returns "PBRClearCoatConfiguration"
  54543. */
  54544. getClassName(): string;
  54545. /**
  54546. * Add fallbacks to the effect fallbacks list.
  54547. * @param defines defines the Base texture to use.
  54548. * @param fallbacks defines the current fallback list.
  54549. * @param currentRank defines the current fallback rank.
  54550. * @returns the new fallback rank.
  54551. */
  54552. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54553. /**
  54554. * Add the required uniforms to the current list.
  54555. * @param uniforms defines the current uniform list.
  54556. */
  54557. static AddUniforms(uniforms: string[]): void;
  54558. /**
  54559. * Add the required samplers to the current list.
  54560. * @param samplers defines the current sampler list.
  54561. */
  54562. static AddSamplers(samplers: string[]): void;
  54563. /**
  54564. * Add the required uniforms to the current buffer.
  54565. * @param uniformBuffer defines the current uniform buffer.
  54566. */
  54567. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54568. /**
  54569. * Makes a duplicate of the current configuration into another one.
  54570. * @param clearCoatConfiguration define the config where to copy the info
  54571. */
  54572. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  54573. /**
  54574. * Serializes this clear coat configuration.
  54575. * @returns - An object with the serialized config.
  54576. */
  54577. serialize(): any;
  54578. /**
  54579. * Parses a anisotropy Configuration from a serialized object.
  54580. * @param source - Serialized object.
  54581. * @param scene Defines the scene we are parsing for
  54582. * @param rootUrl Defines the rootUrl to load from
  54583. */
  54584. parse(source: any, scene: Scene, rootUrl: string): void;
  54585. }
  54586. }
  54587. declare module BABYLON {
  54588. /**
  54589. * @hidden
  54590. */
  54591. export interface IMaterialAnisotropicDefines {
  54592. ANISOTROPIC: boolean;
  54593. ANISOTROPIC_TEXTURE: boolean;
  54594. ANISOTROPIC_TEXTUREDIRECTUV: number;
  54595. MAINUV1: boolean;
  54596. _areTexturesDirty: boolean;
  54597. _needUVs: boolean;
  54598. }
  54599. /**
  54600. * Define the code related to the anisotropic parameters of the pbr material.
  54601. */
  54602. export class PBRAnisotropicConfiguration {
  54603. private _isEnabled;
  54604. /**
  54605. * Defines if the anisotropy is enabled in the material.
  54606. */
  54607. isEnabled: boolean;
  54608. /**
  54609. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  54610. */
  54611. intensity: number;
  54612. /**
  54613. * Defines if the effect is along the tangents, bitangents or in between.
  54614. * By default, the effect is "strectching" the highlights along the tangents.
  54615. */
  54616. direction: Vector2;
  54617. private _texture;
  54618. /**
  54619. * Stores the anisotropy values in a texture.
  54620. * rg is direction (like normal from -1 to 1)
  54621. * b is a intensity
  54622. */
  54623. texture: Nullable<BaseTexture>;
  54624. /** @hidden */
  54625. private _internalMarkAllSubMeshesAsTexturesDirty;
  54626. /** @hidden */
  54627. _markAllSubMeshesAsTexturesDirty(): void;
  54628. /**
  54629. * Instantiate a new istance of anisotropy configuration.
  54630. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54631. */
  54632. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54633. /**
  54634. * Specifies that the submesh is ready to be used.
  54635. * @param defines the list of "defines" to update.
  54636. * @param scene defines the scene the material belongs to.
  54637. * @returns - boolean indicating that the submesh is ready or not.
  54638. */
  54639. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  54640. /**
  54641. * Checks to see if a texture is used in the material.
  54642. * @param defines the list of "defines" to update.
  54643. * @param mesh the mesh we are preparing the defines for.
  54644. * @param scene defines the scene the material belongs to.
  54645. */
  54646. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  54647. /**
  54648. * Binds the material data.
  54649. * @param uniformBuffer defines the Uniform buffer to fill in.
  54650. * @param scene defines the scene the material belongs to.
  54651. * @param isFrozen defines wether the material is frozen or not.
  54652. */
  54653. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  54654. /**
  54655. * Checks to see if a texture is used in the material.
  54656. * @param texture - Base texture to use.
  54657. * @returns - Boolean specifying if a texture is used in the material.
  54658. */
  54659. hasTexture(texture: BaseTexture): boolean;
  54660. /**
  54661. * Returns an array of the actively used textures.
  54662. * @param activeTextures Array of BaseTextures
  54663. */
  54664. getActiveTextures(activeTextures: BaseTexture[]): void;
  54665. /**
  54666. * Returns the animatable textures.
  54667. * @param animatables Array of animatable textures.
  54668. */
  54669. getAnimatables(animatables: IAnimatable[]): void;
  54670. /**
  54671. * Disposes the resources of the material.
  54672. * @param forceDisposeTextures - Forces the disposal of all textures.
  54673. */
  54674. dispose(forceDisposeTextures?: boolean): void;
  54675. /**
  54676. * Get the current class name of the texture useful for serialization or dynamic coding.
  54677. * @returns "PBRAnisotropicConfiguration"
  54678. */
  54679. getClassName(): string;
  54680. /**
  54681. * Add fallbacks to the effect fallbacks list.
  54682. * @param defines defines the Base texture to use.
  54683. * @param fallbacks defines the current fallback list.
  54684. * @param currentRank defines the current fallback rank.
  54685. * @returns the new fallback rank.
  54686. */
  54687. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54688. /**
  54689. * Add the required uniforms to the current list.
  54690. * @param uniforms defines the current uniform list.
  54691. */
  54692. static AddUniforms(uniforms: string[]): void;
  54693. /**
  54694. * Add the required uniforms to the current buffer.
  54695. * @param uniformBuffer defines the current uniform buffer.
  54696. */
  54697. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54698. /**
  54699. * Add the required samplers to the current list.
  54700. * @param samplers defines the current sampler list.
  54701. */
  54702. static AddSamplers(samplers: string[]): void;
  54703. /**
  54704. * Makes a duplicate of the current configuration into another one.
  54705. * @param anisotropicConfiguration define the config where to copy the info
  54706. */
  54707. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  54708. /**
  54709. * Serializes this anisotropy configuration.
  54710. * @returns - An object with the serialized config.
  54711. */
  54712. serialize(): any;
  54713. /**
  54714. * Parses a anisotropy Configuration from a serialized object.
  54715. * @param source - Serialized object.
  54716. * @param scene Defines the scene we are parsing for
  54717. * @param rootUrl Defines the rootUrl to load from
  54718. */
  54719. parse(source: any, scene: Scene, rootUrl: string): void;
  54720. }
  54721. }
  54722. declare module BABYLON {
  54723. /**
  54724. * @hidden
  54725. */
  54726. export interface IMaterialBRDFDefines {
  54727. BRDF_V_HEIGHT_CORRELATED: boolean;
  54728. MS_BRDF_ENERGY_CONSERVATION: boolean;
  54729. SPHERICAL_HARMONICS: boolean;
  54730. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  54731. /** @hidden */
  54732. _areMiscDirty: boolean;
  54733. }
  54734. /**
  54735. * Define the code related to the BRDF parameters of the pbr material.
  54736. */
  54737. export class PBRBRDFConfiguration {
  54738. /**
  54739. * Default value used for the energy conservation.
  54740. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54741. */
  54742. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  54743. /**
  54744. * Default value used for the Smith Visibility Height Correlated mode.
  54745. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54746. */
  54747. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  54748. /**
  54749. * Default value used for the IBL diffuse part.
  54750. * This can help switching back to the polynomials mode globally which is a tiny bit
  54751. * less GPU intensive at the drawback of a lower quality.
  54752. */
  54753. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  54754. /**
  54755. * Default value used for activating energy conservation for the specular workflow.
  54756. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54757. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54758. */
  54759. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  54760. private _useEnergyConservation;
  54761. /**
  54762. * Defines if the material uses energy conservation.
  54763. */
  54764. useEnergyConservation: boolean;
  54765. private _useSmithVisibilityHeightCorrelated;
  54766. /**
  54767. * LEGACY Mode set to false
  54768. * Defines if the material uses height smith correlated visibility term.
  54769. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  54770. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  54771. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  54772. * Not relying on height correlated will also disable energy conservation.
  54773. */
  54774. useSmithVisibilityHeightCorrelated: boolean;
  54775. private _useSphericalHarmonics;
  54776. /**
  54777. * LEGACY Mode set to false
  54778. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  54779. * diffuse part of the IBL.
  54780. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  54781. * to the ground truth.
  54782. */
  54783. useSphericalHarmonics: boolean;
  54784. private _useSpecularGlossinessInputEnergyConservation;
  54785. /**
  54786. * Defines if the material uses energy conservation, when the specular workflow is active.
  54787. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54788. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54789. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  54790. */
  54791. useSpecularGlossinessInputEnergyConservation: boolean;
  54792. /** @hidden */
  54793. private _internalMarkAllSubMeshesAsMiscDirty;
  54794. /** @hidden */
  54795. _markAllSubMeshesAsMiscDirty(): void;
  54796. /**
  54797. * Instantiate a new istance of clear coat configuration.
  54798. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  54799. */
  54800. constructor(markAllSubMeshesAsMiscDirty: () => void);
  54801. /**
  54802. * Checks to see if a texture is used in the material.
  54803. * @param defines the list of "defines" to update.
  54804. */
  54805. prepareDefines(defines: IMaterialBRDFDefines): void;
  54806. /**
  54807. * Get the current class name of the texture useful for serialization or dynamic coding.
  54808. * @returns "PBRClearCoatConfiguration"
  54809. */
  54810. getClassName(): string;
  54811. /**
  54812. * Makes a duplicate of the current configuration into another one.
  54813. * @param brdfConfiguration define the config where to copy the info
  54814. */
  54815. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  54816. /**
  54817. * Serializes this BRDF configuration.
  54818. * @returns - An object with the serialized config.
  54819. */
  54820. serialize(): any;
  54821. /**
  54822. * Parses a anisotropy Configuration from a serialized object.
  54823. * @param source - Serialized object.
  54824. * @param scene Defines the scene we are parsing for
  54825. * @param rootUrl Defines the rootUrl to load from
  54826. */
  54827. parse(source: any, scene: Scene, rootUrl: string): void;
  54828. }
  54829. }
  54830. declare module BABYLON {
  54831. /**
  54832. * @hidden
  54833. */
  54834. export interface IMaterialSheenDefines {
  54835. SHEEN: boolean;
  54836. SHEEN_TEXTURE: boolean;
  54837. SHEEN_TEXTUREDIRECTUV: number;
  54838. SHEEN_LINKWITHALBEDO: boolean;
  54839. SHEEN_ROUGHNESS: boolean;
  54840. SHEEN_ALBEDOSCALING: boolean;
  54841. /** @hidden */
  54842. _areTexturesDirty: boolean;
  54843. }
  54844. /**
  54845. * Define the code related to the Sheen parameters of the pbr material.
  54846. */
  54847. export class PBRSheenConfiguration {
  54848. private _isEnabled;
  54849. /**
  54850. * Defines if the material uses sheen.
  54851. */
  54852. isEnabled: boolean;
  54853. private _linkSheenWithAlbedo;
  54854. /**
  54855. * Defines if the sheen is linked to the sheen color.
  54856. */
  54857. linkSheenWithAlbedo: boolean;
  54858. /**
  54859. * Defines the sheen intensity.
  54860. */
  54861. intensity: number;
  54862. /**
  54863. * Defines the sheen color.
  54864. */
  54865. color: Color3;
  54866. private _texture;
  54867. /**
  54868. * Stores the sheen tint values in a texture.
  54869. * rgb is tint
  54870. * a is a intensity or roughness if roughness has been defined
  54871. */
  54872. texture: Nullable<BaseTexture>;
  54873. private _roughness;
  54874. /**
  54875. * Defines the sheen roughness.
  54876. * It is not taken into account if linkSheenWithAlbedo is true.
  54877. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  54878. */
  54879. roughness: Nullable<number>;
  54880. private _albedoScaling;
  54881. /**
  54882. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  54883. * It allows the strength of the sheen effect to not depend on the base color of the material,
  54884. * making it easier to setup and tweak the effect
  54885. */
  54886. albedoScaling: boolean;
  54887. /** @hidden */
  54888. private _internalMarkAllSubMeshesAsTexturesDirty;
  54889. /** @hidden */
  54890. _markAllSubMeshesAsTexturesDirty(): void;
  54891. /**
  54892. * Instantiate a new istance of clear coat configuration.
  54893. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54894. */
  54895. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54896. /**
  54897. * Specifies that the submesh is ready to be used.
  54898. * @param defines the list of "defines" to update.
  54899. * @param scene defines the scene the material belongs to.
  54900. * @returns - boolean indicating that the submesh is ready or not.
  54901. */
  54902. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  54903. /**
  54904. * Checks to see if a texture is used in the material.
  54905. * @param defines the list of "defines" to update.
  54906. * @param scene defines the scene the material belongs to.
  54907. */
  54908. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  54909. /**
  54910. * Binds the material data.
  54911. * @param uniformBuffer defines the Uniform buffer to fill in.
  54912. * @param scene defines the scene the material belongs to.
  54913. * @param isFrozen defines wether the material is frozen or not.
  54914. */
  54915. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  54916. /**
  54917. * Checks to see if a texture is used in the material.
  54918. * @param texture - Base texture to use.
  54919. * @returns - Boolean specifying if a texture is used in the material.
  54920. */
  54921. hasTexture(texture: BaseTexture): boolean;
  54922. /**
  54923. * Returns an array of the actively used textures.
  54924. * @param activeTextures Array of BaseTextures
  54925. */
  54926. getActiveTextures(activeTextures: BaseTexture[]): void;
  54927. /**
  54928. * Returns the animatable textures.
  54929. * @param animatables Array of animatable textures.
  54930. */
  54931. getAnimatables(animatables: IAnimatable[]): void;
  54932. /**
  54933. * Disposes the resources of the material.
  54934. * @param forceDisposeTextures - Forces the disposal of all textures.
  54935. */
  54936. dispose(forceDisposeTextures?: boolean): void;
  54937. /**
  54938. * Get the current class name of the texture useful for serialization or dynamic coding.
  54939. * @returns "PBRSheenConfiguration"
  54940. */
  54941. getClassName(): string;
  54942. /**
  54943. * Add fallbacks to the effect fallbacks list.
  54944. * @param defines defines the Base texture to use.
  54945. * @param fallbacks defines the current fallback list.
  54946. * @param currentRank defines the current fallback rank.
  54947. * @returns the new fallback rank.
  54948. */
  54949. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54950. /**
  54951. * Add the required uniforms to the current list.
  54952. * @param uniforms defines the current uniform list.
  54953. */
  54954. static AddUniforms(uniforms: string[]): void;
  54955. /**
  54956. * Add the required uniforms to the current buffer.
  54957. * @param uniformBuffer defines the current uniform buffer.
  54958. */
  54959. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54960. /**
  54961. * Add the required samplers to the current list.
  54962. * @param samplers defines the current sampler list.
  54963. */
  54964. static AddSamplers(samplers: string[]): void;
  54965. /**
  54966. * Makes a duplicate of the current configuration into another one.
  54967. * @param sheenConfiguration define the config where to copy the info
  54968. */
  54969. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  54970. /**
  54971. * Serializes this BRDF configuration.
  54972. * @returns - An object with the serialized config.
  54973. */
  54974. serialize(): any;
  54975. /**
  54976. * Parses a anisotropy Configuration from a serialized object.
  54977. * @param source - Serialized object.
  54978. * @param scene Defines the scene we are parsing for
  54979. * @param rootUrl Defines the rootUrl to load from
  54980. */
  54981. parse(source: any, scene: Scene, rootUrl: string): void;
  54982. }
  54983. }
  54984. declare module BABYLON {
  54985. /**
  54986. * @hidden
  54987. */
  54988. export interface IMaterialSubSurfaceDefines {
  54989. SUBSURFACE: boolean;
  54990. SS_REFRACTION: boolean;
  54991. SS_TRANSLUCENCY: boolean;
  54992. SS_SCATTERING: boolean;
  54993. SS_THICKNESSANDMASK_TEXTURE: boolean;
  54994. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  54995. SS_REFRACTIONMAP_3D: boolean;
  54996. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  54997. SS_LODINREFRACTIONALPHA: boolean;
  54998. SS_GAMMAREFRACTION: boolean;
  54999. SS_RGBDREFRACTION: boolean;
  55000. SS_LINEARSPECULARREFRACTION: boolean;
  55001. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  55002. SS_ALBEDOFORREFRACTIONTINT: boolean;
  55003. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  55004. /** @hidden */
  55005. _areTexturesDirty: boolean;
  55006. }
  55007. /**
  55008. * Define the code related to the sub surface parameters of the pbr material.
  55009. */
  55010. export class PBRSubSurfaceConfiguration {
  55011. private _isRefractionEnabled;
  55012. /**
  55013. * Defines if the refraction is enabled in the material.
  55014. */
  55015. isRefractionEnabled: boolean;
  55016. private _isTranslucencyEnabled;
  55017. /**
  55018. * Defines if the translucency is enabled in the material.
  55019. */
  55020. isTranslucencyEnabled: boolean;
  55021. private _isScatteringEnabled;
  55022. /**
  55023. * Defines if the sub surface scattering is enabled in the material.
  55024. */
  55025. isScatteringEnabled: boolean;
  55026. private _scatteringDiffusionProfileIndex;
  55027. /**
  55028. * Diffusion profile for subsurface scattering.
  55029. * Useful for better scattering in the skins or foliages.
  55030. */
  55031. get scatteringDiffusionProfile(): Nullable<Color3>;
  55032. set scatteringDiffusionProfile(c: Nullable<Color3>);
  55033. /**
  55034. * Defines the refraction intensity of the material.
  55035. * The refraction when enabled replaces the Diffuse part of the material.
  55036. * The intensity helps transitionning between diffuse and refraction.
  55037. */
  55038. refractionIntensity: number;
  55039. /**
  55040. * Defines the translucency intensity of the material.
  55041. * When translucency has been enabled, this defines how much of the "translucency"
  55042. * is addded to the diffuse part of the material.
  55043. */
  55044. translucencyIntensity: number;
  55045. /**
  55046. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  55047. */
  55048. useAlbedoToTintRefraction: boolean;
  55049. private _thicknessTexture;
  55050. /**
  55051. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  55052. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  55053. * 0 would mean minimumThickness
  55054. * 1 would mean maximumThickness
  55055. * The other channels might be use as a mask to vary the different effects intensity.
  55056. */
  55057. thicknessTexture: Nullable<BaseTexture>;
  55058. private _refractionTexture;
  55059. /**
  55060. * Defines the texture to use for refraction.
  55061. */
  55062. refractionTexture: Nullable<BaseTexture>;
  55063. private _indexOfRefraction;
  55064. /**
  55065. * Index of refraction of the material base layer.
  55066. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55067. *
  55068. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  55069. *
  55070. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  55071. */
  55072. indexOfRefraction: number;
  55073. private _volumeIndexOfRefraction;
  55074. /**
  55075. * Index of refraction of the material's volume.
  55076. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55077. *
  55078. * This ONLY impacts refraction. If not provided or given a non-valid value,
  55079. * the volume will use the same IOR as the surface.
  55080. */
  55081. get volumeIndexOfRefraction(): number;
  55082. set volumeIndexOfRefraction(value: number);
  55083. private _invertRefractionY;
  55084. /**
  55085. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55086. */
  55087. invertRefractionY: boolean;
  55088. private _linkRefractionWithTransparency;
  55089. /**
  55090. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55091. * Materials half opaque for instance using refraction could benefit from this control.
  55092. */
  55093. linkRefractionWithTransparency: boolean;
  55094. /**
  55095. * Defines the minimum thickness stored in the thickness map.
  55096. * If no thickness map is defined, this value will be used to simulate thickness.
  55097. */
  55098. minimumThickness: number;
  55099. /**
  55100. * Defines the maximum thickness stored in the thickness map.
  55101. */
  55102. maximumThickness: number;
  55103. /**
  55104. * Defines the volume tint of the material.
  55105. * This is used for both translucency and scattering.
  55106. */
  55107. tintColor: Color3;
  55108. /**
  55109. * Defines the distance at which the tint color should be found in the media.
  55110. * This is used for refraction only.
  55111. */
  55112. tintColorAtDistance: number;
  55113. /**
  55114. * Defines how far each channel transmit through the media.
  55115. * It is defined as a color to simplify it selection.
  55116. */
  55117. diffusionDistance: Color3;
  55118. private _useMaskFromThicknessTexture;
  55119. /**
  55120. * Stores the intensity of the different subsurface effects in the thickness texture.
  55121. * * the green channel is the translucency intensity.
  55122. * * the blue channel is the scattering intensity.
  55123. * * the alpha channel is the refraction intensity.
  55124. */
  55125. useMaskFromThicknessTexture: boolean;
  55126. private _scene;
  55127. /** @hidden */
  55128. private _internalMarkAllSubMeshesAsTexturesDirty;
  55129. private _internalMarkScenePrePassDirty;
  55130. /** @hidden */
  55131. _markAllSubMeshesAsTexturesDirty(): void;
  55132. /** @hidden */
  55133. _markScenePrePassDirty(): void;
  55134. /**
  55135. * Instantiate a new istance of sub surface configuration.
  55136. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55137. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  55138. * @param scene The scene
  55139. */
  55140. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  55141. /**
  55142. * Gets wehter the submesh is ready to be used or not.
  55143. * @param defines the list of "defines" to update.
  55144. * @param scene defines the scene the material belongs to.
  55145. * @returns - boolean indicating that the submesh is ready or not.
  55146. */
  55147. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  55148. /**
  55149. * Checks to see if a texture is used in the material.
  55150. * @param defines the list of "defines" to update.
  55151. * @param scene defines the scene to the material belongs to.
  55152. */
  55153. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  55154. /**
  55155. * Binds the material data.
  55156. * @param uniformBuffer defines the Uniform buffer to fill in.
  55157. * @param scene defines the scene the material belongs to.
  55158. * @param engine defines the engine the material belongs to.
  55159. * @param isFrozen defines whether the material is frozen or not.
  55160. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  55161. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  55162. */
  55163. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  55164. /**
  55165. * Unbinds the material from the mesh.
  55166. * @param activeEffect defines the effect that should be unbound from.
  55167. * @returns true if unbound, otherwise false
  55168. */
  55169. unbind(activeEffect: Effect): boolean;
  55170. /**
  55171. * Returns the texture used for refraction or null if none is used.
  55172. * @param scene defines the scene the material belongs to.
  55173. * @returns - Refraction texture if present. If no refraction texture and refraction
  55174. * is linked with transparency, returns environment texture. Otherwise, returns null.
  55175. */
  55176. private _getRefractionTexture;
  55177. /**
  55178. * Returns true if alpha blending should be disabled.
  55179. */
  55180. get disableAlphaBlending(): boolean;
  55181. /**
  55182. * Fills the list of render target textures.
  55183. * @param renderTargets the list of render targets to update
  55184. */
  55185. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  55186. /**
  55187. * Checks to see if a texture is used in the material.
  55188. * @param texture - Base texture to use.
  55189. * @returns - Boolean specifying if a texture is used in the material.
  55190. */
  55191. hasTexture(texture: BaseTexture): boolean;
  55192. /**
  55193. * Gets a boolean indicating that current material needs to register RTT
  55194. * @returns true if this uses a render target otherwise false.
  55195. */
  55196. hasRenderTargetTextures(): boolean;
  55197. /**
  55198. * Returns an array of the actively used textures.
  55199. * @param activeTextures Array of BaseTextures
  55200. */
  55201. getActiveTextures(activeTextures: BaseTexture[]): void;
  55202. /**
  55203. * Returns the animatable textures.
  55204. * @param animatables Array of animatable textures.
  55205. */
  55206. getAnimatables(animatables: IAnimatable[]): void;
  55207. /**
  55208. * Disposes the resources of the material.
  55209. * @param forceDisposeTextures - Forces the disposal of all textures.
  55210. */
  55211. dispose(forceDisposeTextures?: boolean): void;
  55212. /**
  55213. * Get the current class name of the texture useful for serialization or dynamic coding.
  55214. * @returns "PBRSubSurfaceConfiguration"
  55215. */
  55216. getClassName(): string;
  55217. /**
  55218. * Add fallbacks to the effect fallbacks list.
  55219. * @param defines defines the Base texture to use.
  55220. * @param fallbacks defines the current fallback list.
  55221. * @param currentRank defines the current fallback rank.
  55222. * @returns the new fallback rank.
  55223. */
  55224. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55225. /**
  55226. * Add the required uniforms to the current list.
  55227. * @param uniforms defines the current uniform list.
  55228. */
  55229. static AddUniforms(uniforms: string[]): void;
  55230. /**
  55231. * Add the required samplers to the current list.
  55232. * @param samplers defines the current sampler list.
  55233. */
  55234. static AddSamplers(samplers: string[]): void;
  55235. /**
  55236. * Add the required uniforms to the current buffer.
  55237. * @param uniformBuffer defines the current uniform buffer.
  55238. */
  55239. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55240. /**
  55241. * Makes a duplicate of the current configuration into another one.
  55242. * @param configuration define the config where to copy the info
  55243. */
  55244. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  55245. /**
  55246. * Serializes this Sub Surface configuration.
  55247. * @returns - An object with the serialized config.
  55248. */
  55249. serialize(): any;
  55250. /**
  55251. * Parses a anisotropy Configuration from a serialized object.
  55252. * @param source - Serialized object.
  55253. * @param scene Defines the scene we are parsing for
  55254. * @param rootUrl Defines the rootUrl to load from
  55255. */
  55256. parse(source: any, scene: Scene, rootUrl: string): void;
  55257. }
  55258. }
  55259. declare module BABYLON {
  55260. /** @hidden */
  55261. export var pbrFragmentDeclaration: {
  55262. name: string;
  55263. shader: string;
  55264. };
  55265. }
  55266. declare module BABYLON {
  55267. /** @hidden */
  55268. export var pbrUboDeclaration: {
  55269. name: string;
  55270. shader: string;
  55271. };
  55272. }
  55273. declare module BABYLON {
  55274. /** @hidden */
  55275. export var pbrFragmentExtraDeclaration: {
  55276. name: string;
  55277. shader: string;
  55278. };
  55279. }
  55280. declare module BABYLON {
  55281. /** @hidden */
  55282. export var pbrFragmentSamplersDeclaration: {
  55283. name: string;
  55284. shader: string;
  55285. };
  55286. }
  55287. declare module BABYLON {
  55288. /** @hidden */
  55289. export var importanceSampling: {
  55290. name: string;
  55291. shader: string;
  55292. };
  55293. }
  55294. declare module BABYLON {
  55295. /** @hidden */
  55296. export var pbrHelperFunctions: {
  55297. name: string;
  55298. shader: string;
  55299. };
  55300. }
  55301. declare module BABYLON {
  55302. /** @hidden */
  55303. export var harmonicsFunctions: {
  55304. name: string;
  55305. shader: string;
  55306. };
  55307. }
  55308. declare module BABYLON {
  55309. /** @hidden */
  55310. export var pbrDirectLightingSetupFunctions: {
  55311. name: string;
  55312. shader: string;
  55313. };
  55314. }
  55315. declare module BABYLON {
  55316. /** @hidden */
  55317. export var pbrDirectLightingFalloffFunctions: {
  55318. name: string;
  55319. shader: string;
  55320. };
  55321. }
  55322. declare module BABYLON {
  55323. /** @hidden */
  55324. export var pbrBRDFFunctions: {
  55325. name: string;
  55326. shader: string;
  55327. };
  55328. }
  55329. declare module BABYLON {
  55330. /** @hidden */
  55331. export var hdrFilteringFunctions: {
  55332. name: string;
  55333. shader: string;
  55334. };
  55335. }
  55336. declare module BABYLON {
  55337. /** @hidden */
  55338. export var pbrDirectLightingFunctions: {
  55339. name: string;
  55340. shader: string;
  55341. };
  55342. }
  55343. declare module BABYLON {
  55344. /** @hidden */
  55345. export var pbrIBLFunctions: {
  55346. name: string;
  55347. shader: string;
  55348. };
  55349. }
  55350. declare module BABYLON {
  55351. /** @hidden */
  55352. export var pbrBlockAlbedoOpacity: {
  55353. name: string;
  55354. shader: string;
  55355. };
  55356. }
  55357. declare module BABYLON {
  55358. /** @hidden */
  55359. export var pbrBlockReflectivity: {
  55360. name: string;
  55361. shader: string;
  55362. };
  55363. }
  55364. declare module BABYLON {
  55365. /** @hidden */
  55366. export var pbrBlockAmbientOcclusion: {
  55367. name: string;
  55368. shader: string;
  55369. };
  55370. }
  55371. declare module BABYLON {
  55372. /** @hidden */
  55373. export var pbrBlockAlphaFresnel: {
  55374. name: string;
  55375. shader: string;
  55376. };
  55377. }
  55378. declare module BABYLON {
  55379. /** @hidden */
  55380. export var pbrBlockAnisotropic: {
  55381. name: string;
  55382. shader: string;
  55383. };
  55384. }
  55385. declare module BABYLON {
  55386. /** @hidden */
  55387. export var pbrBlockReflection: {
  55388. name: string;
  55389. shader: string;
  55390. };
  55391. }
  55392. declare module BABYLON {
  55393. /** @hidden */
  55394. export var pbrBlockSheen: {
  55395. name: string;
  55396. shader: string;
  55397. };
  55398. }
  55399. declare module BABYLON {
  55400. /** @hidden */
  55401. export var pbrBlockClearcoat: {
  55402. name: string;
  55403. shader: string;
  55404. };
  55405. }
  55406. declare module BABYLON {
  55407. /** @hidden */
  55408. export var pbrBlockSubSurface: {
  55409. name: string;
  55410. shader: string;
  55411. };
  55412. }
  55413. declare module BABYLON {
  55414. /** @hidden */
  55415. export var pbrBlockNormalGeometric: {
  55416. name: string;
  55417. shader: string;
  55418. };
  55419. }
  55420. declare module BABYLON {
  55421. /** @hidden */
  55422. export var pbrBlockNormalFinal: {
  55423. name: string;
  55424. shader: string;
  55425. };
  55426. }
  55427. declare module BABYLON {
  55428. /** @hidden */
  55429. export var pbrBlockLightmapInit: {
  55430. name: string;
  55431. shader: string;
  55432. };
  55433. }
  55434. declare module BABYLON {
  55435. /** @hidden */
  55436. export var pbrBlockGeometryInfo: {
  55437. name: string;
  55438. shader: string;
  55439. };
  55440. }
  55441. declare module BABYLON {
  55442. /** @hidden */
  55443. export var pbrBlockReflectance0: {
  55444. name: string;
  55445. shader: string;
  55446. };
  55447. }
  55448. declare module BABYLON {
  55449. /** @hidden */
  55450. export var pbrBlockReflectance: {
  55451. name: string;
  55452. shader: string;
  55453. };
  55454. }
  55455. declare module BABYLON {
  55456. /** @hidden */
  55457. export var pbrBlockDirectLighting: {
  55458. name: string;
  55459. shader: string;
  55460. };
  55461. }
  55462. declare module BABYLON {
  55463. /** @hidden */
  55464. export var pbrBlockFinalLitComponents: {
  55465. name: string;
  55466. shader: string;
  55467. };
  55468. }
  55469. declare module BABYLON {
  55470. /** @hidden */
  55471. export var pbrBlockFinalUnlitComponents: {
  55472. name: string;
  55473. shader: string;
  55474. };
  55475. }
  55476. declare module BABYLON {
  55477. /** @hidden */
  55478. export var pbrBlockFinalColorComposition: {
  55479. name: string;
  55480. shader: string;
  55481. };
  55482. }
  55483. declare module BABYLON {
  55484. /** @hidden */
  55485. export var pbrBlockImageProcessing: {
  55486. name: string;
  55487. shader: string;
  55488. };
  55489. }
  55490. declare module BABYLON {
  55491. /** @hidden */
  55492. export var pbrDebug: {
  55493. name: string;
  55494. shader: string;
  55495. };
  55496. }
  55497. declare module BABYLON {
  55498. /** @hidden */
  55499. export var pbrPixelShader: {
  55500. name: string;
  55501. shader: string;
  55502. };
  55503. }
  55504. declare module BABYLON {
  55505. /** @hidden */
  55506. export var pbrVertexDeclaration: {
  55507. name: string;
  55508. shader: string;
  55509. };
  55510. }
  55511. declare module BABYLON {
  55512. /** @hidden */
  55513. export var pbrVertexShader: {
  55514. name: string;
  55515. shader: string;
  55516. };
  55517. }
  55518. declare module BABYLON {
  55519. /**
  55520. * Manages the defines for the PBR Material.
  55521. * @hidden
  55522. */
  55523. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  55524. PBR: boolean;
  55525. NUM_SAMPLES: string;
  55526. REALTIME_FILTERING: boolean;
  55527. MAINUV1: boolean;
  55528. MAINUV2: boolean;
  55529. UV1: boolean;
  55530. UV2: boolean;
  55531. ALBEDO: boolean;
  55532. GAMMAALBEDO: boolean;
  55533. ALBEDODIRECTUV: number;
  55534. VERTEXCOLOR: boolean;
  55535. DETAIL: boolean;
  55536. DETAILDIRECTUV: number;
  55537. DETAIL_NORMALBLENDMETHOD: number;
  55538. AMBIENT: boolean;
  55539. AMBIENTDIRECTUV: number;
  55540. AMBIENTINGRAYSCALE: boolean;
  55541. OPACITY: boolean;
  55542. VERTEXALPHA: boolean;
  55543. OPACITYDIRECTUV: number;
  55544. OPACITYRGB: boolean;
  55545. ALPHATEST: boolean;
  55546. DEPTHPREPASS: boolean;
  55547. ALPHABLEND: boolean;
  55548. ALPHAFROMALBEDO: boolean;
  55549. ALPHATESTVALUE: string;
  55550. SPECULAROVERALPHA: boolean;
  55551. RADIANCEOVERALPHA: boolean;
  55552. ALPHAFRESNEL: boolean;
  55553. LINEARALPHAFRESNEL: boolean;
  55554. PREMULTIPLYALPHA: boolean;
  55555. EMISSIVE: boolean;
  55556. EMISSIVEDIRECTUV: number;
  55557. REFLECTIVITY: boolean;
  55558. REFLECTIVITYDIRECTUV: number;
  55559. SPECULARTERM: boolean;
  55560. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  55561. MICROSURFACEAUTOMATIC: boolean;
  55562. LODBASEDMICROSFURACE: boolean;
  55563. MICROSURFACEMAP: boolean;
  55564. MICROSURFACEMAPDIRECTUV: number;
  55565. METALLICWORKFLOW: boolean;
  55566. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  55567. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  55568. METALLNESSSTOREINMETALMAPBLUE: boolean;
  55569. AOSTOREINMETALMAPRED: boolean;
  55570. METALLIC_REFLECTANCE: boolean;
  55571. METALLIC_REFLECTANCEDIRECTUV: number;
  55572. ENVIRONMENTBRDF: boolean;
  55573. ENVIRONMENTBRDF_RGBD: boolean;
  55574. NORMAL: boolean;
  55575. TANGENT: boolean;
  55576. BUMP: boolean;
  55577. BUMPDIRECTUV: number;
  55578. OBJECTSPACE_NORMALMAP: boolean;
  55579. PARALLAX: boolean;
  55580. PARALLAXOCCLUSION: boolean;
  55581. NORMALXYSCALE: boolean;
  55582. LIGHTMAP: boolean;
  55583. LIGHTMAPDIRECTUV: number;
  55584. USELIGHTMAPASSHADOWMAP: boolean;
  55585. GAMMALIGHTMAP: boolean;
  55586. RGBDLIGHTMAP: boolean;
  55587. REFLECTION: boolean;
  55588. REFLECTIONMAP_3D: boolean;
  55589. REFLECTIONMAP_SPHERICAL: boolean;
  55590. REFLECTIONMAP_PLANAR: boolean;
  55591. REFLECTIONMAP_CUBIC: boolean;
  55592. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  55593. REFLECTIONMAP_PROJECTION: boolean;
  55594. REFLECTIONMAP_SKYBOX: boolean;
  55595. REFLECTIONMAP_EXPLICIT: boolean;
  55596. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  55597. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  55598. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  55599. INVERTCUBICMAP: boolean;
  55600. USESPHERICALFROMREFLECTIONMAP: boolean;
  55601. USEIRRADIANCEMAP: boolean;
  55602. SPHERICAL_HARMONICS: boolean;
  55603. USESPHERICALINVERTEX: boolean;
  55604. REFLECTIONMAP_OPPOSITEZ: boolean;
  55605. LODINREFLECTIONALPHA: boolean;
  55606. GAMMAREFLECTION: boolean;
  55607. RGBDREFLECTION: boolean;
  55608. LINEARSPECULARREFLECTION: boolean;
  55609. RADIANCEOCCLUSION: boolean;
  55610. HORIZONOCCLUSION: boolean;
  55611. INSTANCES: boolean;
  55612. THIN_INSTANCES: boolean;
  55613. PREPASS: boolean;
  55614. SCENE_MRT_COUNT: number;
  55615. NUM_BONE_INFLUENCERS: number;
  55616. BonesPerMesh: number;
  55617. BONETEXTURE: boolean;
  55618. NONUNIFORMSCALING: boolean;
  55619. MORPHTARGETS: boolean;
  55620. MORPHTARGETS_NORMAL: boolean;
  55621. MORPHTARGETS_TANGENT: boolean;
  55622. MORPHTARGETS_UV: boolean;
  55623. NUM_MORPH_INFLUENCERS: number;
  55624. IMAGEPROCESSING: boolean;
  55625. VIGNETTE: boolean;
  55626. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55627. VIGNETTEBLENDMODEOPAQUE: boolean;
  55628. TONEMAPPING: boolean;
  55629. TONEMAPPING_ACES: boolean;
  55630. CONTRAST: boolean;
  55631. COLORCURVES: boolean;
  55632. COLORGRADING: boolean;
  55633. COLORGRADING3D: boolean;
  55634. SAMPLER3DGREENDEPTH: boolean;
  55635. SAMPLER3DBGRMAP: boolean;
  55636. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55637. EXPOSURE: boolean;
  55638. MULTIVIEW: boolean;
  55639. USEPHYSICALLIGHTFALLOFF: boolean;
  55640. USEGLTFLIGHTFALLOFF: boolean;
  55641. TWOSIDEDLIGHTING: boolean;
  55642. SHADOWFLOAT: boolean;
  55643. CLIPPLANE: boolean;
  55644. CLIPPLANE2: boolean;
  55645. CLIPPLANE3: boolean;
  55646. CLIPPLANE4: boolean;
  55647. CLIPPLANE5: boolean;
  55648. CLIPPLANE6: boolean;
  55649. POINTSIZE: boolean;
  55650. FOG: boolean;
  55651. LOGARITHMICDEPTH: boolean;
  55652. FORCENORMALFORWARD: boolean;
  55653. SPECULARAA: boolean;
  55654. CLEARCOAT: boolean;
  55655. CLEARCOAT_DEFAULTIOR: boolean;
  55656. CLEARCOAT_TEXTURE: boolean;
  55657. CLEARCOAT_TEXTUREDIRECTUV: number;
  55658. CLEARCOAT_BUMP: boolean;
  55659. CLEARCOAT_BUMPDIRECTUV: number;
  55660. CLEARCOAT_TINT: boolean;
  55661. CLEARCOAT_TINT_TEXTURE: boolean;
  55662. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  55663. ANISOTROPIC: boolean;
  55664. ANISOTROPIC_TEXTURE: boolean;
  55665. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55666. BRDF_V_HEIGHT_CORRELATED: boolean;
  55667. MS_BRDF_ENERGY_CONSERVATION: boolean;
  55668. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  55669. SHEEN: boolean;
  55670. SHEEN_TEXTURE: boolean;
  55671. SHEEN_TEXTUREDIRECTUV: number;
  55672. SHEEN_LINKWITHALBEDO: boolean;
  55673. SHEEN_ROUGHNESS: boolean;
  55674. SHEEN_ALBEDOSCALING: boolean;
  55675. SUBSURFACE: boolean;
  55676. SS_REFRACTION: boolean;
  55677. SS_TRANSLUCENCY: boolean;
  55678. SS_SCATTERING: boolean;
  55679. SS_THICKNESSANDMASK_TEXTURE: boolean;
  55680. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  55681. SS_REFRACTIONMAP_3D: boolean;
  55682. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  55683. SS_LODINREFRACTIONALPHA: boolean;
  55684. SS_GAMMAREFRACTION: boolean;
  55685. SS_RGBDREFRACTION: boolean;
  55686. SS_LINEARSPECULARREFRACTION: boolean;
  55687. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  55688. SS_ALBEDOFORREFRACTIONTINT: boolean;
  55689. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  55690. UNLIT: boolean;
  55691. DEBUGMODE: number;
  55692. /**
  55693. * Initializes the PBR Material defines.
  55694. */
  55695. constructor();
  55696. /**
  55697. * Resets the PBR Material defines.
  55698. */
  55699. reset(): void;
  55700. }
  55701. /**
  55702. * The Physically based material base class of BJS.
  55703. *
  55704. * This offers the main features of a standard PBR material.
  55705. * For more information, please refer to the documentation :
  55706. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55707. */
  55708. export abstract class PBRBaseMaterial extends PushMaterial {
  55709. /**
  55710. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55711. */
  55712. static readonly PBRMATERIAL_OPAQUE: number;
  55713. /**
  55714. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55715. */
  55716. static readonly PBRMATERIAL_ALPHATEST: number;
  55717. /**
  55718. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55719. */
  55720. static readonly PBRMATERIAL_ALPHABLEND: number;
  55721. /**
  55722. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55723. * They are also discarded below the alpha cutoff threshold to improve performances.
  55724. */
  55725. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55726. /**
  55727. * Defines the default value of how much AO map is occluding the analytical lights
  55728. * (point spot...).
  55729. */
  55730. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55731. /**
  55732. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  55733. */
  55734. static readonly LIGHTFALLOFF_PHYSICAL: number;
  55735. /**
  55736. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  55737. * to enhance interoperability with other engines.
  55738. */
  55739. static readonly LIGHTFALLOFF_GLTF: number;
  55740. /**
  55741. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  55742. * to enhance interoperability with other materials.
  55743. */
  55744. static readonly LIGHTFALLOFF_STANDARD: number;
  55745. /**
  55746. * Intensity of the direct lights e.g. the four lights available in your scene.
  55747. * This impacts both the direct diffuse and specular highlights.
  55748. */
  55749. protected _directIntensity: number;
  55750. /**
  55751. * Intensity of the emissive part of the material.
  55752. * This helps controlling the emissive effect without modifying the emissive color.
  55753. */
  55754. protected _emissiveIntensity: number;
  55755. /**
  55756. * Intensity of the environment e.g. how much the environment will light the object
  55757. * either through harmonics for rough material or through the refelction for shiny ones.
  55758. */
  55759. protected _environmentIntensity: number;
  55760. /**
  55761. * This is a special control allowing the reduction of the specular highlights coming from the
  55762. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55763. */
  55764. protected _specularIntensity: number;
  55765. /**
  55766. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  55767. */
  55768. private _lightingInfos;
  55769. /**
  55770. * Debug Control allowing disabling the bump map on this material.
  55771. */
  55772. protected _disableBumpMap: boolean;
  55773. /**
  55774. * AKA Diffuse Texture in standard nomenclature.
  55775. */
  55776. protected _albedoTexture: Nullable<BaseTexture>;
  55777. /**
  55778. * AKA Occlusion Texture in other nomenclature.
  55779. */
  55780. protected _ambientTexture: Nullable<BaseTexture>;
  55781. /**
  55782. * AKA Occlusion Texture Intensity in other nomenclature.
  55783. */
  55784. protected _ambientTextureStrength: number;
  55785. /**
  55786. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55787. * 1 means it completely occludes it
  55788. * 0 mean it has no impact
  55789. */
  55790. protected _ambientTextureImpactOnAnalyticalLights: number;
  55791. /**
  55792. * Stores the alpha values in a texture.
  55793. */
  55794. protected _opacityTexture: Nullable<BaseTexture>;
  55795. /**
  55796. * Stores the reflection values in a texture.
  55797. */
  55798. protected _reflectionTexture: Nullable<BaseTexture>;
  55799. /**
  55800. * Stores the emissive values in a texture.
  55801. */
  55802. protected _emissiveTexture: Nullable<BaseTexture>;
  55803. /**
  55804. * AKA Specular texture in other nomenclature.
  55805. */
  55806. protected _reflectivityTexture: Nullable<BaseTexture>;
  55807. /**
  55808. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55809. */
  55810. protected _metallicTexture: Nullable<BaseTexture>;
  55811. /**
  55812. * Specifies the metallic scalar of the metallic/roughness workflow.
  55813. * Can also be used to scale the metalness values of the metallic texture.
  55814. */
  55815. protected _metallic: Nullable<number>;
  55816. /**
  55817. * Specifies the roughness scalar of the metallic/roughness workflow.
  55818. * Can also be used to scale the roughness values of the metallic texture.
  55819. */
  55820. protected _roughness: Nullable<number>;
  55821. /**
  55822. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55823. * By default the indexOfrefraction is used to compute F0;
  55824. *
  55825. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55826. *
  55827. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55828. * F90 = metallicReflectanceColor;
  55829. */
  55830. protected _metallicF0Factor: number;
  55831. /**
  55832. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55833. * By default the F90 is always 1;
  55834. *
  55835. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55836. *
  55837. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55838. * F90 = metallicReflectanceColor;
  55839. */
  55840. protected _metallicReflectanceColor: Color3;
  55841. /**
  55842. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55843. * This is multiply against the scalar values defined in the material.
  55844. */
  55845. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  55846. /**
  55847. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55848. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55849. */
  55850. protected _microSurfaceTexture: Nullable<BaseTexture>;
  55851. /**
  55852. * Stores surface normal data used to displace a mesh in a texture.
  55853. */
  55854. protected _bumpTexture: Nullable<BaseTexture>;
  55855. /**
  55856. * Stores the pre-calculated light information of a mesh in a texture.
  55857. */
  55858. protected _lightmapTexture: Nullable<BaseTexture>;
  55859. /**
  55860. * The color of a material in ambient lighting.
  55861. */
  55862. protected _ambientColor: Color3;
  55863. /**
  55864. * AKA Diffuse Color in other nomenclature.
  55865. */
  55866. protected _albedoColor: Color3;
  55867. /**
  55868. * AKA Specular Color in other nomenclature.
  55869. */
  55870. protected _reflectivityColor: Color3;
  55871. /**
  55872. * The color applied when light is reflected from a material.
  55873. */
  55874. protected _reflectionColor: Color3;
  55875. /**
  55876. * The color applied when light is emitted from a material.
  55877. */
  55878. protected _emissiveColor: Color3;
  55879. /**
  55880. * AKA Glossiness in other nomenclature.
  55881. */
  55882. protected _microSurface: number;
  55883. /**
  55884. * Specifies that the material will use the light map as a show map.
  55885. */
  55886. protected _useLightmapAsShadowmap: boolean;
  55887. /**
  55888. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  55889. * makes the reflect vector face the model (under horizon).
  55890. */
  55891. protected _useHorizonOcclusion: boolean;
  55892. /**
  55893. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  55894. * too much the area relying on ambient texture to define their ambient occlusion.
  55895. */
  55896. protected _useRadianceOcclusion: boolean;
  55897. /**
  55898. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  55899. */
  55900. protected _useAlphaFromAlbedoTexture: boolean;
  55901. /**
  55902. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  55903. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  55904. */
  55905. protected _useSpecularOverAlpha: boolean;
  55906. /**
  55907. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  55908. */
  55909. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  55910. /**
  55911. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  55912. */
  55913. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  55914. /**
  55915. * Specifies if the metallic texture contains the roughness information in its green channel.
  55916. */
  55917. protected _useRoughnessFromMetallicTextureGreen: boolean;
  55918. /**
  55919. * Specifies if the metallic texture contains the metallness information in its blue channel.
  55920. */
  55921. protected _useMetallnessFromMetallicTextureBlue: boolean;
  55922. /**
  55923. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  55924. */
  55925. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  55926. /**
  55927. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  55928. */
  55929. protected _useAmbientInGrayScale: boolean;
  55930. /**
  55931. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  55932. * The material will try to infer what glossiness each pixel should be.
  55933. */
  55934. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  55935. /**
  55936. * Defines the falloff type used in this material.
  55937. * It by default is Physical.
  55938. */
  55939. protected _lightFalloff: number;
  55940. /**
  55941. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  55942. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  55943. */
  55944. protected _useRadianceOverAlpha: boolean;
  55945. /**
  55946. * Allows using an object space normal map (instead of tangent space).
  55947. */
  55948. protected _useObjectSpaceNormalMap: boolean;
  55949. /**
  55950. * Allows using the bump map in parallax mode.
  55951. */
  55952. protected _useParallax: boolean;
  55953. /**
  55954. * Allows using the bump map in parallax occlusion mode.
  55955. */
  55956. protected _useParallaxOcclusion: boolean;
  55957. /**
  55958. * Controls the scale bias of the parallax mode.
  55959. */
  55960. protected _parallaxScaleBias: number;
  55961. /**
  55962. * If sets to true, disables all the lights affecting the material.
  55963. */
  55964. protected _disableLighting: boolean;
  55965. /**
  55966. * Number of Simultaneous lights allowed on the material.
  55967. */
  55968. protected _maxSimultaneousLights: number;
  55969. /**
  55970. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55971. */
  55972. protected _invertNormalMapX: boolean;
  55973. /**
  55974. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55975. */
  55976. protected _invertNormalMapY: boolean;
  55977. /**
  55978. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55979. */
  55980. protected _twoSidedLighting: boolean;
  55981. /**
  55982. * Defines the alpha limits in alpha test mode.
  55983. */
  55984. protected _alphaCutOff: number;
  55985. /**
  55986. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  55987. */
  55988. protected _forceAlphaTest: boolean;
  55989. /**
  55990. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55991. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  55992. */
  55993. protected _useAlphaFresnel: boolean;
  55994. /**
  55995. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55996. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  55997. */
  55998. protected _useLinearAlphaFresnel: boolean;
  55999. /**
  56000. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  56001. * from cos thetav and roughness:
  56002. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  56003. */
  56004. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  56005. /**
  56006. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  56007. */
  56008. protected _forceIrradianceInFragment: boolean;
  56009. private _realTimeFiltering;
  56010. /**
  56011. * Enables realtime filtering on the texture.
  56012. */
  56013. get realTimeFiltering(): boolean;
  56014. set realTimeFiltering(b: boolean);
  56015. private _realTimeFilteringQuality;
  56016. /**
  56017. * Quality switch for realtime filtering
  56018. */
  56019. get realTimeFilteringQuality(): number;
  56020. set realTimeFilteringQuality(n: number);
  56021. /**
  56022. * Can this material render to several textures at once
  56023. */
  56024. get canRenderToMRT(): boolean;
  56025. /**
  56026. * Force normal to face away from face.
  56027. */
  56028. protected _forceNormalForward: boolean;
  56029. /**
  56030. * Enables specular anti aliasing in the PBR shader.
  56031. * It will both interacts on the Geometry for analytical and IBL lighting.
  56032. * It also prefilter the roughness map based on the bump values.
  56033. */
  56034. protected _enableSpecularAntiAliasing: boolean;
  56035. /**
  56036. * Default configuration related to image processing available in the PBR Material.
  56037. */
  56038. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56039. /**
  56040. * Keep track of the image processing observer to allow dispose and replace.
  56041. */
  56042. private _imageProcessingObserver;
  56043. /**
  56044. * Attaches a new image processing configuration to the PBR Material.
  56045. * @param configuration
  56046. */
  56047. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56048. /**
  56049. * Stores the available render targets.
  56050. */
  56051. private _renderTargets;
  56052. /**
  56053. * Sets the global ambient color for the material used in lighting calculations.
  56054. */
  56055. private _globalAmbientColor;
  56056. /**
  56057. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  56058. */
  56059. private _useLogarithmicDepth;
  56060. /**
  56061. * If set to true, no lighting calculations will be applied.
  56062. */
  56063. private _unlit;
  56064. private _debugMode;
  56065. /**
  56066. * @hidden
  56067. * This is reserved for the inspector.
  56068. * Defines the material debug mode.
  56069. * It helps seeing only some components of the material while troubleshooting.
  56070. */
  56071. debugMode: number;
  56072. /**
  56073. * @hidden
  56074. * This is reserved for the inspector.
  56075. * Specify from where on screen the debug mode should start.
  56076. * The value goes from -1 (full screen) to 1 (not visible)
  56077. * It helps with side by side comparison against the final render
  56078. * This defaults to -1
  56079. */
  56080. private debugLimit;
  56081. /**
  56082. * @hidden
  56083. * This is reserved for the inspector.
  56084. * As the default viewing range might not be enough (if the ambient is really small for instance)
  56085. * You can use the factor to better multiply the final value.
  56086. */
  56087. private debugFactor;
  56088. /**
  56089. * Defines the clear coat layer parameters for the material.
  56090. */
  56091. readonly clearCoat: PBRClearCoatConfiguration;
  56092. /**
  56093. * Defines the anisotropic parameters for the material.
  56094. */
  56095. readonly anisotropy: PBRAnisotropicConfiguration;
  56096. /**
  56097. * Defines the BRDF parameters for the material.
  56098. */
  56099. readonly brdf: PBRBRDFConfiguration;
  56100. /**
  56101. * Defines the Sheen parameters for the material.
  56102. */
  56103. readonly sheen: PBRSheenConfiguration;
  56104. /**
  56105. * Defines the SubSurface parameters for the material.
  56106. */
  56107. readonly subSurface: PBRSubSurfaceConfiguration;
  56108. /**
  56109. * Defines the detail map parameters for the material.
  56110. */
  56111. readonly detailMap: DetailMapConfiguration;
  56112. protected _rebuildInParallel: boolean;
  56113. /**
  56114. * Instantiates a new PBRMaterial instance.
  56115. *
  56116. * @param name The material name
  56117. * @param scene The scene the material will be use in.
  56118. */
  56119. constructor(name: string, scene: Scene);
  56120. /**
  56121. * Gets a boolean indicating that current material needs to register RTT
  56122. */
  56123. get hasRenderTargetTextures(): boolean;
  56124. /**
  56125. * Gets the name of the material class.
  56126. */
  56127. getClassName(): string;
  56128. /**
  56129. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  56130. */
  56131. get useLogarithmicDepth(): boolean;
  56132. /**
  56133. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  56134. */
  56135. set useLogarithmicDepth(value: boolean);
  56136. /**
  56137. * Returns true if alpha blending should be disabled.
  56138. */
  56139. protected get _disableAlphaBlending(): boolean;
  56140. /**
  56141. * Specifies whether or not this material should be rendered in alpha blend mode.
  56142. */
  56143. needAlphaBlending(): boolean;
  56144. /**
  56145. * Specifies whether or not this material should be rendered in alpha test mode.
  56146. */
  56147. needAlphaTesting(): boolean;
  56148. /**
  56149. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  56150. */
  56151. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  56152. /**
  56153. * Gets the texture used for the alpha test.
  56154. */
  56155. getAlphaTestTexture(): Nullable<BaseTexture>;
  56156. /**
  56157. * Specifies that the submesh is ready to be used.
  56158. * @param mesh - BJS mesh.
  56159. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  56160. * @param useInstances - Specifies that instances should be used.
  56161. * @returns - boolean indicating that the submesh is ready or not.
  56162. */
  56163. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56164. /**
  56165. * Specifies if the material uses metallic roughness workflow.
  56166. * @returns boolean specifiying if the material uses metallic roughness workflow.
  56167. */
  56168. isMetallicWorkflow(): boolean;
  56169. private _prepareEffect;
  56170. private _prepareDefines;
  56171. /**
  56172. * Force shader compilation
  56173. */
  56174. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  56175. /**
  56176. * Initializes the uniform buffer layout for the shader.
  56177. */
  56178. buildUniformLayout(): void;
  56179. /**
  56180. * Unbinds the material from the mesh
  56181. */
  56182. unbind(): void;
  56183. /**
  56184. * Binds the submesh data.
  56185. * @param world - The world matrix.
  56186. * @param mesh - The BJS mesh.
  56187. * @param subMesh - A submesh of the BJS mesh.
  56188. */
  56189. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56190. /**
  56191. * Returns the animatable textures.
  56192. * @returns - Array of animatable textures.
  56193. */
  56194. getAnimatables(): IAnimatable[];
  56195. /**
  56196. * Returns the texture used for reflections.
  56197. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  56198. */
  56199. private _getReflectionTexture;
  56200. /**
  56201. * Returns an array of the actively used textures.
  56202. * @returns - Array of BaseTextures
  56203. */
  56204. getActiveTextures(): BaseTexture[];
  56205. /**
  56206. * Checks to see if a texture is used in the material.
  56207. * @param texture - Base texture to use.
  56208. * @returns - Boolean specifying if a texture is used in the material.
  56209. */
  56210. hasTexture(texture: BaseTexture): boolean;
  56211. /**
  56212. * Sets the required values to the prepass renderer.
  56213. * @param prePassRenderer defines the prepass renderer to setup
  56214. */
  56215. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  56216. /**
  56217. * Disposes the resources of the material.
  56218. * @param forceDisposeEffect - Forces the disposal of effects.
  56219. * @param forceDisposeTextures - Forces the disposal of all textures.
  56220. */
  56221. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  56222. }
  56223. }
  56224. declare module BABYLON {
  56225. /**
  56226. * The Physically based material of BJS.
  56227. *
  56228. * This offers the main features of a standard PBR material.
  56229. * For more information, please refer to the documentation :
  56230. * https://doc.babylonjs.com/how_to/physically_based_rendering
  56231. */
  56232. export class PBRMaterial extends PBRBaseMaterial {
  56233. /**
  56234. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  56235. */
  56236. static readonly PBRMATERIAL_OPAQUE: number;
  56237. /**
  56238. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  56239. */
  56240. static readonly PBRMATERIAL_ALPHATEST: number;
  56241. /**
  56242. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56243. */
  56244. static readonly PBRMATERIAL_ALPHABLEND: number;
  56245. /**
  56246. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56247. * They are also discarded below the alpha cutoff threshold to improve performances.
  56248. */
  56249. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  56250. /**
  56251. * Defines the default value of how much AO map is occluding the analytical lights
  56252. * (point spot...).
  56253. */
  56254. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  56255. /**
  56256. * Intensity of the direct lights e.g. the four lights available in your scene.
  56257. * This impacts both the direct diffuse and specular highlights.
  56258. */
  56259. directIntensity: number;
  56260. /**
  56261. * Intensity of the emissive part of the material.
  56262. * This helps controlling the emissive effect without modifying the emissive color.
  56263. */
  56264. emissiveIntensity: number;
  56265. /**
  56266. * Intensity of the environment e.g. how much the environment will light the object
  56267. * either through harmonics for rough material or through the refelction for shiny ones.
  56268. */
  56269. environmentIntensity: number;
  56270. /**
  56271. * This is a special control allowing the reduction of the specular highlights coming from the
  56272. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  56273. */
  56274. specularIntensity: number;
  56275. /**
  56276. * Debug Control allowing disabling the bump map on this material.
  56277. */
  56278. disableBumpMap: boolean;
  56279. /**
  56280. * AKA Diffuse Texture in standard nomenclature.
  56281. */
  56282. albedoTexture: BaseTexture;
  56283. /**
  56284. * AKA Occlusion Texture in other nomenclature.
  56285. */
  56286. ambientTexture: BaseTexture;
  56287. /**
  56288. * AKA Occlusion Texture Intensity in other nomenclature.
  56289. */
  56290. ambientTextureStrength: number;
  56291. /**
  56292. * Defines how much the AO map is occluding the analytical lights (point spot...).
  56293. * 1 means it completely occludes it
  56294. * 0 mean it has no impact
  56295. */
  56296. ambientTextureImpactOnAnalyticalLights: number;
  56297. /**
  56298. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  56299. */
  56300. opacityTexture: BaseTexture;
  56301. /**
  56302. * Stores the reflection values in a texture.
  56303. */
  56304. reflectionTexture: Nullable<BaseTexture>;
  56305. /**
  56306. * Stores the emissive values in a texture.
  56307. */
  56308. emissiveTexture: BaseTexture;
  56309. /**
  56310. * AKA Specular texture in other nomenclature.
  56311. */
  56312. reflectivityTexture: BaseTexture;
  56313. /**
  56314. * Used to switch from specular/glossiness to metallic/roughness workflow.
  56315. */
  56316. metallicTexture: BaseTexture;
  56317. /**
  56318. * Specifies the metallic scalar of the metallic/roughness workflow.
  56319. * Can also be used to scale the metalness values of the metallic texture.
  56320. */
  56321. metallic: Nullable<number>;
  56322. /**
  56323. * Specifies the roughness scalar of the metallic/roughness workflow.
  56324. * Can also be used to scale the roughness values of the metallic texture.
  56325. */
  56326. roughness: Nullable<number>;
  56327. /**
  56328. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  56329. * By default the indexOfrefraction is used to compute F0;
  56330. *
  56331. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  56332. *
  56333. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  56334. * F90 = metallicReflectanceColor;
  56335. */
  56336. metallicF0Factor: number;
  56337. /**
  56338. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  56339. * By default the F90 is always 1;
  56340. *
  56341. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  56342. *
  56343. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  56344. * F90 = metallicReflectanceColor;
  56345. */
  56346. metallicReflectanceColor: Color3;
  56347. /**
  56348. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  56349. * This is multiply against the scalar values defined in the material.
  56350. */
  56351. metallicReflectanceTexture: Nullable<BaseTexture>;
  56352. /**
  56353. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  56354. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  56355. */
  56356. microSurfaceTexture: BaseTexture;
  56357. /**
  56358. * Stores surface normal data used to displace a mesh in a texture.
  56359. */
  56360. bumpTexture: BaseTexture;
  56361. /**
  56362. * Stores the pre-calculated light information of a mesh in a texture.
  56363. */
  56364. lightmapTexture: BaseTexture;
  56365. /**
  56366. * Stores the refracted light information in a texture.
  56367. */
  56368. get refractionTexture(): Nullable<BaseTexture>;
  56369. set refractionTexture(value: Nullable<BaseTexture>);
  56370. /**
  56371. * The color of a material in ambient lighting.
  56372. */
  56373. ambientColor: Color3;
  56374. /**
  56375. * AKA Diffuse Color in other nomenclature.
  56376. */
  56377. albedoColor: Color3;
  56378. /**
  56379. * AKA Specular Color in other nomenclature.
  56380. */
  56381. reflectivityColor: Color3;
  56382. /**
  56383. * The color reflected from the material.
  56384. */
  56385. reflectionColor: Color3;
  56386. /**
  56387. * The color emitted from the material.
  56388. */
  56389. emissiveColor: Color3;
  56390. /**
  56391. * AKA Glossiness in other nomenclature.
  56392. */
  56393. microSurface: number;
  56394. /**
  56395. * Index of refraction of the material base layer.
  56396. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56397. *
  56398. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  56399. *
  56400. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  56401. */
  56402. get indexOfRefraction(): number;
  56403. set indexOfRefraction(value: number);
  56404. /**
  56405. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  56406. */
  56407. get invertRefractionY(): boolean;
  56408. set invertRefractionY(value: boolean);
  56409. /**
  56410. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  56411. * Materials half opaque for instance using refraction could benefit from this control.
  56412. */
  56413. get linkRefractionWithTransparency(): boolean;
  56414. set linkRefractionWithTransparency(value: boolean);
  56415. /**
  56416. * If true, the light map contains occlusion information instead of lighting info.
  56417. */
  56418. useLightmapAsShadowmap: boolean;
  56419. /**
  56420. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  56421. */
  56422. useAlphaFromAlbedoTexture: boolean;
  56423. /**
  56424. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  56425. */
  56426. forceAlphaTest: boolean;
  56427. /**
  56428. * Defines the alpha limits in alpha test mode.
  56429. */
  56430. alphaCutOff: number;
  56431. /**
  56432. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  56433. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  56434. */
  56435. useSpecularOverAlpha: boolean;
  56436. /**
  56437. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  56438. */
  56439. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  56440. /**
  56441. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  56442. */
  56443. useRoughnessFromMetallicTextureAlpha: boolean;
  56444. /**
  56445. * Specifies if the metallic texture contains the roughness information in its green channel.
  56446. */
  56447. useRoughnessFromMetallicTextureGreen: boolean;
  56448. /**
  56449. * Specifies if the metallic texture contains the metallness information in its blue channel.
  56450. */
  56451. useMetallnessFromMetallicTextureBlue: boolean;
  56452. /**
  56453. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  56454. */
  56455. useAmbientOcclusionFromMetallicTextureRed: boolean;
  56456. /**
  56457. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  56458. */
  56459. useAmbientInGrayScale: boolean;
  56460. /**
  56461. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  56462. * The material will try to infer what glossiness each pixel should be.
  56463. */
  56464. useAutoMicroSurfaceFromReflectivityMap: boolean;
  56465. /**
  56466. * BJS is using an harcoded light falloff based on a manually sets up range.
  56467. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  56468. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  56469. */
  56470. get usePhysicalLightFalloff(): boolean;
  56471. /**
  56472. * BJS is using an harcoded light falloff based on a manually sets up range.
  56473. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  56474. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  56475. */
  56476. set usePhysicalLightFalloff(value: boolean);
  56477. /**
  56478. * In order to support the falloff compatibility with gltf, a special mode has been added
  56479. * to reproduce the gltf light falloff.
  56480. */
  56481. get useGLTFLightFalloff(): boolean;
  56482. /**
  56483. * In order to support the falloff compatibility with gltf, a special mode has been added
  56484. * to reproduce the gltf light falloff.
  56485. */
  56486. set useGLTFLightFalloff(value: boolean);
  56487. /**
  56488. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  56489. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  56490. */
  56491. useRadianceOverAlpha: boolean;
  56492. /**
  56493. * Allows using an object space normal map (instead of tangent space).
  56494. */
  56495. useObjectSpaceNormalMap: boolean;
  56496. /**
  56497. * Allows using the bump map in parallax mode.
  56498. */
  56499. useParallax: boolean;
  56500. /**
  56501. * Allows using the bump map in parallax occlusion mode.
  56502. */
  56503. useParallaxOcclusion: boolean;
  56504. /**
  56505. * Controls the scale bias of the parallax mode.
  56506. */
  56507. parallaxScaleBias: number;
  56508. /**
  56509. * If sets to true, disables all the lights affecting the material.
  56510. */
  56511. disableLighting: boolean;
  56512. /**
  56513. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  56514. */
  56515. forceIrradianceInFragment: boolean;
  56516. /**
  56517. * Number of Simultaneous lights allowed on the material.
  56518. */
  56519. maxSimultaneousLights: number;
  56520. /**
  56521. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56522. */
  56523. invertNormalMapX: boolean;
  56524. /**
  56525. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56526. */
  56527. invertNormalMapY: boolean;
  56528. /**
  56529. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56530. */
  56531. twoSidedLighting: boolean;
  56532. /**
  56533. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56534. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  56535. */
  56536. useAlphaFresnel: boolean;
  56537. /**
  56538. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56539. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  56540. */
  56541. useLinearAlphaFresnel: boolean;
  56542. /**
  56543. * Let user defines the brdf lookup texture used for IBL.
  56544. * A default 8bit version is embedded but you could point at :
  56545. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  56546. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  56547. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  56548. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  56549. */
  56550. environmentBRDFTexture: Nullable<BaseTexture>;
  56551. /**
  56552. * Force normal to face away from face.
  56553. */
  56554. forceNormalForward: boolean;
  56555. /**
  56556. * Enables specular anti aliasing in the PBR shader.
  56557. * It will both interacts on the Geometry for analytical and IBL lighting.
  56558. * It also prefilter the roughness map based on the bump values.
  56559. */
  56560. enableSpecularAntiAliasing: boolean;
  56561. /**
  56562. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  56563. * makes the reflect vector face the model (under horizon).
  56564. */
  56565. useHorizonOcclusion: boolean;
  56566. /**
  56567. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  56568. * too much the area relying on ambient texture to define their ambient occlusion.
  56569. */
  56570. useRadianceOcclusion: boolean;
  56571. /**
  56572. * If set to true, no lighting calculations will be applied.
  56573. */
  56574. unlit: boolean;
  56575. /**
  56576. * Gets the image processing configuration used either in this material.
  56577. */
  56578. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  56579. /**
  56580. * Sets the Default image processing configuration used either in the this material.
  56581. *
  56582. * If sets to null, the scene one is in use.
  56583. */
  56584. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  56585. /**
  56586. * Gets wether the color curves effect is enabled.
  56587. */
  56588. get cameraColorCurvesEnabled(): boolean;
  56589. /**
  56590. * Sets wether the color curves effect is enabled.
  56591. */
  56592. set cameraColorCurvesEnabled(value: boolean);
  56593. /**
  56594. * Gets wether the color grading effect is enabled.
  56595. */
  56596. get cameraColorGradingEnabled(): boolean;
  56597. /**
  56598. * Gets wether the color grading effect is enabled.
  56599. */
  56600. set cameraColorGradingEnabled(value: boolean);
  56601. /**
  56602. * Gets wether tonemapping is enabled or not.
  56603. */
  56604. get cameraToneMappingEnabled(): boolean;
  56605. /**
  56606. * Sets wether tonemapping is enabled or not
  56607. */
  56608. set cameraToneMappingEnabled(value: boolean);
  56609. /**
  56610. * The camera exposure used on this material.
  56611. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56612. * This corresponds to a photographic exposure.
  56613. */
  56614. get cameraExposure(): number;
  56615. /**
  56616. * The camera exposure used on this material.
  56617. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56618. * This corresponds to a photographic exposure.
  56619. */
  56620. set cameraExposure(value: number);
  56621. /**
  56622. * Gets The camera contrast used on this material.
  56623. */
  56624. get cameraContrast(): number;
  56625. /**
  56626. * Sets The camera contrast used on this material.
  56627. */
  56628. set cameraContrast(value: number);
  56629. /**
  56630. * Gets the Color Grading 2D Lookup Texture.
  56631. */
  56632. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  56633. /**
  56634. * Sets the Color Grading 2D Lookup Texture.
  56635. */
  56636. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  56637. /**
  56638. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56639. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56640. * 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;
  56641. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56642. */
  56643. get cameraColorCurves(): Nullable<ColorCurves>;
  56644. /**
  56645. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56646. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56647. * 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;
  56648. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56649. */
  56650. set cameraColorCurves(value: Nullable<ColorCurves>);
  56651. /**
  56652. * Instantiates a new PBRMaterial instance.
  56653. *
  56654. * @param name The material name
  56655. * @param scene The scene the material will be use in.
  56656. */
  56657. constructor(name: string, scene: Scene);
  56658. /**
  56659. * Returns the name of this material class.
  56660. */
  56661. getClassName(): string;
  56662. /**
  56663. * Makes a duplicate of the current material.
  56664. * @param name - name to use for the new material.
  56665. */
  56666. clone(name: string): PBRMaterial;
  56667. /**
  56668. * Serializes this PBR Material.
  56669. * @returns - An object with the serialized material.
  56670. */
  56671. serialize(): any;
  56672. /**
  56673. * Parses a PBR Material from a serialized object.
  56674. * @param source - Serialized object.
  56675. * @param scene - BJS scene instance.
  56676. * @param rootUrl - url for the scene object
  56677. * @returns - PBRMaterial
  56678. */
  56679. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  56680. }
  56681. }
  56682. declare module BABYLON {
  56683. /**
  56684. * Direct draw surface info
  56685. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  56686. */
  56687. export interface DDSInfo {
  56688. /**
  56689. * Width of the texture
  56690. */
  56691. width: number;
  56692. /**
  56693. * Width of the texture
  56694. */
  56695. height: number;
  56696. /**
  56697. * Number of Mipmaps for the texture
  56698. * @see https://en.wikipedia.org/wiki/Mipmap
  56699. */
  56700. mipmapCount: number;
  56701. /**
  56702. * If the textures format is a known fourCC format
  56703. * @see https://www.fourcc.org/
  56704. */
  56705. isFourCC: boolean;
  56706. /**
  56707. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  56708. */
  56709. isRGB: boolean;
  56710. /**
  56711. * If the texture is a lumincance format
  56712. */
  56713. isLuminance: boolean;
  56714. /**
  56715. * If this is a cube texture
  56716. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  56717. */
  56718. isCube: boolean;
  56719. /**
  56720. * If the texture is a compressed format eg. FOURCC_DXT1
  56721. */
  56722. isCompressed: boolean;
  56723. /**
  56724. * The dxgiFormat of the texture
  56725. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  56726. */
  56727. dxgiFormat: number;
  56728. /**
  56729. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  56730. */
  56731. textureType: number;
  56732. /**
  56733. * Sphericle polynomial created for the dds texture
  56734. */
  56735. sphericalPolynomial?: SphericalPolynomial;
  56736. }
  56737. /**
  56738. * Class used to provide DDS decompression tools
  56739. */
  56740. export class DDSTools {
  56741. /**
  56742. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  56743. */
  56744. static StoreLODInAlphaChannel: boolean;
  56745. /**
  56746. * Gets DDS information from an array buffer
  56747. * @param data defines the array buffer view to read data from
  56748. * @returns the DDS information
  56749. */
  56750. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  56751. private static _FloatView;
  56752. private static _Int32View;
  56753. private static _ToHalfFloat;
  56754. private static _FromHalfFloat;
  56755. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  56756. private static _GetHalfFloatRGBAArrayBuffer;
  56757. private static _GetFloatRGBAArrayBuffer;
  56758. private static _GetFloatAsUIntRGBAArrayBuffer;
  56759. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  56760. private static _GetRGBAArrayBuffer;
  56761. private static _ExtractLongWordOrder;
  56762. private static _GetRGBArrayBuffer;
  56763. private static _GetLuminanceArrayBuffer;
  56764. /**
  56765. * Uploads DDS Levels to a Babylon Texture
  56766. * @hidden
  56767. */
  56768. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  56769. }
  56770. interface ThinEngine {
  56771. /**
  56772. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  56773. * @param rootUrl defines the url where the file to load is located
  56774. * @param scene defines the current scene
  56775. * @param lodScale defines scale to apply to the mip map selection
  56776. * @param lodOffset defines offset to apply to the mip map selection
  56777. * @param onLoad defines an optional callback raised when the texture is loaded
  56778. * @param onError defines an optional callback raised if there is an issue to load the texture
  56779. * @param format defines the format of the data
  56780. * @param forcedExtension defines the extension to use to pick the right loader
  56781. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  56782. * @returns the cube texture as an InternalTexture
  56783. */
  56784. 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;
  56785. }
  56786. }
  56787. declare module BABYLON {
  56788. /**
  56789. * Implementation of the DDS Texture Loader.
  56790. * @hidden
  56791. */
  56792. export class _DDSTextureLoader implements IInternalTextureLoader {
  56793. /**
  56794. * Defines wether the loader supports cascade loading the different faces.
  56795. */
  56796. readonly supportCascades: boolean;
  56797. /**
  56798. * This returns if the loader support the current file information.
  56799. * @param extension defines the file extension of the file being loaded
  56800. * @returns true if the loader can load the specified file
  56801. */
  56802. canLoad(extension: string): boolean;
  56803. /**
  56804. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56805. * @param data contains the texture data
  56806. * @param texture defines the BabylonJS internal texture
  56807. * @param createPolynomials will be true if polynomials have been requested
  56808. * @param onLoad defines the callback to trigger once the texture is ready
  56809. * @param onError defines the callback to trigger in case of error
  56810. */
  56811. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56812. /**
  56813. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56814. * @param data contains the texture data
  56815. * @param texture defines the BabylonJS internal texture
  56816. * @param callback defines the method to call once ready to upload
  56817. */
  56818. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56819. }
  56820. }
  56821. declare module BABYLON {
  56822. /**
  56823. * Implementation of the ENV Texture Loader.
  56824. * @hidden
  56825. */
  56826. export class _ENVTextureLoader implements IInternalTextureLoader {
  56827. /**
  56828. * Defines wether the loader supports cascade loading the different faces.
  56829. */
  56830. readonly supportCascades: boolean;
  56831. /**
  56832. * This returns if the loader support the current file information.
  56833. * @param extension defines the file extension of the file being loaded
  56834. * @returns true if the loader can load the specified file
  56835. */
  56836. canLoad(extension: string): boolean;
  56837. /**
  56838. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56839. * @param data contains the texture data
  56840. * @param texture defines the BabylonJS internal texture
  56841. * @param createPolynomials will be true if polynomials have been requested
  56842. * @param onLoad defines the callback to trigger once the texture is ready
  56843. * @param onError defines the callback to trigger in case of error
  56844. */
  56845. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56846. /**
  56847. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56848. * @param data contains the texture data
  56849. * @param texture defines the BabylonJS internal texture
  56850. * @param callback defines the method to call once ready to upload
  56851. */
  56852. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56853. }
  56854. }
  56855. declare module BABYLON {
  56856. /**
  56857. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  56858. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  56859. */
  56860. export class KhronosTextureContainer {
  56861. /** contents of the KTX container file */
  56862. data: ArrayBufferView;
  56863. private static HEADER_LEN;
  56864. private static COMPRESSED_2D;
  56865. private static COMPRESSED_3D;
  56866. private static TEX_2D;
  56867. private static TEX_3D;
  56868. /**
  56869. * Gets the openGL type
  56870. */
  56871. glType: number;
  56872. /**
  56873. * Gets the openGL type size
  56874. */
  56875. glTypeSize: number;
  56876. /**
  56877. * Gets the openGL format
  56878. */
  56879. glFormat: number;
  56880. /**
  56881. * Gets the openGL internal format
  56882. */
  56883. glInternalFormat: number;
  56884. /**
  56885. * Gets the base internal format
  56886. */
  56887. glBaseInternalFormat: number;
  56888. /**
  56889. * Gets image width in pixel
  56890. */
  56891. pixelWidth: number;
  56892. /**
  56893. * Gets image height in pixel
  56894. */
  56895. pixelHeight: number;
  56896. /**
  56897. * Gets image depth in pixels
  56898. */
  56899. pixelDepth: number;
  56900. /**
  56901. * Gets the number of array elements
  56902. */
  56903. numberOfArrayElements: number;
  56904. /**
  56905. * Gets the number of faces
  56906. */
  56907. numberOfFaces: number;
  56908. /**
  56909. * Gets the number of mipmap levels
  56910. */
  56911. numberOfMipmapLevels: number;
  56912. /**
  56913. * Gets the bytes of key value data
  56914. */
  56915. bytesOfKeyValueData: number;
  56916. /**
  56917. * Gets the load type
  56918. */
  56919. loadType: number;
  56920. /**
  56921. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  56922. */
  56923. isInvalid: boolean;
  56924. /**
  56925. * Creates a new KhronosTextureContainer
  56926. * @param data contents of the KTX container file
  56927. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  56928. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  56929. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  56930. */
  56931. constructor(
  56932. /** contents of the KTX container file */
  56933. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  56934. /**
  56935. * Uploads KTX content to a Babylon Texture.
  56936. * It is assumed that the texture has already been created & is currently bound
  56937. * @hidden
  56938. */
  56939. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  56940. private _upload2DCompressedLevels;
  56941. /**
  56942. * Checks if the given data starts with a KTX file identifier.
  56943. * @param data the data to check
  56944. * @returns true if the data is a KTX file or false otherwise
  56945. */
  56946. static IsValid(data: ArrayBufferView): boolean;
  56947. }
  56948. }
  56949. declare module BABYLON {
  56950. /**
  56951. * Class for loading KTX2 files
  56952. * !!! Experimental Extension Subject to Changes !!!
  56953. * @hidden
  56954. */
  56955. export class KhronosTextureContainer2 {
  56956. private static _ModulePromise;
  56957. private static _TranscodeFormat;
  56958. constructor(engine: ThinEngine);
  56959. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  56960. private _determineTranscodeFormat;
  56961. /**
  56962. * Checks if the given data starts with a KTX2 file identifier.
  56963. * @param data the data to check
  56964. * @returns true if the data is a KTX2 file or false otherwise
  56965. */
  56966. static IsValid(data: ArrayBufferView): boolean;
  56967. }
  56968. }
  56969. declare module BABYLON {
  56970. /**
  56971. * Implementation of the KTX Texture Loader.
  56972. * @hidden
  56973. */
  56974. export class _KTXTextureLoader implements IInternalTextureLoader {
  56975. /**
  56976. * Defines wether the loader supports cascade loading the different faces.
  56977. */
  56978. readonly supportCascades: boolean;
  56979. /**
  56980. * This returns if the loader support the current file information.
  56981. * @param extension defines the file extension of the file being loaded
  56982. * @param mimeType defines the optional mime type of the file being loaded
  56983. * @returns true if the loader can load the specified file
  56984. */
  56985. canLoad(extension: string, mimeType?: string): boolean;
  56986. /**
  56987. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56988. * @param data contains the texture data
  56989. * @param texture defines the BabylonJS internal texture
  56990. * @param createPolynomials will be true if polynomials have been requested
  56991. * @param onLoad defines the callback to trigger once the texture is ready
  56992. * @param onError defines the callback to trigger in case of error
  56993. */
  56994. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56995. /**
  56996. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56997. * @param data contains the texture data
  56998. * @param texture defines the BabylonJS internal texture
  56999. * @param callback defines the method to call once ready to upload
  57000. */
  57001. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  57002. }
  57003. }
  57004. declare module BABYLON {
  57005. /** @hidden */
  57006. export var _forceSceneHelpersToBundle: boolean;
  57007. interface Scene {
  57008. /**
  57009. * Creates a default light for the scene.
  57010. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  57011. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  57012. */
  57013. createDefaultLight(replace?: boolean): void;
  57014. /**
  57015. * Creates a default camera for the scene.
  57016. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  57017. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  57018. * @param replace has default false, when true replaces the active camera in the scene
  57019. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  57020. */
  57021. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  57022. /**
  57023. * Creates a default camera and a default light.
  57024. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  57025. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  57026. * @param replace has the default false, when true replaces the active camera/light in the scene
  57027. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  57028. */
  57029. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  57030. /**
  57031. * Creates a new sky box
  57032. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  57033. * @param environmentTexture defines the texture to use as environment texture
  57034. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  57035. * @param scale defines the overall scale of the skybox
  57036. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  57037. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  57038. * @returns a new mesh holding the sky box
  57039. */
  57040. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  57041. /**
  57042. * Creates a new environment
  57043. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  57044. * @param options defines the options you can use to configure the environment
  57045. * @returns the new EnvironmentHelper
  57046. */
  57047. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  57048. /**
  57049. * Creates a new VREXperienceHelper
  57050. * @see https://doc.babylonjs.com/how_to/webvr_helper
  57051. * @param webVROptions defines the options used to create the new VREXperienceHelper
  57052. * @returns a new VREXperienceHelper
  57053. */
  57054. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  57055. /**
  57056. * Creates a new WebXRDefaultExperience
  57057. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  57058. * @param options experience options
  57059. * @returns a promise for a new WebXRDefaultExperience
  57060. */
  57061. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  57062. }
  57063. }
  57064. declare module BABYLON {
  57065. /**
  57066. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  57067. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  57068. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  57069. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57070. */
  57071. export class VideoDome extends TransformNode {
  57072. /**
  57073. * Define the video source as a Monoscopic panoramic 360 video.
  57074. */
  57075. static readonly MODE_MONOSCOPIC: number;
  57076. /**
  57077. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  57078. */
  57079. static readonly MODE_TOPBOTTOM: number;
  57080. /**
  57081. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  57082. */
  57083. static readonly MODE_SIDEBYSIDE: number;
  57084. private _halfDome;
  57085. private _useDirectMapping;
  57086. /**
  57087. * The video texture being displayed on the sphere
  57088. */
  57089. protected _videoTexture: VideoTexture;
  57090. /**
  57091. * Gets the video texture being displayed on the sphere
  57092. */
  57093. get videoTexture(): VideoTexture;
  57094. /**
  57095. * The skybox material
  57096. */
  57097. protected _material: BackgroundMaterial;
  57098. /**
  57099. * The surface used for the video dome
  57100. */
  57101. protected _mesh: Mesh;
  57102. /**
  57103. * Gets the mesh used for the video dome.
  57104. */
  57105. get mesh(): Mesh;
  57106. /**
  57107. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  57108. */
  57109. private _halfDomeMask;
  57110. /**
  57111. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57112. * Also see the options.resolution property.
  57113. */
  57114. get fovMultiplier(): number;
  57115. set fovMultiplier(value: number);
  57116. private _videoMode;
  57117. /**
  57118. * Gets or set the current video mode for the video. It can be:
  57119. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  57120. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  57121. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  57122. */
  57123. get videoMode(): number;
  57124. set videoMode(value: number);
  57125. /**
  57126. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  57127. *
  57128. */
  57129. get halfDome(): boolean;
  57130. /**
  57131. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  57132. */
  57133. set halfDome(enabled: boolean);
  57134. /**
  57135. * Oberserver used in Stereoscopic VR Mode.
  57136. */
  57137. private _onBeforeCameraRenderObserver;
  57138. /**
  57139. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  57140. * @param name Element's name, child elements will append suffixes for their own names.
  57141. * @param urlsOrVideo defines the url(s) or the video element to use
  57142. * @param options An object containing optional or exposed sub element properties
  57143. */
  57144. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  57145. resolution?: number;
  57146. clickToPlay?: boolean;
  57147. autoPlay?: boolean;
  57148. loop?: boolean;
  57149. size?: number;
  57150. poster?: string;
  57151. faceForward?: boolean;
  57152. useDirectMapping?: boolean;
  57153. halfDomeMode?: boolean;
  57154. }, scene: Scene);
  57155. private _changeVideoMode;
  57156. /**
  57157. * Releases resources associated with this node.
  57158. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  57159. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  57160. */
  57161. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  57162. }
  57163. }
  57164. declare module BABYLON {
  57165. /**
  57166. * This class can be used to get instrumentation data from a Babylon engine
  57167. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  57168. */
  57169. export class EngineInstrumentation implements IDisposable {
  57170. /**
  57171. * Define the instrumented engine.
  57172. */
  57173. engine: Engine;
  57174. private _captureGPUFrameTime;
  57175. private _gpuFrameTimeToken;
  57176. private _gpuFrameTime;
  57177. private _captureShaderCompilationTime;
  57178. private _shaderCompilationTime;
  57179. private _onBeginFrameObserver;
  57180. private _onEndFrameObserver;
  57181. private _onBeforeShaderCompilationObserver;
  57182. private _onAfterShaderCompilationObserver;
  57183. /**
  57184. * Gets the perf counter used for GPU frame time
  57185. */
  57186. get gpuFrameTimeCounter(): PerfCounter;
  57187. /**
  57188. * Gets the GPU frame time capture status
  57189. */
  57190. get captureGPUFrameTime(): boolean;
  57191. /**
  57192. * Enable or disable the GPU frame time capture
  57193. */
  57194. set captureGPUFrameTime(value: boolean);
  57195. /**
  57196. * Gets the perf counter used for shader compilation time
  57197. */
  57198. get shaderCompilationTimeCounter(): PerfCounter;
  57199. /**
  57200. * Gets the shader compilation time capture status
  57201. */
  57202. get captureShaderCompilationTime(): boolean;
  57203. /**
  57204. * Enable or disable the shader compilation time capture
  57205. */
  57206. set captureShaderCompilationTime(value: boolean);
  57207. /**
  57208. * Instantiates a new engine instrumentation.
  57209. * This class can be used to get instrumentation data from a Babylon engine
  57210. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  57211. * @param engine Defines the engine to instrument
  57212. */
  57213. constructor(
  57214. /**
  57215. * Define the instrumented engine.
  57216. */
  57217. engine: Engine);
  57218. /**
  57219. * Dispose and release associated resources.
  57220. */
  57221. dispose(): void;
  57222. }
  57223. }
  57224. declare module BABYLON {
  57225. /**
  57226. * This class can be used to get instrumentation data from a Babylon engine
  57227. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  57228. */
  57229. export class SceneInstrumentation implements IDisposable {
  57230. /**
  57231. * Defines the scene to instrument
  57232. */
  57233. scene: Scene;
  57234. private _captureActiveMeshesEvaluationTime;
  57235. private _activeMeshesEvaluationTime;
  57236. private _captureRenderTargetsRenderTime;
  57237. private _renderTargetsRenderTime;
  57238. private _captureFrameTime;
  57239. private _frameTime;
  57240. private _captureRenderTime;
  57241. private _renderTime;
  57242. private _captureInterFrameTime;
  57243. private _interFrameTime;
  57244. private _captureParticlesRenderTime;
  57245. private _particlesRenderTime;
  57246. private _captureSpritesRenderTime;
  57247. private _spritesRenderTime;
  57248. private _capturePhysicsTime;
  57249. private _physicsTime;
  57250. private _captureAnimationsTime;
  57251. private _animationsTime;
  57252. private _captureCameraRenderTime;
  57253. private _cameraRenderTime;
  57254. private _onBeforeActiveMeshesEvaluationObserver;
  57255. private _onAfterActiveMeshesEvaluationObserver;
  57256. private _onBeforeRenderTargetsRenderObserver;
  57257. private _onAfterRenderTargetsRenderObserver;
  57258. private _onAfterRenderObserver;
  57259. private _onBeforeDrawPhaseObserver;
  57260. private _onAfterDrawPhaseObserver;
  57261. private _onBeforeAnimationsObserver;
  57262. private _onBeforeParticlesRenderingObserver;
  57263. private _onAfterParticlesRenderingObserver;
  57264. private _onBeforeSpritesRenderingObserver;
  57265. private _onAfterSpritesRenderingObserver;
  57266. private _onBeforePhysicsObserver;
  57267. private _onAfterPhysicsObserver;
  57268. private _onAfterAnimationsObserver;
  57269. private _onBeforeCameraRenderObserver;
  57270. private _onAfterCameraRenderObserver;
  57271. /**
  57272. * Gets the perf counter used for active meshes evaluation time
  57273. */
  57274. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  57275. /**
  57276. * Gets the active meshes evaluation time capture status
  57277. */
  57278. get captureActiveMeshesEvaluationTime(): boolean;
  57279. /**
  57280. * Enable or disable the active meshes evaluation time capture
  57281. */
  57282. set captureActiveMeshesEvaluationTime(value: boolean);
  57283. /**
  57284. * Gets the perf counter used for render targets render time
  57285. */
  57286. get renderTargetsRenderTimeCounter(): PerfCounter;
  57287. /**
  57288. * Gets the render targets render time capture status
  57289. */
  57290. get captureRenderTargetsRenderTime(): boolean;
  57291. /**
  57292. * Enable or disable the render targets render time capture
  57293. */
  57294. set captureRenderTargetsRenderTime(value: boolean);
  57295. /**
  57296. * Gets the perf counter used for particles render time
  57297. */
  57298. get particlesRenderTimeCounter(): PerfCounter;
  57299. /**
  57300. * Gets the particles render time capture status
  57301. */
  57302. get captureParticlesRenderTime(): boolean;
  57303. /**
  57304. * Enable or disable the particles render time capture
  57305. */
  57306. set captureParticlesRenderTime(value: boolean);
  57307. /**
  57308. * Gets the perf counter used for sprites render time
  57309. */
  57310. get spritesRenderTimeCounter(): PerfCounter;
  57311. /**
  57312. * Gets the sprites render time capture status
  57313. */
  57314. get captureSpritesRenderTime(): boolean;
  57315. /**
  57316. * Enable or disable the sprites render time capture
  57317. */
  57318. set captureSpritesRenderTime(value: boolean);
  57319. /**
  57320. * Gets the perf counter used for physics time
  57321. */
  57322. get physicsTimeCounter(): PerfCounter;
  57323. /**
  57324. * Gets the physics time capture status
  57325. */
  57326. get capturePhysicsTime(): boolean;
  57327. /**
  57328. * Enable or disable the physics time capture
  57329. */
  57330. set capturePhysicsTime(value: boolean);
  57331. /**
  57332. * Gets the perf counter used for animations time
  57333. */
  57334. get animationsTimeCounter(): PerfCounter;
  57335. /**
  57336. * Gets the animations time capture status
  57337. */
  57338. get captureAnimationsTime(): boolean;
  57339. /**
  57340. * Enable or disable the animations time capture
  57341. */
  57342. set captureAnimationsTime(value: boolean);
  57343. /**
  57344. * Gets the perf counter used for frame time capture
  57345. */
  57346. get frameTimeCounter(): PerfCounter;
  57347. /**
  57348. * Gets the frame time capture status
  57349. */
  57350. get captureFrameTime(): boolean;
  57351. /**
  57352. * Enable or disable the frame time capture
  57353. */
  57354. set captureFrameTime(value: boolean);
  57355. /**
  57356. * Gets the perf counter used for inter-frames time capture
  57357. */
  57358. get interFrameTimeCounter(): PerfCounter;
  57359. /**
  57360. * Gets the inter-frames time capture status
  57361. */
  57362. get captureInterFrameTime(): boolean;
  57363. /**
  57364. * Enable or disable the inter-frames time capture
  57365. */
  57366. set captureInterFrameTime(value: boolean);
  57367. /**
  57368. * Gets the perf counter used for render time capture
  57369. */
  57370. get renderTimeCounter(): PerfCounter;
  57371. /**
  57372. * Gets the render time capture status
  57373. */
  57374. get captureRenderTime(): boolean;
  57375. /**
  57376. * Enable or disable the render time capture
  57377. */
  57378. set captureRenderTime(value: boolean);
  57379. /**
  57380. * Gets the perf counter used for camera render time capture
  57381. */
  57382. get cameraRenderTimeCounter(): PerfCounter;
  57383. /**
  57384. * Gets the camera render time capture status
  57385. */
  57386. get captureCameraRenderTime(): boolean;
  57387. /**
  57388. * Enable or disable the camera render time capture
  57389. */
  57390. set captureCameraRenderTime(value: boolean);
  57391. /**
  57392. * Gets the perf counter used for draw calls
  57393. */
  57394. get drawCallsCounter(): PerfCounter;
  57395. /**
  57396. * Instantiates a new scene instrumentation.
  57397. * This class can be used to get instrumentation data from a Babylon engine
  57398. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  57399. * @param scene Defines the scene to instrument
  57400. */
  57401. constructor(
  57402. /**
  57403. * Defines the scene to instrument
  57404. */
  57405. scene: Scene);
  57406. /**
  57407. * Dispose and release associated resources.
  57408. */
  57409. dispose(): void;
  57410. }
  57411. }
  57412. declare module BABYLON {
  57413. /** @hidden */
  57414. export var glowMapGenerationPixelShader: {
  57415. name: string;
  57416. shader: string;
  57417. };
  57418. }
  57419. declare module BABYLON {
  57420. /** @hidden */
  57421. export var glowMapGenerationVertexShader: {
  57422. name: string;
  57423. shader: string;
  57424. };
  57425. }
  57426. declare module BABYLON {
  57427. /**
  57428. * Effect layer options. This helps customizing the behaviour
  57429. * of the effect layer.
  57430. */
  57431. export interface IEffectLayerOptions {
  57432. /**
  57433. * Multiplication factor apply to the canvas size to compute the render target size
  57434. * used to generated the objects (the smaller the faster).
  57435. */
  57436. mainTextureRatio: number;
  57437. /**
  57438. * Enforces a fixed size texture to ensure effect stability across devices.
  57439. */
  57440. mainTextureFixedSize?: number;
  57441. /**
  57442. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  57443. */
  57444. alphaBlendingMode: number;
  57445. /**
  57446. * The camera attached to the layer.
  57447. */
  57448. camera: Nullable<Camera>;
  57449. /**
  57450. * The rendering group to draw the layer in.
  57451. */
  57452. renderingGroupId: number;
  57453. }
  57454. /**
  57455. * The effect layer Helps adding post process effect blended with the main pass.
  57456. *
  57457. * This can be for instance use to generate glow or higlight effects on the scene.
  57458. *
  57459. * The effect layer class can not be used directly and is intented to inherited from to be
  57460. * customized per effects.
  57461. */
  57462. export abstract class EffectLayer {
  57463. private _vertexBuffers;
  57464. private _indexBuffer;
  57465. private _cachedDefines;
  57466. private _effectLayerMapGenerationEffect;
  57467. private _effectLayerOptions;
  57468. private _mergeEffect;
  57469. protected _scene: Scene;
  57470. protected _engine: Engine;
  57471. protected _maxSize: number;
  57472. protected _mainTextureDesiredSize: ISize;
  57473. protected _mainTexture: RenderTargetTexture;
  57474. protected _shouldRender: boolean;
  57475. protected _postProcesses: PostProcess[];
  57476. protected _textures: BaseTexture[];
  57477. protected _emissiveTextureAndColor: {
  57478. texture: Nullable<BaseTexture>;
  57479. color: Color4;
  57480. };
  57481. /**
  57482. * The name of the layer
  57483. */
  57484. name: string;
  57485. /**
  57486. * The clear color of the texture used to generate the glow map.
  57487. */
  57488. neutralColor: Color4;
  57489. /**
  57490. * Specifies whether the highlight layer is enabled or not.
  57491. */
  57492. isEnabled: boolean;
  57493. /**
  57494. * Gets the camera attached to the layer.
  57495. */
  57496. get camera(): Nullable<Camera>;
  57497. /**
  57498. * Gets the rendering group id the layer should render in.
  57499. */
  57500. get renderingGroupId(): number;
  57501. set renderingGroupId(renderingGroupId: number);
  57502. /**
  57503. * An event triggered when the effect layer has been disposed.
  57504. */
  57505. onDisposeObservable: Observable<EffectLayer>;
  57506. /**
  57507. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  57508. */
  57509. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  57510. /**
  57511. * An event triggered when the generated texture is being merged in the scene.
  57512. */
  57513. onBeforeComposeObservable: Observable<EffectLayer>;
  57514. /**
  57515. * An event triggered when the mesh is rendered into the effect render target.
  57516. */
  57517. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  57518. /**
  57519. * An event triggered after the mesh has been rendered into the effect render target.
  57520. */
  57521. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  57522. /**
  57523. * An event triggered when the generated texture has been merged in the scene.
  57524. */
  57525. onAfterComposeObservable: Observable<EffectLayer>;
  57526. /**
  57527. * An event triggered when the efffect layer changes its size.
  57528. */
  57529. onSizeChangedObservable: Observable<EffectLayer>;
  57530. /** @hidden */
  57531. static _SceneComponentInitialization: (scene: Scene) => void;
  57532. /**
  57533. * Instantiates a new effect Layer and references it in the scene.
  57534. * @param name The name of the layer
  57535. * @param scene The scene to use the layer in
  57536. */
  57537. constructor(
  57538. /** The Friendly of the effect in the scene */
  57539. name: string, scene: Scene);
  57540. /**
  57541. * Get the effect name of the layer.
  57542. * @return The effect name
  57543. */
  57544. abstract getEffectName(): string;
  57545. /**
  57546. * Checks for the readiness of the element composing the layer.
  57547. * @param subMesh the mesh to check for
  57548. * @param useInstances specify whether or not to use instances to render the mesh
  57549. * @return true if ready otherwise, false
  57550. */
  57551. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57552. /**
  57553. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  57554. * @returns true if the effect requires stencil during the main canvas render pass.
  57555. */
  57556. abstract needStencil(): boolean;
  57557. /**
  57558. * Create the merge effect. This is the shader use to blit the information back
  57559. * to the main canvas at the end of the scene rendering.
  57560. * @returns The effect containing the shader used to merge the effect on the main canvas
  57561. */
  57562. protected abstract _createMergeEffect(): Effect;
  57563. /**
  57564. * Creates the render target textures and post processes used in the effect layer.
  57565. */
  57566. protected abstract _createTextureAndPostProcesses(): void;
  57567. /**
  57568. * Implementation specific of rendering the generating effect on the main canvas.
  57569. * @param effect The effect used to render through
  57570. */
  57571. protected abstract _internalRender(effect: Effect): void;
  57572. /**
  57573. * Sets the required values for both the emissive texture and and the main color.
  57574. */
  57575. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57576. /**
  57577. * Free any resources and references associated to a mesh.
  57578. * Internal use
  57579. * @param mesh The mesh to free.
  57580. */
  57581. abstract _disposeMesh(mesh: Mesh): void;
  57582. /**
  57583. * Serializes this layer (Glow or Highlight for example)
  57584. * @returns a serialized layer object
  57585. */
  57586. abstract serialize?(): any;
  57587. /**
  57588. * Initializes the effect layer with the required options.
  57589. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  57590. */
  57591. protected _init(options: Partial<IEffectLayerOptions>): void;
  57592. /**
  57593. * Generates the index buffer of the full screen quad blending to the main canvas.
  57594. */
  57595. private _generateIndexBuffer;
  57596. /**
  57597. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  57598. */
  57599. private _generateVertexBuffer;
  57600. /**
  57601. * Sets the main texture desired size which is the closest power of two
  57602. * of the engine canvas size.
  57603. */
  57604. private _setMainTextureSize;
  57605. /**
  57606. * Creates the main texture for the effect layer.
  57607. */
  57608. protected _createMainTexture(): void;
  57609. /**
  57610. * Adds specific effects defines.
  57611. * @param defines The defines to add specifics to.
  57612. */
  57613. protected _addCustomEffectDefines(defines: string[]): void;
  57614. /**
  57615. * Checks for the readiness of the element composing the layer.
  57616. * @param subMesh the mesh to check for
  57617. * @param useInstances specify whether or not to use instances to render the mesh
  57618. * @param emissiveTexture the associated emissive texture used to generate the glow
  57619. * @return true if ready otherwise, false
  57620. */
  57621. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  57622. /**
  57623. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  57624. */
  57625. render(): void;
  57626. /**
  57627. * Determine if a given mesh will be used in the current effect.
  57628. * @param mesh mesh to test
  57629. * @returns true if the mesh will be used
  57630. */
  57631. hasMesh(mesh: AbstractMesh): boolean;
  57632. /**
  57633. * Returns true if the layer contains information to display, otherwise false.
  57634. * @returns true if the glow layer should be rendered
  57635. */
  57636. shouldRender(): boolean;
  57637. /**
  57638. * Returns true if the mesh should render, otherwise false.
  57639. * @param mesh The mesh to render
  57640. * @returns true if it should render otherwise false
  57641. */
  57642. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  57643. /**
  57644. * Returns true if the mesh can be rendered, otherwise false.
  57645. * @param mesh The mesh to render
  57646. * @param material The material used on the mesh
  57647. * @returns true if it can be rendered otherwise false
  57648. */
  57649. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57650. /**
  57651. * Returns true if the mesh should render, otherwise false.
  57652. * @param mesh The mesh to render
  57653. * @returns true if it should render otherwise false
  57654. */
  57655. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  57656. /**
  57657. * Renders the submesh passed in parameter to the generation map.
  57658. */
  57659. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  57660. /**
  57661. * Defines whether the current material of the mesh should be use to render the effect.
  57662. * @param mesh defines the current mesh to render
  57663. */
  57664. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  57665. /**
  57666. * Rebuild the required buffers.
  57667. * @hidden Internal use only.
  57668. */
  57669. _rebuild(): void;
  57670. /**
  57671. * Dispose only the render target textures and post process.
  57672. */
  57673. private _disposeTextureAndPostProcesses;
  57674. /**
  57675. * Dispose the highlight layer and free resources.
  57676. */
  57677. dispose(): void;
  57678. /**
  57679. * Gets the class name of the effect layer
  57680. * @returns the string with the class name of the effect layer
  57681. */
  57682. getClassName(): string;
  57683. /**
  57684. * Creates an effect layer from parsed effect layer data
  57685. * @param parsedEffectLayer defines effect layer data
  57686. * @param scene defines the current scene
  57687. * @param rootUrl defines the root URL containing the effect layer information
  57688. * @returns a parsed effect Layer
  57689. */
  57690. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  57691. }
  57692. }
  57693. declare module BABYLON {
  57694. interface AbstractScene {
  57695. /**
  57696. * The list of effect layers (highlights/glow) added to the scene
  57697. * @see https://doc.babylonjs.com/how_to/highlight_layer
  57698. * @see https://doc.babylonjs.com/how_to/glow_layer
  57699. */
  57700. effectLayers: Array<EffectLayer>;
  57701. /**
  57702. * Removes the given effect layer from this scene.
  57703. * @param toRemove defines the effect layer to remove
  57704. * @returns the index of the removed effect layer
  57705. */
  57706. removeEffectLayer(toRemove: EffectLayer): number;
  57707. /**
  57708. * Adds the given effect layer to this scene
  57709. * @param newEffectLayer defines the effect layer to add
  57710. */
  57711. addEffectLayer(newEffectLayer: EffectLayer): void;
  57712. }
  57713. /**
  57714. * Defines the layer scene component responsible to manage any effect layers
  57715. * in a given scene.
  57716. */
  57717. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  57718. /**
  57719. * The component name helpfull to identify the component in the list of scene components.
  57720. */
  57721. readonly name: string;
  57722. /**
  57723. * The scene the component belongs to.
  57724. */
  57725. scene: Scene;
  57726. private _engine;
  57727. private _renderEffects;
  57728. private _needStencil;
  57729. private _previousStencilState;
  57730. /**
  57731. * Creates a new instance of the component for the given scene
  57732. * @param scene Defines the scene to register the component in
  57733. */
  57734. constructor(scene: Scene);
  57735. /**
  57736. * Registers the component in a given scene
  57737. */
  57738. register(): void;
  57739. /**
  57740. * Rebuilds the elements related to this component in case of
  57741. * context lost for instance.
  57742. */
  57743. rebuild(): void;
  57744. /**
  57745. * Serializes the component data to the specified json object
  57746. * @param serializationObject The object to serialize to
  57747. */
  57748. serialize(serializationObject: any): void;
  57749. /**
  57750. * Adds all the elements from the container to the scene
  57751. * @param container the container holding the elements
  57752. */
  57753. addFromContainer(container: AbstractScene): void;
  57754. /**
  57755. * Removes all the elements in the container from the scene
  57756. * @param container contains the elements to remove
  57757. * @param dispose if the removed element should be disposed (default: false)
  57758. */
  57759. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57760. /**
  57761. * Disposes the component and the associated ressources.
  57762. */
  57763. dispose(): void;
  57764. private _isReadyForMesh;
  57765. private _renderMainTexture;
  57766. private _setStencil;
  57767. private _setStencilBack;
  57768. private _draw;
  57769. private _drawCamera;
  57770. private _drawRenderingGroup;
  57771. }
  57772. }
  57773. declare module BABYLON {
  57774. /** @hidden */
  57775. export var glowMapMergePixelShader: {
  57776. name: string;
  57777. shader: string;
  57778. };
  57779. }
  57780. declare module BABYLON {
  57781. /** @hidden */
  57782. export var glowMapMergeVertexShader: {
  57783. name: string;
  57784. shader: string;
  57785. };
  57786. }
  57787. declare module BABYLON {
  57788. interface AbstractScene {
  57789. /**
  57790. * Return a the first highlight layer of the scene with a given name.
  57791. * @param name The name of the highlight layer to look for.
  57792. * @return The highlight layer if found otherwise null.
  57793. */
  57794. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  57795. }
  57796. /**
  57797. * Glow layer options. This helps customizing the behaviour
  57798. * of the glow layer.
  57799. */
  57800. export interface IGlowLayerOptions {
  57801. /**
  57802. * Multiplication factor apply to the canvas size to compute the render target size
  57803. * used to generated the glowing objects (the smaller the faster).
  57804. */
  57805. mainTextureRatio: number;
  57806. /**
  57807. * Enforces a fixed size texture to ensure resize independant blur.
  57808. */
  57809. mainTextureFixedSize?: number;
  57810. /**
  57811. * How big is the kernel of the blur texture.
  57812. */
  57813. blurKernelSize: number;
  57814. /**
  57815. * The camera attached to the layer.
  57816. */
  57817. camera: Nullable<Camera>;
  57818. /**
  57819. * Enable MSAA by chosing the number of samples.
  57820. */
  57821. mainTextureSamples?: number;
  57822. /**
  57823. * The rendering group to draw the layer in.
  57824. */
  57825. renderingGroupId: number;
  57826. }
  57827. /**
  57828. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  57829. *
  57830. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  57831. *
  57832. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  57833. */
  57834. export class GlowLayer extends EffectLayer {
  57835. /**
  57836. * Effect Name of the layer.
  57837. */
  57838. static readonly EffectName: string;
  57839. /**
  57840. * The default blur kernel size used for the glow.
  57841. */
  57842. static DefaultBlurKernelSize: number;
  57843. /**
  57844. * The default texture size ratio used for the glow.
  57845. */
  57846. static DefaultTextureRatio: number;
  57847. /**
  57848. * Sets the kernel size of the blur.
  57849. */
  57850. set blurKernelSize(value: number);
  57851. /**
  57852. * Gets the kernel size of the blur.
  57853. */
  57854. get blurKernelSize(): number;
  57855. /**
  57856. * Sets the glow intensity.
  57857. */
  57858. set intensity(value: number);
  57859. /**
  57860. * Gets the glow intensity.
  57861. */
  57862. get intensity(): number;
  57863. private _options;
  57864. private _intensity;
  57865. private _horizontalBlurPostprocess1;
  57866. private _verticalBlurPostprocess1;
  57867. private _horizontalBlurPostprocess2;
  57868. private _verticalBlurPostprocess2;
  57869. private _blurTexture1;
  57870. private _blurTexture2;
  57871. private _postProcesses1;
  57872. private _postProcesses2;
  57873. private _includedOnlyMeshes;
  57874. private _excludedMeshes;
  57875. private _meshesUsingTheirOwnMaterials;
  57876. /**
  57877. * Callback used to let the user override the color selection on a per mesh basis
  57878. */
  57879. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  57880. /**
  57881. * Callback used to let the user override the texture selection on a per mesh basis
  57882. */
  57883. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  57884. /**
  57885. * Instantiates a new glow Layer and references it to the scene.
  57886. * @param name The name of the layer
  57887. * @param scene The scene to use the layer in
  57888. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  57889. */
  57890. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  57891. /**
  57892. * Get the effect name of the layer.
  57893. * @return The effect name
  57894. */
  57895. getEffectName(): string;
  57896. /**
  57897. * Create the merge effect. This is the shader use to blit the information back
  57898. * to the main canvas at the end of the scene rendering.
  57899. */
  57900. protected _createMergeEffect(): Effect;
  57901. /**
  57902. * Creates the render target textures and post processes used in the glow layer.
  57903. */
  57904. protected _createTextureAndPostProcesses(): void;
  57905. /**
  57906. * Checks for the readiness of the element composing the layer.
  57907. * @param subMesh the mesh to check for
  57908. * @param useInstances specify wether or not to use instances to render the mesh
  57909. * @param emissiveTexture the associated emissive texture used to generate the glow
  57910. * @return true if ready otherwise, false
  57911. */
  57912. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57913. /**
  57914. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  57915. */
  57916. needStencil(): boolean;
  57917. /**
  57918. * Returns true if the mesh can be rendered, otherwise false.
  57919. * @param mesh The mesh to render
  57920. * @param material The material used on the mesh
  57921. * @returns true if it can be rendered otherwise false
  57922. */
  57923. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57924. /**
  57925. * Implementation specific of rendering the generating effect on the main canvas.
  57926. * @param effect The effect used to render through
  57927. */
  57928. protected _internalRender(effect: Effect): void;
  57929. /**
  57930. * Sets the required values for both the emissive texture and and the main color.
  57931. */
  57932. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57933. /**
  57934. * Returns true if the mesh should render, otherwise false.
  57935. * @param mesh The mesh to render
  57936. * @returns true if it should render otherwise false
  57937. */
  57938. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57939. /**
  57940. * Adds specific effects defines.
  57941. * @param defines The defines to add specifics to.
  57942. */
  57943. protected _addCustomEffectDefines(defines: string[]): void;
  57944. /**
  57945. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  57946. * @param mesh The mesh to exclude from the glow layer
  57947. */
  57948. addExcludedMesh(mesh: Mesh): void;
  57949. /**
  57950. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  57951. * @param mesh The mesh to remove
  57952. */
  57953. removeExcludedMesh(mesh: Mesh): void;
  57954. /**
  57955. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  57956. * @param mesh The mesh to include in the glow layer
  57957. */
  57958. addIncludedOnlyMesh(mesh: Mesh): void;
  57959. /**
  57960. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  57961. * @param mesh The mesh to remove
  57962. */
  57963. removeIncludedOnlyMesh(mesh: Mesh): void;
  57964. /**
  57965. * Determine if a given mesh will be used in the glow layer
  57966. * @param mesh The mesh to test
  57967. * @returns true if the mesh will be highlighted by the current glow layer
  57968. */
  57969. hasMesh(mesh: AbstractMesh): boolean;
  57970. /**
  57971. * Defines whether the current material of the mesh should be use to render the effect.
  57972. * @param mesh defines the current mesh to render
  57973. */
  57974. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  57975. /**
  57976. * Add a mesh to be rendered through its own material and not with emissive only.
  57977. * @param mesh The mesh for which we need to use its material
  57978. */
  57979. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  57980. /**
  57981. * Remove a mesh from being rendered through its own material and not with emissive only.
  57982. * @param mesh The mesh for which we need to not use its material
  57983. */
  57984. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  57985. /**
  57986. * Free any resources and references associated to a mesh.
  57987. * Internal use
  57988. * @param mesh The mesh to free.
  57989. * @hidden
  57990. */
  57991. _disposeMesh(mesh: Mesh): void;
  57992. /**
  57993. * Gets the class name of the effect layer
  57994. * @returns the string with the class name of the effect layer
  57995. */
  57996. getClassName(): string;
  57997. /**
  57998. * Serializes this glow layer
  57999. * @returns a serialized glow layer object
  58000. */
  58001. serialize(): any;
  58002. /**
  58003. * Creates a Glow Layer from parsed glow layer data
  58004. * @param parsedGlowLayer defines glow layer data
  58005. * @param scene defines the current scene
  58006. * @param rootUrl defines the root URL containing the glow layer information
  58007. * @returns a parsed Glow Layer
  58008. */
  58009. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  58010. }
  58011. }
  58012. declare module BABYLON {
  58013. /** @hidden */
  58014. export var glowBlurPostProcessPixelShader: {
  58015. name: string;
  58016. shader: string;
  58017. };
  58018. }
  58019. declare module BABYLON {
  58020. interface AbstractScene {
  58021. /**
  58022. * Return a the first highlight layer of the scene with a given name.
  58023. * @param name The name of the highlight layer to look for.
  58024. * @return The highlight layer if found otherwise null.
  58025. */
  58026. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  58027. }
  58028. /**
  58029. * Highlight layer options. This helps customizing the behaviour
  58030. * of the highlight layer.
  58031. */
  58032. export interface IHighlightLayerOptions {
  58033. /**
  58034. * Multiplication factor apply to the canvas size to compute the render target size
  58035. * used to generated the glowing objects (the smaller the faster).
  58036. */
  58037. mainTextureRatio: number;
  58038. /**
  58039. * Enforces a fixed size texture to ensure resize independant blur.
  58040. */
  58041. mainTextureFixedSize?: number;
  58042. /**
  58043. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  58044. * of the picture to blur (the smaller the faster).
  58045. */
  58046. blurTextureSizeRatio: number;
  58047. /**
  58048. * How big in texel of the blur texture is the vertical blur.
  58049. */
  58050. blurVerticalSize: number;
  58051. /**
  58052. * How big in texel of the blur texture is the horizontal blur.
  58053. */
  58054. blurHorizontalSize: number;
  58055. /**
  58056. * Alpha blending mode used to apply the blur. Default is combine.
  58057. */
  58058. alphaBlendingMode: number;
  58059. /**
  58060. * The camera attached to the layer.
  58061. */
  58062. camera: Nullable<Camera>;
  58063. /**
  58064. * Should we display highlight as a solid stroke?
  58065. */
  58066. isStroke?: boolean;
  58067. /**
  58068. * The rendering group to draw the layer in.
  58069. */
  58070. renderingGroupId: number;
  58071. }
  58072. /**
  58073. * The highlight layer Helps adding a glow effect around a mesh.
  58074. *
  58075. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  58076. * glowy meshes to your scene.
  58077. *
  58078. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  58079. */
  58080. export class HighlightLayer extends EffectLayer {
  58081. name: string;
  58082. /**
  58083. * Effect Name of the highlight layer.
  58084. */
  58085. static readonly EffectName: string;
  58086. /**
  58087. * The neutral color used during the preparation of the glow effect.
  58088. * This is black by default as the blend operation is a blend operation.
  58089. */
  58090. static NeutralColor: Color4;
  58091. /**
  58092. * Stencil value used for glowing meshes.
  58093. */
  58094. static GlowingMeshStencilReference: number;
  58095. /**
  58096. * Stencil value used for the other meshes in the scene.
  58097. */
  58098. static NormalMeshStencilReference: number;
  58099. /**
  58100. * Specifies whether or not the inner glow is ACTIVE in the layer.
  58101. */
  58102. innerGlow: boolean;
  58103. /**
  58104. * Specifies whether or not the outer glow is ACTIVE in the layer.
  58105. */
  58106. outerGlow: boolean;
  58107. /**
  58108. * Specifies the horizontal size of the blur.
  58109. */
  58110. set blurHorizontalSize(value: number);
  58111. /**
  58112. * Specifies the vertical size of the blur.
  58113. */
  58114. set blurVerticalSize(value: number);
  58115. /**
  58116. * Gets the horizontal size of the blur.
  58117. */
  58118. get blurHorizontalSize(): number;
  58119. /**
  58120. * Gets the vertical size of the blur.
  58121. */
  58122. get blurVerticalSize(): number;
  58123. /**
  58124. * An event triggered when the highlight layer is being blurred.
  58125. */
  58126. onBeforeBlurObservable: Observable<HighlightLayer>;
  58127. /**
  58128. * An event triggered when the highlight layer has been blurred.
  58129. */
  58130. onAfterBlurObservable: Observable<HighlightLayer>;
  58131. private _instanceGlowingMeshStencilReference;
  58132. private _options;
  58133. private _downSamplePostprocess;
  58134. private _horizontalBlurPostprocess;
  58135. private _verticalBlurPostprocess;
  58136. private _blurTexture;
  58137. private _meshes;
  58138. private _excludedMeshes;
  58139. /**
  58140. * Instantiates a new highlight Layer and references it to the scene..
  58141. * @param name The name of the layer
  58142. * @param scene The scene to use the layer in
  58143. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  58144. */
  58145. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  58146. /**
  58147. * Get the effect name of the layer.
  58148. * @return The effect name
  58149. */
  58150. getEffectName(): string;
  58151. /**
  58152. * Create the merge effect. This is the shader use to blit the information back
  58153. * to the main canvas at the end of the scene rendering.
  58154. */
  58155. protected _createMergeEffect(): Effect;
  58156. /**
  58157. * Creates the render target textures and post processes used in the highlight layer.
  58158. */
  58159. protected _createTextureAndPostProcesses(): void;
  58160. /**
  58161. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  58162. */
  58163. needStencil(): boolean;
  58164. /**
  58165. * Checks for the readiness of the element composing the layer.
  58166. * @param subMesh the mesh to check for
  58167. * @param useInstances specify wether or not to use instances to render the mesh
  58168. * @param emissiveTexture the associated emissive texture used to generate the glow
  58169. * @return true if ready otherwise, false
  58170. */
  58171. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58172. /**
  58173. * Implementation specific of rendering the generating effect on the main canvas.
  58174. * @param effect The effect used to render through
  58175. */
  58176. protected _internalRender(effect: Effect): void;
  58177. /**
  58178. * Returns true if the layer contains information to display, otherwise false.
  58179. */
  58180. shouldRender(): boolean;
  58181. /**
  58182. * Returns true if the mesh should render, otherwise false.
  58183. * @param mesh The mesh to render
  58184. * @returns true if it should render otherwise false
  58185. */
  58186. protected _shouldRenderMesh(mesh: Mesh): boolean;
  58187. /**
  58188. * Returns true if the mesh can be rendered, otherwise false.
  58189. * @param mesh The mesh to render
  58190. * @param material The material used on the mesh
  58191. * @returns true if it can be rendered otherwise false
  58192. */
  58193. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58194. /**
  58195. * Adds specific effects defines.
  58196. * @param defines The defines to add specifics to.
  58197. */
  58198. protected _addCustomEffectDefines(defines: string[]): void;
  58199. /**
  58200. * Sets the required values for both the emissive texture and and the main color.
  58201. */
  58202. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58203. /**
  58204. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  58205. * @param mesh The mesh to exclude from the highlight layer
  58206. */
  58207. addExcludedMesh(mesh: Mesh): void;
  58208. /**
  58209. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  58210. * @param mesh The mesh to highlight
  58211. */
  58212. removeExcludedMesh(mesh: Mesh): void;
  58213. /**
  58214. * Determine if a given mesh will be highlighted by the current HighlightLayer
  58215. * @param mesh mesh to test
  58216. * @returns true if the mesh will be highlighted by the current HighlightLayer
  58217. */
  58218. hasMesh(mesh: AbstractMesh): boolean;
  58219. /**
  58220. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  58221. * @param mesh The mesh to highlight
  58222. * @param color The color of the highlight
  58223. * @param glowEmissiveOnly Extract the glow from the emissive texture
  58224. */
  58225. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  58226. /**
  58227. * Remove a mesh from the highlight layer in order to make it stop glowing.
  58228. * @param mesh The mesh to highlight
  58229. */
  58230. removeMesh(mesh: Mesh): void;
  58231. /**
  58232. * Remove all the meshes currently referenced in the highlight layer
  58233. */
  58234. removeAllMeshes(): void;
  58235. /**
  58236. * Force the stencil to the normal expected value for none glowing parts
  58237. */
  58238. private _defaultStencilReference;
  58239. /**
  58240. * Free any resources and references associated to a mesh.
  58241. * Internal use
  58242. * @param mesh The mesh to free.
  58243. * @hidden
  58244. */
  58245. _disposeMesh(mesh: Mesh): void;
  58246. /**
  58247. * Dispose the highlight layer and free resources.
  58248. */
  58249. dispose(): void;
  58250. /**
  58251. * Gets the class name of the effect layer
  58252. * @returns the string with the class name of the effect layer
  58253. */
  58254. getClassName(): string;
  58255. /**
  58256. * Serializes this Highlight layer
  58257. * @returns a serialized Highlight layer object
  58258. */
  58259. serialize(): any;
  58260. /**
  58261. * Creates a Highlight layer from parsed Highlight layer data
  58262. * @param parsedHightlightLayer defines the Highlight layer data
  58263. * @param scene defines the current scene
  58264. * @param rootUrl defines the root URL containing the Highlight layer information
  58265. * @returns a parsed Highlight layer
  58266. */
  58267. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  58268. }
  58269. }
  58270. declare module BABYLON {
  58271. interface AbstractScene {
  58272. /**
  58273. * The list of layers (background and foreground) of the scene
  58274. */
  58275. layers: Array<Layer>;
  58276. }
  58277. /**
  58278. * Defines the layer scene component responsible to manage any layers
  58279. * in a given scene.
  58280. */
  58281. export class LayerSceneComponent implements ISceneComponent {
  58282. /**
  58283. * The component name helpfull to identify the component in the list of scene components.
  58284. */
  58285. readonly name: string;
  58286. /**
  58287. * The scene the component belongs to.
  58288. */
  58289. scene: Scene;
  58290. private _engine;
  58291. /**
  58292. * Creates a new instance of the component for the given scene
  58293. * @param scene Defines the scene to register the component in
  58294. */
  58295. constructor(scene: Scene);
  58296. /**
  58297. * Registers the component in a given scene
  58298. */
  58299. register(): void;
  58300. /**
  58301. * Rebuilds the elements related to this component in case of
  58302. * context lost for instance.
  58303. */
  58304. rebuild(): void;
  58305. /**
  58306. * Disposes the component and the associated ressources.
  58307. */
  58308. dispose(): void;
  58309. private _draw;
  58310. private _drawCameraPredicate;
  58311. private _drawCameraBackground;
  58312. private _drawCameraForeground;
  58313. private _drawRenderTargetPredicate;
  58314. private _drawRenderTargetBackground;
  58315. private _drawRenderTargetForeground;
  58316. /**
  58317. * Adds all the elements from the container to the scene
  58318. * @param container the container holding the elements
  58319. */
  58320. addFromContainer(container: AbstractScene): void;
  58321. /**
  58322. * Removes all the elements in the container from the scene
  58323. * @param container contains the elements to remove
  58324. * @param dispose if the removed element should be disposed (default: false)
  58325. */
  58326. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58327. }
  58328. }
  58329. declare module BABYLON {
  58330. /** @hidden */
  58331. export var layerPixelShader: {
  58332. name: string;
  58333. shader: string;
  58334. };
  58335. }
  58336. declare module BABYLON {
  58337. /** @hidden */
  58338. export var layerVertexShader: {
  58339. name: string;
  58340. shader: string;
  58341. };
  58342. }
  58343. declare module BABYLON {
  58344. /**
  58345. * This represents a full screen 2d layer.
  58346. * This can be useful to display a picture in the background of your scene for instance.
  58347. * @see https://www.babylonjs-playground.com/#08A2BS#1
  58348. */
  58349. export class Layer {
  58350. /**
  58351. * Define the name of the layer.
  58352. */
  58353. name: string;
  58354. /**
  58355. * Define the texture the layer should display.
  58356. */
  58357. texture: Nullable<Texture>;
  58358. /**
  58359. * Is the layer in background or foreground.
  58360. */
  58361. isBackground: boolean;
  58362. /**
  58363. * Define the color of the layer (instead of texture).
  58364. */
  58365. color: Color4;
  58366. /**
  58367. * Define the scale of the layer in order to zoom in out of the texture.
  58368. */
  58369. scale: Vector2;
  58370. /**
  58371. * Define an offset for the layer in order to shift the texture.
  58372. */
  58373. offset: Vector2;
  58374. /**
  58375. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  58376. */
  58377. alphaBlendingMode: number;
  58378. /**
  58379. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  58380. * Alpha test will not mix with the background color in case of transparency.
  58381. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  58382. */
  58383. alphaTest: boolean;
  58384. /**
  58385. * Define a mask to restrict the layer to only some of the scene cameras.
  58386. */
  58387. layerMask: number;
  58388. /**
  58389. * Define the list of render target the layer is visible into.
  58390. */
  58391. renderTargetTextures: RenderTargetTexture[];
  58392. /**
  58393. * Define if the layer is only used in renderTarget or if it also
  58394. * renders in the main frame buffer of the canvas.
  58395. */
  58396. renderOnlyInRenderTargetTextures: boolean;
  58397. private _scene;
  58398. private _vertexBuffers;
  58399. private _indexBuffer;
  58400. private _effect;
  58401. private _previousDefines;
  58402. /**
  58403. * An event triggered when the layer is disposed.
  58404. */
  58405. onDisposeObservable: Observable<Layer>;
  58406. private _onDisposeObserver;
  58407. /**
  58408. * Back compatibility with callback before the onDisposeObservable existed.
  58409. * The set callback will be triggered when the layer has been disposed.
  58410. */
  58411. set onDispose(callback: () => void);
  58412. /**
  58413. * An event triggered before rendering the scene
  58414. */
  58415. onBeforeRenderObservable: Observable<Layer>;
  58416. private _onBeforeRenderObserver;
  58417. /**
  58418. * Back compatibility with callback before the onBeforeRenderObservable existed.
  58419. * The set callback will be triggered just before rendering the layer.
  58420. */
  58421. set onBeforeRender(callback: () => void);
  58422. /**
  58423. * An event triggered after rendering the scene
  58424. */
  58425. onAfterRenderObservable: Observable<Layer>;
  58426. private _onAfterRenderObserver;
  58427. /**
  58428. * Back compatibility with callback before the onAfterRenderObservable existed.
  58429. * The set callback will be triggered just after rendering the layer.
  58430. */
  58431. set onAfterRender(callback: () => void);
  58432. /**
  58433. * Instantiates a new layer.
  58434. * This represents a full screen 2d layer.
  58435. * This can be useful to display a picture in the background of your scene for instance.
  58436. * @see https://www.babylonjs-playground.com/#08A2BS#1
  58437. * @param name Define the name of the layer in the scene
  58438. * @param imgUrl Define the url of the texture to display in the layer
  58439. * @param scene Define the scene the layer belongs to
  58440. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  58441. * @param color Defines a color for the layer
  58442. */
  58443. constructor(
  58444. /**
  58445. * Define the name of the layer.
  58446. */
  58447. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  58448. private _createIndexBuffer;
  58449. /** @hidden */
  58450. _rebuild(): void;
  58451. /**
  58452. * Renders the layer in the scene.
  58453. */
  58454. render(): void;
  58455. /**
  58456. * Disposes and releases the associated ressources.
  58457. */
  58458. dispose(): void;
  58459. }
  58460. }
  58461. declare module BABYLON {
  58462. /** @hidden */
  58463. export var lensFlarePixelShader: {
  58464. name: string;
  58465. shader: string;
  58466. };
  58467. }
  58468. declare module BABYLON {
  58469. /** @hidden */
  58470. export var lensFlareVertexShader: {
  58471. name: string;
  58472. shader: string;
  58473. };
  58474. }
  58475. declare module BABYLON {
  58476. /**
  58477. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  58478. * It is usually composed of several `lensFlare`.
  58479. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58480. */
  58481. export class LensFlareSystem {
  58482. /**
  58483. * Define the name of the lens flare system
  58484. */
  58485. name: string;
  58486. /**
  58487. * List of lens flares used in this system.
  58488. */
  58489. lensFlares: LensFlare[];
  58490. /**
  58491. * Define a limit from the border the lens flare can be visible.
  58492. */
  58493. borderLimit: number;
  58494. /**
  58495. * Define a viewport border we do not want to see the lens flare in.
  58496. */
  58497. viewportBorder: number;
  58498. /**
  58499. * Define a predicate which could limit the list of meshes able to occlude the effect.
  58500. */
  58501. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  58502. /**
  58503. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  58504. */
  58505. layerMask: number;
  58506. /**
  58507. * Define the id of the lens flare system in the scene.
  58508. * (equal to name by default)
  58509. */
  58510. id: string;
  58511. private _scene;
  58512. private _emitter;
  58513. private _vertexBuffers;
  58514. private _indexBuffer;
  58515. private _effect;
  58516. private _positionX;
  58517. private _positionY;
  58518. private _isEnabled;
  58519. /** @hidden */
  58520. static _SceneComponentInitialization: (scene: Scene) => void;
  58521. /**
  58522. * Instantiates a lens flare system.
  58523. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  58524. * It is usually composed of several `lensFlare`.
  58525. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58526. * @param name Define the name of the lens flare system in the scene
  58527. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  58528. * @param scene Define the scene the lens flare system belongs to
  58529. */
  58530. constructor(
  58531. /**
  58532. * Define the name of the lens flare system
  58533. */
  58534. name: string, emitter: any, scene: Scene);
  58535. /**
  58536. * Define if the lens flare system is enabled.
  58537. */
  58538. get isEnabled(): boolean;
  58539. set isEnabled(value: boolean);
  58540. /**
  58541. * Get the scene the effects belongs to.
  58542. * @returns the scene holding the lens flare system
  58543. */
  58544. getScene(): Scene;
  58545. /**
  58546. * Get the emitter of the lens flare system.
  58547. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  58548. * @returns the emitter of the lens flare system
  58549. */
  58550. getEmitter(): any;
  58551. /**
  58552. * Set the emitter of the lens flare system.
  58553. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  58554. * @param newEmitter Define the new emitter of the system
  58555. */
  58556. setEmitter(newEmitter: any): void;
  58557. /**
  58558. * Get the lens flare system emitter position.
  58559. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  58560. * @returns the position
  58561. */
  58562. getEmitterPosition(): Vector3;
  58563. /**
  58564. * @hidden
  58565. */
  58566. computeEffectivePosition(globalViewport: Viewport): boolean;
  58567. /** @hidden */
  58568. _isVisible(): boolean;
  58569. /**
  58570. * @hidden
  58571. */
  58572. render(): boolean;
  58573. /**
  58574. * Dispose and release the lens flare with its associated resources.
  58575. */
  58576. dispose(): void;
  58577. /**
  58578. * Parse a lens flare system from a JSON repressentation
  58579. * @param parsedLensFlareSystem Define the JSON to parse
  58580. * @param scene Define the scene the parsed system should be instantiated in
  58581. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  58582. * @returns the parsed system
  58583. */
  58584. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  58585. /**
  58586. * Serialize the current Lens Flare System into a JSON representation.
  58587. * @returns the serialized JSON
  58588. */
  58589. serialize(): any;
  58590. }
  58591. }
  58592. declare module BABYLON {
  58593. /**
  58594. * This represents one of the lens effect in a `lensFlareSystem`.
  58595. * It controls one of the indiviual texture used in the effect.
  58596. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58597. */
  58598. export class LensFlare {
  58599. /**
  58600. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  58601. */
  58602. size: number;
  58603. /**
  58604. * 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.
  58605. */
  58606. position: number;
  58607. /**
  58608. * Define the lens color.
  58609. */
  58610. color: Color3;
  58611. /**
  58612. * Define the lens texture.
  58613. */
  58614. texture: Nullable<Texture>;
  58615. /**
  58616. * Define the alpha mode to render this particular lens.
  58617. */
  58618. alphaMode: number;
  58619. private _system;
  58620. /**
  58621. * Creates a new Lens Flare.
  58622. * This represents one of the lens effect in a `lensFlareSystem`.
  58623. * It controls one of the indiviual texture used in the effect.
  58624. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58625. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  58626. * @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.
  58627. * @param color Define the lens color
  58628. * @param imgUrl Define the lens texture url
  58629. * @param system Define the `lensFlareSystem` this flare is part of
  58630. * @returns The newly created Lens Flare
  58631. */
  58632. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  58633. /**
  58634. * Instantiates a new Lens Flare.
  58635. * This represents one of the lens effect in a `lensFlareSystem`.
  58636. * It controls one of the indiviual texture used in the effect.
  58637. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58638. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  58639. * @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.
  58640. * @param color Define the lens color
  58641. * @param imgUrl Define the lens texture url
  58642. * @param system Define the `lensFlareSystem` this flare is part of
  58643. */
  58644. constructor(
  58645. /**
  58646. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  58647. */
  58648. size: number,
  58649. /**
  58650. * 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.
  58651. */
  58652. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  58653. /**
  58654. * Dispose and release the lens flare with its associated resources.
  58655. */
  58656. dispose(): void;
  58657. }
  58658. }
  58659. declare module BABYLON {
  58660. interface AbstractScene {
  58661. /**
  58662. * The list of lens flare system added to the scene
  58663. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58664. */
  58665. lensFlareSystems: Array<LensFlareSystem>;
  58666. /**
  58667. * Removes the given lens flare system from this scene.
  58668. * @param toRemove The lens flare system to remove
  58669. * @returns The index of the removed lens flare system
  58670. */
  58671. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  58672. /**
  58673. * Adds the given lens flare system to this scene
  58674. * @param newLensFlareSystem The lens flare system to add
  58675. */
  58676. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  58677. /**
  58678. * Gets a lens flare system using its name
  58679. * @param name defines the name to look for
  58680. * @returns the lens flare system or null if not found
  58681. */
  58682. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  58683. /**
  58684. * Gets a lens flare system using its id
  58685. * @param id defines the id to look for
  58686. * @returns the lens flare system or null if not found
  58687. */
  58688. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  58689. }
  58690. /**
  58691. * Defines the lens flare scene component responsible to manage any lens flares
  58692. * in a given scene.
  58693. */
  58694. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  58695. /**
  58696. * The component name helpfull to identify the component in the list of scene components.
  58697. */
  58698. readonly name: string;
  58699. /**
  58700. * The scene the component belongs to.
  58701. */
  58702. scene: Scene;
  58703. /**
  58704. * Creates a new instance of the component for the given scene
  58705. * @param scene Defines the scene to register the component in
  58706. */
  58707. constructor(scene: Scene);
  58708. /**
  58709. * Registers the component in a given scene
  58710. */
  58711. register(): void;
  58712. /**
  58713. * Rebuilds the elements related to this component in case of
  58714. * context lost for instance.
  58715. */
  58716. rebuild(): void;
  58717. /**
  58718. * Adds all the elements from the container to the scene
  58719. * @param container the container holding the elements
  58720. */
  58721. addFromContainer(container: AbstractScene): void;
  58722. /**
  58723. * Removes all the elements in the container from the scene
  58724. * @param container contains the elements to remove
  58725. * @param dispose if the removed element should be disposed (default: false)
  58726. */
  58727. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58728. /**
  58729. * Serializes the component data to the specified json object
  58730. * @param serializationObject The object to serialize to
  58731. */
  58732. serialize(serializationObject: any): void;
  58733. /**
  58734. * Disposes the component and the associated ressources.
  58735. */
  58736. dispose(): void;
  58737. private _draw;
  58738. }
  58739. }
  58740. declare module BABYLON {
  58741. /** @hidden */
  58742. export var depthPixelShader: {
  58743. name: string;
  58744. shader: string;
  58745. };
  58746. }
  58747. declare module BABYLON {
  58748. /** @hidden */
  58749. export var depthVertexShader: {
  58750. name: string;
  58751. shader: string;
  58752. };
  58753. }
  58754. declare module BABYLON {
  58755. /**
  58756. * This represents a depth renderer in Babylon.
  58757. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  58758. */
  58759. export class DepthRenderer {
  58760. private _scene;
  58761. private _depthMap;
  58762. private _effect;
  58763. private readonly _storeNonLinearDepth;
  58764. private readonly _clearColor;
  58765. /** Get if the depth renderer is using packed depth or not */
  58766. readonly isPacked: boolean;
  58767. private _cachedDefines;
  58768. private _camera;
  58769. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  58770. enabled: boolean;
  58771. /**
  58772. * Specifiess that the depth renderer will only be used within
  58773. * the camera it is created for.
  58774. * This can help forcing its rendering during the camera processing.
  58775. */
  58776. useOnlyInActiveCamera: boolean;
  58777. /** @hidden */
  58778. static _SceneComponentInitialization: (scene: Scene) => void;
  58779. /**
  58780. * Instantiates a depth renderer
  58781. * @param scene The scene the renderer belongs to
  58782. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  58783. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  58784. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  58785. */
  58786. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  58787. /**
  58788. * Creates the depth rendering effect and checks if the effect is ready.
  58789. * @param subMesh The submesh to be used to render the depth map of
  58790. * @param useInstances If multiple world instances should be used
  58791. * @returns if the depth renderer is ready to render the depth map
  58792. */
  58793. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58794. /**
  58795. * Gets the texture which the depth map will be written to.
  58796. * @returns The depth map texture
  58797. */
  58798. getDepthMap(): RenderTargetTexture;
  58799. /**
  58800. * Disposes of the depth renderer.
  58801. */
  58802. dispose(): void;
  58803. }
  58804. }
  58805. declare module BABYLON {
  58806. /** @hidden */
  58807. export var minmaxReduxPixelShader: {
  58808. name: string;
  58809. shader: string;
  58810. };
  58811. }
  58812. declare module BABYLON {
  58813. /**
  58814. * This class computes a min/max reduction from a texture: it means it computes the minimum
  58815. * and maximum values from all values of the texture.
  58816. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  58817. * The source values are read from the red channel of the texture.
  58818. */
  58819. export class MinMaxReducer {
  58820. /**
  58821. * Observable triggered when the computation has been performed
  58822. */
  58823. onAfterReductionPerformed: Observable<{
  58824. min: number;
  58825. max: number;
  58826. }>;
  58827. protected _camera: Camera;
  58828. protected _sourceTexture: Nullable<RenderTargetTexture>;
  58829. protected _reductionSteps: Nullable<Array<PostProcess>>;
  58830. protected _postProcessManager: PostProcessManager;
  58831. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  58832. protected _forceFullscreenViewport: boolean;
  58833. /**
  58834. * Creates a min/max reducer
  58835. * @param camera The camera to use for the post processes
  58836. */
  58837. constructor(camera: Camera);
  58838. /**
  58839. * Gets the texture used to read the values from.
  58840. */
  58841. get sourceTexture(): Nullable<RenderTargetTexture>;
  58842. /**
  58843. * Sets the source texture to read the values from.
  58844. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  58845. * because in such textures '1' value must not be taken into account to compute the maximum
  58846. * as this value is used to clear the texture.
  58847. * Note that the computation is not activated by calling this function, you must call activate() for that!
  58848. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  58849. * @param depthRedux Indicates if the texture is a depth texture or not
  58850. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  58851. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  58852. */
  58853. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  58854. /**
  58855. * Defines the refresh rate of the computation.
  58856. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58857. */
  58858. get refreshRate(): number;
  58859. set refreshRate(value: number);
  58860. protected _activated: boolean;
  58861. /**
  58862. * Gets the activation status of the reducer
  58863. */
  58864. get activated(): boolean;
  58865. /**
  58866. * Activates the reduction computation.
  58867. * When activated, the observers registered in onAfterReductionPerformed are
  58868. * called after the compuation is performed
  58869. */
  58870. activate(): void;
  58871. /**
  58872. * Deactivates the reduction computation.
  58873. */
  58874. deactivate(): void;
  58875. /**
  58876. * Disposes the min/max reducer
  58877. * @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.
  58878. */
  58879. dispose(disposeAll?: boolean): void;
  58880. }
  58881. }
  58882. declare module BABYLON {
  58883. /**
  58884. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  58885. */
  58886. export class DepthReducer extends MinMaxReducer {
  58887. private _depthRenderer;
  58888. private _depthRendererId;
  58889. /**
  58890. * Gets the depth renderer used for the computation.
  58891. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  58892. */
  58893. get depthRenderer(): Nullable<DepthRenderer>;
  58894. /**
  58895. * Creates a depth reducer
  58896. * @param camera The camera used to render the depth texture
  58897. */
  58898. constructor(camera: Camera);
  58899. /**
  58900. * Sets the depth renderer to use to generate the depth map
  58901. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  58902. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  58903. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  58904. */
  58905. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  58906. /** @hidden */
  58907. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  58908. /**
  58909. * Activates the reduction computation.
  58910. * When activated, the observers registered in onAfterReductionPerformed are
  58911. * called after the compuation is performed
  58912. */
  58913. activate(): void;
  58914. /**
  58915. * Deactivates the reduction computation.
  58916. */
  58917. deactivate(): void;
  58918. /**
  58919. * Disposes the depth reducer
  58920. * @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.
  58921. */
  58922. dispose(disposeAll?: boolean): void;
  58923. }
  58924. }
  58925. declare module BABYLON {
  58926. /**
  58927. * A CSM implementation allowing casting shadows on large scenes.
  58928. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  58929. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  58930. */
  58931. export class CascadedShadowGenerator extends ShadowGenerator {
  58932. private static readonly frustumCornersNDCSpace;
  58933. /**
  58934. * Name of the CSM class
  58935. */
  58936. static CLASSNAME: string;
  58937. /**
  58938. * Defines the default number of cascades used by the CSM.
  58939. */
  58940. static readonly DEFAULT_CASCADES_COUNT: number;
  58941. /**
  58942. * Defines the minimum number of cascades used by the CSM.
  58943. */
  58944. static readonly MIN_CASCADES_COUNT: number;
  58945. /**
  58946. * Defines the maximum number of cascades used by the CSM.
  58947. */
  58948. static readonly MAX_CASCADES_COUNT: number;
  58949. protected _validateFilter(filter: number): number;
  58950. /**
  58951. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  58952. */
  58953. penumbraDarkness: number;
  58954. private _numCascades;
  58955. /**
  58956. * Gets or set the number of cascades used by the CSM.
  58957. */
  58958. get numCascades(): number;
  58959. set numCascades(value: number);
  58960. /**
  58961. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  58962. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  58963. */
  58964. stabilizeCascades: boolean;
  58965. private _freezeShadowCastersBoundingInfo;
  58966. private _freezeShadowCastersBoundingInfoObservable;
  58967. /**
  58968. * Enables or disables the shadow casters bounding info computation.
  58969. * If your shadow casters don't move, you can disable this feature.
  58970. * If it is enabled, the bounding box computation is done every frame.
  58971. */
  58972. get freezeShadowCastersBoundingInfo(): boolean;
  58973. set freezeShadowCastersBoundingInfo(freeze: boolean);
  58974. private _scbiMin;
  58975. private _scbiMax;
  58976. protected _computeShadowCastersBoundingInfo(): void;
  58977. protected _shadowCastersBoundingInfo: BoundingInfo;
  58978. /**
  58979. * Gets or sets the shadow casters bounding info.
  58980. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  58981. * so that the system won't overwrite the bounds you provide
  58982. */
  58983. get shadowCastersBoundingInfo(): BoundingInfo;
  58984. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  58985. protected _breaksAreDirty: boolean;
  58986. protected _minDistance: number;
  58987. protected _maxDistance: number;
  58988. /**
  58989. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  58990. *
  58991. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  58992. * If you don't know these values, simply leave them to their defaults and don't call this function.
  58993. * @param min minimal distance for the breaks (default to 0.)
  58994. * @param max maximal distance for the breaks (default to 1.)
  58995. */
  58996. setMinMaxDistance(min: number, max: number): void;
  58997. /** Gets the minimal distance used in the cascade break computation */
  58998. get minDistance(): number;
  58999. /** Gets the maximal distance used in the cascade break computation */
  59000. get maxDistance(): number;
  59001. /**
  59002. * Gets the class name of that object
  59003. * @returns "CascadedShadowGenerator"
  59004. */
  59005. getClassName(): string;
  59006. private _cascadeMinExtents;
  59007. private _cascadeMaxExtents;
  59008. /**
  59009. * Gets a cascade minimum extents
  59010. * @param cascadeIndex index of the cascade
  59011. * @returns the minimum cascade extents
  59012. */
  59013. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  59014. /**
  59015. * Gets a cascade maximum extents
  59016. * @param cascadeIndex index of the cascade
  59017. * @returns the maximum cascade extents
  59018. */
  59019. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  59020. private _cascades;
  59021. private _currentLayer;
  59022. private _viewSpaceFrustumsZ;
  59023. private _viewMatrices;
  59024. private _projectionMatrices;
  59025. private _transformMatrices;
  59026. private _transformMatricesAsArray;
  59027. private _frustumLengths;
  59028. private _lightSizeUVCorrection;
  59029. private _depthCorrection;
  59030. private _frustumCornersWorldSpace;
  59031. private _frustumCenter;
  59032. private _shadowCameraPos;
  59033. private _shadowMaxZ;
  59034. /**
  59035. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  59036. * It defaults to camera.maxZ
  59037. */
  59038. get shadowMaxZ(): number;
  59039. /**
  59040. * Sets the shadow max z distance.
  59041. */
  59042. set shadowMaxZ(value: number);
  59043. protected _debug: boolean;
  59044. /**
  59045. * Gets or sets the debug flag.
  59046. * When enabled, the cascades are materialized by different colors on the screen.
  59047. */
  59048. get debug(): boolean;
  59049. set debug(dbg: boolean);
  59050. private _depthClamp;
  59051. /**
  59052. * Gets or sets the depth clamping value.
  59053. *
  59054. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  59055. * to account for the shadow casters far away.
  59056. *
  59057. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  59058. */
  59059. get depthClamp(): boolean;
  59060. set depthClamp(value: boolean);
  59061. private _cascadeBlendPercentage;
  59062. /**
  59063. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  59064. * It defaults to 0.1 (10% blending).
  59065. */
  59066. get cascadeBlendPercentage(): number;
  59067. set cascadeBlendPercentage(value: number);
  59068. private _lambda;
  59069. /**
  59070. * Gets or set the lambda parameter.
  59071. * This parameter is used to split the camera frustum and create the cascades.
  59072. * 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.
  59073. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  59074. */
  59075. get lambda(): number;
  59076. set lambda(value: number);
  59077. /**
  59078. * Gets the view matrix corresponding to a given cascade
  59079. * @param cascadeNum cascade to retrieve the view matrix from
  59080. * @returns the cascade view matrix
  59081. */
  59082. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  59083. /**
  59084. * Gets the projection matrix corresponding to a given cascade
  59085. * @param cascadeNum cascade to retrieve the projection matrix from
  59086. * @returns the cascade projection matrix
  59087. */
  59088. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  59089. /**
  59090. * Gets the transformation matrix corresponding to a given cascade
  59091. * @param cascadeNum cascade to retrieve the transformation matrix from
  59092. * @returns the cascade transformation matrix
  59093. */
  59094. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  59095. private _depthRenderer;
  59096. /**
  59097. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  59098. *
  59099. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  59100. *
  59101. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  59102. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  59103. * @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
  59104. */
  59105. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  59106. private _depthReducer;
  59107. private _autoCalcDepthBounds;
  59108. /**
  59109. * Gets or sets the autoCalcDepthBounds property.
  59110. *
  59111. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  59112. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  59113. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  59114. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  59115. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  59116. */
  59117. get autoCalcDepthBounds(): boolean;
  59118. set autoCalcDepthBounds(value: boolean);
  59119. /**
  59120. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  59121. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  59122. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  59123. * for setting the refresh rate on the renderer yourself!
  59124. */
  59125. get autoCalcDepthBoundsRefreshRate(): number;
  59126. set autoCalcDepthBoundsRefreshRate(value: number);
  59127. /**
  59128. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  59129. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  59130. * you change the camera near/far planes!
  59131. */
  59132. splitFrustum(): void;
  59133. private _splitFrustum;
  59134. private _computeMatrices;
  59135. private _computeFrustumInWorldSpace;
  59136. private _computeCascadeFrustum;
  59137. /**
  59138. * Support test.
  59139. */
  59140. static get IsSupported(): boolean;
  59141. /** @hidden */
  59142. static _SceneComponentInitialization: (scene: Scene) => void;
  59143. /**
  59144. * Creates a Cascaded Shadow Generator object.
  59145. * A ShadowGenerator is the required tool to use the shadows.
  59146. * Each directional light casting shadows needs to use its own ShadowGenerator.
  59147. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  59148. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  59149. * @param light The directional light object generating the shadows.
  59150. * @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.
  59151. */
  59152. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  59153. protected _initializeGenerator(): void;
  59154. protected _createTargetRenderTexture(): void;
  59155. protected _initializeShadowMap(): void;
  59156. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  59157. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  59158. /**
  59159. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  59160. * @param defines Defines of the material we want to update
  59161. * @param lightIndex Index of the light in the enabled light list of the material
  59162. */
  59163. prepareDefines(defines: any, lightIndex: number): void;
  59164. /**
  59165. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  59166. * defined in the generator but impacting the effect).
  59167. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  59168. * @param effect The effect we are binfing the information for
  59169. */
  59170. bindShadowLight(lightIndex: string, effect: Effect): void;
  59171. /**
  59172. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  59173. * (eq to view projection * shadow projection matrices)
  59174. * @returns The transform matrix used to create the shadow map
  59175. */
  59176. getTransformMatrix(): Matrix;
  59177. /**
  59178. * Disposes the ShadowGenerator.
  59179. * Returns nothing.
  59180. */
  59181. dispose(): void;
  59182. /**
  59183. * Serializes the shadow generator setup to a json object.
  59184. * @returns The serialized JSON object
  59185. */
  59186. serialize(): any;
  59187. /**
  59188. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  59189. * @param parsedShadowGenerator The JSON object to parse
  59190. * @param scene The scene to create the shadow map for
  59191. * @returns The parsed shadow generator
  59192. */
  59193. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  59194. }
  59195. }
  59196. declare module BABYLON {
  59197. /**
  59198. * Defines the shadow generator component responsible to manage any shadow generators
  59199. * in a given scene.
  59200. */
  59201. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  59202. /**
  59203. * The component name helpfull to identify the component in the list of scene components.
  59204. */
  59205. readonly name: string;
  59206. /**
  59207. * The scene the component belongs to.
  59208. */
  59209. scene: Scene;
  59210. /**
  59211. * Creates a new instance of the component for the given scene
  59212. * @param scene Defines the scene to register the component in
  59213. */
  59214. constructor(scene: Scene);
  59215. /**
  59216. * Registers the component in a given scene
  59217. */
  59218. register(): void;
  59219. /**
  59220. * Rebuilds the elements related to this component in case of
  59221. * context lost for instance.
  59222. */
  59223. rebuild(): void;
  59224. /**
  59225. * Serializes the component data to the specified json object
  59226. * @param serializationObject The object to serialize to
  59227. */
  59228. serialize(serializationObject: any): void;
  59229. /**
  59230. * Adds all the elements from the container to the scene
  59231. * @param container the container holding the elements
  59232. */
  59233. addFromContainer(container: AbstractScene): void;
  59234. /**
  59235. * Removes all the elements in the container from the scene
  59236. * @param container contains the elements to remove
  59237. * @param dispose if the removed element should be disposed (default: false)
  59238. */
  59239. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59240. /**
  59241. * Rebuilds the elements related to this component in case of
  59242. * context lost for instance.
  59243. */
  59244. dispose(): void;
  59245. private _gatherRenderTargets;
  59246. }
  59247. }
  59248. declare module BABYLON {
  59249. /**
  59250. * A point light is a light defined by an unique point in world space.
  59251. * The light is emitted in every direction from this point.
  59252. * A good example of a point light is a standard light bulb.
  59253. * Documentation: https://doc.babylonjs.com/babylon101/lights
  59254. */
  59255. export class PointLight extends ShadowLight {
  59256. private _shadowAngle;
  59257. /**
  59258. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59259. * This specifies what angle the shadow will use to be created.
  59260. *
  59261. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  59262. */
  59263. get shadowAngle(): number;
  59264. /**
  59265. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59266. * This specifies what angle the shadow will use to be created.
  59267. *
  59268. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  59269. */
  59270. set shadowAngle(value: number);
  59271. /**
  59272. * Gets the direction if it has been set.
  59273. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59274. */
  59275. get direction(): Vector3;
  59276. /**
  59277. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59278. */
  59279. set direction(value: Vector3);
  59280. /**
  59281. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  59282. * A PointLight emits the light in every direction.
  59283. * It can cast shadows.
  59284. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  59285. * ```javascript
  59286. * var pointLight = new PointLight("pl", camera.position, scene);
  59287. * ```
  59288. * Documentation : https://doc.babylonjs.com/babylon101/lights
  59289. * @param name The light friendly name
  59290. * @param position The position of the point light in the scene
  59291. * @param scene The scene the lights belongs to
  59292. */
  59293. constructor(name: string, position: Vector3, scene: Scene);
  59294. /**
  59295. * Returns the string "PointLight"
  59296. * @returns the class name
  59297. */
  59298. getClassName(): string;
  59299. /**
  59300. * Returns the integer 0.
  59301. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  59302. */
  59303. getTypeID(): number;
  59304. /**
  59305. * Specifies wether or not the shadowmap should be a cube texture.
  59306. * @returns true if the shadowmap needs to be a cube texture.
  59307. */
  59308. needCube(): boolean;
  59309. /**
  59310. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  59311. * @param faceIndex The index of the face we are computed the direction to generate shadow
  59312. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  59313. */
  59314. getShadowDirection(faceIndex?: number): Vector3;
  59315. /**
  59316. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  59317. * - fov = PI / 2
  59318. * - aspect ratio : 1.0
  59319. * - z-near and far equal to the active camera minZ and maxZ.
  59320. * Returns the PointLight.
  59321. */
  59322. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59323. protected _buildUniformLayout(): void;
  59324. /**
  59325. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  59326. * @param effect The effect to update
  59327. * @param lightIndex The index of the light in the effect to update
  59328. * @returns The point light
  59329. */
  59330. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  59331. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  59332. /**
  59333. * Prepares the list of defines specific to the light type.
  59334. * @param defines the list of defines
  59335. * @param lightIndex defines the index of the light for the effect
  59336. */
  59337. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  59338. }
  59339. }
  59340. declare module BABYLON {
  59341. /**
  59342. * Header information of HDR texture files.
  59343. */
  59344. export interface HDRInfo {
  59345. /**
  59346. * The height of the texture in pixels.
  59347. */
  59348. height: number;
  59349. /**
  59350. * The width of the texture in pixels.
  59351. */
  59352. width: number;
  59353. /**
  59354. * The index of the beginning of the data in the binary file.
  59355. */
  59356. dataPosition: number;
  59357. }
  59358. /**
  59359. * This groups tools to convert HDR texture to native colors array.
  59360. */
  59361. export class HDRTools {
  59362. private static Ldexp;
  59363. private static Rgbe2float;
  59364. private static readStringLine;
  59365. /**
  59366. * Reads header information from an RGBE texture stored in a native array.
  59367. * More information on this format are available here:
  59368. * https://en.wikipedia.org/wiki/RGBE_image_format
  59369. *
  59370. * @param uint8array The binary file stored in native array.
  59371. * @return The header information.
  59372. */
  59373. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  59374. /**
  59375. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  59376. * This RGBE texture needs to store the information as a panorama.
  59377. *
  59378. * More information on this format are available here:
  59379. * https://en.wikipedia.org/wiki/RGBE_image_format
  59380. *
  59381. * @param buffer The binary file stored in an array buffer.
  59382. * @param size The expected size of the extracted cubemap.
  59383. * @return The Cube Map information.
  59384. */
  59385. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  59386. /**
  59387. * Returns the pixels data extracted from an RGBE texture.
  59388. * This pixels will be stored left to right up to down in the R G B order in one array.
  59389. *
  59390. * More information on this format are available here:
  59391. * https://en.wikipedia.org/wiki/RGBE_image_format
  59392. *
  59393. * @param uint8array The binary file stored in an array buffer.
  59394. * @param hdrInfo The header information of the file.
  59395. * @return The pixels data in RGB right to left up to down order.
  59396. */
  59397. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  59398. private static RGBE_ReadPixels_RLE;
  59399. private static RGBE_ReadPixels_NOT_RLE;
  59400. }
  59401. }
  59402. declare module BABYLON {
  59403. /**
  59404. * Effect Render Options
  59405. */
  59406. export interface IEffectRendererOptions {
  59407. /**
  59408. * Defines the vertices positions.
  59409. */
  59410. positions?: number[];
  59411. /**
  59412. * Defines the indices.
  59413. */
  59414. indices?: number[];
  59415. }
  59416. /**
  59417. * Helper class to render one or more effects.
  59418. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  59419. */
  59420. export class EffectRenderer {
  59421. private engine;
  59422. private static _DefaultOptions;
  59423. private _vertexBuffers;
  59424. private _indexBuffer;
  59425. private _fullscreenViewport;
  59426. /**
  59427. * Creates an effect renderer
  59428. * @param engine the engine to use for rendering
  59429. * @param options defines the options of the effect renderer
  59430. */
  59431. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  59432. /**
  59433. * Sets the current viewport in normalized coordinates 0-1
  59434. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  59435. */
  59436. setViewport(viewport?: Viewport): void;
  59437. /**
  59438. * Binds the embedded attributes buffer to the effect.
  59439. * @param effect Defines the effect to bind the attributes for
  59440. */
  59441. bindBuffers(effect: Effect): void;
  59442. /**
  59443. * Sets the current effect wrapper to use during draw.
  59444. * The effect needs to be ready before calling this api.
  59445. * This also sets the default full screen position attribute.
  59446. * @param effectWrapper Defines the effect to draw with
  59447. */
  59448. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  59449. /**
  59450. * Restores engine states
  59451. */
  59452. restoreStates(): void;
  59453. /**
  59454. * Draws a full screen quad.
  59455. */
  59456. draw(): void;
  59457. private isRenderTargetTexture;
  59458. /**
  59459. * renders one or more effects to a specified texture
  59460. * @param effectWrapper the effect to renderer
  59461. * @param outputTexture texture to draw to, if null it will render to the screen.
  59462. */
  59463. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  59464. /**
  59465. * Disposes of the effect renderer
  59466. */
  59467. dispose(): void;
  59468. }
  59469. /**
  59470. * Options to create an EffectWrapper
  59471. */
  59472. interface EffectWrapperCreationOptions {
  59473. /**
  59474. * Engine to use to create the effect
  59475. */
  59476. engine: ThinEngine;
  59477. /**
  59478. * Fragment shader for the effect
  59479. */
  59480. fragmentShader: string;
  59481. /**
  59482. * Use the shader store instead of direct source code
  59483. */
  59484. useShaderStore?: boolean;
  59485. /**
  59486. * Vertex shader for the effect
  59487. */
  59488. vertexShader?: string;
  59489. /**
  59490. * Attributes to use in the shader
  59491. */
  59492. attributeNames?: Array<string>;
  59493. /**
  59494. * Uniforms to use in the shader
  59495. */
  59496. uniformNames?: Array<string>;
  59497. /**
  59498. * Texture sampler names to use in the shader
  59499. */
  59500. samplerNames?: Array<string>;
  59501. /**
  59502. * Defines to use in the shader
  59503. */
  59504. defines?: Array<string>;
  59505. /**
  59506. * Callback when effect is compiled
  59507. */
  59508. onCompiled?: Nullable<(effect: Effect) => void>;
  59509. /**
  59510. * The friendly name of the effect displayed in Spector.
  59511. */
  59512. name?: string;
  59513. }
  59514. /**
  59515. * Wraps an effect to be used for rendering
  59516. */
  59517. export class EffectWrapper {
  59518. /**
  59519. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  59520. */
  59521. onApplyObservable: Observable<{}>;
  59522. /**
  59523. * The underlying effect
  59524. */
  59525. effect: Effect;
  59526. /**
  59527. * Creates an effect to be renderer
  59528. * @param creationOptions options to create the effect
  59529. */
  59530. constructor(creationOptions: EffectWrapperCreationOptions);
  59531. /**
  59532. * Disposes of the effect wrapper
  59533. */
  59534. dispose(): void;
  59535. }
  59536. }
  59537. declare module BABYLON {
  59538. /** @hidden */
  59539. export var hdrFilteringVertexShader: {
  59540. name: string;
  59541. shader: string;
  59542. };
  59543. }
  59544. declare module BABYLON {
  59545. /** @hidden */
  59546. export var hdrFilteringPixelShader: {
  59547. name: string;
  59548. shader: string;
  59549. };
  59550. }
  59551. declare module BABYLON {
  59552. /**
  59553. * Options for texture filtering
  59554. */
  59555. interface IHDRFilteringOptions {
  59556. /**
  59557. * Scales pixel intensity for the input HDR map.
  59558. */
  59559. hdrScale?: number;
  59560. /**
  59561. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  59562. */
  59563. quality?: number;
  59564. }
  59565. /**
  59566. * Filters HDR maps to get correct renderings of PBR reflections
  59567. */
  59568. export class HDRFiltering {
  59569. private _engine;
  59570. private _effectRenderer;
  59571. private _effectWrapper;
  59572. private _lodGenerationOffset;
  59573. private _lodGenerationScale;
  59574. /**
  59575. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  59576. * you care about baking speed.
  59577. */
  59578. quality: number;
  59579. /**
  59580. * Scales pixel intensity for the input HDR map.
  59581. */
  59582. hdrScale: number;
  59583. /**
  59584. * Instantiates HDR filter for reflection maps
  59585. *
  59586. * @param engine Thin engine
  59587. * @param options Options
  59588. */
  59589. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  59590. private _createRenderTarget;
  59591. private _prefilterInternal;
  59592. private _createEffect;
  59593. /**
  59594. * Get a value indicating if the filter is ready to be used
  59595. * @param texture Texture to filter
  59596. * @returns true if the filter is ready
  59597. */
  59598. isReady(texture: BaseTexture): boolean;
  59599. /**
  59600. * Prefilters a cube texture to have mipmap levels representing roughness values.
  59601. * Prefiltering will be invoked at the end of next rendering pass.
  59602. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  59603. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  59604. * @param texture Texture to filter
  59605. * @param onFinished Callback when filtering is done
  59606. * @return Promise called when prefiltering is done
  59607. */
  59608. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  59609. }
  59610. }
  59611. declare module BABYLON {
  59612. /**
  59613. * This represents a texture coming from an HDR input.
  59614. *
  59615. * The only supported format is currently panorama picture stored in RGBE format.
  59616. * Example of such files can be found on HDRLib: http://hdrlib.com/
  59617. */
  59618. export class HDRCubeTexture extends BaseTexture {
  59619. private static _facesMapping;
  59620. private _generateHarmonics;
  59621. private _noMipmap;
  59622. private _prefilterOnLoad;
  59623. private _textureMatrix;
  59624. private _size;
  59625. private _onLoad;
  59626. private _onError;
  59627. /**
  59628. * The texture URL.
  59629. */
  59630. url: string;
  59631. /**
  59632. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  59633. */
  59634. coordinatesMode: number;
  59635. protected _isBlocking: boolean;
  59636. /**
  59637. * Sets wether or not the texture is blocking during loading.
  59638. */
  59639. set isBlocking(value: boolean);
  59640. /**
  59641. * Gets wether or not the texture is blocking during loading.
  59642. */
  59643. get isBlocking(): boolean;
  59644. protected _rotationY: number;
  59645. /**
  59646. * Sets texture matrix rotation angle around Y axis in radians.
  59647. */
  59648. set rotationY(value: number);
  59649. /**
  59650. * Gets texture matrix rotation angle around Y axis radians.
  59651. */
  59652. get rotationY(): number;
  59653. /**
  59654. * Gets or sets the center of the bounding box associated with the cube texture
  59655. * It must define where the camera used to render the texture was set
  59656. */
  59657. boundingBoxPosition: Vector3;
  59658. private _boundingBoxSize;
  59659. /**
  59660. * Gets or sets the size of the bounding box associated with the cube texture
  59661. * When defined, the cubemap will switch to local mode
  59662. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  59663. * @example https://www.babylonjs-playground.com/#RNASML
  59664. */
  59665. set boundingBoxSize(value: Vector3);
  59666. get boundingBoxSize(): Vector3;
  59667. /**
  59668. * Instantiates an HDRTexture from the following parameters.
  59669. *
  59670. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  59671. * @param sceneOrEngine The scene or engine the texture will be used in
  59672. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59673. * @param noMipmap Forces to not generate the mipmap if true
  59674. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  59675. * @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)
  59676. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  59677. */
  59678. 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>);
  59679. /**
  59680. * Get the current class name of the texture useful for serialization or dynamic coding.
  59681. * @returns "HDRCubeTexture"
  59682. */
  59683. getClassName(): string;
  59684. /**
  59685. * Occurs when the file is raw .hdr file.
  59686. */
  59687. private loadTexture;
  59688. clone(): HDRCubeTexture;
  59689. delayLoad(): void;
  59690. /**
  59691. * Get the texture reflection matrix used to rotate/transform the reflection.
  59692. * @returns the reflection matrix
  59693. */
  59694. getReflectionTextureMatrix(): Matrix;
  59695. /**
  59696. * Set the texture reflection matrix used to rotate/transform the reflection.
  59697. * @param value Define the reflection matrix to set
  59698. */
  59699. setReflectionTextureMatrix(value: Matrix): void;
  59700. /**
  59701. * Parses a JSON representation of an HDR Texture in order to create the texture
  59702. * @param parsedTexture Define the JSON representation
  59703. * @param scene Define the scene the texture should be created in
  59704. * @param rootUrl Define the root url in case we need to load relative dependencies
  59705. * @returns the newly created texture after parsing
  59706. */
  59707. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  59708. serialize(): any;
  59709. }
  59710. }
  59711. declare module BABYLON {
  59712. /**
  59713. * Class used to control physics engine
  59714. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  59715. */
  59716. export class PhysicsEngine implements IPhysicsEngine {
  59717. private _physicsPlugin;
  59718. /**
  59719. * Global value used to control the smallest number supported by the simulation
  59720. */
  59721. static Epsilon: number;
  59722. private _impostors;
  59723. private _joints;
  59724. private _subTimeStep;
  59725. /**
  59726. * Gets the gravity vector used by the simulation
  59727. */
  59728. gravity: Vector3;
  59729. /**
  59730. * Factory used to create the default physics plugin.
  59731. * @returns The default physics plugin
  59732. */
  59733. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  59734. /**
  59735. * Creates a new Physics Engine
  59736. * @param gravity defines the gravity vector used by the simulation
  59737. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  59738. */
  59739. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  59740. /**
  59741. * Sets the gravity vector used by the simulation
  59742. * @param gravity defines the gravity vector to use
  59743. */
  59744. setGravity(gravity: Vector3): void;
  59745. /**
  59746. * Set the time step of the physics engine.
  59747. * Default is 1/60.
  59748. * To slow it down, enter 1/600 for example.
  59749. * To speed it up, 1/30
  59750. * @param newTimeStep defines the new timestep to apply to this world.
  59751. */
  59752. setTimeStep(newTimeStep?: number): void;
  59753. /**
  59754. * Get the time step of the physics engine.
  59755. * @returns the current time step
  59756. */
  59757. getTimeStep(): number;
  59758. /**
  59759. * Set the sub time step of the physics engine.
  59760. * Default is 0 meaning there is no sub steps
  59761. * To increase physics resolution precision, set a small value (like 1 ms)
  59762. * @param subTimeStep defines the new sub timestep used for physics resolution.
  59763. */
  59764. setSubTimeStep(subTimeStep?: number): void;
  59765. /**
  59766. * Get the sub time step of the physics engine.
  59767. * @returns the current sub time step
  59768. */
  59769. getSubTimeStep(): number;
  59770. /**
  59771. * Release all resources
  59772. */
  59773. dispose(): void;
  59774. /**
  59775. * Gets the name of the current physics plugin
  59776. * @returns the name of the plugin
  59777. */
  59778. getPhysicsPluginName(): string;
  59779. /**
  59780. * Adding a new impostor for the impostor tracking.
  59781. * This will be done by the impostor itself.
  59782. * @param impostor the impostor to add
  59783. */
  59784. addImpostor(impostor: PhysicsImpostor): void;
  59785. /**
  59786. * Remove an impostor from the engine.
  59787. * This impostor and its mesh will not longer be updated by the physics engine.
  59788. * @param impostor the impostor to remove
  59789. */
  59790. removeImpostor(impostor: PhysicsImpostor): void;
  59791. /**
  59792. * Add a joint to the physics engine
  59793. * @param mainImpostor defines the main impostor to which the joint is added.
  59794. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  59795. * @param joint defines the joint that will connect both impostors.
  59796. */
  59797. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59798. /**
  59799. * Removes a joint from the simulation
  59800. * @param mainImpostor defines the impostor used with the joint
  59801. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  59802. * @param joint defines the joint to remove
  59803. */
  59804. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59805. /**
  59806. * Called by the scene. No need to call it.
  59807. * @param delta defines the timespam between frames
  59808. */
  59809. _step(delta: number): void;
  59810. /**
  59811. * Gets the current plugin used to run the simulation
  59812. * @returns current plugin
  59813. */
  59814. getPhysicsPlugin(): IPhysicsEnginePlugin;
  59815. /**
  59816. * Gets the list of physic impostors
  59817. * @returns an array of PhysicsImpostor
  59818. */
  59819. getImpostors(): Array<PhysicsImpostor>;
  59820. /**
  59821. * Gets the impostor for a physics enabled object
  59822. * @param object defines the object impersonated by the impostor
  59823. * @returns the PhysicsImpostor or null if not found
  59824. */
  59825. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  59826. /**
  59827. * Gets the impostor for a physics body object
  59828. * @param body defines physics body used by the impostor
  59829. * @returns the PhysicsImpostor or null if not found
  59830. */
  59831. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  59832. /**
  59833. * Does a raycast in the physics world
  59834. * @param from when should the ray start?
  59835. * @param to when should the ray end?
  59836. * @returns PhysicsRaycastResult
  59837. */
  59838. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59839. }
  59840. }
  59841. declare module BABYLON {
  59842. /** @hidden */
  59843. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  59844. private _useDeltaForWorldStep;
  59845. world: any;
  59846. name: string;
  59847. private _physicsMaterials;
  59848. private _fixedTimeStep;
  59849. private _cannonRaycastResult;
  59850. private _raycastResult;
  59851. private _physicsBodysToRemoveAfterStep;
  59852. private _firstFrame;
  59853. BJSCANNON: any;
  59854. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  59855. setGravity(gravity: Vector3): void;
  59856. setTimeStep(timeStep: number): void;
  59857. getTimeStep(): number;
  59858. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59859. private _removeMarkedPhysicsBodiesFromWorld;
  59860. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59861. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59862. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59863. private _processChildMeshes;
  59864. removePhysicsBody(impostor: PhysicsImpostor): void;
  59865. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59866. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59867. private _addMaterial;
  59868. private _checkWithEpsilon;
  59869. private _createShape;
  59870. private _createHeightmap;
  59871. private _minus90X;
  59872. private _plus90X;
  59873. private _tmpPosition;
  59874. private _tmpDeltaPosition;
  59875. private _tmpUnityRotation;
  59876. private _updatePhysicsBodyTransformation;
  59877. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59878. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59879. isSupported(): boolean;
  59880. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59881. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59882. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59883. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59884. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59885. getBodyMass(impostor: PhysicsImpostor): number;
  59886. getBodyFriction(impostor: PhysicsImpostor): number;
  59887. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59888. getBodyRestitution(impostor: PhysicsImpostor): number;
  59889. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59890. sleepBody(impostor: PhysicsImpostor): void;
  59891. wakeUpBody(impostor: PhysicsImpostor): void;
  59892. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  59893. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  59894. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  59895. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59896. getRadius(impostor: PhysicsImpostor): number;
  59897. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59898. dispose(): void;
  59899. private _extendNamespace;
  59900. /**
  59901. * Does a raycast in the physics world
  59902. * @param from when should the ray start?
  59903. * @param to when should the ray end?
  59904. * @returns PhysicsRaycastResult
  59905. */
  59906. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59907. }
  59908. }
  59909. declare module BABYLON {
  59910. /** @hidden */
  59911. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  59912. private _useDeltaForWorldStep;
  59913. world: any;
  59914. name: string;
  59915. BJSOIMO: any;
  59916. private _raycastResult;
  59917. private _fixedTimeStep;
  59918. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  59919. setGravity(gravity: Vector3): void;
  59920. setTimeStep(timeStep: number): void;
  59921. getTimeStep(): number;
  59922. private _tmpImpostorsArray;
  59923. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59924. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59925. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59926. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59927. private _tmpPositionVector;
  59928. removePhysicsBody(impostor: PhysicsImpostor): void;
  59929. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59930. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59931. isSupported(): boolean;
  59932. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59933. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59934. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59935. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59936. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59937. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59938. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59939. getBodyMass(impostor: PhysicsImpostor): number;
  59940. getBodyFriction(impostor: PhysicsImpostor): number;
  59941. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59942. getBodyRestitution(impostor: PhysicsImpostor): number;
  59943. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59944. sleepBody(impostor: PhysicsImpostor): void;
  59945. wakeUpBody(impostor: PhysicsImpostor): void;
  59946. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  59947. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  59948. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  59949. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59950. getRadius(impostor: PhysicsImpostor): number;
  59951. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59952. dispose(): void;
  59953. /**
  59954. * Does a raycast in the physics world
  59955. * @param from when should the ray start?
  59956. * @param to when should the ray end?
  59957. * @returns PhysicsRaycastResult
  59958. */
  59959. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59960. }
  59961. }
  59962. declare module BABYLON {
  59963. /**
  59964. * Class containing static functions to help procedurally build meshes
  59965. */
  59966. export class RibbonBuilder {
  59967. /**
  59968. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59969. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59970. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59971. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59972. * * 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
  59973. * * 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
  59974. * * 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
  59975. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59976. * * 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
  59977. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59978. * * 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
  59979. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59980. * * 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
  59981. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59982. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59983. * @param name defines the name of the mesh
  59984. * @param options defines the options used to create the mesh
  59985. * @param scene defines the hosting scene
  59986. * @returns the ribbon mesh
  59987. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59988. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59989. */
  59990. static CreateRibbon(name: string, options: {
  59991. pathArray: Vector3[][];
  59992. closeArray?: boolean;
  59993. closePath?: boolean;
  59994. offset?: number;
  59995. updatable?: boolean;
  59996. sideOrientation?: number;
  59997. frontUVs?: Vector4;
  59998. backUVs?: Vector4;
  59999. instance?: Mesh;
  60000. invertUV?: boolean;
  60001. uvs?: Vector2[];
  60002. colors?: Color4[];
  60003. }, scene?: Nullable<Scene>): Mesh;
  60004. }
  60005. }
  60006. declare module BABYLON {
  60007. /**
  60008. * Class containing static functions to help procedurally build meshes
  60009. */
  60010. export class ShapeBuilder {
  60011. /**
  60012. * 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.
  60013. * * 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.
  60014. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60015. * * 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.
  60016. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  60017. * * 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
  60018. * * 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
  60019. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  60020. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60021. * * 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
  60022. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  60023. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60024. * @param name defines the name of the mesh
  60025. * @param options defines the options used to create the mesh
  60026. * @param scene defines the hosting scene
  60027. * @returns the extruded shape mesh
  60028. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60029. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60030. */
  60031. static ExtrudeShape(name: string, options: {
  60032. shape: Vector3[];
  60033. path: Vector3[];
  60034. scale?: number;
  60035. rotation?: number;
  60036. cap?: number;
  60037. updatable?: boolean;
  60038. sideOrientation?: number;
  60039. frontUVs?: Vector4;
  60040. backUVs?: Vector4;
  60041. instance?: Mesh;
  60042. invertUV?: boolean;
  60043. }, scene?: Nullable<Scene>): Mesh;
  60044. /**
  60045. * Creates an custom extruded shape mesh.
  60046. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  60047. * * 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.
  60048. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60049. * * 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
  60050. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  60051. * * 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
  60052. * * It must returns a float value that will be the scale value applied to the shape on each path point
  60053. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  60054. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  60055. * * 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
  60056. * * 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
  60057. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  60058. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60059. * * 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
  60060. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60061. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60062. * @param name defines the name of the mesh
  60063. * @param options defines the options used to create the mesh
  60064. * @param scene defines the hosting scene
  60065. * @returns the custom extruded shape mesh
  60066. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  60067. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60068. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60069. */
  60070. static ExtrudeShapeCustom(name: string, options: {
  60071. shape: Vector3[];
  60072. path: Vector3[];
  60073. scaleFunction?: any;
  60074. rotationFunction?: any;
  60075. ribbonCloseArray?: boolean;
  60076. ribbonClosePath?: boolean;
  60077. cap?: number;
  60078. updatable?: boolean;
  60079. sideOrientation?: number;
  60080. frontUVs?: Vector4;
  60081. backUVs?: Vector4;
  60082. instance?: Mesh;
  60083. invertUV?: boolean;
  60084. }, scene?: Nullable<Scene>): Mesh;
  60085. private static _ExtrudeShapeGeneric;
  60086. }
  60087. }
  60088. declare module BABYLON {
  60089. /**
  60090. * AmmoJS Physics plugin
  60091. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60092. * @see https://github.com/kripken/ammo.js/
  60093. */
  60094. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  60095. private _useDeltaForWorldStep;
  60096. /**
  60097. * Reference to the Ammo library
  60098. */
  60099. bjsAMMO: any;
  60100. /**
  60101. * Created ammoJS world which physics bodies are added to
  60102. */
  60103. world: any;
  60104. /**
  60105. * Name of the plugin
  60106. */
  60107. name: string;
  60108. private _timeStep;
  60109. private _fixedTimeStep;
  60110. private _maxSteps;
  60111. private _tmpQuaternion;
  60112. private _tmpAmmoTransform;
  60113. private _tmpAmmoQuaternion;
  60114. private _tmpAmmoConcreteContactResultCallback;
  60115. private _collisionConfiguration;
  60116. private _dispatcher;
  60117. private _overlappingPairCache;
  60118. private _solver;
  60119. private _softBodySolver;
  60120. private _tmpAmmoVectorA;
  60121. private _tmpAmmoVectorB;
  60122. private _tmpAmmoVectorC;
  60123. private _tmpAmmoVectorD;
  60124. private _tmpContactCallbackResult;
  60125. private _tmpAmmoVectorRCA;
  60126. private _tmpAmmoVectorRCB;
  60127. private _raycastResult;
  60128. private static readonly DISABLE_COLLISION_FLAG;
  60129. private static readonly KINEMATIC_FLAG;
  60130. private static readonly DISABLE_DEACTIVATION_FLAG;
  60131. /**
  60132. * Initializes the ammoJS plugin
  60133. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  60134. * @param ammoInjection can be used to inject your own ammo reference
  60135. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  60136. */
  60137. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  60138. /**
  60139. * Sets the gravity of the physics world (m/(s^2))
  60140. * @param gravity Gravity to set
  60141. */
  60142. setGravity(gravity: Vector3): void;
  60143. /**
  60144. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  60145. * @param timeStep timestep to use in seconds
  60146. */
  60147. setTimeStep(timeStep: number): void;
  60148. /**
  60149. * 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)
  60150. * @param fixedTimeStep fixedTimeStep to use in seconds
  60151. */
  60152. setFixedTimeStep(fixedTimeStep: number): void;
  60153. /**
  60154. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  60155. * @param maxSteps the maximum number of steps by the physics engine per frame
  60156. */
  60157. setMaxSteps(maxSteps: number): void;
  60158. /**
  60159. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  60160. * @returns the current timestep in seconds
  60161. */
  60162. getTimeStep(): number;
  60163. /**
  60164. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  60165. */
  60166. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  60167. private _isImpostorInContact;
  60168. private _isImpostorPairInContact;
  60169. private _stepSimulation;
  60170. /**
  60171. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  60172. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  60173. * After the step the babylon meshes are set to the position of the physics imposters
  60174. * @param delta amount of time to step forward
  60175. * @param impostors array of imposters to update before/after the step
  60176. */
  60177. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60178. /**
  60179. * Update babylon mesh to match physics world object
  60180. * @param impostor imposter to match
  60181. */
  60182. private _afterSoftStep;
  60183. /**
  60184. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  60185. * @param impostor imposter to match
  60186. */
  60187. private _ropeStep;
  60188. /**
  60189. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  60190. * @param impostor imposter to match
  60191. */
  60192. private _softbodyOrClothStep;
  60193. private _tmpMatrix;
  60194. /**
  60195. * Applies an impulse on the imposter
  60196. * @param impostor imposter to apply impulse to
  60197. * @param force amount of force to be applied to the imposter
  60198. * @param contactPoint the location to apply the impulse on the imposter
  60199. */
  60200. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60201. /**
  60202. * Applies a force on the imposter
  60203. * @param impostor imposter to apply force
  60204. * @param force amount of force to be applied to the imposter
  60205. * @param contactPoint the location to apply the force on the imposter
  60206. */
  60207. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60208. /**
  60209. * Creates a physics body using the plugin
  60210. * @param impostor the imposter to create the physics body on
  60211. */
  60212. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60213. /**
  60214. * Removes the physics body from the imposter and disposes of the body's memory
  60215. * @param impostor imposter to remove the physics body from
  60216. */
  60217. removePhysicsBody(impostor: PhysicsImpostor): void;
  60218. /**
  60219. * Generates a joint
  60220. * @param impostorJoint the imposter joint to create the joint with
  60221. */
  60222. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60223. /**
  60224. * Removes a joint
  60225. * @param impostorJoint the imposter joint to remove the joint from
  60226. */
  60227. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60228. private _addMeshVerts;
  60229. /**
  60230. * Initialise the soft body vertices to match its object's (mesh) vertices
  60231. * Softbody vertices (nodes) are in world space and to match this
  60232. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  60233. * @param impostor to create the softbody for
  60234. */
  60235. private _softVertexData;
  60236. /**
  60237. * Create an impostor's soft body
  60238. * @param impostor to create the softbody for
  60239. */
  60240. private _createSoftbody;
  60241. /**
  60242. * Create cloth for an impostor
  60243. * @param impostor to create the softbody for
  60244. */
  60245. private _createCloth;
  60246. /**
  60247. * Create rope for an impostor
  60248. * @param impostor to create the softbody for
  60249. */
  60250. private _createRope;
  60251. /**
  60252. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  60253. * @param impostor to create the custom physics shape for
  60254. */
  60255. private _createCustom;
  60256. private _addHullVerts;
  60257. private _createShape;
  60258. /**
  60259. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  60260. * @param impostor imposter containing the physics body and babylon object
  60261. */
  60262. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60263. /**
  60264. * Sets the babylon object's position/rotation from the physics body's position/rotation
  60265. * @param impostor imposter containing the physics body and babylon object
  60266. * @param newPosition new position
  60267. * @param newRotation new rotation
  60268. */
  60269. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60270. /**
  60271. * If this plugin is supported
  60272. * @returns true if its supported
  60273. */
  60274. isSupported(): boolean;
  60275. /**
  60276. * Sets the linear velocity of the physics body
  60277. * @param impostor imposter to set the velocity on
  60278. * @param velocity velocity to set
  60279. */
  60280. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60281. /**
  60282. * Sets the angular velocity of the physics body
  60283. * @param impostor imposter to set the velocity on
  60284. * @param velocity velocity to set
  60285. */
  60286. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60287. /**
  60288. * gets the linear velocity
  60289. * @param impostor imposter to get linear velocity from
  60290. * @returns linear velocity
  60291. */
  60292. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60293. /**
  60294. * gets the angular velocity
  60295. * @param impostor imposter to get angular velocity from
  60296. * @returns angular velocity
  60297. */
  60298. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60299. /**
  60300. * Sets the mass of physics body
  60301. * @param impostor imposter to set the mass on
  60302. * @param mass mass to set
  60303. */
  60304. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60305. /**
  60306. * Gets the mass of the physics body
  60307. * @param impostor imposter to get the mass from
  60308. * @returns mass
  60309. */
  60310. getBodyMass(impostor: PhysicsImpostor): number;
  60311. /**
  60312. * Gets friction of the impostor
  60313. * @param impostor impostor to get friction from
  60314. * @returns friction value
  60315. */
  60316. getBodyFriction(impostor: PhysicsImpostor): number;
  60317. /**
  60318. * Sets friction of the impostor
  60319. * @param impostor impostor to set friction on
  60320. * @param friction friction value
  60321. */
  60322. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60323. /**
  60324. * Gets restitution of the impostor
  60325. * @param impostor impostor to get restitution from
  60326. * @returns restitution value
  60327. */
  60328. getBodyRestitution(impostor: PhysicsImpostor): number;
  60329. /**
  60330. * Sets resitution of the impostor
  60331. * @param impostor impostor to set resitution on
  60332. * @param restitution resitution value
  60333. */
  60334. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60335. /**
  60336. * Gets pressure inside the impostor
  60337. * @param impostor impostor to get pressure from
  60338. * @returns pressure value
  60339. */
  60340. getBodyPressure(impostor: PhysicsImpostor): number;
  60341. /**
  60342. * Sets pressure inside a soft body impostor
  60343. * Cloth and rope must remain 0 pressure
  60344. * @param impostor impostor to set pressure on
  60345. * @param pressure pressure value
  60346. */
  60347. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  60348. /**
  60349. * Gets stiffness of the impostor
  60350. * @param impostor impostor to get stiffness from
  60351. * @returns pressure value
  60352. */
  60353. getBodyStiffness(impostor: PhysicsImpostor): number;
  60354. /**
  60355. * Sets stiffness of the impostor
  60356. * @param impostor impostor to set stiffness on
  60357. * @param stiffness stiffness value from 0 to 1
  60358. */
  60359. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  60360. /**
  60361. * Gets velocityIterations of the impostor
  60362. * @param impostor impostor to get velocity iterations from
  60363. * @returns velocityIterations value
  60364. */
  60365. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  60366. /**
  60367. * Sets velocityIterations of the impostor
  60368. * @param impostor impostor to set velocity iterations on
  60369. * @param velocityIterations velocityIterations value
  60370. */
  60371. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  60372. /**
  60373. * Gets positionIterations of the impostor
  60374. * @param impostor impostor to get position iterations from
  60375. * @returns positionIterations value
  60376. */
  60377. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  60378. /**
  60379. * Sets positionIterations of the impostor
  60380. * @param impostor impostor to set position on
  60381. * @param positionIterations positionIterations value
  60382. */
  60383. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  60384. /**
  60385. * Append an anchor to a cloth object
  60386. * @param impostor is the cloth impostor to add anchor to
  60387. * @param otherImpostor is the rigid impostor to anchor to
  60388. * @param width ratio across width from 0 to 1
  60389. * @param height ratio up height from 0 to 1
  60390. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  60391. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  60392. */
  60393. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  60394. /**
  60395. * Append an hook to a rope object
  60396. * @param impostor is the rope impostor to add hook to
  60397. * @param otherImpostor is the rigid impostor to hook to
  60398. * @param length ratio along the rope from 0 to 1
  60399. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  60400. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  60401. */
  60402. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  60403. /**
  60404. * Sleeps the physics body and stops it from being active
  60405. * @param impostor impostor to sleep
  60406. */
  60407. sleepBody(impostor: PhysicsImpostor): void;
  60408. /**
  60409. * Activates the physics body
  60410. * @param impostor impostor to activate
  60411. */
  60412. wakeUpBody(impostor: PhysicsImpostor): void;
  60413. /**
  60414. * Updates the distance parameters of the joint
  60415. * @param joint joint to update
  60416. * @param maxDistance maximum distance of the joint
  60417. * @param minDistance minimum distance of the joint
  60418. */
  60419. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  60420. /**
  60421. * Sets a motor on the joint
  60422. * @param joint joint to set motor on
  60423. * @param speed speed of the motor
  60424. * @param maxForce maximum force of the motor
  60425. * @param motorIndex index of the motor
  60426. */
  60427. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  60428. /**
  60429. * Sets the motors limit
  60430. * @param joint joint to set limit on
  60431. * @param upperLimit upper limit
  60432. * @param lowerLimit lower limit
  60433. */
  60434. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  60435. /**
  60436. * Syncs the position and rotation of a mesh with the impostor
  60437. * @param mesh mesh to sync
  60438. * @param impostor impostor to update the mesh with
  60439. */
  60440. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60441. /**
  60442. * Gets the radius of the impostor
  60443. * @param impostor impostor to get radius from
  60444. * @returns the radius
  60445. */
  60446. getRadius(impostor: PhysicsImpostor): number;
  60447. /**
  60448. * Gets the box size of the impostor
  60449. * @param impostor impostor to get box size from
  60450. * @param result the resulting box size
  60451. */
  60452. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60453. /**
  60454. * Disposes of the impostor
  60455. */
  60456. dispose(): void;
  60457. /**
  60458. * Does a raycast in the physics world
  60459. * @param from when should the ray start?
  60460. * @param to when should the ray end?
  60461. * @returns PhysicsRaycastResult
  60462. */
  60463. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60464. }
  60465. }
  60466. declare module BABYLON {
  60467. interface AbstractScene {
  60468. /**
  60469. * The list of reflection probes added to the scene
  60470. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  60471. */
  60472. reflectionProbes: Array<ReflectionProbe>;
  60473. /**
  60474. * Removes the given reflection probe from this scene.
  60475. * @param toRemove The reflection probe to remove
  60476. * @returns The index of the removed reflection probe
  60477. */
  60478. removeReflectionProbe(toRemove: ReflectionProbe): number;
  60479. /**
  60480. * Adds the given reflection probe to this scene.
  60481. * @param newReflectionProbe The reflection probe to add
  60482. */
  60483. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  60484. }
  60485. /**
  60486. * Class used to generate realtime reflection / refraction cube textures
  60487. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  60488. */
  60489. export class ReflectionProbe {
  60490. /** defines the name of the probe */
  60491. name: string;
  60492. private _scene;
  60493. private _renderTargetTexture;
  60494. private _projectionMatrix;
  60495. private _viewMatrix;
  60496. private _target;
  60497. private _add;
  60498. private _attachedMesh;
  60499. private _invertYAxis;
  60500. /** Gets or sets probe position (center of the cube map) */
  60501. position: Vector3;
  60502. /**
  60503. * Creates a new reflection probe
  60504. * @param name defines the name of the probe
  60505. * @param size defines the texture resolution (for each face)
  60506. * @param scene defines the hosting scene
  60507. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  60508. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  60509. */
  60510. constructor(
  60511. /** defines the name of the probe */
  60512. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  60513. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  60514. get samples(): number;
  60515. set samples(value: number);
  60516. /** Gets or sets the refresh rate to use (on every frame by default) */
  60517. get refreshRate(): number;
  60518. set refreshRate(value: number);
  60519. /**
  60520. * Gets the hosting scene
  60521. * @returns a Scene
  60522. */
  60523. getScene(): Scene;
  60524. /** Gets the internal CubeTexture used to render to */
  60525. get cubeTexture(): RenderTargetTexture;
  60526. /** Gets the list of meshes to render */
  60527. get renderList(): Nullable<AbstractMesh[]>;
  60528. /**
  60529. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  60530. * @param mesh defines the mesh to attach to
  60531. */
  60532. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  60533. /**
  60534. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  60535. * @param renderingGroupId The rendering group id corresponding to its index
  60536. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  60537. */
  60538. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  60539. /**
  60540. * Clean all associated resources
  60541. */
  60542. dispose(): void;
  60543. /**
  60544. * Converts the reflection probe information to a readable string for debug purpose.
  60545. * @param fullDetails Supports for multiple levels of logging within scene loading
  60546. * @returns the human readable reflection probe info
  60547. */
  60548. toString(fullDetails?: boolean): string;
  60549. /**
  60550. * Get the class name of the relfection probe.
  60551. * @returns "ReflectionProbe"
  60552. */
  60553. getClassName(): string;
  60554. /**
  60555. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  60556. * @returns The JSON representation of the texture
  60557. */
  60558. serialize(): any;
  60559. /**
  60560. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  60561. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  60562. * @param scene Define the scene the parsed reflection probe should be instantiated in
  60563. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  60564. * @returns The parsed reflection probe if successful
  60565. */
  60566. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  60567. }
  60568. }
  60569. declare module BABYLON {
  60570. /** @hidden */
  60571. export var _BabylonLoaderRegistered: boolean;
  60572. /**
  60573. * Helps setting up some configuration for the babylon file loader.
  60574. */
  60575. export class BabylonFileLoaderConfiguration {
  60576. /**
  60577. * The loader does not allow injecting custom physix engine into the plugins.
  60578. * Unfortunately in ES6, we need to manually inject them into the plugin.
  60579. * So you could set this variable to your engine import to make it work.
  60580. */
  60581. static LoaderInjectedPhysicsEngine: any;
  60582. }
  60583. }
  60584. declare module BABYLON {
  60585. /**
  60586. * The Physically based simple base material of BJS.
  60587. *
  60588. * This enables better naming and convention enforcements on top of the pbrMaterial.
  60589. * It is used as the base class for both the specGloss and metalRough conventions.
  60590. */
  60591. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  60592. /**
  60593. * Number of Simultaneous lights allowed on the material.
  60594. */
  60595. maxSimultaneousLights: number;
  60596. /**
  60597. * If sets to true, disables all the lights affecting the material.
  60598. */
  60599. disableLighting: boolean;
  60600. /**
  60601. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  60602. */
  60603. environmentTexture: BaseTexture;
  60604. /**
  60605. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  60606. */
  60607. invertNormalMapX: boolean;
  60608. /**
  60609. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  60610. */
  60611. invertNormalMapY: boolean;
  60612. /**
  60613. * Normal map used in the model.
  60614. */
  60615. normalTexture: BaseTexture;
  60616. /**
  60617. * Emissivie color used to self-illuminate the model.
  60618. */
  60619. emissiveColor: Color3;
  60620. /**
  60621. * Emissivie texture used to self-illuminate the model.
  60622. */
  60623. emissiveTexture: BaseTexture;
  60624. /**
  60625. * Occlusion Channel Strenght.
  60626. */
  60627. occlusionStrength: number;
  60628. /**
  60629. * Occlusion Texture of the material (adding extra occlusion effects).
  60630. */
  60631. occlusionTexture: BaseTexture;
  60632. /**
  60633. * Defines the alpha limits in alpha test mode.
  60634. */
  60635. alphaCutOff: number;
  60636. /**
  60637. * Gets the current double sided mode.
  60638. */
  60639. get doubleSided(): boolean;
  60640. /**
  60641. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  60642. */
  60643. set doubleSided(value: boolean);
  60644. /**
  60645. * Stores the pre-calculated light information of a mesh in a texture.
  60646. */
  60647. lightmapTexture: BaseTexture;
  60648. /**
  60649. * If true, the light map contains occlusion information instead of lighting info.
  60650. */
  60651. useLightmapAsShadowmap: boolean;
  60652. /**
  60653. * Instantiates a new PBRMaterial instance.
  60654. *
  60655. * @param name The material name
  60656. * @param scene The scene the material will be use in.
  60657. */
  60658. constructor(name: string, scene: Scene);
  60659. getClassName(): string;
  60660. }
  60661. }
  60662. declare module BABYLON {
  60663. /**
  60664. * The PBR material of BJS following the metal roughness convention.
  60665. *
  60666. * This fits to the PBR convention in the GLTF definition:
  60667. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  60668. */
  60669. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  60670. /**
  60671. * The base color has two different interpretations depending on the value of metalness.
  60672. * When the material is a metal, the base color is the specific measured reflectance value
  60673. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  60674. * of the material.
  60675. */
  60676. baseColor: Color3;
  60677. /**
  60678. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  60679. * well as opacity information in the alpha channel.
  60680. */
  60681. baseTexture: BaseTexture;
  60682. /**
  60683. * Specifies the metallic scalar value of the material.
  60684. * Can also be used to scale the metalness values of the metallic texture.
  60685. */
  60686. metallic: number;
  60687. /**
  60688. * Specifies the roughness scalar value of the material.
  60689. * Can also be used to scale the roughness values of the metallic texture.
  60690. */
  60691. roughness: number;
  60692. /**
  60693. * Texture containing both the metallic value in the B channel and the
  60694. * roughness value in the G channel to keep better precision.
  60695. */
  60696. metallicRoughnessTexture: BaseTexture;
  60697. /**
  60698. * Instantiates a new PBRMetalRoughnessMaterial instance.
  60699. *
  60700. * @param name The material name
  60701. * @param scene The scene the material will be use in.
  60702. */
  60703. constructor(name: string, scene: Scene);
  60704. /**
  60705. * Return the currrent class name of the material.
  60706. */
  60707. getClassName(): string;
  60708. /**
  60709. * Makes a duplicate of the current material.
  60710. * @param name - name to use for the new material.
  60711. */
  60712. clone(name: string): PBRMetallicRoughnessMaterial;
  60713. /**
  60714. * Serialize the material to a parsable JSON object.
  60715. */
  60716. serialize(): any;
  60717. /**
  60718. * Parses a JSON object correponding to the serialize function.
  60719. */
  60720. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  60721. }
  60722. }
  60723. declare module BABYLON {
  60724. /**
  60725. * The PBR material of BJS following the specular glossiness convention.
  60726. *
  60727. * This fits to the PBR convention in the GLTF definition:
  60728. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  60729. */
  60730. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  60731. /**
  60732. * Specifies the diffuse color of the material.
  60733. */
  60734. diffuseColor: Color3;
  60735. /**
  60736. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  60737. * channel.
  60738. */
  60739. diffuseTexture: BaseTexture;
  60740. /**
  60741. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  60742. */
  60743. specularColor: Color3;
  60744. /**
  60745. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  60746. */
  60747. glossiness: number;
  60748. /**
  60749. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  60750. */
  60751. specularGlossinessTexture: BaseTexture;
  60752. /**
  60753. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  60754. *
  60755. * @param name The material name
  60756. * @param scene The scene the material will be use in.
  60757. */
  60758. constructor(name: string, scene: Scene);
  60759. /**
  60760. * Return the currrent class name of the material.
  60761. */
  60762. getClassName(): string;
  60763. /**
  60764. * Makes a duplicate of the current material.
  60765. * @param name - name to use for the new material.
  60766. */
  60767. clone(name: string): PBRSpecularGlossinessMaterial;
  60768. /**
  60769. * Serialize the material to a parsable JSON object.
  60770. */
  60771. serialize(): any;
  60772. /**
  60773. * Parses a JSON object correponding to the serialize function.
  60774. */
  60775. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  60776. }
  60777. }
  60778. declare module BABYLON {
  60779. /**
  60780. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  60781. * It can help converting any input color in a desired output one. This can then be used to create effects
  60782. * from sepia, black and white to sixties or futuristic rendering...
  60783. *
  60784. * The only supported format is currently 3dl.
  60785. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  60786. */
  60787. export class ColorGradingTexture extends BaseTexture {
  60788. /**
  60789. * The texture URL.
  60790. */
  60791. url: string;
  60792. /**
  60793. * Empty line regex stored for GC.
  60794. */
  60795. private static _noneEmptyLineRegex;
  60796. private _textureMatrix;
  60797. private _onLoad;
  60798. /**
  60799. * Instantiates a ColorGradingTexture from the following parameters.
  60800. *
  60801. * @param url The location of the color gradind data (currently only supporting 3dl)
  60802. * @param sceneOrEngine The scene or engine the texture will be used in
  60803. * @param onLoad defines a callback triggered when the texture has been loaded
  60804. */
  60805. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  60806. /**
  60807. * Fires the onload event from the constructor if requested.
  60808. */
  60809. private _triggerOnLoad;
  60810. /**
  60811. * Returns the texture matrix used in most of the material.
  60812. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  60813. */
  60814. getTextureMatrix(): Matrix;
  60815. /**
  60816. * Occurs when the file being loaded is a .3dl LUT file.
  60817. */
  60818. private load3dlTexture;
  60819. /**
  60820. * Starts the loading process of the texture.
  60821. */
  60822. private loadTexture;
  60823. /**
  60824. * Clones the color gradind texture.
  60825. */
  60826. clone(): ColorGradingTexture;
  60827. /**
  60828. * Called during delayed load for textures.
  60829. */
  60830. delayLoad(): void;
  60831. /**
  60832. * Parses a color grading texture serialized by Babylon.
  60833. * @param parsedTexture The texture information being parsedTexture
  60834. * @param scene The scene to load the texture in
  60835. * @param rootUrl The root url of the data assets to load
  60836. * @return A color gradind texture
  60837. */
  60838. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  60839. /**
  60840. * Serializes the LUT texture to json format.
  60841. */
  60842. serialize(): any;
  60843. }
  60844. }
  60845. declare module BABYLON {
  60846. /**
  60847. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  60848. */
  60849. export class EquiRectangularCubeTexture extends BaseTexture {
  60850. /** The six faces of the cube. */
  60851. private static _FacesMapping;
  60852. private _noMipmap;
  60853. private _onLoad;
  60854. private _onError;
  60855. /** The size of the cubemap. */
  60856. private _size;
  60857. /** The buffer of the image. */
  60858. private _buffer;
  60859. /** The width of the input image. */
  60860. private _width;
  60861. /** The height of the input image. */
  60862. private _height;
  60863. /** The URL to the image. */
  60864. url: string;
  60865. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  60866. coordinatesMode: number;
  60867. /**
  60868. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  60869. * @param url The location of the image
  60870. * @param scene The scene the texture will be used in
  60871. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60872. * @param noMipmap Forces to not generate the mipmap if true
  60873. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  60874. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  60875. * @param onLoad — defines a callback called when texture is loaded
  60876. * @param onError — defines a callback called if there is an error
  60877. */
  60878. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  60879. /**
  60880. * Load the image data, by putting the image on a canvas and extracting its buffer.
  60881. */
  60882. private loadImage;
  60883. /**
  60884. * Convert the image buffer into a cubemap and create a CubeTexture.
  60885. */
  60886. private loadTexture;
  60887. /**
  60888. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  60889. * @param buffer The ArrayBuffer that should be converted.
  60890. * @returns The buffer as Float32Array.
  60891. */
  60892. private getFloat32ArrayFromArrayBuffer;
  60893. /**
  60894. * Get the current class name of the texture useful for serialization or dynamic coding.
  60895. * @returns "EquiRectangularCubeTexture"
  60896. */
  60897. getClassName(): string;
  60898. /**
  60899. * Create a clone of the current EquiRectangularCubeTexture and return it.
  60900. * @returns A clone of the current EquiRectangularCubeTexture.
  60901. */
  60902. clone(): EquiRectangularCubeTexture;
  60903. }
  60904. }
  60905. declare module BABYLON {
  60906. /**
  60907. * Defines the options related to the creation of an HtmlElementTexture
  60908. */
  60909. export interface IHtmlElementTextureOptions {
  60910. /**
  60911. * Defines wether mip maps should be created or not.
  60912. */
  60913. generateMipMaps?: boolean;
  60914. /**
  60915. * Defines the sampling mode of the texture.
  60916. */
  60917. samplingMode?: number;
  60918. /**
  60919. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  60920. */
  60921. engine: Nullable<ThinEngine>;
  60922. /**
  60923. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  60924. */
  60925. scene: Nullable<Scene>;
  60926. }
  60927. /**
  60928. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  60929. * To be as efficient as possible depending on your constraints nothing aside the first upload
  60930. * is automatically managed.
  60931. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  60932. * in your application.
  60933. *
  60934. * As the update is not automatic, you need to call them manually.
  60935. */
  60936. export class HtmlElementTexture extends BaseTexture {
  60937. /**
  60938. * The texture URL.
  60939. */
  60940. element: HTMLVideoElement | HTMLCanvasElement;
  60941. private static readonly DefaultOptions;
  60942. private _textureMatrix;
  60943. private _isVideo;
  60944. private _generateMipMaps;
  60945. private _samplingMode;
  60946. /**
  60947. * Instantiates a HtmlElementTexture from the following parameters.
  60948. *
  60949. * @param name Defines the name of the texture
  60950. * @param element Defines the video or canvas the texture is filled with
  60951. * @param options Defines the other none mandatory texture creation options
  60952. */
  60953. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  60954. private _createInternalTexture;
  60955. /**
  60956. * Returns the texture matrix used in most of the material.
  60957. */
  60958. getTextureMatrix(): Matrix;
  60959. /**
  60960. * Updates the content of the texture.
  60961. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  60962. */
  60963. update(invertY?: Nullable<boolean>): void;
  60964. }
  60965. }
  60966. declare module BABYLON {
  60967. /**
  60968. * Based on jsTGALoader - Javascript loader for TGA file
  60969. * By Vincent Thibault
  60970. * @see http://blog.robrowser.com/javascript-tga-loader.html
  60971. */
  60972. export class TGATools {
  60973. private static _TYPE_INDEXED;
  60974. private static _TYPE_RGB;
  60975. private static _TYPE_GREY;
  60976. private static _TYPE_RLE_INDEXED;
  60977. private static _TYPE_RLE_RGB;
  60978. private static _TYPE_RLE_GREY;
  60979. private static _ORIGIN_MASK;
  60980. private static _ORIGIN_SHIFT;
  60981. private static _ORIGIN_BL;
  60982. private static _ORIGIN_BR;
  60983. private static _ORIGIN_UL;
  60984. private static _ORIGIN_UR;
  60985. /**
  60986. * Gets the header of a TGA file
  60987. * @param data defines the TGA data
  60988. * @returns the header
  60989. */
  60990. static GetTGAHeader(data: Uint8Array): any;
  60991. /**
  60992. * Uploads TGA content to a Babylon Texture
  60993. * @hidden
  60994. */
  60995. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  60996. /** @hidden */
  60997. 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;
  60998. /** @hidden */
  60999. 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;
  61000. /** @hidden */
  61001. 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;
  61002. /** @hidden */
  61003. 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;
  61004. /** @hidden */
  61005. 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;
  61006. /** @hidden */
  61007. 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;
  61008. }
  61009. }
  61010. declare module BABYLON {
  61011. /**
  61012. * Implementation of the TGA Texture Loader.
  61013. * @hidden
  61014. */
  61015. export class _TGATextureLoader implements IInternalTextureLoader {
  61016. /**
  61017. * Defines wether the loader supports cascade loading the different faces.
  61018. */
  61019. readonly supportCascades: boolean;
  61020. /**
  61021. * This returns if the loader support the current file information.
  61022. * @param extension defines the file extension of the file being loaded
  61023. * @returns true if the loader can load the specified file
  61024. */
  61025. canLoad(extension: string): boolean;
  61026. /**
  61027. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61028. * @param data contains the texture data
  61029. * @param texture defines the BabylonJS internal texture
  61030. * @param createPolynomials will be true if polynomials have been requested
  61031. * @param onLoad defines the callback to trigger once the texture is ready
  61032. * @param onError defines the callback to trigger in case of error
  61033. */
  61034. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61035. /**
  61036. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61037. * @param data contains the texture data
  61038. * @param texture defines the BabylonJS internal texture
  61039. * @param callback defines the method to call once ready to upload
  61040. */
  61041. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61042. }
  61043. }
  61044. declare module BABYLON {
  61045. /**
  61046. * Info about the .basis files
  61047. */
  61048. class BasisFileInfo {
  61049. /**
  61050. * If the file has alpha
  61051. */
  61052. hasAlpha: boolean;
  61053. /**
  61054. * Info about each image of the basis file
  61055. */
  61056. images: Array<{
  61057. levels: Array<{
  61058. width: number;
  61059. height: number;
  61060. transcodedPixels: ArrayBufferView;
  61061. }>;
  61062. }>;
  61063. }
  61064. /**
  61065. * Result of transcoding a basis file
  61066. */
  61067. class TranscodeResult {
  61068. /**
  61069. * Info about the .basis file
  61070. */
  61071. fileInfo: BasisFileInfo;
  61072. /**
  61073. * Format to use when loading the file
  61074. */
  61075. format: number;
  61076. }
  61077. /**
  61078. * Configuration options for the Basis transcoder
  61079. */
  61080. export class BasisTranscodeConfiguration {
  61081. /**
  61082. * Supported compression formats used to determine the supported output format of the transcoder
  61083. */
  61084. supportedCompressionFormats?: {
  61085. /**
  61086. * etc1 compression format
  61087. */
  61088. etc1?: boolean;
  61089. /**
  61090. * s3tc compression format
  61091. */
  61092. s3tc?: boolean;
  61093. /**
  61094. * pvrtc compression format
  61095. */
  61096. pvrtc?: boolean;
  61097. /**
  61098. * etc2 compression format
  61099. */
  61100. etc2?: boolean;
  61101. };
  61102. /**
  61103. * If mipmap levels should be loaded for transcoded images (Default: true)
  61104. */
  61105. loadMipmapLevels?: boolean;
  61106. /**
  61107. * Index of a single image to load (Default: all images)
  61108. */
  61109. loadSingleImage?: number;
  61110. }
  61111. /**
  61112. * Used to load .Basis files
  61113. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  61114. */
  61115. export class BasisTools {
  61116. private static _IgnoreSupportedFormats;
  61117. /**
  61118. * URL to use when loading the basis transcoder
  61119. */
  61120. static JSModuleURL: string;
  61121. /**
  61122. * URL to use when loading the wasm module for the transcoder
  61123. */
  61124. static WasmModuleURL: string;
  61125. /**
  61126. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  61127. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  61128. * @returns internal format corresponding to the Basis format
  61129. */
  61130. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  61131. private static _WorkerPromise;
  61132. private static _Worker;
  61133. private static _actionId;
  61134. private static _CreateWorkerAsync;
  61135. /**
  61136. * Transcodes a loaded image file to compressed pixel data
  61137. * @param data image data to transcode
  61138. * @param config configuration options for the transcoding
  61139. * @returns a promise resulting in the transcoded image
  61140. */
  61141. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  61142. /**
  61143. * Loads a texture from the transcode result
  61144. * @param texture texture load to
  61145. * @param transcodeResult the result of transcoding the basis file to load from
  61146. */
  61147. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  61148. }
  61149. }
  61150. declare module BABYLON {
  61151. /**
  61152. * Loader for .basis file format
  61153. */
  61154. export class _BasisTextureLoader implements IInternalTextureLoader {
  61155. /**
  61156. * Defines whether the loader supports cascade loading the different faces.
  61157. */
  61158. readonly supportCascades: boolean;
  61159. /**
  61160. * This returns if the loader support the current file information.
  61161. * @param extension defines the file extension of the file being loaded
  61162. * @returns true if the loader can load the specified file
  61163. */
  61164. canLoad(extension: string): boolean;
  61165. /**
  61166. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61167. * @param data contains the texture data
  61168. * @param texture defines the BabylonJS internal texture
  61169. * @param createPolynomials will be true if polynomials have been requested
  61170. * @param onLoad defines the callback to trigger once the texture is ready
  61171. * @param onError defines the callback to trigger in case of error
  61172. */
  61173. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61174. /**
  61175. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61176. * @param data contains the texture data
  61177. * @param texture defines the BabylonJS internal texture
  61178. * @param callback defines the method to call once ready to upload
  61179. */
  61180. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61181. }
  61182. }
  61183. declare module BABYLON {
  61184. /**
  61185. * Defines the basic options interface of a TexturePacker Frame
  61186. */
  61187. export interface ITexturePackerFrame {
  61188. /**
  61189. * The frame ID
  61190. */
  61191. id: number;
  61192. /**
  61193. * The frames Scale
  61194. */
  61195. scale: Vector2;
  61196. /**
  61197. * The Frames offset
  61198. */
  61199. offset: Vector2;
  61200. }
  61201. /**
  61202. * This is a support class for frame Data on texture packer sets.
  61203. */
  61204. export class TexturePackerFrame implements ITexturePackerFrame {
  61205. /**
  61206. * The frame ID
  61207. */
  61208. id: number;
  61209. /**
  61210. * The frames Scale
  61211. */
  61212. scale: Vector2;
  61213. /**
  61214. * The Frames offset
  61215. */
  61216. offset: Vector2;
  61217. /**
  61218. * Initializes a texture package frame.
  61219. * @param id The numerical frame identifier
  61220. * @param scale Scalar Vector2 for UV frame
  61221. * @param offset Vector2 for the frame position in UV units.
  61222. * @returns TexturePackerFrame
  61223. */
  61224. constructor(id: number, scale: Vector2, offset: Vector2);
  61225. }
  61226. }
  61227. declare module BABYLON {
  61228. /**
  61229. * Defines the basic options interface of a TexturePacker
  61230. */
  61231. export interface ITexturePackerOptions {
  61232. /**
  61233. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  61234. */
  61235. map?: string[];
  61236. /**
  61237. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  61238. */
  61239. uvsIn?: string;
  61240. /**
  61241. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  61242. */
  61243. uvsOut?: string;
  61244. /**
  61245. * number representing the layout style. Defaults to LAYOUT_STRIP
  61246. */
  61247. layout?: number;
  61248. /**
  61249. * number of columns if using custom column count layout(2). This defaults to 4.
  61250. */
  61251. colnum?: number;
  61252. /**
  61253. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  61254. */
  61255. updateInputMeshes?: boolean;
  61256. /**
  61257. * boolean flag to dispose all the source textures. Defaults to true.
  61258. */
  61259. disposeSources?: boolean;
  61260. /**
  61261. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  61262. */
  61263. fillBlanks?: boolean;
  61264. /**
  61265. * string value representing the context fill style color. Defaults to 'black'.
  61266. */
  61267. customFillColor?: string;
  61268. /**
  61269. * Width and Height Value of each Frame in the TexturePacker Sets
  61270. */
  61271. frameSize?: number;
  61272. /**
  61273. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  61274. */
  61275. paddingRatio?: number;
  61276. /**
  61277. * Number that declares the fill method for the padding gutter.
  61278. */
  61279. paddingMode?: number;
  61280. /**
  61281. * If in SUBUV_COLOR padding mode what color to use.
  61282. */
  61283. paddingColor?: Color3 | Color4;
  61284. }
  61285. /**
  61286. * Defines the basic interface of a TexturePacker JSON File
  61287. */
  61288. export interface ITexturePackerJSON {
  61289. /**
  61290. * The frame ID
  61291. */
  61292. name: string;
  61293. /**
  61294. * The base64 channel data
  61295. */
  61296. sets: any;
  61297. /**
  61298. * The options of the Packer
  61299. */
  61300. options: ITexturePackerOptions;
  61301. /**
  61302. * The frame data of the Packer
  61303. */
  61304. frames: Array<number>;
  61305. }
  61306. /**
  61307. * This is a support class that generates a series of packed texture sets.
  61308. * @see https://doc.babylonjs.com/babylon101/materials
  61309. */
  61310. export class TexturePacker {
  61311. /** Packer Layout Constant 0 */
  61312. static readonly LAYOUT_STRIP: number;
  61313. /** Packer Layout Constant 1 */
  61314. static readonly LAYOUT_POWER2: number;
  61315. /** Packer Layout Constant 2 */
  61316. static readonly LAYOUT_COLNUM: number;
  61317. /** Packer Layout Constant 0 */
  61318. static readonly SUBUV_WRAP: number;
  61319. /** Packer Layout Constant 1 */
  61320. static readonly SUBUV_EXTEND: number;
  61321. /** Packer Layout Constant 2 */
  61322. static readonly SUBUV_COLOR: number;
  61323. /** The Name of the Texture Package */
  61324. name: string;
  61325. /** The scene scope of the TexturePacker */
  61326. scene: Scene;
  61327. /** The Meshes to target */
  61328. meshes: AbstractMesh[];
  61329. /** Arguments passed with the Constructor */
  61330. options: ITexturePackerOptions;
  61331. /** The promise that is started upon initialization */
  61332. promise: Nullable<Promise<TexturePacker | string>>;
  61333. /** The Container object for the channel sets that are generated */
  61334. sets: object;
  61335. /** The Container array for the frames that are generated */
  61336. frames: TexturePackerFrame[];
  61337. /** The expected number of textures the system is parsing. */
  61338. private _expecting;
  61339. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  61340. private _paddingValue;
  61341. /**
  61342. * Initializes a texture package series from an array of meshes or a single mesh.
  61343. * @param name The name of the package
  61344. * @param meshes The target meshes to compose the package from
  61345. * @param options The arguments that texture packer should follow while building.
  61346. * @param scene The scene which the textures are scoped to.
  61347. * @returns TexturePacker
  61348. */
  61349. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  61350. /**
  61351. * Starts the package process
  61352. * @param resolve The promises resolution function
  61353. * @returns TexturePacker
  61354. */
  61355. private _createFrames;
  61356. /**
  61357. * Calculates the Size of the Channel Sets
  61358. * @returns Vector2
  61359. */
  61360. private _calculateSize;
  61361. /**
  61362. * Calculates the UV data for the frames.
  61363. * @param baseSize the base frameSize
  61364. * @param padding the base frame padding
  61365. * @param dtSize size of the Dynamic Texture for that channel
  61366. * @param dtUnits is 1/dtSize
  61367. * @param update flag to update the input meshes
  61368. */
  61369. private _calculateMeshUVFrames;
  61370. /**
  61371. * Calculates the frames Offset.
  61372. * @param index of the frame
  61373. * @returns Vector2
  61374. */
  61375. private _getFrameOffset;
  61376. /**
  61377. * Updates a Mesh to the frame data
  61378. * @param mesh that is the target
  61379. * @param frameID or the frame index
  61380. */
  61381. private _updateMeshUV;
  61382. /**
  61383. * Updates a Meshes materials to use the texture packer channels
  61384. * @param m is the mesh to target
  61385. * @param force all channels on the packer to be set.
  61386. */
  61387. private _updateTextureReferences;
  61388. /**
  61389. * Public method to set a Mesh to a frame
  61390. * @param m that is the target
  61391. * @param frameID or the frame index
  61392. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  61393. */
  61394. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  61395. /**
  61396. * Starts the async promise to compile the texture packer.
  61397. * @returns Promise<void>
  61398. */
  61399. processAsync(): Promise<void>;
  61400. /**
  61401. * Disposes all textures associated with this packer
  61402. */
  61403. dispose(): void;
  61404. /**
  61405. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  61406. * @param imageType is the image type to use.
  61407. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  61408. */
  61409. download(imageType?: string, quality?: number): void;
  61410. /**
  61411. * Public method to load a texturePacker JSON file.
  61412. * @param data of the JSON file in string format.
  61413. */
  61414. updateFromJSON(data: string): void;
  61415. }
  61416. }
  61417. declare module BABYLON {
  61418. /**
  61419. * 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.
  61420. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  61421. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  61422. */
  61423. export class CustomProceduralTexture extends ProceduralTexture {
  61424. private _animate;
  61425. private _time;
  61426. private _config;
  61427. private _texturePath;
  61428. /**
  61429. * Instantiates a new Custom Procedural Texture.
  61430. * 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.
  61431. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  61432. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  61433. * @param name Define the name of the texture
  61434. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  61435. * @param size Define the size of the texture to create
  61436. * @param scene Define the scene the texture belongs to
  61437. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  61438. * @param generateMipMaps Define if the texture should creates mip maps or not
  61439. */
  61440. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  61441. private _loadJson;
  61442. /**
  61443. * Is the texture ready to be used ? (rendered at least once)
  61444. * @returns true if ready, otherwise, false.
  61445. */
  61446. isReady(): boolean;
  61447. /**
  61448. * Render the texture to its associated render target.
  61449. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  61450. */
  61451. render(useCameraPostProcess?: boolean): void;
  61452. /**
  61453. * Update the list of dependant textures samplers in the shader.
  61454. */
  61455. updateTextures(): void;
  61456. /**
  61457. * Update the uniform values of the procedural texture in the shader.
  61458. */
  61459. updateShaderUniforms(): void;
  61460. /**
  61461. * Define if the texture animates or not.
  61462. */
  61463. get animate(): boolean;
  61464. set animate(value: boolean);
  61465. }
  61466. }
  61467. declare module BABYLON {
  61468. /** @hidden */
  61469. export var noisePixelShader: {
  61470. name: string;
  61471. shader: string;
  61472. };
  61473. }
  61474. declare module BABYLON {
  61475. /**
  61476. * Class used to generate noise procedural textures
  61477. */
  61478. export class NoiseProceduralTexture extends ProceduralTexture {
  61479. private _time;
  61480. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  61481. brightness: number;
  61482. /** Defines the number of octaves to process */
  61483. octaves: number;
  61484. /** Defines the level of persistence (0.8 by default) */
  61485. persistence: number;
  61486. /** Gets or sets animation speed factor (default is 1) */
  61487. animationSpeedFactor: number;
  61488. /**
  61489. * Creates a new NoiseProceduralTexture
  61490. * @param name defines the name fo the texture
  61491. * @param size defines the size of the texture (default is 256)
  61492. * @param scene defines the hosting scene
  61493. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  61494. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  61495. */
  61496. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  61497. private _updateShaderUniforms;
  61498. protected _getDefines(): string;
  61499. /** Generate the current state of the procedural texture */
  61500. render(useCameraPostProcess?: boolean): void;
  61501. /**
  61502. * Serializes this noise procedural texture
  61503. * @returns a serialized noise procedural texture object
  61504. */
  61505. serialize(): any;
  61506. /**
  61507. * Clone the texture.
  61508. * @returns the cloned texture
  61509. */
  61510. clone(): NoiseProceduralTexture;
  61511. /**
  61512. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  61513. * @param parsedTexture defines parsed texture data
  61514. * @param scene defines the current scene
  61515. * @param rootUrl defines the root URL containing noise procedural texture information
  61516. * @returns a parsed NoiseProceduralTexture
  61517. */
  61518. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  61519. }
  61520. }
  61521. declare module BABYLON {
  61522. /**
  61523. * Raw cube texture where the raw buffers are passed in
  61524. */
  61525. export class RawCubeTexture extends CubeTexture {
  61526. /**
  61527. * Creates a cube texture where the raw buffers are passed in.
  61528. * @param scene defines the scene the texture is attached to
  61529. * @param data defines the array of data to use to create each face
  61530. * @param size defines the size of the textures
  61531. * @param format defines the format of the data
  61532. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  61533. * @param generateMipMaps defines if the engine should generate the mip levels
  61534. * @param invertY defines if data must be stored with Y axis inverted
  61535. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  61536. * @param compression defines the compression used (null by default)
  61537. */
  61538. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  61539. /**
  61540. * Updates the raw cube texture.
  61541. * @param data defines the data to store
  61542. * @param format defines the data format
  61543. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  61544. * @param invertY defines if data must be stored with Y axis inverted
  61545. * @param compression defines the compression used (null by default)
  61546. * @param level defines which level of the texture to update
  61547. */
  61548. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  61549. /**
  61550. * Updates a raw cube texture with RGBD encoded data.
  61551. * @param data defines the array of data [mipmap][face] to use to create each face
  61552. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  61553. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  61554. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  61555. * @returns a promsie that resolves when the operation is complete
  61556. */
  61557. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  61558. /**
  61559. * Clones the raw cube texture.
  61560. * @return a new cube texture
  61561. */
  61562. clone(): CubeTexture;
  61563. /** @hidden */
  61564. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  61565. }
  61566. }
  61567. declare module BABYLON {
  61568. /**
  61569. * Class used to store 2D array textures containing user data
  61570. */
  61571. export class RawTexture2DArray extends Texture {
  61572. /** Gets or sets the texture format to use */
  61573. format: number;
  61574. /**
  61575. * Create a new RawTexture2DArray
  61576. * @param data defines the data of the texture
  61577. * @param width defines the width of the texture
  61578. * @param height defines the height of the texture
  61579. * @param depth defines the number of layers of the texture
  61580. * @param format defines the texture format to use
  61581. * @param scene defines the hosting scene
  61582. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  61583. * @param invertY defines if texture must be stored with Y axis inverted
  61584. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61585. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  61586. */
  61587. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  61588. /** Gets or sets the texture format to use */
  61589. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  61590. /**
  61591. * Update the texture with new data
  61592. * @param data defines the data to store in the texture
  61593. */
  61594. update(data: ArrayBufferView): void;
  61595. }
  61596. }
  61597. declare module BABYLON {
  61598. /**
  61599. * Class used to store 3D textures containing user data
  61600. */
  61601. export class RawTexture3D extends Texture {
  61602. /** Gets or sets the texture format to use */
  61603. format: number;
  61604. /**
  61605. * Create a new RawTexture3D
  61606. * @param data defines the data of the texture
  61607. * @param width defines the width of the texture
  61608. * @param height defines the height of the texture
  61609. * @param depth defines the depth of the texture
  61610. * @param format defines the texture format to use
  61611. * @param scene defines the hosting scene
  61612. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  61613. * @param invertY defines if texture must be stored with Y axis inverted
  61614. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61615. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  61616. */
  61617. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  61618. /** Gets or sets the texture format to use */
  61619. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  61620. /**
  61621. * Update the texture with new data
  61622. * @param data defines the data to store in the texture
  61623. */
  61624. update(data: ArrayBufferView): void;
  61625. }
  61626. }
  61627. declare module BABYLON {
  61628. /**
  61629. * Creates a refraction texture used by refraction channel of the standard material.
  61630. * It is like a mirror but to see through a material.
  61631. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61632. */
  61633. export class RefractionTexture extends RenderTargetTexture {
  61634. /**
  61635. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  61636. * 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.
  61637. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61638. */
  61639. refractionPlane: Plane;
  61640. /**
  61641. * Define how deep under the surface we should see.
  61642. */
  61643. depth: number;
  61644. /**
  61645. * Creates a refraction texture used by refraction channel of the standard material.
  61646. * It is like a mirror but to see through a material.
  61647. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61648. * @param name Define the texture name
  61649. * @param size Define the size of the underlying texture
  61650. * @param scene Define the scene the refraction belongs to
  61651. * @param generateMipMaps Define if we need to generate mips level for the refraction
  61652. */
  61653. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  61654. /**
  61655. * Clone the refraction texture.
  61656. * @returns the cloned texture
  61657. */
  61658. clone(): RefractionTexture;
  61659. /**
  61660. * Serialize the texture to a JSON representation you could use in Parse later on
  61661. * @returns the serialized JSON representation
  61662. */
  61663. serialize(): any;
  61664. }
  61665. }
  61666. declare module BABYLON {
  61667. /**
  61668. * Block used to add support for vertex skinning (bones)
  61669. */
  61670. export class BonesBlock extends NodeMaterialBlock {
  61671. /**
  61672. * Creates a new BonesBlock
  61673. * @param name defines the block name
  61674. */
  61675. constructor(name: string);
  61676. /**
  61677. * Initialize the block and prepare the context for build
  61678. * @param state defines the state that will be used for the build
  61679. */
  61680. initialize(state: NodeMaterialBuildState): void;
  61681. /**
  61682. * Gets the current class name
  61683. * @returns the class name
  61684. */
  61685. getClassName(): string;
  61686. /**
  61687. * Gets the matrix indices input component
  61688. */
  61689. get matricesIndices(): NodeMaterialConnectionPoint;
  61690. /**
  61691. * Gets the matrix weights input component
  61692. */
  61693. get matricesWeights(): NodeMaterialConnectionPoint;
  61694. /**
  61695. * Gets the extra matrix indices input component
  61696. */
  61697. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  61698. /**
  61699. * Gets the extra matrix weights input component
  61700. */
  61701. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  61702. /**
  61703. * Gets the world input component
  61704. */
  61705. get world(): NodeMaterialConnectionPoint;
  61706. /**
  61707. * Gets the output component
  61708. */
  61709. get output(): NodeMaterialConnectionPoint;
  61710. autoConfigure(material: NodeMaterial): void;
  61711. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61712. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61713. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61714. protected _buildBlock(state: NodeMaterialBuildState): this;
  61715. }
  61716. }
  61717. declare module BABYLON {
  61718. /**
  61719. * Block used to add support for instances
  61720. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  61721. */
  61722. export class InstancesBlock extends NodeMaterialBlock {
  61723. /**
  61724. * Creates a new InstancesBlock
  61725. * @param name defines the block name
  61726. */
  61727. constructor(name: string);
  61728. /**
  61729. * Gets the current class name
  61730. * @returns the class name
  61731. */
  61732. getClassName(): string;
  61733. /**
  61734. * Gets the first world row input component
  61735. */
  61736. get world0(): NodeMaterialConnectionPoint;
  61737. /**
  61738. * Gets the second world row input component
  61739. */
  61740. get world1(): NodeMaterialConnectionPoint;
  61741. /**
  61742. * Gets the third world row input component
  61743. */
  61744. get world2(): NodeMaterialConnectionPoint;
  61745. /**
  61746. * Gets the forth world row input component
  61747. */
  61748. get world3(): NodeMaterialConnectionPoint;
  61749. /**
  61750. * Gets the world input component
  61751. */
  61752. get world(): NodeMaterialConnectionPoint;
  61753. /**
  61754. * Gets the output component
  61755. */
  61756. get output(): NodeMaterialConnectionPoint;
  61757. /**
  61758. * Gets the isntanceID component
  61759. */
  61760. get instanceID(): NodeMaterialConnectionPoint;
  61761. autoConfigure(material: NodeMaterial): void;
  61762. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  61763. protected _buildBlock(state: NodeMaterialBuildState): this;
  61764. }
  61765. }
  61766. declare module BABYLON {
  61767. /**
  61768. * Block used to add morph targets support to vertex shader
  61769. */
  61770. export class MorphTargetsBlock extends NodeMaterialBlock {
  61771. private _repeatableContentAnchor;
  61772. /**
  61773. * Create a new MorphTargetsBlock
  61774. * @param name defines the block name
  61775. */
  61776. constructor(name: string);
  61777. /**
  61778. * Gets the current class name
  61779. * @returns the class name
  61780. */
  61781. getClassName(): string;
  61782. /**
  61783. * Gets the position input component
  61784. */
  61785. get position(): NodeMaterialConnectionPoint;
  61786. /**
  61787. * Gets the normal input component
  61788. */
  61789. get normal(): NodeMaterialConnectionPoint;
  61790. /**
  61791. * Gets the tangent input component
  61792. */
  61793. get tangent(): NodeMaterialConnectionPoint;
  61794. /**
  61795. * Gets the tangent input component
  61796. */
  61797. get uv(): NodeMaterialConnectionPoint;
  61798. /**
  61799. * Gets the position output component
  61800. */
  61801. get positionOutput(): NodeMaterialConnectionPoint;
  61802. /**
  61803. * Gets the normal output component
  61804. */
  61805. get normalOutput(): NodeMaterialConnectionPoint;
  61806. /**
  61807. * Gets the tangent output component
  61808. */
  61809. get tangentOutput(): NodeMaterialConnectionPoint;
  61810. /**
  61811. * Gets the tangent output component
  61812. */
  61813. get uvOutput(): NodeMaterialConnectionPoint;
  61814. initialize(state: NodeMaterialBuildState): void;
  61815. autoConfigure(material: NodeMaterial): void;
  61816. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61817. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61818. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61819. protected _buildBlock(state: NodeMaterialBuildState): this;
  61820. }
  61821. }
  61822. declare module BABYLON {
  61823. /**
  61824. * Block used to get data information from a light
  61825. */
  61826. export class LightInformationBlock extends NodeMaterialBlock {
  61827. private _lightDataUniformName;
  61828. private _lightColorUniformName;
  61829. private _lightTypeDefineName;
  61830. /**
  61831. * Gets or sets the light associated with this block
  61832. */
  61833. light: Nullable<Light>;
  61834. /**
  61835. * Creates a new LightInformationBlock
  61836. * @param name defines the block name
  61837. */
  61838. constructor(name: string);
  61839. /**
  61840. * Gets the current class name
  61841. * @returns the class name
  61842. */
  61843. getClassName(): string;
  61844. /**
  61845. * Gets the world position input component
  61846. */
  61847. get worldPosition(): NodeMaterialConnectionPoint;
  61848. /**
  61849. * Gets the direction output component
  61850. */
  61851. get direction(): NodeMaterialConnectionPoint;
  61852. /**
  61853. * Gets the direction output component
  61854. */
  61855. get color(): NodeMaterialConnectionPoint;
  61856. /**
  61857. * Gets the direction output component
  61858. */
  61859. get intensity(): NodeMaterialConnectionPoint;
  61860. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61861. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61862. protected _buildBlock(state: NodeMaterialBuildState): this;
  61863. serialize(): any;
  61864. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61865. }
  61866. }
  61867. declare module BABYLON {
  61868. /**
  61869. * Block used to add image processing support to fragment shader
  61870. */
  61871. export class ImageProcessingBlock extends NodeMaterialBlock {
  61872. /**
  61873. * Create a new ImageProcessingBlock
  61874. * @param name defines the block name
  61875. */
  61876. constructor(name: string);
  61877. /**
  61878. * Gets the current class name
  61879. * @returns the class name
  61880. */
  61881. getClassName(): string;
  61882. /**
  61883. * Gets the color input component
  61884. */
  61885. get color(): NodeMaterialConnectionPoint;
  61886. /**
  61887. * Gets the output component
  61888. */
  61889. get output(): NodeMaterialConnectionPoint;
  61890. /**
  61891. * Initialize the block and prepare the context for build
  61892. * @param state defines the state that will be used for the build
  61893. */
  61894. initialize(state: NodeMaterialBuildState): void;
  61895. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61896. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61897. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61898. protected _buildBlock(state: NodeMaterialBuildState): this;
  61899. }
  61900. }
  61901. declare module BABYLON {
  61902. /**
  61903. * Block used to pertub normals based on a normal map
  61904. */
  61905. export class PerturbNormalBlock extends NodeMaterialBlock {
  61906. private _tangentSpaceParameterName;
  61907. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61908. invertX: boolean;
  61909. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61910. invertY: boolean;
  61911. /**
  61912. * Create a new PerturbNormalBlock
  61913. * @param name defines the block name
  61914. */
  61915. constructor(name: string);
  61916. /**
  61917. * Gets the current class name
  61918. * @returns the class name
  61919. */
  61920. getClassName(): string;
  61921. /**
  61922. * Gets the world position input component
  61923. */
  61924. get worldPosition(): NodeMaterialConnectionPoint;
  61925. /**
  61926. * Gets the world normal input component
  61927. */
  61928. get worldNormal(): NodeMaterialConnectionPoint;
  61929. /**
  61930. * Gets the world tangent input component
  61931. */
  61932. get worldTangent(): NodeMaterialConnectionPoint;
  61933. /**
  61934. * Gets the uv input component
  61935. */
  61936. get uv(): NodeMaterialConnectionPoint;
  61937. /**
  61938. * Gets the normal map color input component
  61939. */
  61940. get normalMapColor(): NodeMaterialConnectionPoint;
  61941. /**
  61942. * Gets the strength input component
  61943. */
  61944. get strength(): NodeMaterialConnectionPoint;
  61945. /**
  61946. * Gets the output component
  61947. */
  61948. get output(): NodeMaterialConnectionPoint;
  61949. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61950. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61951. autoConfigure(material: NodeMaterial): void;
  61952. protected _buildBlock(state: NodeMaterialBuildState): this;
  61953. protected _dumpPropertiesCode(): string;
  61954. serialize(): any;
  61955. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61956. }
  61957. }
  61958. declare module BABYLON {
  61959. /**
  61960. * Block used to discard a pixel if a value is smaller than a cutoff
  61961. */
  61962. export class DiscardBlock extends NodeMaterialBlock {
  61963. /**
  61964. * Create a new DiscardBlock
  61965. * @param name defines the block name
  61966. */
  61967. constructor(name: string);
  61968. /**
  61969. * Gets the current class name
  61970. * @returns the class name
  61971. */
  61972. getClassName(): string;
  61973. /**
  61974. * Gets the color input component
  61975. */
  61976. get value(): NodeMaterialConnectionPoint;
  61977. /**
  61978. * Gets the cutoff input component
  61979. */
  61980. get cutoff(): NodeMaterialConnectionPoint;
  61981. protected _buildBlock(state: NodeMaterialBuildState): this;
  61982. }
  61983. }
  61984. declare module BABYLON {
  61985. /**
  61986. * Block used to test if the fragment shader is front facing
  61987. */
  61988. export class FrontFacingBlock extends NodeMaterialBlock {
  61989. /**
  61990. * Creates a new FrontFacingBlock
  61991. * @param name defines the block name
  61992. */
  61993. constructor(name: string);
  61994. /**
  61995. * Gets the current class name
  61996. * @returns the class name
  61997. */
  61998. getClassName(): string;
  61999. /**
  62000. * Gets the output component
  62001. */
  62002. get output(): NodeMaterialConnectionPoint;
  62003. protected _buildBlock(state: NodeMaterialBuildState): this;
  62004. }
  62005. }
  62006. declare module BABYLON {
  62007. /**
  62008. * Block used to get the derivative value on x and y of a given input
  62009. */
  62010. export class DerivativeBlock extends NodeMaterialBlock {
  62011. /**
  62012. * Create a new DerivativeBlock
  62013. * @param name defines the block name
  62014. */
  62015. constructor(name: string);
  62016. /**
  62017. * Gets the current class name
  62018. * @returns the class name
  62019. */
  62020. getClassName(): string;
  62021. /**
  62022. * Gets the input component
  62023. */
  62024. get input(): NodeMaterialConnectionPoint;
  62025. /**
  62026. * Gets the derivative output on x
  62027. */
  62028. get dx(): NodeMaterialConnectionPoint;
  62029. /**
  62030. * Gets the derivative output on y
  62031. */
  62032. get dy(): NodeMaterialConnectionPoint;
  62033. protected _buildBlock(state: NodeMaterialBuildState): this;
  62034. }
  62035. }
  62036. declare module BABYLON {
  62037. /**
  62038. * Block used to make gl_FragCoord available
  62039. */
  62040. export class FragCoordBlock extends NodeMaterialBlock {
  62041. /**
  62042. * Creates a new FragCoordBlock
  62043. * @param name defines the block name
  62044. */
  62045. constructor(name: string);
  62046. /**
  62047. * Gets the current class name
  62048. * @returns the class name
  62049. */
  62050. getClassName(): string;
  62051. /**
  62052. * Gets the xy component
  62053. */
  62054. get xy(): NodeMaterialConnectionPoint;
  62055. /**
  62056. * Gets the xyz component
  62057. */
  62058. get xyz(): NodeMaterialConnectionPoint;
  62059. /**
  62060. * Gets the xyzw component
  62061. */
  62062. get xyzw(): NodeMaterialConnectionPoint;
  62063. /**
  62064. * Gets the x component
  62065. */
  62066. get x(): NodeMaterialConnectionPoint;
  62067. /**
  62068. * Gets the y component
  62069. */
  62070. get y(): NodeMaterialConnectionPoint;
  62071. /**
  62072. * Gets the z component
  62073. */
  62074. get z(): NodeMaterialConnectionPoint;
  62075. /**
  62076. * Gets the w component
  62077. */
  62078. get output(): NodeMaterialConnectionPoint;
  62079. protected writeOutputs(state: NodeMaterialBuildState): string;
  62080. protected _buildBlock(state: NodeMaterialBuildState): this;
  62081. }
  62082. }
  62083. declare module BABYLON {
  62084. /**
  62085. * Block used to get the screen sizes
  62086. */
  62087. export class ScreenSizeBlock extends NodeMaterialBlock {
  62088. private _varName;
  62089. private _scene;
  62090. /**
  62091. * Creates a new ScreenSizeBlock
  62092. * @param name defines the block name
  62093. */
  62094. constructor(name: string);
  62095. /**
  62096. * Gets the current class name
  62097. * @returns the class name
  62098. */
  62099. getClassName(): string;
  62100. /**
  62101. * Gets the xy component
  62102. */
  62103. get xy(): NodeMaterialConnectionPoint;
  62104. /**
  62105. * Gets the x component
  62106. */
  62107. get x(): NodeMaterialConnectionPoint;
  62108. /**
  62109. * Gets the y component
  62110. */
  62111. get y(): NodeMaterialConnectionPoint;
  62112. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62113. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  62114. protected _buildBlock(state: NodeMaterialBuildState): this;
  62115. }
  62116. }
  62117. declare module BABYLON {
  62118. /**
  62119. * Block used to add support for scene fog
  62120. */
  62121. export class FogBlock extends NodeMaterialBlock {
  62122. private _fogDistanceName;
  62123. private _fogParameters;
  62124. /**
  62125. * Create a new FogBlock
  62126. * @param name defines the block name
  62127. */
  62128. constructor(name: string);
  62129. /**
  62130. * Gets the current class name
  62131. * @returns the class name
  62132. */
  62133. getClassName(): string;
  62134. /**
  62135. * Gets the world position input component
  62136. */
  62137. get worldPosition(): NodeMaterialConnectionPoint;
  62138. /**
  62139. * Gets the view input component
  62140. */
  62141. get view(): NodeMaterialConnectionPoint;
  62142. /**
  62143. * Gets the color input component
  62144. */
  62145. get input(): NodeMaterialConnectionPoint;
  62146. /**
  62147. * Gets the fog color input component
  62148. */
  62149. get fogColor(): NodeMaterialConnectionPoint;
  62150. /**
  62151. * Gets the output component
  62152. */
  62153. get output(): NodeMaterialConnectionPoint;
  62154. autoConfigure(material: NodeMaterial): void;
  62155. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62156. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62157. protected _buildBlock(state: NodeMaterialBuildState): this;
  62158. }
  62159. }
  62160. declare module BABYLON {
  62161. /**
  62162. * Block used to add light in the fragment shader
  62163. */
  62164. export class LightBlock extends NodeMaterialBlock {
  62165. private _lightId;
  62166. /**
  62167. * Gets or sets the light associated with this block
  62168. */
  62169. light: Nullable<Light>;
  62170. /**
  62171. * Create a new LightBlock
  62172. * @param name defines the block name
  62173. */
  62174. constructor(name: string);
  62175. /**
  62176. * Gets the current class name
  62177. * @returns the class name
  62178. */
  62179. getClassName(): string;
  62180. /**
  62181. * Gets the world position input component
  62182. */
  62183. get worldPosition(): NodeMaterialConnectionPoint;
  62184. /**
  62185. * Gets the world normal input component
  62186. */
  62187. get worldNormal(): NodeMaterialConnectionPoint;
  62188. /**
  62189. * Gets the camera (or eye) position component
  62190. */
  62191. get cameraPosition(): NodeMaterialConnectionPoint;
  62192. /**
  62193. * Gets the glossiness component
  62194. */
  62195. get glossiness(): NodeMaterialConnectionPoint;
  62196. /**
  62197. * Gets the glossinness power component
  62198. */
  62199. get glossPower(): NodeMaterialConnectionPoint;
  62200. /**
  62201. * Gets the diffuse color component
  62202. */
  62203. get diffuseColor(): NodeMaterialConnectionPoint;
  62204. /**
  62205. * Gets the specular color component
  62206. */
  62207. get specularColor(): NodeMaterialConnectionPoint;
  62208. /**
  62209. * Gets the diffuse output component
  62210. */
  62211. get diffuseOutput(): NodeMaterialConnectionPoint;
  62212. /**
  62213. * Gets the specular output component
  62214. */
  62215. get specularOutput(): NodeMaterialConnectionPoint;
  62216. /**
  62217. * Gets the shadow output component
  62218. */
  62219. get shadow(): NodeMaterialConnectionPoint;
  62220. autoConfigure(material: NodeMaterial): void;
  62221. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62222. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  62223. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62224. private _injectVertexCode;
  62225. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62226. serialize(): any;
  62227. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62228. }
  62229. }
  62230. declare module BABYLON {
  62231. /**
  62232. * Block used to read a reflection texture from a sampler
  62233. */
  62234. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  62235. /**
  62236. * Create a new ReflectionTextureBlock
  62237. * @param name defines the block name
  62238. */
  62239. constructor(name: string);
  62240. /**
  62241. * Gets the current class name
  62242. * @returns the class name
  62243. */
  62244. getClassName(): string;
  62245. /**
  62246. * Gets the world position input component
  62247. */
  62248. get position(): NodeMaterialConnectionPoint;
  62249. /**
  62250. * Gets the world position input component
  62251. */
  62252. get worldPosition(): NodeMaterialConnectionPoint;
  62253. /**
  62254. * Gets the world normal input component
  62255. */
  62256. get worldNormal(): NodeMaterialConnectionPoint;
  62257. /**
  62258. * Gets the world input component
  62259. */
  62260. get world(): NodeMaterialConnectionPoint;
  62261. /**
  62262. * Gets the camera (or eye) position component
  62263. */
  62264. get cameraPosition(): NodeMaterialConnectionPoint;
  62265. /**
  62266. * Gets the view input component
  62267. */
  62268. get view(): NodeMaterialConnectionPoint;
  62269. /**
  62270. * Gets the rgb output component
  62271. */
  62272. get rgb(): NodeMaterialConnectionPoint;
  62273. /**
  62274. * Gets the rgba output component
  62275. */
  62276. get rgba(): NodeMaterialConnectionPoint;
  62277. /**
  62278. * Gets the r output component
  62279. */
  62280. get r(): NodeMaterialConnectionPoint;
  62281. /**
  62282. * Gets the g output component
  62283. */
  62284. get g(): NodeMaterialConnectionPoint;
  62285. /**
  62286. * Gets the b output component
  62287. */
  62288. get b(): NodeMaterialConnectionPoint;
  62289. /**
  62290. * Gets the a output component
  62291. */
  62292. get a(): NodeMaterialConnectionPoint;
  62293. autoConfigure(material: NodeMaterial): void;
  62294. protected _buildBlock(state: NodeMaterialBuildState): this;
  62295. }
  62296. }
  62297. declare module BABYLON {
  62298. /**
  62299. * Block used to add 2 vectors
  62300. */
  62301. export class AddBlock extends NodeMaterialBlock {
  62302. /**
  62303. * Creates a new AddBlock
  62304. * @param name defines the block name
  62305. */
  62306. constructor(name: string);
  62307. /**
  62308. * Gets the current class name
  62309. * @returns the class name
  62310. */
  62311. getClassName(): string;
  62312. /**
  62313. * Gets the left operand input component
  62314. */
  62315. get left(): NodeMaterialConnectionPoint;
  62316. /**
  62317. * Gets the right operand input component
  62318. */
  62319. get right(): NodeMaterialConnectionPoint;
  62320. /**
  62321. * Gets the output component
  62322. */
  62323. get output(): NodeMaterialConnectionPoint;
  62324. protected _buildBlock(state: NodeMaterialBuildState): this;
  62325. }
  62326. }
  62327. declare module BABYLON {
  62328. /**
  62329. * Block used to scale a vector by a float
  62330. */
  62331. export class ScaleBlock extends NodeMaterialBlock {
  62332. /**
  62333. * Creates a new ScaleBlock
  62334. * @param name defines the block name
  62335. */
  62336. constructor(name: string);
  62337. /**
  62338. * Gets the current class name
  62339. * @returns the class name
  62340. */
  62341. getClassName(): string;
  62342. /**
  62343. * Gets the input component
  62344. */
  62345. get input(): NodeMaterialConnectionPoint;
  62346. /**
  62347. * Gets the factor input component
  62348. */
  62349. get factor(): NodeMaterialConnectionPoint;
  62350. /**
  62351. * Gets the output component
  62352. */
  62353. get output(): NodeMaterialConnectionPoint;
  62354. protected _buildBlock(state: NodeMaterialBuildState): this;
  62355. }
  62356. }
  62357. declare module BABYLON {
  62358. /**
  62359. * Block used to clamp a float
  62360. */
  62361. export class ClampBlock extends NodeMaterialBlock {
  62362. /** Gets or sets the minimum range */
  62363. minimum: number;
  62364. /** Gets or sets the maximum range */
  62365. maximum: number;
  62366. /**
  62367. * Creates a new ClampBlock
  62368. * @param name defines the block name
  62369. */
  62370. constructor(name: string);
  62371. /**
  62372. * Gets the current class name
  62373. * @returns the class name
  62374. */
  62375. getClassName(): string;
  62376. /**
  62377. * Gets the value input component
  62378. */
  62379. get value(): NodeMaterialConnectionPoint;
  62380. /**
  62381. * Gets the output component
  62382. */
  62383. get output(): NodeMaterialConnectionPoint;
  62384. protected _buildBlock(state: NodeMaterialBuildState): this;
  62385. protected _dumpPropertiesCode(): string;
  62386. serialize(): any;
  62387. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62388. }
  62389. }
  62390. declare module BABYLON {
  62391. /**
  62392. * Block used to apply a cross product between 2 vectors
  62393. */
  62394. export class CrossBlock extends NodeMaterialBlock {
  62395. /**
  62396. * Creates a new CrossBlock
  62397. * @param name defines the block name
  62398. */
  62399. constructor(name: string);
  62400. /**
  62401. * Gets the current class name
  62402. * @returns the class name
  62403. */
  62404. getClassName(): string;
  62405. /**
  62406. * Gets the left operand input component
  62407. */
  62408. get left(): NodeMaterialConnectionPoint;
  62409. /**
  62410. * Gets the right operand input component
  62411. */
  62412. get right(): NodeMaterialConnectionPoint;
  62413. /**
  62414. * Gets the output component
  62415. */
  62416. get output(): NodeMaterialConnectionPoint;
  62417. protected _buildBlock(state: NodeMaterialBuildState): this;
  62418. }
  62419. }
  62420. declare module BABYLON {
  62421. /**
  62422. * Block used to apply a dot product between 2 vectors
  62423. */
  62424. export class DotBlock extends NodeMaterialBlock {
  62425. /**
  62426. * Creates a new DotBlock
  62427. * @param name defines the block name
  62428. */
  62429. constructor(name: string);
  62430. /**
  62431. * Gets the current class name
  62432. * @returns the class name
  62433. */
  62434. getClassName(): string;
  62435. /**
  62436. * Gets the left operand input component
  62437. */
  62438. get left(): NodeMaterialConnectionPoint;
  62439. /**
  62440. * Gets the right operand input component
  62441. */
  62442. get right(): NodeMaterialConnectionPoint;
  62443. /**
  62444. * Gets the output component
  62445. */
  62446. get output(): NodeMaterialConnectionPoint;
  62447. protected _buildBlock(state: NodeMaterialBuildState): this;
  62448. }
  62449. }
  62450. declare module BABYLON {
  62451. /**
  62452. * Block used to normalize a vector
  62453. */
  62454. export class NormalizeBlock extends NodeMaterialBlock {
  62455. /**
  62456. * Creates a new NormalizeBlock
  62457. * @param name defines the block name
  62458. */
  62459. constructor(name: string);
  62460. /**
  62461. * Gets the current class name
  62462. * @returns the class name
  62463. */
  62464. getClassName(): string;
  62465. /**
  62466. * Gets the input component
  62467. */
  62468. get input(): NodeMaterialConnectionPoint;
  62469. /**
  62470. * Gets the output component
  62471. */
  62472. get output(): NodeMaterialConnectionPoint;
  62473. protected _buildBlock(state: NodeMaterialBuildState): this;
  62474. }
  62475. }
  62476. declare module BABYLON {
  62477. /**
  62478. * Operations supported by the Trigonometry block
  62479. */
  62480. export enum TrigonometryBlockOperations {
  62481. /** Cos */
  62482. Cos = 0,
  62483. /** Sin */
  62484. Sin = 1,
  62485. /** Abs */
  62486. Abs = 2,
  62487. /** Exp */
  62488. Exp = 3,
  62489. /** Exp2 */
  62490. Exp2 = 4,
  62491. /** Round */
  62492. Round = 5,
  62493. /** Floor */
  62494. Floor = 6,
  62495. /** Ceiling */
  62496. Ceiling = 7,
  62497. /** Square root */
  62498. Sqrt = 8,
  62499. /** Log */
  62500. Log = 9,
  62501. /** Tangent */
  62502. Tan = 10,
  62503. /** Arc tangent */
  62504. ArcTan = 11,
  62505. /** Arc cosinus */
  62506. ArcCos = 12,
  62507. /** Arc sinus */
  62508. ArcSin = 13,
  62509. /** Fraction */
  62510. Fract = 14,
  62511. /** Sign */
  62512. Sign = 15,
  62513. /** To radians (from degrees) */
  62514. Radians = 16,
  62515. /** To degrees (from radians) */
  62516. Degrees = 17
  62517. }
  62518. /**
  62519. * Block used to apply trigonometry operation to floats
  62520. */
  62521. export class TrigonometryBlock extends NodeMaterialBlock {
  62522. /**
  62523. * Gets or sets the operation applied by the block
  62524. */
  62525. operation: TrigonometryBlockOperations;
  62526. /**
  62527. * Creates a new TrigonometryBlock
  62528. * @param name defines the block name
  62529. */
  62530. constructor(name: string);
  62531. /**
  62532. * Gets the current class name
  62533. * @returns the class name
  62534. */
  62535. getClassName(): string;
  62536. /**
  62537. * Gets the input component
  62538. */
  62539. get input(): NodeMaterialConnectionPoint;
  62540. /**
  62541. * Gets the output component
  62542. */
  62543. get output(): NodeMaterialConnectionPoint;
  62544. protected _buildBlock(state: NodeMaterialBuildState): this;
  62545. serialize(): any;
  62546. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62547. protected _dumpPropertiesCode(): string;
  62548. }
  62549. }
  62550. declare module BABYLON {
  62551. /**
  62552. * Block used to create a Color3/4 out of individual inputs (one for each component)
  62553. */
  62554. export class ColorMergerBlock extends NodeMaterialBlock {
  62555. /**
  62556. * Create a new ColorMergerBlock
  62557. * @param name defines the block name
  62558. */
  62559. constructor(name: string);
  62560. /**
  62561. * Gets the current class name
  62562. * @returns the class name
  62563. */
  62564. getClassName(): string;
  62565. /**
  62566. * Gets the rgb component (input)
  62567. */
  62568. get rgbIn(): NodeMaterialConnectionPoint;
  62569. /**
  62570. * Gets the r component (input)
  62571. */
  62572. get r(): NodeMaterialConnectionPoint;
  62573. /**
  62574. * Gets the g component (input)
  62575. */
  62576. get g(): NodeMaterialConnectionPoint;
  62577. /**
  62578. * Gets the b component (input)
  62579. */
  62580. get b(): NodeMaterialConnectionPoint;
  62581. /**
  62582. * Gets the a component (input)
  62583. */
  62584. get a(): NodeMaterialConnectionPoint;
  62585. /**
  62586. * Gets the rgba component (output)
  62587. */
  62588. get rgba(): NodeMaterialConnectionPoint;
  62589. /**
  62590. * Gets the rgb component (output)
  62591. */
  62592. get rgbOut(): NodeMaterialConnectionPoint;
  62593. /**
  62594. * Gets the rgb component (output)
  62595. * @deprecated Please use rgbOut instead.
  62596. */
  62597. get rgb(): NodeMaterialConnectionPoint;
  62598. protected _buildBlock(state: NodeMaterialBuildState): this;
  62599. }
  62600. }
  62601. declare module BABYLON {
  62602. /**
  62603. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  62604. */
  62605. export class VectorSplitterBlock extends NodeMaterialBlock {
  62606. /**
  62607. * Create a new VectorSplitterBlock
  62608. * @param name defines the block name
  62609. */
  62610. constructor(name: string);
  62611. /**
  62612. * Gets the current class name
  62613. * @returns the class name
  62614. */
  62615. getClassName(): string;
  62616. /**
  62617. * Gets the xyzw component (input)
  62618. */
  62619. get xyzw(): NodeMaterialConnectionPoint;
  62620. /**
  62621. * Gets the xyz component (input)
  62622. */
  62623. get xyzIn(): NodeMaterialConnectionPoint;
  62624. /**
  62625. * Gets the xy component (input)
  62626. */
  62627. get xyIn(): NodeMaterialConnectionPoint;
  62628. /**
  62629. * Gets the xyz component (output)
  62630. */
  62631. get xyzOut(): NodeMaterialConnectionPoint;
  62632. /**
  62633. * Gets the xy component (output)
  62634. */
  62635. get xyOut(): NodeMaterialConnectionPoint;
  62636. /**
  62637. * Gets the x component (output)
  62638. */
  62639. get x(): NodeMaterialConnectionPoint;
  62640. /**
  62641. * Gets the y component (output)
  62642. */
  62643. get y(): NodeMaterialConnectionPoint;
  62644. /**
  62645. * Gets the z component (output)
  62646. */
  62647. get z(): NodeMaterialConnectionPoint;
  62648. /**
  62649. * Gets the w component (output)
  62650. */
  62651. get w(): NodeMaterialConnectionPoint;
  62652. protected _inputRename(name: string): string;
  62653. protected _outputRename(name: string): string;
  62654. protected _buildBlock(state: NodeMaterialBuildState): this;
  62655. }
  62656. }
  62657. declare module BABYLON {
  62658. /**
  62659. * Block used to lerp between 2 values
  62660. */
  62661. export class LerpBlock extends NodeMaterialBlock {
  62662. /**
  62663. * Creates a new LerpBlock
  62664. * @param name defines the block name
  62665. */
  62666. constructor(name: string);
  62667. /**
  62668. * Gets the current class name
  62669. * @returns the class name
  62670. */
  62671. getClassName(): string;
  62672. /**
  62673. * Gets the left operand input component
  62674. */
  62675. get left(): NodeMaterialConnectionPoint;
  62676. /**
  62677. * Gets the right operand input component
  62678. */
  62679. get right(): NodeMaterialConnectionPoint;
  62680. /**
  62681. * Gets the gradient operand input component
  62682. */
  62683. get gradient(): NodeMaterialConnectionPoint;
  62684. /**
  62685. * Gets the output component
  62686. */
  62687. get output(): NodeMaterialConnectionPoint;
  62688. protected _buildBlock(state: NodeMaterialBuildState): this;
  62689. }
  62690. }
  62691. declare module BABYLON {
  62692. /**
  62693. * Block used to divide 2 vectors
  62694. */
  62695. export class DivideBlock extends NodeMaterialBlock {
  62696. /**
  62697. * Creates a new DivideBlock
  62698. * @param name defines the block name
  62699. */
  62700. constructor(name: string);
  62701. /**
  62702. * Gets the current class name
  62703. * @returns the class name
  62704. */
  62705. getClassName(): string;
  62706. /**
  62707. * Gets the left operand input component
  62708. */
  62709. get left(): NodeMaterialConnectionPoint;
  62710. /**
  62711. * Gets the right operand input component
  62712. */
  62713. get right(): NodeMaterialConnectionPoint;
  62714. /**
  62715. * Gets the output component
  62716. */
  62717. get output(): NodeMaterialConnectionPoint;
  62718. protected _buildBlock(state: NodeMaterialBuildState): this;
  62719. }
  62720. }
  62721. declare module BABYLON {
  62722. /**
  62723. * Block used to subtract 2 vectors
  62724. */
  62725. export class SubtractBlock extends NodeMaterialBlock {
  62726. /**
  62727. * Creates a new SubtractBlock
  62728. * @param name defines the block name
  62729. */
  62730. constructor(name: string);
  62731. /**
  62732. * Gets the current class name
  62733. * @returns the class name
  62734. */
  62735. getClassName(): string;
  62736. /**
  62737. * Gets the left operand input component
  62738. */
  62739. get left(): NodeMaterialConnectionPoint;
  62740. /**
  62741. * Gets the right operand input component
  62742. */
  62743. get right(): NodeMaterialConnectionPoint;
  62744. /**
  62745. * Gets the output component
  62746. */
  62747. get output(): NodeMaterialConnectionPoint;
  62748. protected _buildBlock(state: NodeMaterialBuildState): this;
  62749. }
  62750. }
  62751. declare module BABYLON {
  62752. /**
  62753. * Block used to step a value
  62754. */
  62755. export class StepBlock extends NodeMaterialBlock {
  62756. /**
  62757. * Creates a new StepBlock
  62758. * @param name defines the block name
  62759. */
  62760. constructor(name: string);
  62761. /**
  62762. * Gets the current class name
  62763. * @returns the class name
  62764. */
  62765. getClassName(): string;
  62766. /**
  62767. * Gets the value operand input component
  62768. */
  62769. get value(): NodeMaterialConnectionPoint;
  62770. /**
  62771. * Gets the edge operand input component
  62772. */
  62773. get edge(): NodeMaterialConnectionPoint;
  62774. /**
  62775. * Gets the output component
  62776. */
  62777. get output(): NodeMaterialConnectionPoint;
  62778. protected _buildBlock(state: NodeMaterialBuildState): this;
  62779. }
  62780. }
  62781. declare module BABYLON {
  62782. /**
  62783. * Block used to get the opposite (1 - x) of a value
  62784. */
  62785. export class OneMinusBlock extends NodeMaterialBlock {
  62786. /**
  62787. * Creates a new OneMinusBlock
  62788. * @param name defines the block name
  62789. */
  62790. constructor(name: string);
  62791. /**
  62792. * Gets the current class name
  62793. * @returns the class name
  62794. */
  62795. getClassName(): string;
  62796. /**
  62797. * Gets the input component
  62798. */
  62799. get input(): NodeMaterialConnectionPoint;
  62800. /**
  62801. * Gets the output component
  62802. */
  62803. get output(): NodeMaterialConnectionPoint;
  62804. protected _buildBlock(state: NodeMaterialBuildState): this;
  62805. }
  62806. }
  62807. declare module BABYLON {
  62808. /**
  62809. * Block used to get the view direction
  62810. */
  62811. export class ViewDirectionBlock extends NodeMaterialBlock {
  62812. /**
  62813. * Creates a new ViewDirectionBlock
  62814. * @param name defines the block name
  62815. */
  62816. constructor(name: string);
  62817. /**
  62818. * Gets the current class name
  62819. * @returns the class name
  62820. */
  62821. getClassName(): string;
  62822. /**
  62823. * Gets the world position component
  62824. */
  62825. get worldPosition(): NodeMaterialConnectionPoint;
  62826. /**
  62827. * Gets the camera position component
  62828. */
  62829. get cameraPosition(): NodeMaterialConnectionPoint;
  62830. /**
  62831. * Gets the output component
  62832. */
  62833. get output(): NodeMaterialConnectionPoint;
  62834. autoConfigure(material: NodeMaterial): void;
  62835. protected _buildBlock(state: NodeMaterialBuildState): this;
  62836. }
  62837. }
  62838. declare module BABYLON {
  62839. /**
  62840. * Block used to compute fresnel value
  62841. */
  62842. export class FresnelBlock extends NodeMaterialBlock {
  62843. /**
  62844. * Create a new FresnelBlock
  62845. * @param name defines the block name
  62846. */
  62847. constructor(name: string);
  62848. /**
  62849. * Gets the current class name
  62850. * @returns the class name
  62851. */
  62852. getClassName(): string;
  62853. /**
  62854. * Gets the world normal input component
  62855. */
  62856. get worldNormal(): NodeMaterialConnectionPoint;
  62857. /**
  62858. * Gets the view direction input component
  62859. */
  62860. get viewDirection(): NodeMaterialConnectionPoint;
  62861. /**
  62862. * Gets the bias input component
  62863. */
  62864. get bias(): NodeMaterialConnectionPoint;
  62865. /**
  62866. * Gets the camera (or eye) position component
  62867. */
  62868. get power(): NodeMaterialConnectionPoint;
  62869. /**
  62870. * Gets the fresnel output component
  62871. */
  62872. get fresnel(): NodeMaterialConnectionPoint;
  62873. autoConfigure(material: NodeMaterial): void;
  62874. protected _buildBlock(state: NodeMaterialBuildState): this;
  62875. }
  62876. }
  62877. declare module BABYLON {
  62878. /**
  62879. * Block used to get the max of 2 values
  62880. */
  62881. export class MaxBlock extends NodeMaterialBlock {
  62882. /**
  62883. * Creates a new MaxBlock
  62884. * @param name defines the block name
  62885. */
  62886. constructor(name: string);
  62887. /**
  62888. * Gets the current class name
  62889. * @returns the class name
  62890. */
  62891. getClassName(): string;
  62892. /**
  62893. * Gets the left operand input component
  62894. */
  62895. get left(): NodeMaterialConnectionPoint;
  62896. /**
  62897. * Gets the right operand input component
  62898. */
  62899. get right(): NodeMaterialConnectionPoint;
  62900. /**
  62901. * Gets the output component
  62902. */
  62903. get output(): NodeMaterialConnectionPoint;
  62904. protected _buildBlock(state: NodeMaterialBuildState): this;
  62905. }
  62906. }
  62907. declare module BABYLON {
  62908. /**
  62909. * Block used to get the min of 2 values
  62910. */
  62911. export class MinBlock extends NodeMaterialBlock {
  62912. /**
  62913. * Creates a new MinBlock
  62914. * @param name defines the block name
  62915. */
  62916. constructor(name: string);
  62917. /**
  62918. * Gets the current class name
  62919. * @returns the class name
  62920. */
  62921. getClassName(): string;
  62922. /**
  62923. * Gets the left operand input component
  62924. */
  62925. get left(): NodeMaterialConnectionPoint;
  62926. /**
  62927. * Gets the right operand input component
  62928. */
  62929. get right(): NodeMaterialConnectionPoint;
  62930. /**
  62931. * Gets the output component
  62932. */
  62933. get output(): NodeMaterialConnectionPoint;
  62934. protected _buildBlock(state: NodeMaterialBuildState): this;
  62935. }
  62936. }
  62937. declare module BABYLON {
  62938. /**
  62939. * Block used to get the distance between 2 values
  62940. */
  62941. export class DistanceBlock extends NodeMaterialBlock {
  62942. /**
  62943. * Creates a new DistanceBlock
  62944. * @param name defines the block name
  62945. */
  62946. constructor(name: string);
  62947. /**
  62948. * Gets the current class name
  62949. * @returns the class name
  62950. */
  62951. getClassName(): string;
  62952. /**
  62953. * Gets the left operand input component
  62954. */
  62955. get left(): NodeMaterialConnectionPoint;
  62956. /**
  62957. * Gets the right operand input component
  62958. */
  62959. get right(): NodeMaterialConnectionPoint;
  62960. /**
  62961. * Gets the output component
  62962. */
  62963. get output(): NodeMaterialConnectionPoint;
  62964. protected _buildBlock(state: NodeMaterialBuildState): this;
  62965. }
  62966. }
  62967. declare module BABYLON {
  62968. /**
  62969. * Block used to get the length of a vector
  62970. */
  62971. export class LengthBlock extends NodeMaterialBlock {
  62972. /**
  62973. * Creates a new LengthBlock
  62974. * @param name defines the block name
  62975. */
  62976. constructor(name: string);
  62977. /**
  62978. * Gets the current class name
  62979. * @returns the class name
  62980. */
  62981. getClassName(): string;
  62982. /**
  62983. * Gets the value input component
  62984. */
  62985. get value(): NodeMaterialConnectionPoint;
  62986. /**
  62987. * Gets the output component
  62988. */
  62989. get output(): NodeMaterialConnectionPoint;
  62990. protected _buildBlock(state: NodeMaterialBuildState): this;
  62991. }
  62992. }
  62993. declare module BABYLON {
  62994. /**
  62995. * Block used to get negative version of a value (i.e. x * -1)
  62996. */
  62997. export class NegateBlock extends NodeMaterialBlock {
  62998. /**
  62999. * Creates a new NegateBlock
  63000. * @param name defines the block name
  63001. */
  63002. constructor(name: string);
  63003. /**
  63004. * Gets the current class name
  63005. * @returns the class name
  63006. */
  63007. getClassName(): string;
  63008. /**
  63009. * Gets the value input component
  63010. */
  63011. get value(): NodeMaterialConnectionPoint;
  63012. /**
  63013. * Gets the output component
  63014. */
  63015. get output(): NodeMaterialConnectionPoint;
  63016. protected _buildBlock(state: NodeMaterialBuildState): this;
  63017. }
  63018. }
  63019. declare module BABYLON {
  63020. /**
  63021. * Block used to get the value of the first parameter raised to the power of the second
  63022. */
  63023. export class PowBlock extends NodeMaterialBlock {
  63024. /**
  63025. * Creates a new PowBlock
  63026. * @param name defines the block name
  63027. */
  63028. constructor(name: string);
  63029. /**
  63030. * Gets the current class name
  63031. * @returns the class name
  63032. */
  63033. getClassName(): string;
  63034. /**
  63035. * Gets the value operand input component
  63036. */
  63037. get value(): NodeMaterialConnectionPoint;
  63038. /**
  63039. * Gets the power operand input component
  63040. */
  63041. get power(): NodeMaterialConnectionPoint;
  63042. /**
  63043. * Gets the output component
  63044. */
  63045. get output(): NodeMaterialConnectionPoint;
  63046. protected _buildBlock(state: NodeMaterialBuildState): this;
  63047. }
  63048. }
  63049. declare module BABYLON {
  63050. /**
  63051. * Block used to get a random number
  63052. */
  63053. export class RandomNumberBlock extends NodeMaterialBlock {
  63054. /**
  63055. * Creates a new RandomNumberBlock
  63056. * @param name defines the block name
  63057. */
  63058. constructor(name: string);
  63059. /**
  63060. * Gets the current class name
  63061. * @returns the class name
  63062. */
  63063. getClassName(): string;
  63064. /**
  63065. * Gets the seed input component
  63066. */
  63067. get seed(): NodeMaterialConnectionPoint;
  63068. /**
  63069. * Gets the output component
  63070. */
  63071. get output(): NodeMaterialConnectionPoint;
  63072. protected _buildBlock(state: NodeMaterialBuildState): this;
  63073. }
  63074. }
  63075. declare module BABYLON {
  63076. /**
  63077. * Block used to compute arc tangent of 2 values
  63078. */
  63079. export class ArcTan2Block extends NodeMaterialBlock {
  63080. /**
  63081. * Creates a new ArcTan2Block
  63082. * @param name defines the block name
  63083. */
  63084. constructor(name: string);
  63085. /**
  63086. * Gets the current class name
  63087. * @returns the class name
  63088. */
  63089. getClassName(): string;
  63090. /**
  63091. * Gets the x operand input component
  63092. */
  63093. get x(): NodeMaterialConnectionPoint;
  63094. /**
  63095. * Gets the y operand input component
  63096. */
  63097. get y(): NodeMaterialConnectionPoint;
  63098. /**
  63099. * Gets the output component
  63100. */
  63101. get output(): NodeMaterialConnectionPoint;
  63102. protected _buildBlock(state: NodeMaterialBuildState): this;
  63103. }
  63104. }
  63105. declare module BABYLON {
  63106. /**
  63107. * Block used to smooth step a value
  63108. */
  63109. export class SmoothStepBlock extends NodeMaterialBlock {
  63110. /**
  63111. * Creates a new SmoothStepBlock
  63112. * @param name defines the block name
  63113. */
  63114. constructor(name: string);
  63115. /**
  63116. * Gets the current class name
  63117. * @returns the class name
  63118. */
  63119. getClassName(): string;
  63120. /**
  63121. * Gets the value operand input component
  63122. */
  63123. get value(): NodeMaterialConnectionPoint;
  63124. /**
  63125. * Gets the first edge operand input component
  63126. */
  63127. get edge0(): NodeMaterialConnectionPoint;
  63128. /**
  63129. * Gets the second edge operand input component
  63130. */
  63131. get edge1(): NodeMaterialConnectionPoint;
  63132. /**
  63133. * Gets the output component
  63134. */
  63135. get output(): NodeMaterialConnectionPoint;
  63136. protected _buildBlock(state: NodeMaterialBuildState): this;
  63137. }
  63138. }
  63139. declare module BABYLON {
  63140. /**
  63141. * Block used to get the reciprocal (1 / x) of a value
  63142. */
  63143. export class ReciprocalBlock extends NodeMaterialBlock {
  63144. /**
  63145. * Creates a new ReciprocalBlock
  63146. * @param name defines the block name
  63147. */
  63148. constructor(name: string);
  63149. /**
  63150. * Gets the current class name
  63151. * @returns the class name
  63152. */
  63153. getClassName(): string;
  63154. /**
  63155. * Gets the input component
  63156. */
  63157. get input(): NodeMaterialConnectionPoint;
  63158. /**
  63159. * Gets the output component
  63160. */
  63161. get output(): NodeMaterialConnectionPoint;
  63162. protected _buildBlock(state: NodeMaterialBuildState): this;
  63163. }
  63164. }
  63165. declare module BABYLON {
  63166. /**
  63167. * Block used to replace a color by another one
  63168. */
  63169. export class ReplaceColorBlock extends NodeMaterialBlock {
  63170. /**
  63171. * Creates a new ReplaceColorBlock
  63172. * @param name defines the block name
  63173. */
  63174. constructor(name: string);
  63175. /**
  63176. * Gets the current class name
  63177. * @returns the class name
  63178. */
  63179. getClassName(): string;
  63180. /**
  63181. * Gets the value input component
  63182. */
  63183. get value(): NodeMaterialConnectionPoint;
  63184. /**
  63185. * Gets the reference input component
  63186. */
  63187. get reference(): NodeMaterialConnectionPoint;
  63188. /**
  63189. * Gets the distance input component
  63190. */
  63191. get distance(): NodeMaterialConnectionPoint;
  63192. /**
  63193. * Gets the replacement input component
  63194. */
  63195. get replacement(): NodeMaterialConnectionPoint;
  63196. /**
  63197. * Gets the output component
  63198. */
  63199. get output(): NodeMaterialConnectionPoint;
  63200. protected _buildBlock(state: NodeMaterialBuildState): this;
  63201. }
  63202. }
  63203. declare module BABYLON {
  63204. /**
  63205. * Block used to posterize a value
  63206. * @see https://en.wikipedia.org/wiki/Posterization
  63207. */
  63208. export class PosterizeBlock extends NodeMaterialBlock {
  63209. /**
  63210. * Creates a new PosterizeBlock
  63211. * @param name defines the block name
  63212. */
  63213. constructor(name: string);
  63214. /**
  63215. * Gets the current class name
  63216. * @returns the class name
  63217. */
  63218. getClassName(): string;
  63219. /**
  63220. * Gets the value input component
  63221. */
  63222. get value(): NodeMaterialConnectionPoint;
  63223. /**
  63224. * Gets the steps input component
  63225. */
  63226. get steps(): NodeMaterialConnectionPoint;
  63227. /**
  63228. * Gets the output component
  63229. */
  63230. get output(): NodeMaterialConnectionPoint;
  63231. protected _buildBlock(state: NodeMaterialBuildState): this;
  63232. }
  63233. }
  63234. declare module BABYLON {
  63235. /**
  63236. * Operations supported by the Wave block
  63237. */
  63238. export enum WaveBlockKind {
  63239. /** SawTooth */
  63240. SawTooth = 0,
  63241. /** Square */
  63242. Square = 1,
  63243. /** Triangle */
  63244. Triangle = 2
  63245. }
  63246. /**
  63247. * Block used to apply wave operation to floats
  63248. */
  63249. export class WaveBlock extends NodeMaterialBlock {
  63250. /**
  63251. * Gets or sets the kibnd of wave to be applied by the block
  63252. */
  63253. kind: WaveBlockKind;
  63254. /**
  63255. * Creates a new WaveBlock
  63256. * @param name defines the block name
  63257. */
  63258. constructor(name: string);
  63259. /**
  63260. * Gets the current class name
  63261. * @returns the class name
  63262. */
  63263. getClassName(): string;
  63264. /**
  63265. * Gets the input component
  63266. */
  63267. get input(): NodeMaterialConnectionPoint;
  63268. /**
  63269. * Gets the output component
  63270. */
  63271. get output(): NodeMaterialConnectionPoint;
  63272. protected _buildBlock(state: NodeMaterialBuildState): this;
  63273. serialize(): any;
  63274. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63275. }
  63276. }
  63277. declare module BABYLON {
  63278. /**
  63279. * Class used to store a color step for the GradientBlock
  63280. */
  63281. export class GradientBlockColorStep {
  63282. /**
  63283. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63284. */
  63285. step: number;
  63286. /**
  63287. * Gets or sets the color associated with this step
  63288. */
  63289. color: Color3;
  63290. /**
  63291. * Creates a new GradientBlockColorStep
  63292. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  63293. * @param color defines the color associated with this step
  63294. */
  63295. constructor(
  63296. /**
  63297. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63298. */
  63299. step: number,
  63300. /**
  63301. * Gets or sets the color associated with this step
  63302. */
  63303. color: Color3);
  63304. }
  63305. /**
  63306. * Block used to return a color from a gradient based on an input value between 0 and 1
  63307. */
  63308. export class GradientBlock extends NodeMaterialBlock {
  63309. /**
  63310. * Gets or sets the list of color steps
  63311. */
  63312. colorSteps: GradientBlockColorStep[];
  63313. /**
  63314. * Creates a new GradientBlock
  63315. * @param name defines the block name
  63316. */
  63317. constructor(name: string);
  63318. /**
  63319. * Gets the current class name
  63320. * @returns the class name
  63321. */
  63322. getClassName(): string;
  63323. /**
  63324. * Gets the gradient input component
  63325. */
  63326. get gradient(): NodeMaterialConnectionPoint;
  63327. /**
  63328. * Gets the output component
  63329. */
  63330. get output(): NodeMaterialConnectionPoint;
  63331. private _writeColorConstant;
  63332. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63333. serialize(): any;
  63334. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63335. protected _dumpPropertiesCode(): string;
  63336. }
  63337. }
  63338. declare module BABYLON {
  63339. /**
  63340. * Block used to normalize lerp between 2 values
  63341. */
  63342. export class NLerpBlock extends NodeMaterialBlock {
  63343. /**
  63344. * Creates a new NLerpBlock
  63345. * @param name defines the block name
  63346. */
  63347. constructor(name: string);
  63348. /**
  63349. * Gets the current class name
  63350. * @returns the class name
  63351. */
  63352. getClassName(): string;
  63353. /**
  63354. * Gets the left operand input component
  63355. */
  63356. get left(): NodeMaterialConnectionPoint;
  63357. /**
  63358. * Gets the right operand input component
  63359. */
  63360. get right(): NodeMaterialConnectionPoint;
  63361. /**
  63362. * Gets the gradient operand input component
  63363. */
  63364. get gradient(): NodeMaterialConnectionPoint;
  63365. /**
  63366. * Gets the output component
  63367. */
  63368. get output(): NodeMaterialConnectionPoint;
  63369. protected _buildBlock(state: NodeMaterialBuildState): this;
  63370. }
  63371. }
  63372. declare module BABYLON {
  63373. /**
  63374. * block used to Generate a Worley Noise 3D Noise Pattern
  63375. */
  63376. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  63377. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63378. manhattanDistance: boolean;
  63379. /**
  63380. * Creates a new WorleyNoise3DBlock
  63381. * @param name defines the block name
  63382. */
  63383. constructor(name: string);
  63384. /**
  63385. * Gets the current class name
  63386. * @returns the class name
  63387. */
  63388. getClassName(): string;
  63389. /**
  63390. * Gets the seed input component
  63391. */
  63392. get seed(): NodeMaterialConnectionPoint;
  63393. /**
  63394. * Gets the jitter input component
  63395. */
  63396. get jitter(): NodeMaterialConnectionPoint;
  63397. /**
  63398. * Gets the output component
  63399. */
  63400. get output(): NodeMaterialConnectionPoint;
  63401. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63402. /**
  63403. * Exposes the properties to the UI?
  63404. */
  63405. protected _dumpPropertiesCode(): string;
  63406. /**
  63407. * Exposes the properties to the Seralize?
  63408. */
  63409. serialize(): any;
  63410. /**
  63411. * Exposes the properties to the deseralize?
  63412. */
  63413. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63414. }
  63415. }
  63416. declare module BABYLON {
  63417. /**
  63418. * block used to Generate a Simplex Perlin 3d Noise Pattern
  63419. */
  63420. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  63421. /**
  63422. * Creates a new SimplexPerlin3DBlock
  63423. * @param name defines the block name
  63424. */
  63425. constructor(name: string);
  63426. /**
  63427. * Gets the current class name
  63428. * @returns the class name
  63429. */
  63430. getClassName(): string;
  63431. /**
  63432. * Gets the seed operand input component
  63433. */
  63434. get seed(): NodeMaterialConnectionPoint;
  63435. /**
  63436. * Gets the output component
  63437. */
  63438. get output(): NodeMaterialConnectionPoint;
  63439. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63440. }
  63441. }
  63442. declare module BABYLON {
  63443. /**
  63444. * Block used to blend normals
  63445. */
  63446. export class NormalBlendBlock extends NodeMaterialBlock {
  63447. /**
  63448. * Creates a new NormalBlendBlock
  63449. * @param name defines the block name
  63450. */
  63451. constructor(name: string);
  63452. /**
  63453. * Gets the current class name
  63454. * @returns the class name
  63455. */
  63456. getClassName(): string;
  63457. /**
  63458. * Gets the first input component
  63459. */
  63460. get normalMap0(): NodeMaterialConnectionPoint;
  63461. /**
  63462. * Gets the second input component
  63463. */
  63464. get normalMap1(): NodeMaterialConnectionPoint;
  63465. /**
  63466. * Gets the output component
  63467. */
  63468. get output(): NodeMaterialConnectionPoint;
  63469. protected _buildBlock(state: NodeMaterialBuildState): this;
  63470. }
  63471. }
  63472. declare module BABYLON {
  63473. /**
  63474. * Block used to rotate a 2d vector by a given angle
  63475. */
  63476. export class Rotate2dBlock extends NodeMaterialBlock {
  63477. /**
  63478. * Creates a new Rotate2dBlock
  63479. * @param name defines the block name
  63480. */
  63481. constructor(name: string);
  63482. /**
  63483. * Gets the current class name
  63484. * @returns the class name
  63485. */
  63486. getClassName(): string;
  63487. /**
  63488. * Gets the input vector
  63489. */
  63490. get input(): NodeMaterialConnectionPoint;
  63491. /**
  63492. * Gets the input angle
  63493. */
  63494. get angle(): NodeMaterialConnectionPoint;
  63495. /**
  63496. * Gets the output component
  63497. */
  63498. get output(): NodeMaterialConnectionPoint;
  63499. autoConfigure(material: NodeMaterial): void;
  63500. protected _buildBlock(state: NodeMaterialBuildState): this;
  63501. }
  63502. }
  63503. declare module BABYLON {
  63504. /**
  63505. * Block used to get the reflected vector from a direction and a normal
  63506. */
  63507. export class ReflectBlock extends NodeMaterialBlock {
  63508. /**
  63509. * Creates a new ReflectBlock
  63510. * @param name defines the block name
  63511. */
  63512. constructor(name: string);
  63513. /**
  63514. * Gets the current class name
  63515. * @returns the class name
  63516. */
  63517. getClassName(): string;
  63518. /**
  63519. * Gets the incident component
  63520. */
  63521. get incident(): NodeMaterialConnectionPoint;
  63522. /**
  63523. * Gets the normal component
  63524. */
  63525. get normal(): NodeMaterialConnectionPoint;
  63526. /**
  63527. * Gets the output component
  63528. */
  63529. get output(): NodeMaterialConnectionPoint;
  63530. protected _buildBlock(state: NodeMaterialBuildState): this;
  63531. }
  63532. }
  63533. declare module BABYLON {
  63534. /**
  63535. * Block used to get the refracted vector from a direction and a normal
  63536. */
  63537. export class RefractBlock extends NodeMaterialBlock {
  63538. /**
  63539. * Creates a new RefractBlock
  63540. * @param name defines the block name
  63541. */
  63542. constructor(name: string);
  63543. /**
  63544. * Gets the current class name
  63545. * @returns the class name
  63546. */
  63547. getClassName(): string;
  63548. /**
  63549. * Gets the incident component
  63550. */
  63551. get incident(): NodeMaterialConnectionPoint;
  63552. /**
  63553. * Gets the normal component
  63554. */
  63555. get normal(): NodeMaterialConnectionPoint;
  63556. /**
  63557. * Gets the index of refraction component
  63558. */
  63559. get ior(): NodeMaterialConnectionPoint;
  63560. /**
  63561. * Gets the output component
  63562. */
  63563. get output(): NodeMaterialConnectionPoint;
  63564. protected _buildBlock(state: NodeMaterialBuildState): this;
  63565. }
  63566. }
  63567. declare module BABYLON {
  63568. /**
  63569. * Block used to desaturate a color
  63570. */
  63571. export class DesaturateBlock extends NodeMaterialBlock {
  63572. /**
  63573. * Creates a new DesaturateBlock
  63574. * @param name defines the block name
  63575. */
  63576. constructor(name: string);
  63577. /**
  63578. * Gets the current class name
  63579. * @returns the class name
  63580. */
  63581. getClassName(): string;
  63582. /**
  63583. * Gets the color operand input component
  63584. */
  63585. get color(): NodeMaterialConnectionPoint;
  63586. /**
  63587. * Gets the level operand input component
  63588. */
  63589. get level(): NodeMaterialConnectionPoint;
  63590. /**
  63591. * Gets the output component
  63592. */
  63593. get output(): NodeMaterialConnectionPoint;
  63594. protected _buildBlock(state: NodeMaterialBuildState): this;
  63595. }
  63596. }
  63597. declare module BABYLON {
  63598. /**
  63599. * Block used to implement the ambient occlusion module of the PBR material
  63600. */
  63601. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  63602. /**
  63603. * Create a new AmbientOcclusionBlock
  63604. * @param name defines the block name
  63605. */
  63606. constructor(name: string);
  63607. /**
  63608. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  63609. */
  63610. useAmbientInGrayScale: boolean;
  63611. /**
  63612. * Initialize the block and prepare the context for build
  63613. * @param state defines the state that will be used for the build
  63614. */
  63615. initialize(state: NodeMaterialBuildState): void;
  63616. /**
  63617. * Gets the current class name
  63618. * @returns the class name
  63619. */
  63620. getClassName(): string;
  63621. /**
  63622. * Gets the texture input component
  63623. */
  63624. get texture(): NodeMaterialConnectionPoint;
  63625. /**
  63626. * Gets the texture intensity component
  63627. */
  63628. get intensity(): NodeMaterialConnectionPoint;
  63629. /**
  63630. * Gets the direct light intensity input component
  63631. */
  63632. get directLightIntensity(): NodeMaterialConnectionPoint;
  63633. /**
  63634. * Gets the ambient occlusion object output component
  63635. */
  63636. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63637. /**
  63638. * Gets the main code of the block (fragment side)
  63639. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  63640. * @returns the shader code
  63641. */
  63642. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  63643. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63644. protected _buildBlock(state: NodeMaterialBuildState): this;
  63645. protected _dumpPropertiesCode(): string;
  63646. serialize(): any;
  63647. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63648. }
  63649. }
  63650. declare module BABYLON {
  63651. /**
  63652. * Block used to implement the reflection module of the PBR material
  63653. */
  63654. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  63655. /** @hidden */
  63656. _defineLODReflectionAlpha: string;
  63657. /** @hidden */
  63658. _defineLinearSpecularReflection: string;
  63659. private _vEnvironmentIrradianceName;
  63660. /** @hidden */
  63661. _vReflectionMicrosurfaceInfosName: string;
  63662. /** @hidden */
  63663. _vReflectionInfosName: string;
  63664. /** @hidden */
  63665. _vReflectionFilteringInfoName: string;
  63666. private _scene;
  63667. /**
  63668. * The three properties below are set by the main PBR block prior to calling methods of this class.
  63669. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  63670. * It's less burden on the user side in the editor part.
  63671. */
  63672. /** @hidden */
  63673. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  63674. /** @hidden */
  63675. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  63676. /** @hidden */
  63677. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  63678. /**
  63679. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  63680. * diffuse part of the IBL.
  63681. */
  63682. useSphericalHarmonics: boolean;
  63683. /**
  63684. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  63685. */
  63686. forceIrradianceInFragment: boolean;
  63687. /**
  63688. * Create a new ReflectionBlock
  63689. * @param name defines the block name
  63690. */
  63691. constructor(name: string);
  63692. /**
  63693. * Gets the current class name
  63694. * @returns the class name
  63695. */
  63696. getClassName(): string;
  63697. /**
  63698. * Gets the position input component
  63699. */
  63700. get position(): NodeMaterialConnectionPoint;
  63701. /**
  63702. * Gets the world position input component
  63703. */
  63704. get worldPosition(): NodeMaterialConnectionPoint;
  63705. /**
  63706. * Gets the world normal input component
  63707. */
  63708. get worldNormal(): NodeMaterialConnectionPoint;
  63709. /**
  63710. * Gets the world input component
  63711. */
  63712. get world(): NodeMaterialConnectionPoint;
  63713. /**
  63714. * Gets the camera (or eye) position component
  63715. */
  63716. get cameraPosition(): NodeMaterialConnectionPoint;
  63717. /**
  63718. * Gets the view input component
  63719. */
  63720. get view(): NodeMaterialConnectionPoint;
  63721. /**
  63722. * Gets the color input component
  63723. */
  63724. get color(): NodeMaterialConnectionPoint;
  63725. /**
  63726. * Gets the reflection object output component
  63727. */
  63728. get reflection(): NodeMaterialConnectionPoint;
  63729. /**
  63730. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  63731. */
  63732. get hasTexture(): boolean;
  63733. /**
  63734. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  63735. */
  63736. get reflectionColor(): string;
  63737. protected _getTexture(): Nullable<BaseTexture>;
  63738. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63739. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63740. /**
  63741. * Gets the code to inject in the vertex shader
  63742. * @param state current state of the node material building
  63743. * @returns the shader code
  63744. */
  63745. handleVertexSide(state: NodeMaterialBuildState): string;
  63746. /**
  63747. * Gets the main code of the block (fragment side)
  63748. * @param state current state of the node material building
  63749. * @param normalVarName name of the existing variable corresponding to the normal
  63750. * @returns the shader code
  63751. */
  63752. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  63753. protected _buildBlock(state: NodeMaterialBuildState): this;
  63754. protected _dumpPropertiesCode(): string;
  63755. serialize(): any;
  63756. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63757. }
  63758. }
  63759. declare module BABYLON {
  63760. /**
  63761. * Block used to implement the sheen module of the PBR material
  63762. */
  63763. export class SheenBlock extends NodeMaterialBlock {
  63764. /**
  63765. * Create a new SheenBlock
  63766. * @param name defines the block name
  63767. */
  63768. constructor(name: string);
  63769. /**
  63770. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  63771. * It allows the strength of the sheen effect to not depend on the base color of the material,
  63772. * making it easier to setup and tweak the effect
  63773. */
  63774. albedoScaling: boolean;
  63775. /**
  63776. * Defines if the sheen is linked to the sheen color.
  63777. */
  63778. linkSheenWithAlbedo: boolean;
  63779. /**
  63780. * Initialize the block and prepare the context for build
  63781. * @param state defines the state that will be used for the build
  63782. */
  63783. initialize(state: NodeMaterialBuildState): void;
  63784. /**
  63785. * Gets the current class name
  63786. * @returns the class name
  63787. */
  63788. getClassName(): string;
  63789. /**
  63790. * Gets the intensity input component
  63791. */
  63792. get intensity(): NodeMaterialConnectionPoint;
  63793. /**
  63794. * Gets the color input component
  63795. */
  63796. get color(): NodeMaterialConnectionPoint;
  63797. /**
  63798. * Gets the roughness input component
  63799. */
  63800. get roughness(): NodeMaterialConnectionPoint;
  63801. /**
  63802. * Gets the sheen object output component
  63803. */
  63804. get sheen(): NodeMaterialConnectionPoint;
  63805. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63806. /**
  63807. * Gets the main code of the block (fragment side)
  63808. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63809. * @returns the shader code
  63810. */
  63811. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  63812. protected _buildBlock(state: NodeMaterialBuildState): this;
  63813. protected _dumpPropertiesCode(): string;
  63814. serialize(): any;
  63815. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63816. }
  63817. }
  63818. declare module BABYLON {
  63819. /**
  63820. * Block used to implement the reflectivity module of the PBR material
  63821. */
  63822. export class ReflectivityBlock extends NodeMaterialBlock {
  63823. private _metallicReflectanceColor;
  63824. private _metallicF0Factor;
  63825. /** @hidden */
  63826. _vMetallicReflectanceFactorsName: string;
  63827. /**
  63828. * The property below is set by the main PBR block prior to calling methods of this class.
  63829. */
  63830. /** @hidden */
  63831. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  63832. /**
  63833. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  63834. */
  63835. useAmbientOcclusionFromMetallicTextureRed: boolean;
  63836. /**
  63837. * Specifies if the metallic texture contains the metallness information in its blue channel.
  63838. */
  63839. useMetallnessFromMetallicTextureBlue: boolean;
  63840. /**
  63841. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  63842. */
  63843. useRoughnessFromMetallicTextureAlpha: boolean;
  63844. /**
  63845. * Specifies if the metallic texture contains the roughness information in its green channel.
  63846. */
  63847. useRoughnessFromMetallicTextureGreen: boolean;
  63848. /**
  63849. * Create a new ReflectivityBlock
  63850. * @param name defines the block name
  63851. */
  63852. constructor(name: string);
  63853. /**
  63854. * Initialize the block and prepare the context for build
  63855. * @param state defines the state that will be used for the build
  63856. */
  63857. initialize(state: NodeMaterialBuildState): void;
  63858. /**
  63859. * Gets the current class name
  63860. * @returns the class name
  63861. */
  63862. getClassName(): string;
  63863. /**
  63864. * Gets the metallic input component
  63865. */
  63866. get metallic(): NodeMaterialConnectionPoint;
  63867. /**
  63868. * Gets the roughness input component
  63869. */
  63870. get roughness(): NodeMaterialConnectionPoint;
  63871. /**
  63872. * Gets the texture input component
  63873. */
  63874. get texture(): NodeMaterialConnectionPoint;
  63875. /**
  63876. * Gets the reflectivity object output component
  63877. */
  63878. get reflectivity(): NodeMaterialConnectionPoint;
  63879. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63880. /**
  63881. * Gets the main code of the block (fragment side)
  63882. * @param state current state of the node material building
  63883. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  63884. * @returns the shader code
  63885. */
  63886. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  63887. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63888. protected _buildBlock(state: NodeMaterialBuildState): this;
  63889. protected _dumpPropertiesCode(): string;
  63890. serialize(): any;
  63891. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63892. }
  63893. }
  63894. declare module BABYLON {
  63895. /**
  63896. * Block used to implement the anisotropy module of the PBR material
  63897. */
  63898. export class AnisotropyBlock extends NodeMaterialBlock {
  63899. /**
  63900. * The two properties below are set by the main PBR block prior to calling methods of this class.
  63901. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  63902. * It's less burden on the user side in the editor part.
  63903. */
  63904. /** @hidden */
  63905. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  63906. /** @hidden */
  63907. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  63908. /**
  63909. * Create a new AnisotropyBlock
  63910. * @param name defines the block name
  63911. */
  63912. constructor(name: string);
  63913. /**
  63914. * Initialize the block and prepare the context for build
  63915. * @param state defines the state that will be used for the build
  63916. */
  63917. initialize(state: NodeMaterialBuildState): void;
  63918. /**
  63919. * Gets the current class name
  63920. * @returns the class name
  63921. */
  63922. getClassName(): string;
  63923. /**
  63924. * Gets the intensity input component
  63925. */
  63926. get intensity(): NodeMaterialConnectionPoint;
  63927. /**
  63928. * Gets the direction input component
  63929. */
  63930. get direction(): NodeMaterialConnectionPoint;
  63931. /**
  63932. * Gets the texture input component
  63933. */
  63934. get texture(): NodeMaterialConnectionPoint;
  63935. /**
  63936. * Gets the uv input component
  63937. */
  63938. get uv(): NodeMaterialConnectionPoint;
  63939. /**
  63940. * Gets the worldTangent input component
  63941. */
  63942. get worldTangent(): NodeMaterialConnectionPoint;
  63943. /**
  63944. * Gets the anisotropy object output component
  63945. */
  63946. get anisotropy(): NodeMaterialConnectionPoint;
  63947. private _generateTBNSpace;
  63948. /**
  63949. * Gets the main code of the block (fragment side)
  63950. * @param state current state of the node material building
  63951. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  63952. * @returns the shader code
  63953. */
  63954. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  63955. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63956. protected _buildBlock(state: NodeMaterialBuildState): this;
  63957. }
  63958. }
  63959. declare module BABYLON {
  63960. /**
  63961. * Block used to implement the clear coat module of the PBR material
  63962. */
  63963. export class ClearCoatBlock extends NodeMaterialBlock {
  63964. private _scene;
  63965. /**
  63966. * Create a new ClearCoatBlock
  63967. * @param name defines the block name
  63968. */
  63969. constructor(name: string);
  63970. /**
  63971. * Initialize the block and prepare the context for build
  63972. * @param state defines the state that will be used for the build
  63973. */
  63974. initialize(state: NodeMaterialBuildState): void;
  63975. /**
  63976. * Gets the current class name
  63977. * @returns the class name
  63978. */
  63979. getClassName(): string;
  63980. /**
  63981. * Gets the intensity input component
  63982. */
  63983. get intensity(): NodeMaterialConnectionPoint;
  63984. /**
  63985. * Gets the roughness input component
  63986. */
  63987. get roughness(): NodeMaterialConnectionPoint;
  63988. /**
  63989. * Gets the ior input component
  63990. */
  63991. get ior(): NodeMaterialConnectionPoint;
  63992. /**
  63993. * Gets the texture input component
  63994. */
  63995. get texture(): NodeMaterialConnectionPoint;
  63996. /**
  63997. * Gets the bump texture input component
  63998. */
  63999. get bumpTexture(): NodeMaterialConnectionPoint;
  64000. /**
  64001. * Gets the uv input component
  64002. */
  64003. get uv(): NodeMaterialConnectionPoint;
  64004. /**
  64005. * Gets the tint color input component
  64006. */
  64007. get tintColor(): NodeMaterialConnectionPoint;
  64008. /**
  64009. * Gets the tint "at distance" input component
  64010. */
  64011. get tintAtDistance(): NodeMaterialConnectionPoint;
  64012. /**
  64013. * Gets the tint thickness input component
  64014. */
  64015. get tintThickness(): NodeMaterialConnectionPoint;
  64016. /**
  64017. * Gets the world tangent input component
  64018. */
  64019. get worldTangent(): NodeMaterialConnectionPoint;
  64020. /**
  64021. * Gets the clear coat object output component
  64022. */
  64023. get clearcoat(): NodeMaterialConnectionPoint;
  64024. autoConfigure(material: NodeMaterial): void;
  64025. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64026. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64027. private _generateTBNSpace;
  64028. /**
  64029. * Gets the main code of the block (fragment side)
  64030. * @param state current state of the node material building
  64031. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  64032. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64033. * @param worldPosVarName name of the variable holding the world position
  64034. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64035. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  64036. * @param worldNormalVarName name of the variable holding the world normal
  64037. * @returns the shader code
  64038. */
  64039. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  64040. protected _buildBlock(state: NodeMaterialBuildState): this;
  64041. }
  64042. }
  64043. declare module BABYLON {
  64044. /**
  64045. * Block used to implement the sub surface module of the PBR material
  64046. */
  64047. export class SubSurfaceBlock extends NodeMaterialBlock {
  64048. /**
  64049. * Create a new SubSurfaceBlock
  64050. * @param name defines the block name
  64051. */
  64052. constructor(name: string);
  64053. /**
  64054. * Stores the intensity of the different subsurface effects in the thickness texture.
  64055. * * the green channel is the translucency intensity.
  64056. * * the blue channel is the scattering intensity.
  64057. * * the alpha channel is the refraction intensity.
  64058. */
  64059. useMaskFromThicknessTexture: boolean;
  64060. /**
  64061. * Initialize the block and prepare the context for build
  64062. * @param state defines the state that will be used for the build
  64063. */
  64064. initialize(state: NodeMaterialBuildState): void;
  64065. /**
  64066. * Gets the current class name
  64067. * @returns the class name
  64068. */
  64069. getClassName(): string;
  64070. /**
  64071. * Gets the min thickness input component
  64072. */
  64073. get minThickness(): NodeMaterialConnectionPoint;
  64074. /**
  64075. * Gets the max thickness input component
  64076. */
  64077. get maxThickness(): NodeMaterialConnectionPoint;
  64078. /**
  64079. * Gets the thickness texture component
  64080. */
  64081. get thicknessTexture(): NodeMaterialConnectionPoint;
  64082. /**
  64083. * Gets the tint color input component
  64084. */
  64085. get tintColor(): NodeMaterialConnectionPoint;
  64086. /**
  64087. * Gets the translucency intensity input component
  64088. */
  64089. get translucencyIntensity(): NodeMaterialConnectionPoint;
  64090. /**
  64091. * Gets the translucency diffusion distance input component
  64092. */
  64093. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  64094. /**
  64095. * Gets the refraction object parameters
  64096. */
  64097. get refraction(): NodeMaterialConnectionPoint;
  64098. /**
  64099. * Gets the sub surface object output component
  64100. */
  64101. get subsurface(): NodeMaterialConnectionPoint;
  64102. autoConfigure(material: NodeMaterial): void;
  64103. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64104. /**
  64105. * Gets the main code of the block (fragment side)
  64106. * @param state current state of the node material building
  64107. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  64108. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64109. * @param worldPosVarName name of the variable holding the world position
  64110. * @returns the shader code
  64111. */
  64112. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  64113. protected _buildBlock(state: NodeMaterialBuildState): this;
  64114. }
  64115. }
  64116. declare module BABYLON {
  64117. /**
  64118. * Block used to implement the PBR metallic/roughness model
  64119. */
  64120. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  64121. /**
  64122. * Gets or sets the light associated with this block
  64123. */
  64124. light: Nullable<Light>;
  64125. private _lightId;
  64126. private _scene;
  64127. private _environmentBRDFTexture;
  64128. private _environmentBrdfSamplerName;
  64129. private _vNormalWName;
  64130. private _invertNormalName;
  64131. /**
  64132. * Create a new ReflectionBlock
  64133. * @param name defines the block name
  64134. */
  64135. constructor(name: string);
  64136. /**
  64137. * Intensity of the direct lights e.g. the four lights available in your scene.
  64138. * This impacts both the direct diffuse and specular highlights.
  64139. */
  64140. directIntensity: number;
  64141. /**
  64142. * Intensity of the environment e.g. how much the environment will light the object
  64143. * either through harmonics for rough material or through the refelction for shiny ones.
  64144. */
  64145. environmentIntensity: number;
  64146. /**
  64147. * This is a special control allowing the reduction of the specular highlights coming from the
  64148. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  64149. */
  64150. specularIntensity: number;
  64151. /**
  64152. * Defines the falloff type used in this material.
  64153. * It by default is Physical.
  64154. */
  64155. lightFalloff: number;
  64156. /**
  64157. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  64158. */
  64159. useAlphaFromAlbedoTexture: boolean;
  64160. /**
  64161. * Specifies that alpha test should be used
  64162. */
  64163. useAlphaTest: boolean;
  64164. /**
  64165. * Defines the alpha limits in alpha test mode.
  64166. */
  64167. alphaTestCutoff: number;
  64168. /**
  64169. * Specifies that alpha blending should be used
  64170. */
  64171. useAlphaBlending: boolean;
  64172. /**
  64173. * Defines if the alpha value should be determined via the rgb values.
  64174. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  64175. */
  64176. opacityRGB: boolean;
  64177. /**
  64178. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  64179. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  64180. */
  64181. useRadianceOverAlpha: boolean;
  64182. /**
  64183. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  64184. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  64185. */
  64186. useSpecularOverAlpha: boolean;
  64187. /**
  64188. * Enables specular anti aliasing in the PBR shader.
  64189. * It will both interacts on the Geometry for analytical and IBL lighting.
  64190. * It also prefilter the roughness map based on the bump values.
  64191. */
  64192. enableSpecularAntiAliasing: boolean;
  64193. /**
  64194. * Enables realtime filtering on the texture.
  64195. */
  64196. realTimeFiltering: boolean;
  64197. /**
  64198. * Quality switch for realtime filtering
  64199. */
  64200. realTimeFilteringQuality: number;
  64201. /**
  64202. * Defines if the material uses energy conservation.
  64203. */
  64204. useEnergyConservation: boolean;
  64205. /**
  64206. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  64207. * too much the area relying on ambient texture to define their ambient occlusion.
  64208. */
  64209. useRadianceOcclusion: boolean;
  64210. /**
  64211. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  64212. * makes the reflect vector face the model (under horizon).
  64213. */
  64214. useHorizonOcclusion: boolean;
  64215. /**
  64216. * If set to true, no lighting calculations will be applied.
  64217. */
  64218. unlit: boolean;
  64219. /**
  64220. * Force normal to face away from face.
  64221. */
  64222. forceNormalForward: boolean;
  64223. /**
  64224. * Defines the material debug mode.
  64225. * It helps seeing only some components of the material while troubleshooting.
  64226. */
  64227. debugMode: number;
  64228. /**
  64229. * Specify from where on screen the debug mode should start.
  64230. * The value goes from -1 (full screen) to 1 (not visible)
  64231. * It helps with side by side comparison against the final render
  64232. * This defaults to 0
  64233. */
  64234. debugLimit: number;
  64235. /**
  64236. * As the default viewing range might not be enough (if the ambient is really small for instance)
  64237. * You can use the factor to better multiply the final value.
  64238. */
  64239. debugFactor: number;
  64240. /**
  64241. * Initialize the block and prepare the context for build
  64242. * @param state defines the state that will be used for the build
  64243. */
  64244. initialize(state: NodeMaterialBuildState): void;
  64245. /**
  64246. * Gets the current class name
  64247. * @returns the class name
  64248. */
  64249. getClassName(): string;
  64250. /**
  64251. * Gets the world position input component
  64252. */
  64253. get worldPosition(): NodeMaterialConnectionPoint;
  64254. /**
  64255. * Gets the world normal input component
  64256. */
  64257. get worldNormal(): NodeMaterialConnectionPoint;
  64258. /**
  64259. * Gets the perturbed normal input component
  64260. */
  64261. get perturbedNormal(): NodeMaterialConnectionPoint;
  64262. /**
  64263. * Gets the camera position input component
  64264. */
  64265. get cameraPosition(): NodeMaterialConnectionPoint;
  64266. /**
  64267. * Gets the base color input component
  64268. */
  64269. get baseColor(): NodeMaterialConnectionPoint;
  64270. /**
  64271. * Gets the opacity texture input component
  64272. */
  64273. get opacityTexture(): NodeMaterialConnectionPoint;
  64274. /**
  64275. * Gets the ambient color input component
  64276. */
  64277. get ambientColor(): NodeMaterialConnectionPoint;
  64278. /**
  64279. * Gets the reflectivity object parameters
  64280. */
  64281. get reflectivity(): NodeMaterialConnectionPoint;
  64282. /**
  64283. * Gets the ambient occlusion object parameters
  64284. */
  64285. get ambientOcclusion(): NodeMaterialConnectionPoint;
  64286. /**
  64287. * Gets the reflection object parameters
  64288. */
  64289. get reflection(): NodeMaterialConnectionPoint;
  64290. /**
  64291. * Gets the sheen object parameters
  64292. */
  64293. get sheen(): NodeMaterialConnectionPoint;
  64294. /**
  64295. * Gets the clear coat object parameters
  64296. */
  64297. get clearcoat(): NodeMaterialConnectionPoint;
  64298. /**
  64299. * Gets the sub surface object parameters
  64300. */
  64301. get subsurface(): NodeMaterialConnectionPoint;
  64302. /**
  64303. * Gets the anisotropy object parameters
  64304. */
  64305. get anisotropy(): NodeMaterialConnectionPoint;
  64306. /**
  64307. * Gets the ambient output component
  64308. */
  64309. get ambient(): NodeMaterialConnectionPoint;
  64310. /**
  64311. * Gets the diffuse output component
  64312. */
  64313. get diffuse(): NodeMaterialConnectionPoint;
  64314. /**
  64315. * Gets the specular output component
  64316. */
  64317. get specular(): NodeMaterialConnectionPoint;
  64318. /**
  64319. * Gets the sheen output component
  64320. */
  64321. get sheenDir(): NodeMaterialConnectionPoint;
  64322. /**
  64323. * Gets the clear coat output component
  64324. */
  64325. get clearcoatDir(): NodeMaterialConnectionPoint;
  64326. /**
  64327. * Gets the indirect diffuse output component
  64328. */
  64329. get diffuseIndirect(): NodeMaterialConnectionPoint;
  64330. /**
  64331. * Gets the indirect specular output component
  64332. */
  64333. get specularIndirect(): NodeMaterialConnectionPoint;
  64334. /**
  64335. * Gets the indirect sheen output component
  64336. */
  64337. get sheenIndirect(): NodeMaterialConnectionPoint;
  64338. /**
  64339. * Gets the indirect clear coat output component
  64340. */
  64341. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  64342. /**
  64343. * Gets the refraction output component
  64344. */
  64345. get refraction(): NodeMaterialConnectionPoint;
  64346. /**
  64347. * Gets the global lighting output component
  64348. */
  64349. get lighting(): NodeMaterialConnectionPoint;
  64350. /**
  64351. * Gets the shadow output component
  64352. */
  64353. get shadow(): NodeMaterialConnectionPoint;
  64354. /**
  64355. * Gets the alpha output component
  64356. */
  64357. get alpha(): NodeMaterialConnectionPoint;
  64358. autoConfigure(material: NodeMaterial): void;
  64359. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64360. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64361. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64362. private _injectVertexCode;
  64363. /**
  64364. * Gets the code corresponding to the albedo/opacity module
  64365. * @returns the shader code
  64366. */
  64367. getAlbedoOpacityCode(): string;
  64368. protected _buildBlock(state: NodeMaterialBuildState): this;
  64369. protected _dumpPropertiesCode(): string;
  64370. serialize(): any;
  64371. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64372. }
  64373. }
  64374. declare module BABYLON {
  64375. /**
  64376. * Block used to compute value of one parameter modulo another
  64377. */
  64378. export class ModBlock extends NodeMaterialBlock {
  64379. /**
  64380. * Creates a new ModBlock
  64381. * @param name defines the block name
  64382. */
  64383. constructor(name: string);
  64384. /**
  64385. * Gets the current class name
  64386. * @returns the class name
  64387. */
  64388. getClassName(): string;
  64389. /**
  64390. * Gets the left operand input component
  64391. */
  64392. get left(): NodeMaterialConnectionPoint;
  64393. /**
  64394. * Gets the right operand input component
  64395. */
  64396. get right(): NodeMaterialConnectionPoint;
  64397. /**
  64398. * Gets the output component
  64399. */
  64400. get output(): NodeMaterialConnectionPoint;
  64401. protected _buildBlock(state: NodeMaterialBuildState): this;
  64402. }
  64403. }
  64404. declare module BABYLON {
  64405. /**
  64406. * Helper class to push actions to a pool of workers.
  64407. */
  64408. export class WorkerPool implements IDisposable {
  64409. private _workerInfos;
  64410. private _pendingActions;
  64411. /**
  64412. * Constructor
  64413. * @param workers Array of workers to use for actions
  64414. */
  64415. constructor(workers: Array<Worker>);
  64416. /**
  64417. * Terminates all workers and clears any pending actions.
  64418. */
  64419. dispose(): void;
  64420. /**
  64421. * Pushes an action to the worker pool. If all the workers are active, the action will be
  64422. * pended until a worker has completed its action.
  64423. * @param action The action to perform. Call onComplete when the action is complete.
  64424. */
  64425. push(action: (worker: Worker, onComplete: () => void) => void): void;
  64426. private _execute;
  64427. }
  64428. }
  64429. declare module BABYLON {
  64430. /**
  64431. * Configuration for Draco compression
  64432. */
  64433. export interface IDracoCompressionConfiguration {
  64434. /**
  64435. * Configuration for the decoder.
  64436. */
  64437. decoder: {
  64438. /**
  64439. * The url to the WebAssembly module.
  64440. */
  64441. wasmUrl?: string;
  64442. /**
  64443. * The url to the WebAssembly binary.
  64444. */
  64445. wasmBinaryUrl?: string;
  64446. /**
  64447. * The url to the fallback JavaScript module.
  64448. */
  64449. fallbackUrl?: string;
  64450. };
  64451. }
  64452. /**
  64453. * Draco compression (https://google.github.io/draco/)
  64454. *
  64455. * This class wraps the Draco module.
  64456. *
  64457. * **Encoder**
  64458. *
  64459. * The encoder is not currently implemented.
  64460. *
  64461. * **Decoder**
  64462. *
  64463. * 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.
  64464. *
  64465. * To update the configuration, use the following code:
  64466. * ```javascript
  64467. * DracoCompression.Configuration = {
  64468. * decoder: {
  64469. * wasmUrl: "<url to the WebAssembly library>",
  64470. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  64471. * fallbackUrl: "<url to the fallback JavaScript library>",
  64472. * }
  64473. * };
  64474. * ```
  64475. *
  64476. * 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.
  64477. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  64478. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  64479. *
  64480. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  64481. * ```javascript
  64482. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  64483. * ```
  64484. *
  64485. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  64486. */
  64487. export class DracoCompression implements IDisposable {
  64488. private _workerPoolPromise?;
  64489. private _decoderModulePromise?;
  64490. /**
  64491. * The configuration. Defaults to the following urls:
  64492. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  64493. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  64494. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  64495. */
  64496. static Configuration: IDracoCompressionConfiguration;
  64497. /**
  64498. * Returns true if the decoder configuration is available.
  64499. */
  64500. static get DecoderAvailable(): boolean;
  64501. /**
  64502. * Default number of workers to create when creating the draco compression object.
  64503. */
  64504. static DefaultNumWorkers: number;
  64505. private static GetDefaultNumWorkers;
  64506. private static _Default;
  64507. /**
  64508. * Default instance for the draco compression object.
  64509. */
  64510. static get Default(): DracoCompression;
  64511. /**
  64512. * Constructor
  64513. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  64514. */
  64515. constructor(numWorkers?: number);
  64516. /**
  64517. * Stop all async operations and release resources.
  64518. */
  64519. dispose(): void;
  64520. /**
  64521. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  64522. * @returns a promise that resolves when ready
  64523. */
  64524. whenReadyAsync(): Promise<void>;
  64525. /**
  64526. * Decode Draco compressed mesh data to vertex data.
  64527. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  64528. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  64529. * @returns A promise that resolves with the decoded vertex data
  64530. */
  64531. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  64532. [kind: string]: number;
  64533. }): Promise<VertexData>;
  64534. }
  64535. }
  64536. declare module BABYLON {
  64537. /**
  64538. * Class for building Constructive Solid Geometry
  64539. */
  64540. export class CSG {
  64541. private polygons;
  64542. /**
  64543. * The world matrix
  64544. */
  64545. matrix: Matrix;
  64546. /**
  64547. * Stores the position
  64548. */
  64549. position: Vector3;
  64550. /**
  64551. * Stores the rotation
  64552. */
  64553. rotation: Vector3;
  64554. /**
  64555. * Stores the rotation quaternion
  64556. */
  64557. rotationQuaternion: Nullable<Quaternion>;
  64558. /**
  64559. * Stores the scaling vector
  64560. */
  64561. scaling: Vector3;
  64562. /**
  64563. * Convert the Mesh to CSG
  64564. * @param mesh The Mesh to convert to CSG
  64565. * @returns A new CSG from the Mesh
  64566. */
  64567. static FromMesh(mesh: Mesh): CSG;
  64568. /**
  64569. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  64570. * @param polygons Polygons used to construct a CSG solid
  64571. */
  64572. private static FromPolygons;
  64573. /**
  64574. * Clones, or makes a deep copy, of the CSG
  64575. * @returns A new CSG
  64576. */
  64577. clone(): CSG;
  64578. /**
  64579. * Unions this CSG with another CSG
  64580. * @param csg The CSG to union against this CSG
  64581. * @returns The unioned CSG
  64582. */
  64583. union(csg: CSG): CSG;
  64584. /**
  64585. * Unions this CSG with another CSG in place
  64586. * @param csg The CSG to union against this CSG
  64587. */
  64588. unionInPlace(csg: CSG): void;
  64589. /**
  64590. * Subtracts this CSG with another CSG
  64591. * @param csg The CSG to subtract against this CSG
  64592. * @returns A new CSG
  64593. */
  64594. subtract(csg: CSG): CSG;
  64595. /**
  64596. * Subtracts this CSG with another CSG in place
  64597. * @param csg The CSG to subtact against this CSG
  64598. */
  64599. subtractInPlace(csg: CSG): void;
  64600. /**
  64601. * Intersect this CSG with another CSG
  64602. * @param csg The CSG to intersect against this CSG
  64603. * @returns A new CSG
  64604. */
  64605. intersect(csg: CSG): CSG;
  64606. /**
  64607. * Intersects this CSG with another CSG in place
  64608. * @param csg The CSG to intersect against this CSG
  64609. */
  64610. intersectInPlace(csg: CSG): void;
  64611. /**
  64612. * Return a new CSG solid with solid and empty space switched. This solid is
  64613. * not modified.
  64614. * @returns A new CSG solid with solid and empty space switched
  64615. */
  64616. inverse(): CSG;
  64617. /**
  64618. * Inverses the CSG in place
  64619. */
  64620. inverseInPlace(): void;
  64621. /**
  64622. * This is used to keep meshes transformations so they can be restored
  64623. * when we build back a Babylon Mesh
  64624. * NB : All CSG operations are performed in world coordinates
  64625. * @param csg The CSG to copy the transform attributes from
  64626. * @returns This CSG
  64627. */
  64628. copyTransformAttributes(csg: CSG): CSG;
  64629. /**
  64630. * Build Raw mesh from CSG
  64631. * Coordinates here are in world space
  64632. * @param name The name of the mesh geometry
  64633. * @param scene The Scene
  64634. * @param keepSubMeshes Specifies if the submeshes should be kept
  64635. * @returns A new Mesh
  64636. */
  64637. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64638. /**
  64639. * Build Mesh from CSG taking material and transforms into account
  64640. * @param name The name of the Mesh
  64641. * @param material The material of the Mesh
  64642. * @param scene The Scene
  64643. * @param keepSubMeshes Specifies if submeshes should be kept
  64644. * @returns The new Mesh
  64645. */
  64646. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64647. }
  64648. }
  64649. declare module BABYLON {
  64650. /**
  64651. * Class used to create a trail following a mesh
  64652. */
  64653. export class TrailMesh extends Mesh {
  64654. private _generator;
  64655. private _autoStart;
  64656. private _running;
  64657. private _diameter;
  64658. private _length;
  64659. private _sectionPolygonPointsCount;
  64660. private _sectionVectors;
  64661. private _sectionNormalVectors;
  64662. private _beforeRenderObserver;
  64663. /**
  64664. * @constructor
  64665. * @param name The value used by scene.getMeshByName() to do a lookup.
  64666. * @param generator The mesh or transform node to generate a trail.
  64667. * @param scene The scene to add this mesh to.
  64668. * @param diameter Diameter of trailing mesh. Default is 1.
  64669. * @param length Length of trailing mesh. Default is 60.
  64670. * @param autoStart Automatically start trailing mesh. Default true.
  64671. */
  64672. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  64673. /**
  64674. * "TrailMesh"
  64675. * @returns "TrailMesh"
  64676. */
  64677. getClassName(): string;
  64678. private _createMesh;
  64679. /**
  64680. * Start trailing mesh.
  64681. */
  64682. start(): void;
  64683. /**
  64684. * Stop trailing mesh.
  64685. */
  64686. stop(): void;
  64687. /**
  64688. * Update trailing mesh geometry.
  64689. */
  64690. update(): void;
  64691. /**
  64692. * Returns a new TrailMesh object.
  64693. * @param name is a string, the name given to the new mesh
  64694. * @param newGenerator use new generator object for cloned trail mesh
  64695. * @returns a new mesh
  64696. */
  64697. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  64698. /**
  64699. * Serializes this trail mesh
  64700. * @param serializationObject object to write serialization to
  64701. */
  64702. serialize(serializationObject: any): void;
  64703. /**
  64704. * Parses a serialized trail mesh
  64705. * @param parsedMesh the serialized mesh
  64706. * @param scene the scene to create the trail mesh in
  64707. * @returns the created trail mesh
  64708. */
  64709. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  64710. }
  64711. }
  64712. declare module BABYLON {
  64713. /**
  64714. * Class containing static functions to help procedurally build meshes
  64715. */
  64716. export class TiledBoxBuilder {
  64717. /**
  64718. * Creates a box mesh
  64719. * 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)
  64720. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64721. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64722. * * 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
  64723. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64724. * @param name defines the name of the mesh
  64725. * @param options defines the options used to create the mesh
  64726. * @param scene defines the hosting scene
  64727. * @returns the box mesh
  64728. */
  64729. static CreateTiledBox(name: string, options: {
  64730. pattern?: number;
  64731. width?: number;
  64732. height?: number;
  64733. depth?: number;
  64734. tileSize?: number;
  64735. tileWidth?: number;
  64736. tileHeight?: number;
  64737. alignHorizontal?: number;
  64738. alignVertical?: number;
  64739. faceUV?: Vector4[];
  64740. faceColors?: Color4[];
  64741. sideOrientation?: number;
  64742. updatable?: boolean;
  64743. }, scene?: Nullable<Scene>): Mesh;
  64744. }
  64745. }
  64746. declare module BABYLON {
  64747. /**
  64748. * Class containing static functions to help procedurally build meshes
  64749. */
  64750. export class TorusKnotBuilder {
  64751. /**
  64752. * Creates a torus knot mesh
  64753. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64754. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64755. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64756. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64757. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64758. * * 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
  64759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64760. * @param name defines the name of the mesh
  64761. * @param options defines the options used to create the mesh
  64762. * @param scene defines the hosting scene
  64763. * @returns the torus knot mesh
  64764. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64765. */
  64766. static CreateTorusKnot(name: string, options: {
  64767. radius?: number;
  64768. tube?: number;
  64769. radialSegments?: number;
  64770. tubularSegments?: number;
  64771. p?: number;
  64772. q?: number;
  64773. updatable?: boolean;
  64774. sideOrientation?: number;
  64775. frontUVs?: Vector4;
  64776. backUVs?: Vector4;
  64777. }, scene: any): Mesh;
  64778. }
  64779. }
  64780. declare module BABYLON {
  64781. /**
  64782. * Polygon
  64783. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  64784. */
  64785. export class Polygon {
  64786. /**
  64787. * Creates a rectangle
  64788. * @param xmin bottom X coord
  64789. * @param ymin bottom Y coord
  64790. * @param xmax top X coord
  64791. * @param ymax top Y coord
  64792. * @returns points that make the resulting rectation
  64793. */
  64794. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  64795. /**
  64796. * Creates a circle
  64797. * @param radius radius of circle
  64798. * @param cx scale in x
  64799. * @param cy scale in y
  64800. * @param numberOfSides number of sides that make up the circle
  64801. * @returns points that make the resulting circle
  64802. */
  64803. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  64804. /**
  64805. * Creates a polygon from input string
  64806. * @param input Input polygon data
  64807. * @returns the parsed points
  64808. */
  64809. static Parse(input: string): Vector2[];
  64810. /**
  64811. * Starts building a polygon from x and y coordinates
  64812. * @param x x coordinate
  64813. * @param y y coordinate
  64814. * @returns the started path2
  64815. */
  64816. static StartingAt(x: number, y: number): Path2;
  64817. }
  64818. /**
  64819. * Builds a polygon
  64820. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  64821. */
  64822. export class PolygonMeshBuilder {
  64823. private _points;
  64824. private _outlinepoints;
  64825. private _holes;
  64826. private _name;
  64827. private _scene;
  64828. private _epoints;
  64829. private _eholes;
  64830. private _addToepoint;
  64831. /**
  64832. * Babylon reference to the earcut plugin.
  64833. */
  64834. bjsEarcut: any;
  64835. /**
  64836. * Creates a PolygonMeshBuilder
  64837. * @param name name of the builder
  64838. * @param contours Path of the polygon
  64839. * @param scene scene to add to when creating the mesh
  64840. * @param earcutInjection can be used to inject your own earcut reference
  64841. */
  64842. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  64843. /**
  64844. * Adds a whole within the polygon
  64845. * @param hole Array of points defining the hole
  64846. * @returns this
  64847. */
  64848. addHole(hole: Vector2[]): PolygonMeshBuilder;
  64849. /**
  64850. * Creates the polygon
  64851. * @param updatable If the mesh should be updatable
  64852. * @param depth The depth of the mesh created
  64853. * @returns the created mesh
  64854. */
  64855. build(updatable?: boolean, depth?: number): Mesh;
  64856. /**
  64857. * Creates the polygon
  64858. * @param depth The depth of the mesh created
  64859. * @returns the created VertexData
  64860. */
  64861. buildVertexData(depth?: number): VertexData;
  64862. /**
  64863. * Adds a side to the polygon
  64864. * @param positions points that make the polygon
  64865. * @param normals normals of the polygon
  64866. * @param uvs uvs of the polygon
  64867. * @param indices indices of the polygon
  64868. * @param bounds bounds of the polygon
  64869. * @param points points of the polygon
  64870. * @param depth depth of the polygon
  64871. * @param flip flip of the polygon
  64872. */
  64873. private addSide;
  64874. }
  64875. }
  64876. declare module BABYLON {
  64877. /**
  64878. * Class containing static functions to help procedurally build meshes
  64879. */
  64880. export class PolygonBuilder {
  64881. /**
  64882. * Creates a polygon mesh
  64883. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64884. * * 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
  64885. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64886. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64887. * * 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)
  64888. * * Remember you can only change the shape positions, not their number when updating a polygon
  64889. * @param name defines the name of the mesh
  64890. * @param options defines the options used to create the mesh
  64891. * @param scene defines the hosting scene
  64892. * @param earcutInjection can be used to inject your own earcut reference
  64893. * @returns the polygon mesh
  64894. */
  64895. static CreatePolygon(name: string, options: {
  64896. shape: Vector3[];
  64897. holes?: Vector3[][];
  64898. depth?: number;
  64899. faceUV?: Vector4[];
  64900. faceColors?: Color4[];
  64901. updatable?: boolean;
  64902. sideOrientation?: number;
  64903. frontUVs?: Vector4;
  64904. backUVs?: Vector4;
  64905. wrap?: boolean;
  64906. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64907. /**
  64908. * Creates an extruded polygon mesh, with depth in the Y direction.
  64909. * * 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)
  64910. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64911. * @param name defines the name of the mesh
  64912. * @param options defines the options used to create the mesh
  64913. * @param scene defines the hosting scene
  64914. * @param earcutInjection can be used to inject your own earcut reference
  64915. * @returns the polygon mesh
  64916. */
  64917. static ExtrudePolygon(name: string, options: {
  64918. shape: Vector3[];
  64919. holes?: Vector3[][];
  64920. depth?: number;
  64921. faceUV?: Vector4[];
  64922. faceColors?: Color4[];
  64923. updatable?: boolean;
  64924. sideOrientation?: number;
  64925. frontUVs?: Vector4;
  64926. backUVs?: Vector4;
  64927. wrap?: boolean;
  64928. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64929. }
  64930. }
  64931. declare module BABYLON {
  64932. /**
  64933. * Class containing static functions to help procedurally build meshes
  64934. */
  64935. export class LatheBuilder {
  64936. /**
  64937. * Creates lathe mesh.
  64938. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64939. * * 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
  64940. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64941. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64942. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64943. * * 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
  64944. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64945. * * 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
  64946. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64947. * * 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
  64948. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64949. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64950. * @param name defines the name of the mesh
  64951. * @param options defines the options used to create the mesh
  64952. * @param scene defines the hosting scene
  64953. * @returns the lathe mesh
  64954. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64955. */
  64956. static CreateLathe(name: string, options: {
  64957. shape: Vector3[];
  64958. radius?: number;
  64959. tessellation?: number;
  64960. clip?: number;
  64961. arc?: number;
  64962. closed?: boolean;
  64963. updatable?: boolean;
  64964. sideOrientation?: number;
  64965. frontUVs?: Vector4;
  64966. backUVs?: Vector4;
  64967. cap?: number;
  64968. invertUV?: boolean;
  64969. }, scene?: Nullable<Scene>): Mesh;
  64970. }
  64971. }
  64972. declare module BABYLON {
  64973. /**
  64974. * Class containing static functions to help procedurally build meshes
  64975. */
  64976. export class TiledPlaneBuilder {
  64977. /**
  64978. * Creates a tiled plane mesh
  64979. * * The parameter `pattern` will, depending on value, do nothing or
  64980. * * * flip (reflect about central vertical) alternate tiles across and up
  64981. * * * flip every tile on alternate rows
  64982. * * * rotate (180 degs) alternate tiles across and up
  64983. * * * rotate every tile on alternate rows
  64984. * * * flip and rotate alternate tiles across and up
  64985. * * * flip and rotate every tile on alternate rows
  64986. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  64987. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  64988. * * 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
  64989. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64990. * * 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)
  64991. * * 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)
  64992. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64993. * @param name defines the name of the mesh
  64994. * @param options defines the options used to create the mesh
  64995. * @param scene defines the hosting scene
  64996. * @returns the box mesh
  64997. */
  64998. static CreateTiledPlane(name: string, options: {
  64999. pattern?: number;
  65000. tileSize?: number;
  65001. tileWidth?: number;
  65002. tileHeight?: number;
  65003. size?: number;
  65004. width?: number;
  65005. height?: number;
  65006. alignHorizontal?: number;
  65007. alignVertical?: number;
  65008. sideOrientation?: number;
  65009. frontUVs?: Vector4;
  65010. backUVs?: Vector4;
  65011. updatable?: boolean;
  65012. }, scene?: Nullable<Scene>): Mesh;
  65013. }
  65014. }
  65015. declare module BABYLON {
  65016. /**
  65017. * Class containing static functions to help procedurally build meshes
  65018. */
  65019. export class TubeBuilder {
  65020. /**
  65021. * Creates a tube mesh.
  65022. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65023. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65024. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65025. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65026. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65027. * * 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)
  65028. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65029. * * 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
  65030. * * 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
  65031. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65032. * * 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
  65033. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65034. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65035. * @param name defines the name of the mesh
  65036. * @param options defines the options used to create the mesh
  65037. * @param scene defines the hosting scene
  65038. * @returns the tube mesh
  65039. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65040. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65041. */
  65042. static CreateTube(name: string, options: {
  65043. path: Vector3[];
  65044. radius?: number;
  65045. tessellation?: number;
  65046. radiusFunction?: {
  65047. (i: number, distance: number): number;
  65048. };
  65049. cap?: number;
  65050. arc?: number;
  65051. updatable?: boolean;
  65052. sideOrientation?: number;
  65053. frontUVs?: Vector4;
  65054. backUVs?: Vector4;
  65055. instance?: Mesh;
  65056. invertUV?: boolean;
  65057. }, scene?: Nullable<Scene>): Mesh;
  65058. }
  65059. }
  65060. declare module BABYLON {
  65061. /**
  65062. * Class containing static functions to help procedurally build meshes
  65063. */
  65064. export class IcoSphereBuilder {
  65065. /**
  65066. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65067. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65068. * * 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`)
  65069. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65070. * * 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
  65071. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65072. * * 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
  65073. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65074. * @param name defines the name of the mesh
  65075. * @param options defines the options used to create the mesh
  65076. * @param scene defines the hosting scene
  65077. * @returns the icosahedron mesh
  65078. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65079. */
  65080. static CreateIcoSphere(name: string, options: {
  65081. radius?: number;
  65082. radiusX?: number;
  65083. radiusY?: number;
  65084. radiusZ?: number;
  65085. flat?: boolean;
  65086. subdivisions?: number;
  65087. sideOrientation?: number;
  65088. frontUVs?: Vector4;
  65089. backUVs?: Vector4;
  65090. updatable?: boolean;
  65091. }, scene?: Nullable<Scene>): Mesh;
  65092. }
  65093. }
  65094. declare module BABYLON {
  65095. /**
  65096. * Class containing static functions to help procedurally build meshes
  65097. */
  65098. export class DecalBuilder {
  65099. /**
  65100. * Creates a decal mesh.
  65101. * 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
  65102. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65103. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65104. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65105. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65106. * @param name defines the name of the mesh
  65107. * @param sourceMesh defines the mesh where the decal must be applied
  65108. * @param options defines the options used to create the mesh
  65109. * @param scene defines the hosting scene
  65110. * @returns the decal mesh
  65111. * @see https://doc.babylonjs.com/how_to/decals
  65112. */
  65113. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65114. position?: Vector3;
  65115. normal?: Vector3;
  65116. size?: Vector3;
  65117. angle?: number;
  65118. }): Mesh;
  65119. }
  65120. }
  65121. declare module BABYLON {
  65122. /**
  65123. * Class containing static functions to help procedurally build meshes
  65124. */
  65125. export class MeshBuilder {
  65126. /**
  65127. * Creates a box mesh
  65128. * * The parameter `size` sets the size (float) of each box side (default 1)
  65129. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  65130. * * 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)
  65131. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65132. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65133. * * 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
  65134. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65135. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65136. * @param name defines the name of the mesh
  65137. * @param options defines the options used to create the mesh
  65138. * @param scene defines the hosting scene
  65139. * @returns the box mesh
  65140. */
  65141. static CreateBox(name: string, options: {
  65142. size?: number;
  65143. width?: number;
  65144. height?: number;
  65145. depth?: number;
  65146. faceUV?: Vector4[];
  65147. faceColors?: Color4[];
  65148. sideOrientation?: number;
  65149. frontUVs?: Vector4;
  65150. backUVs?: Vector4;
  65151. wrap?: boolean;
  65152. topBaseAt?: number;
  65153. bottomBaseAt?: number;
  65154. updatable?: boolean;
  65155. }, scene?: Nullable<Scene>): Mesh;
  65156. /**
  65157. * Creates a tiled box mesh
  65158. * * faceTiles sets the pattern, tile size and number of tiles for a face
  65159. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65160. * @param name defines the name of the mesh
  65161. * @param options defines the options used to create the mesh
  65162. * @param scene defines the hosting scene
  65163. * @returns the tiled box mesh
  65164. */
  65165. static CreateTiledBox(name: string, options: {
  65166. pattern?: number;
  65167. size?: number;
  65168. width?: number;
  65169. height?: number;
  65170. depth: number;
  65171. tileSize?: number;
  65172. tileWidth?: number;
  65173. tileHeight?: number;
  65174. faceUV?: Vector4[];
  65175. faceColors?: Color4[];
  65176. alignHorizontal?: number;
  65177. alignVertical?: number;
  65178. sideOrientation?: number;
  65179. updatable?: boolean;
  65180. }, scene?: Nullable<Scene>): Mesh;
  65181. /**
  65182. * Creates a sphere mesh
  65183. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  65184. * * 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`)
  65185. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  65186. * * 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
  65187. * * 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)
  65188. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65189. * * 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
  65190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65191. * @param name defines the name of the mesh
  65192. * @param options defines the options used to create the mesh
  65193. * @param scene defines the hosting scene
  65194. * @returns the sphere mesh
  65195. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  65196. */
  65197. static CreateSphere(name: string, options: {
  65198. segments?: number;
  65199. diameter?: number;
  65200. diameterX?: number;
  65201. diameterY?: number;
  65202. diameterZ?: number;
  65203. arc?: number;
  65204. slice?: number;
  65205. sideOrientation?: number;
  65206. frontUVs?: Vector4;
  65207. backUVs?: Vector4;
  65208. updatable?: boolean;
  65209. }, scene?: Nullable<Scene>): Mesh;
  65210. /**
  65211. * Creates a plane polygonal mesh. By default, this is a disc
  65212. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  65213. * * 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
  65214. * * 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
  65215. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65216. * * 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
  65217. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65218. * @param name defines the name of the mesh
  65219. * @param options defines the options used to create the mesh
  65220. * @param scene defines the hosting scene
  65221. * @returns the plane polygonal mesh
  65222. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  65223. */
  65224. static CreateDisc(name: string, options: {
  65225. radius?: number;
  65226. tessellation?: number;
  65227. arc?: number;
  65228. updatable?: boolean;
  65229. sideOrientation?: number;
  65230. frontUVs?: Vector4;
  65231. backUVs?: Vector4;
  65232. }, scene?: Nullable<Scene>): Mesh;
  65233. /**
  65234. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65235. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65236. * * 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`)
  65237. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65238. * * 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
  65239. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65240. * * 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
  65241. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65242. * @param name defines the name of the mesh
  65243. * @param options defines the options used to create the mesh
  65244. * @param scene defines the hosting scene
  65245. * @returns the icosahedron mesh
  65246. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65247. */
  65248. static CreateIcoSphere(name: string, options: {
  65249. radius?: number;
  65250. radiusX?: number;
  65251. radiusY?: number;
  65252. radiusZ?: number;
  65253. flat?: boolean;
  65254. subdivisions?: number;
  65255. sideOrientation?: number;
  65256. frontUVs?: Vector4;
  65257. backUVs?: Vector4;
  65258. updatable?: boolean;
  65259. }, scene?: Nullable<Scene>): Mesh;
  65260. /**
  65261. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65262. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  65263. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  65264. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  65265. * * 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
  65266. * * 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
  65267. * * 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
  65268. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65269. * * 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
  65270. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65271. * * 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
  65272. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  65273. * * 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
  65274. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  65275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65276. * @param name defines the name of the mesh
  65277. * @param options defines the options used to create the mesh
  65278. * @param scene defines the hosting scene
  65279. * @returns the ribbon mesh
  65280. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  65281. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65282. */
  65283. static CreateRibbon(name: string, options: {
  65284. pathArray: Vector3[][];
  65285. closeArray?: boolean;
  65286. closePath?: boolean;
  65287. offset?: number;
  65288. updatable?: boolean;
  65289. sideOrientation?: number;
  65290. frontUVs?: Vector4;
  65291. backUVs?: Vector4;
  65292. instance?: Mesh;
  65293. invertUV?: boolean;
  65294. uvs?: Vector2[];
  65295. colors?: Color4[];
  65296. }, scene?: Nullable<Scene>): Mesh;
  65297. /**
  65298. * Creates a cylinder or a cone mesh
  65299. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  65300. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  65301. * * 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.
  65302. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  65303. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  65304. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  65305. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  65306. * * 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).
  65307. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  65308. * * 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).
  65309. * * 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
  65310. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  65311. * * 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
  65312. * * 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.
  65313. * * If `enclose` is false, a ring surface is one element.
  65314. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  65315. * * 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
  65316. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65317. * * 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
  65318. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65319. * @param name defines the name of the mesh
  65320. * @param options defines the options used to create the mesh
  65321. * @param scene defines the hosting scene
  65322. * @returns the cylinder mesh
  65323. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  65324. */
  65325. static CreateCylinder(name: string, options: {
  65326. height?: number;
  65327. diameterTop?: number;
  65328. diameterBottom?: number;
  65329. diameter?: number;
  65330. tessellation?: number;
  65331. subdivisions?: number;
  65332. arc?: number;
  65333. faceColors?: Color4[];
  65334. faceUV?: Vector4[];
  65335. updatable?: boolean;
  65336. hasRings?: boolean;
  65337. enclose?: boolean;
  65338. cap?: number;
  65339. sideOrientation?: number;
  65340. frontUVs?: Vector4;
  65341. backUVs?: Vector4;
  65342. }, scene?: Nullable<Scene>): Mesh;
  65343. /**
  65344. * Creates a torus mesh
  65345. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  65346. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  65347. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  65348. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65349. * * 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
  65350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65351. * @param name defines the name of the mesh
  65352. * @param options defines the options used to create the mesh
  65353. * @param scene defines the hosting scene
  65354. * @returns the torus mesh
  65355. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  65356. */
  65357. static CreateTorus(name: string, options: {
  65358. diameter?: number;
  65359. thickness?: number;
  65360. tessellation?: number;
  65361. updatable?: boolean;
  65362. sideOrientation?: number;
  65363. frontUVs?: Vector4;
  65364. backUVs?: Vector4;
  65365. }, scene?: Nullable<Scene>): Mesh;
  65366. /**
  65367. * Creates a torus knot mesh
  65368. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65369. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65370. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65371. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65372. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65373. * * 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
  65374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65375. * @param name defines the name of the mesh
  65376. * @param options defines the options used to create the mesh
  65377. * @param scene defines the hosting scene
  65378. * @returns the torus knot mesh
  65379. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65380. */
  65381. static CreateTorusKnot(name: string, options: {
  65382. radius?: number;
  65383. tube?: number;
  65384. radialSegments?: number;
  65385. tubularSegments?: number;
  65386. p?: number;
  65387. q?: number;
  65388. updatable?: boolean;
  65389. sideOrientation?: number;
  65390. frontUVs?: Vector4;
  65391. backUVs?: Vector4;
  65392. }, scene?: Nullable<Scene>): Mesh;
  65393. /**
  65394. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  65395. * * 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
  65396. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  65397. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  65398. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  65399. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  65400. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  65401. * * 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
  65402. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  65403. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65404. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  65405. * @param name defines the name of the new line system
  65406. * @param options defines the options used to create the line system
  65407. * @param scene defines the hosting scene
  65408. * @returns a new line system mesh
  65409. */
  65410. static CreateLineSystem(name: string, options: {
  65411. lines: Vector3[][];
  65412. updatable?: boolean;
  65413. instance?: Nullable<LinesMesh>;
  65414. colors?: Nullable<Color4[][]>;
  65415. useVertexAlpha?: boolean;
  65416. }, scene: Nullable<Scene>): LinesMesh;
  65417. /**
  65418. * Creates a line mesh
  65419. * 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
  65420. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  65421. * * The parameter `points` is an array successive Vector3
  65422. * * 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
  65423. * * The optional parameter `colors` is an array of successive Color4, one per line point
  65424. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  65425. * * When updating an instance, remember that only point positions can change, not the number of points
  65426. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65427. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  65428. * @param name defines the name of the new line system
  65429. * @param options defines the options used to create the line system
  65430. * @param scene defines the hosting scene
  65431. * @returns a new line mesh
  65432. */
  65433. static CreateLines(name: string, options: {
  65434. points: Vector3[];
  65435. updatable?: boolean;
  65436. instance?: Nullable<LinesMesh>;
  65437. colors?: Color4[];
  65438. useVertexAlpha?: boolean;
  65439. }, scene?: Nullable<Scene>): LinesMesh;
  65440. /**
  65441. * Creates a dashed line mesh
  65442. * * 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
  65443. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  65444. * * The parameter `points` is an array successive Vector3
  65445. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  65446. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  65447. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  65448. * * 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
  65449. * * When updating an instance, remember that only point positions can change, not the number of points
  65450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65451. * @param name defines the name of the mesh
  65452. * @param options defines the options used to create the mesh
  65453. * @param scene defines the hosting scene
  65454. * @returns the dashed line mesh
  65455. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  65456. */
  65457. static CreateDashedLines(name: string, options: {
  65458. points: Vector3[];
  65459. dashSize?: number;
  65460. gapSize?: number;
  65461. dashNb?: number;
  65462. updatable?: boolean;
  65463. instance?: LinesMesh;
  65464. }, scene?: Nullable<Scene>): LinesMesh;
  65465. /**
  65466. * 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.
  65467. * * 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.
  65468. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65469. * * 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.
  65470. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  65471. * * 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
  65472. * * 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
  65473. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  65474. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65475. * * 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
  65476. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  65477. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65478. * @param name defines the name of the mesh
  65479. * @param options defines the options used to create the mesh
  65480. * @param scene defines the hosting scene
  65481. * @returns the extruded shape mesh
  65482. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65483. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65484. */
  65485. static ExtrudeShape(name: string, options: {
  65486. shape: Vector3[];
  65487. path: Vector3[];
  65488. scale?: number;
  65489. rotation?: number;
  65490. cap?: number;
  65491. updatable?: boolean;
  65492. sideOrientation?: number;
  65493. frontUVs?: Vector4;
  65494. backUVs?: Vector4;
  65495. instance?: Mesh;
  65496. invertUV?: boolean;
  65497. }, scene?: Nullable<Scene>): Mesh;
  65498. /**
  65499. * Creates an custom extruded shape mesh.
  65500. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  65501. * * 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.
  65502. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65503. * * 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
  65504. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  65505. * * 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
  65506. * * It must returns a float value that will be the scale value applied to the shape on each path point
  65507. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  65508. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  65509. * * 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
  65510. * * 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
  65511. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  65512. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65513. * * 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
  65514. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65516. * @param name defines the name of the mesh
  65517. * @param options defines the options used to create the mesh
  65518. * @param scene defines the hosting scene
  65519. * @returns the custom extruded shape mesh
  65520. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  65521. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65522. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65523. */
  65524. static ExtrudeShapeCustom(name: string, options: {
  65525. shape: Vector3[];
  65526. path: Vector3[];
  65527. scaleFunction?: any;
  65528. rotationFunction?: any;
  65529. ribbonCloseArray?: boolean;
  65530. ribbonClosePath?: boolean;
  65531. cap?: number;
  65532. updatable?: boolean;
  65533. sideOrientation?: number;
  65534. frontUVs?: Vector4;
  65535. backUVs?: Vector4;
  65536. instance?: Mesh;
  65537. invertUV?: boolean;
  65538. }, scene?: Nullable<Scene>): Mesh;
  65539. /**
  65540. * Creates lathe mesh.
  65541. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65542. * * 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
  65543. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65544. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65545. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65546. * * 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
  65547. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65548. * * 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
  65549. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65550. * * 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
  65551. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65553. * @param name defines the name of the mesh
  65554. * @param options defines the options used to create the mesh
  65555. * @param scene defines the hosting scene
  65556. * @returns the lathe mesh
  65557. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65558. */
  65559. static CreateLathe(name: string, options: {
  65560. shape: Vector3[];
  65561. radius?: number;
  65562. tessellation?: number;
  65563. clip?: number;
  65564. arc?: number;
  65565. closed?: boolean;
  65566. updatable?: boolean;
  65567. sideOrientation?: number;
  65568. frontUVs?: Vector4;
  65569. backUVs?: Vector4;
  65570. cap?: number;
  65571. invertUV?: boolean;
  65572. }, scene?: Nullable<Scene>): Mesh;
  65573. /**
  65574. * Creates a tiled plane mesh
  65575. * * You can set a limited pattern arrangement with the tiles
  65576. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65577. * * 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
  65578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65579. * @param name defines the name of the mesh
  65580. * @param options defines the options used to create the mesh
  65581. * @param scene defines the hosting scene
  65582. * @returns the plane mesh
  65583. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65584. */
  65585. static CreateTiledPlane(name: string, options: {
  65586. pattern?: number;
  65587. tileSize?: number;
  65588. tileWidth?: number;
  65589. tileHeight?: number;
  65590. size?: number;
  65591. width?: number;
  65592. height?: number;
  65593. alignHorizontal?: number;
  65594. alignVertical?: number;
  65595. sideOrientation?: number;
  65596. frontUVs?: Vector4;
  65597. backUVs?: Vector4;
  65598. updatable?: boolean;
  65599. }, scene?: Nullable<Scene>): Mesh;
  65600. /**
  65601. * Creates a plane mesh
  65602. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  65603. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  65604. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  65605. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65606. * * 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
  65607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65608. * @param name defines the name of the mesh
  65609. * @param options defines the options used to create the mesh
  65610. * @param scene defines the hosting scene
  65611. * @returns the plane mesh
  65612. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65613. */
  65614. static CreatePlane(name: string, options: {
  65615. size?: number;
  65616. width?: number;
  65617. height?: number;
  65618. sideOrientation?: number;
  65619. frontUVs?: Vector4;
  65620. backUVs?: Vector4;
  65621. updatable?: boolean;
  65622. sourcePlane?: Plane;
  65623. }, scene?: Nullable<Scene>): Mesh;
  65624. /**
  65625. * Creates a ground mesh
  65626. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  65627. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  65628. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65629. * @param name defines the name of the mesh
  65630. * @param options defines the options used to create the mesh
  65631. * @param scene defines the hosting scene
  65632. * @returns the ground mesh
  65633. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  65634. */
  65635. static CreateGround(name: string, options: {
  65636. width?: number;
  65637. height?: number;
  65638. subdivisions?: number;
  65639. subdivisionsX?: number;
  65640. subdivisionsY?: number;
  65641. updatable?: boolean;
  65642. }, scene?: Nullable<Scene>): Mesh;
  65643. /**
  65644. * Creates a tiled ground mesh
  65645. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  65646. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  65647. * * 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
  65648. * * 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
  65649. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65650. * @param name defines the name of the mesh
  65651. * @param options defines the options used to create the mesh
  65652. * @param scene defines the hosting scene
  65653. * @returns the tiled ground mesh
  65654. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  65655. */
  65656. static CreateTiledGround(name: string, options: {
  65657. xmin: number;
  65658. zmin: number;
  65659. xmax: number;
  65660. zmax: number;
  65661. subdivisions?: {
  65662. w: number;
  65663. h: number;
  65664. };
  65665. precision?: {
  65666. w: number;
  65667. h: number;
  65668. };
  65669. updatable?: boolean;
  65670. }, scene?: Nullable<Scene>): Mesh;
  65671. /**
  65672. * Creates a ground mesh from a height map
  65673. * * The parameter `url` sets the URL of the height map image resource.
  65674. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  65675. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  65676. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  65677. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  65678. * * 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.
  65679. * * 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).
  65680. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  65681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65682. * @param name defines the name of the mesh
  65683. * @param url defines the url to the height map
  65684. * @param options defines the options used to create the mesh
  65685. * @param scene defines the hosting scene
  65686. * @returns the ground mesh
  65687. * @see https://doc.babylonjs.com/babylon101/height_map
  65688. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  65689. */
  65690. static CreateGroundFromHeightMap(name: string, url: string, options: {
  65691. width?: number;
  65692. height?: number;
  65693. subdivisions?: number;
  65694. minHeight?: number;
  65695. maxHeight?: number;
  65696. colorFilter?: Color3;
  65697. alphaFilter?: number;
  65698. updatable?: boolean;
  65699. onReady?: (mesh: GroundMesh) => void;
  65700. }, scene?: Nullable<Scene>): GroundMesh;
  65701. /**
  65702. * Creates a polygon mesh
  65703. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65704. * * 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
  65705. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65706. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65707. * * 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)
  65708. * * Remember you can only change the shape positions, not their number when updating a polygon
  65709. * @param name defines the name of the mesh
  65710. * @param options defines the options used to create the mesh
  65711. * @param scene defines the hosting scene
  65712. * @param earcutInjection can be used to inject your own earcut reference
  65713. * @returns the polygon mesh
  65714. */
  65715. static CreatePolygon(name: string, options: {
  65716. shape: Vector3[];
  65717. holes?: Vector3[][];
  65718. depth?: number;
  65719. faceUV?: Vector4[];
  65720. faceColors?: Color4[];
  65721. updatable?: boolean;
  65722. sideOrientation?: number;
  65723. frontUVs?: Vector4;
  65724. backUVs?: Vector4;
  65725. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65726. /**
  65727. * Creates an extruded polygon mesh, with depth in the Y direction.
  65728. * * 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)
  65729. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65730. * @param name defines the name of the mesh
  65731. * @param options defines the options used to create the mesh
  65732. * @param scene defines the hosting scene
  65733. * @param earcutInjection can be used to inject your own earcut reference
  65734. * @returns the polygon mesh
  65735. */
  65736. static ExtrudePolygon(name: string, options: {
  65737. shape: Vector3[];
  65738. holes?: Vector3[][];
  65739. depth?: number;
  65740. faceUV?: Vector4[];
  65741. faceColors?: Color4[];
  65742. updatable?: boolean;
  65743. sideOrientation?: number;
  65744. frontUVs?: Vector4;
  65745. backUVs?: Vector4;
  65746. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65747. /**
  65748. * Creates a tube mesh.
  65749. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65750. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65751. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65752. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65753. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65754. * * 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)
  65755. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65756. * * 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
  65757. * * 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
  65758. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65759. * * 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
  65760. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65761. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65762. * @param name defines the name of the mesh
  65763. * @param options defines the options used to create the mesh
  65764. * @param scene defines the hosting scene
  65765. * @returns the tube mesh
  65766. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65767. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65768. */
  65769. static CreateTube(name: string, options: {
  65770. path: Vector3[];
  65771. radius?: number;
  65772. tessellation?: number;
  65773. radiusFunction?: {
  65774. (i: number, distance: number): number;
  65775. };
  65776. cap?: number;
  65777. arc?: number;
  65778. updatable?: boolean;
  65779. sideOrientation?: number;
  65780. frontUVs?: Vector4;
  65781. backUVs?: Vector4;
  65782. instance?: Mesh;
  65783. invertUV?: boolean;
  65784. }, scene?: Nullable<Scene>): Mesh;
  65785. /**
  65786. * Creates a polyhedron mesh
  65787. * * 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
  65788. * * The parameter `size` (positive float, default 1) sets the polygon size
  65789. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  65790. * * 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`
  65791. * * 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
  65792. * * 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)`)
  65793. * * 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
  65794. * * 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
  65795. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65796. * * 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
  65797. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65798. * @param name defines the name of the mesh
  65799. * @param options defines the options used to create the mesh
  65800. * @param scene defines the hosting scene
  65801. * @returns the polyhedron mesh
  65802. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  65803. */
  65804. static CreatePolyhedron(name: string, options: {
  65805. type?: number;
  65806. size?: number;
  65807. sizeX?: number;
  65808. sizeY?: number;
  65809. sizeZ?: number;
  65810. custom?: any;
  65811. faceUV?: Vector4[];
  65812. faceColors?: Color4[];
  65813. flat?: boolean;
  65814. updatable?: boolean;
  65815. sideOrientation?: number;
  65816. frontUVs?: Vector4;
  65817. backUVs?: Vector4;
  65818. }, scene?: Nullable<Scene>): Mesh;
  65819. /**
  65820. * Creates a decal mesh.
  65821. * 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
  65822. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65823. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65824. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65825. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65826. * @param name defines the name of the mesh
  65827. * @param sourceMesh defines the mesh where the decal must be applied
  65828. * @param options defines the options used to create the mesh
  65829. * @param scene defines the hosting scene
  65830. * @returns the decal mesh
  65831. * @see https://doc.babylonjs.com/how_to/decals
  65832. */
  65833. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65834. position?: Vector3;
  65835. normal?: Vector3;
  65836. size?: Vector3;
  65837. angle?: number;
  65838. }): Mesh;
  65839. }
  65840. }
  65841. declare module BABYLON {
  65842. /**
  65843. * A simplifier interface for future simplification implementations
  65844. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65845. */
  65846. export interface ISimplifier {
  65847. /**
  65848. * Simplification of a given mesh according to the given settings.
  65849. * Since this requires computation, it is assumed that the function runs async.
  65850. * @param settings The settings of the simplification, including quality and distance
  65851. * @param successCallback A callback that will be called after the mesh was simplified.
  65852. * @param errorCallback in case of an error, this callback will be called. optional.
  65853. */
  65854. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  65855. }
  65856. /**
  65857. * Expected simplification settings.
  65858. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  65859. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65860. */
  65861. export interface ISimplificationSettings {
  65862. /**
  65863. * Gets or sets the expected quality
  65864. */
  65865. quality: number;
  65866. /**
  65867. * Gets or sets the distance when this optimized version should be used
  65868. */
  65869. distance: number;
  65870. /**
  65871. * Gets an already optimized mesh
  65872. */
  65873. optimizeMesh?: boolean;
  65874. }
  65875. /**
  65876. * Class used to specify simplification options
  65877. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65878. */
  65879. export class SimplificationSettings implements ISimplificationSettings {
  65880. /** expected quality */
  65881. quality: number;
  65882. /** distance when this optimized version should be used */
  65883. distance: number;
  65884. /** already optimized mesh */
  65885. optimizeMesh?: boolean | undefined;
  65886. /**
  65887. * Creates a SimplificationSettings
  65888. * @param quality expected quality
  65889. * @param distance distance when this optimized version should be used
  65890. * @param optimizeMesh already optimized mesh
  65891. */
  65892. constructor(
  65893. /** expected quality */
  65894. quality: number,
  65895. /** distance when this optimized version should be used */
  65896. distance: number,
  65897. /** already optimized mesh */
  65898. optimizeMesh?: boolean | undefined);
  65899. }
  65900. /**
  65901. * Interface used to define a simplification task
  65902. */
  65903. export interface ISimplificationTask {
  65904. /**
  65905. * Array of settings
  65906. */
  65907. settings: Array<ISimplificationSettings>;
  65908. /**
  65909. * Simplification type
  65910. */
  65911. simplificationType: SimplificationType;
  65912. /**
  65913. * Mesh to simplify
  65914. */
  65915. mesh: Mesh;
  65916. /**
  65917. * Callback called on success
  65918. */
  65919. successCallback?: () => void;
  65920. /**
  65921. * Defines if parallel processing can be used
  65922. */
  65923. parallelProcessing: boolean;
  65924. }
  65925. /**
  65926. * Queue used to order the simplification tasks
  65927. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65928. */
  65929. export class SimplificationQueue {
  65930. private _simplificationArray;
  65931. /**
  65932. * Gets a boolean indicating that the process is still running
  65933. */
  65934. running: boolean;
  65935. /**
  65936. * Creates a new queue
  65937. */
  65938. constructor();
  65939. /**
  65940. * Adds a new simplification task
  65941. * @param task defines a task to add
  65942. */
  65943. addTask(task: ISimplificationTask): void;
  65944. /**
  65945. * Execute next task
  65946. */
  65947. executeNext(): void;
  65948. /**
  65949. * Execute a simplification task
  65950. * @param task defines the task to run
  65951. */
  65952. runSimplification(task: ISimplificationTask): void;
  65953. private getSimplifier;
  65954. }
  65955. /**
  65956. * The implemented types of simplification
  65957. * At the moment only Quadratic Error Decimation is implemented
  65958. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65959. */
  65960. export enum SimplificationType {
  65961. /** Quadratic error decimation */
  65962. QUADRATIC = 0
  65963. }
  65964. /**
  65965. * An implementation of the Quadratic Error simplification algorithm.
  65966. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  65967. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  65968. * @author RaananW
  65969. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65970. */
  65971. export class QuadraticErrorSimplification implements ISimplifier {
  65972. private _mesh;
  65973. private triangles;
  65974. private vertices;
  65975. private references;
  65976. private _reconstructedMesh;
  65977. /** Gets or sets the number pf sync interations */
  65978. syncIterations: number;
  65979. /** Gets or sets the aggressiveness of the simplifier */
  65980. aggressiveness: number;
  65981. /** Gets or sets the number of allowed iterations for decimation */
  65982. decimationIterations: number;
  65983. /** Gets or sets the espilon to use for bounding box computation */
  65984. boundingBoxEpsilon: number;
  65985. /**
  65986. * Creates a new QuadraticErrorSimplification
  65987. * @param _mesh defines the target mesh
  65988. */
  65989. constructor(_mesh: Mesh);
  65990. /**
  65991. * Simplification of a given mesh according to the given settings.
  65992. * Since this requires computation, it is assumed that the function runs async.
  65993. * @param settings The settings of the simplification, including quality and distance
  65994. * @param successCallback A callback that will be called after the mesh was simplified.
  65995. */
  65996. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  65997. private runDecimation;
  65998. private initWithMesh;
  65999. private init;
  66000. private reconstructMesh;
  66001. private initDecimatedMesh;
  66002. private isFlipped;
  66003. private updateTriangles;
  66004. private identifyBorder;
  66005. private updateMesh;
  66006. private vertexError;
  66007. private calculateError;
  66008. }
  66009. }
  66010. declare module BABYLON {
  66011. interface Scene {
  66012. /** @hidden (Backing field) */
  66013. _simplificationQueue: SimplificationQueue;
  66014. /**
  66015. * Gets or sets the simplification queue attached to the scene
  66016. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66017. */
  66018. simplificationQueue: SimplificationQueue;
  66019. }
  66020. interface Mesh {
  66021. /**
  66022. * Simplify the mesh according to the given array of settings.
  66023. * Function will return immediately and will simplify async
  66024. * @param settings a collection of simplification settings
  66025. * @param parallelProcessing should all levels calculate parallel or one after the other
  66026. * @param simplificationType the type of simplification to run
  66027. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  66028. * @returns the current mesh
  66029. */
  66030. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  66031. }
  66032. /**
  66033. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  66034. * created in a scene
  66035. */
  66036. export class SimplicationQueueSceneComponent implements ISceneComponent {
  66037. /**
  66038. * The component name helpfull to identify the component in the list of scene components.
  66039. */
  66040. readonly name: string;
  66041. /**
  66042. * The scene the component belongs to.
  66043. */
  66044. scene: Scene;
  66045. /**
  66046. * Creates a new instance of the component for the given scene
  66047. * @param scene Defines the scene to register the component in
  66048. */
  66049. constructor(scene: Scene);
  66050. /**
  66051. * Registers the component in a given scene
  66052. */
  66053. register(): void;
  66054. /**
  66055. * Rebuilds the elements related to this component in case of
  66056. * context lost for instance.
  66057. */
  66058. rebuild(): void;
  66059. /**
  66060. * Disposes the component and the associated ressources
  66061. */
  66062. dispose(): void;
  66063. private _beforeCameraUpdate;
  66064. }
  66065. }
  66066. declare module BABYLON {
  66067. interface Mesh {
  66068. /**
  66069. * Creates a new thin instance
  66070. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  66071. * @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
  66072. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  66073. */
  66074. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  66075. /**
  66076. * Adds the transformation (matrix) of the current mesh as a thin instance
  66077. * @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
  66078. * @returns the thin instance index number
  66079. */
  66080. thinInstanceAddSelf(refresh: boolean): number;
  66081. /**
  66082. * Registers a custom attribute to be used with thin instances
  66083. * @param kind name of the attribute
  66084. * @param stride size in floats of the attribute
  66085. */
  66086. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  66087. /**
  66088. * Sets the matrix of a thin instance
  66089. * @param index index of the thin instance
  66090. * @param matrix matrix to set
  66091. * @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
  66092. */
  66093. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  66094. /**
  66095. * Sets the value of a custom attribute for a thin instance
  66096. * @param kind name of the attribute
  66097. * @param index index of the thin instance
  66098. * @param value value to set
  66099. * @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
  66100. */
  66101. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  66102. /**
  66103. * 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.
  66104. */
  66105. thinInstanceCount: number;
  66106. /**
  66107. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  66108. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  66109. * @param buffer buffer to set
  66110. * @param stride size in floats of each value of the buffer
  66111. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  66112. */
  66113. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  66114. /**
  66115. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  66116. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  66117. */
  66118. thinInstanceBufferUpdated(kind: string): void;
  66119. /**
  66120. * Refreshes the bounding info, taking into account all the thin instances defined
  66121. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  66122. */
  66123. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  66124. /** @hidden */
  66125. _thinInstanceInitializeUserStorage(): void;
  66126. /** @hidden */
  66127. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  66128. /** @hidden */
  66129. _userThinInstanceBuffersStorage: {
  66130. data: {
  66131. [key: string]: Float32Array;
  66132. };
  66133. sizes: {
  66134. [key: string]: number;
  66135. };
  66136. vertexBuffers: {
  66137. [key: string]: Nullable<VertexBuffer>;
  66138. };
  66139. strides: {
  66140. [key: string]: number;
  66141. };
  66142. };
  66143. }
  66144. }
  66145. declare module BABYLON {
  66146. /**
  66147. * Navigation plugin interface to add navigation constrained by a navigation mesh
  66148. */
  66149. export interface INavigationEnginePlugin {
  66150. /**
  66151. * plugin name
  66152. */
  66153. name: string;
  66154. /**
  66155. * Creates a navigation mesh
  66156. * @param meshes array of all the geometry used to compute the navigatio mesh
  66157. * @param parameters bunch of parameters used to filter geometry
  66158. */
  66159. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66160. /**
  66161. * Create a navigation mesh debug mesh
  66162. * @param scene is where the mesh will be added
  66163. * @returns debug display mesh
  66164. */
  66165. createDebugNavMesh(scene: Scene): Mesh;
  66166. /**
  66167. * Get a navigation mesh constrained position, closest to the parameter position
  66168. * @param position world position
  66169. * @returns the closest point to position constrained by the navigation mesh
  66170. */
  66171. getClosestPoint(position: Vector3): Vector3;
  66172. /**
  66173. * Get a navigation mesh constrained position, closest to the parameter position
  66174. * @param position world position
  66175. * @param result output the closest point to position constrained by the navigation mesh
  66176. */
  66177. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66178. /**
  66179. * Get a navigation mesh constrained position, within a particular radius
  66180. * @param position world position
  66181. * @param maxRadius the maximum distance to the constrained world position
  66182. * @returns the closest point to position constrained by the navigation mesh
  66183. */
  66184. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66185. /**
  66186. * Get a navigation mesh constrained position, within a particular radius
  66187. * @param position world position
  66188. * @param maxRadius the maximum distance to the constrained world position
  66189. * @param result output the closest point to position constrained by the navigation mesh
  66190. */
  66191. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66192. /**
  66193. * Compute the final position from a segment made of destination-position
  66194. * @param position world position
  66195. * @param destination world position
  66196. * @returns the resulting point along the navmesh
  66197. */
  66198. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66199. /**
  66200. * Compute the final position from a segment made of destination-position
  66201. * @param position world position
  66202. * @param destination world position
  66203. * @param result output the resulting point along the navmesh
  66204. */
  66205. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66206. /**
  66207. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66208. * @param start world position
  66209. * @param end world position
  66210. * @returns array containing world position composing the path
  66211. */
  66212. computePath(start: Vector3, end: Vector3): Vector3[];
  66213. /**
  66214. * If this plugin is supported
  66215. * @returns true if plugin is supported
  66216. */
  66217. isSupported(): boolean;
  66218. /**
  66219. * Create a new Crowd so you can add agents
  66220. * @param maxAgents the maximum agent count in the crowd
  66221. * @param maxAgentRadius the maximum radius an agent can have
  66222. * @param scene to attach the crowd to
  66223. * @returns the crowd you can add agents to
  66224. */
  66225. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66226. /**
  66227. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66228. * The queries will try to find a solution within those bounds
  66229. * default is (1,1,1)
  66230. * @param extent x,y,z value that define the extent around the queries point of reference
  66231. */
  66232. setDefaultQueryExtent(extent: Vector3): void;
  66233. /**
  66234. * Get the Bounding box extent specified by setDefaultQueryExtent
  66235. * @returns the box extent values
  66236. */
  66237. getDefaultQueryExtent(): Vector3;
  66238. /**
  66239. * build the navmesh from a previously saved state using getNavmeshData
  66240. * @param data the Uint8Array returned by getNavmeshData
  66241. */
  66242. buildFromNavmeshData(data: Uint8Array): void;
  66243. /**
  66244. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66245. * @returns data the Uint8Array that can be saved and reused
  66246. */
  66247. getNavmeshData(): Uint8Array;
  66248. /**
  66249. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66250. * @param result output the box extent values
  66251. */
  66252. getDefaultQueryExtentToRef(result: Vector3): void;
  66253. /**
  66254. * Release all resources
  66255. */
  66256. dispose(): void;
  66257. }
  66258. /**
  66259. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  66260. */
  66261. export interface ICrowd {
  66262. /**
  66263. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  66264. * You can attach anything to that node. The node position is updated in the scene update tick.
  66265. * @param pos world position that will be constrained by the navigation mesh
  66266. * @param parameters agent parameters
  66267. * @param transform hooked to the agent that will be update by the scene
  66268. * @returns agent index
  66269. */
  66270. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66271. /**
  66272. * Returns the agent position in world space
  66273. * @param index agent index returned by addAgent
  66274. * @returns world space position
  66275. */
  66276. getAgentPosition(index: number): Vector3;
  66277. /**
  66278. * Gets the agent position result in world space
  66279. * @param index agent index returned by addAgent
  66280. * @param result output world space position
  66281. */
  66282. getAgentPositionToRef(index: number, result: Vector3): void;
  66283. /**
  66284. * Gets the agent velocity in world space
  66285. * @param index agent index returned by addAgent
  66286. * @returns world space velocity
  66287. */
  66288. getAgentVelocity(index: number): Vector3;
  66289. /**
  66290. * Gets the agent velocity result in world space
  66291. * @param index agent index returned by addAgent
  66292. * @param result output world space velocity
  66293. */
  66294. getAgentVelocityToRef(index: number, result: Vector3): void;
  66295. /**
  66296. * remove a particular agent previously created
  66297. * @param index agent index returned by addAgent
  66298. */
  66299. removeAgent(index: number): void;
  66300. /**
  66301. * get the list of all agents attached to this crowd
  66302. * @returns list of agent indices
  66303. */
  66304. getAgents(): number[];
  66305. /**
  66306. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66307. * @param deltaTime in seconds
  66308. */
  66309. update(deltaTime: number): void;
  66310. /**
  66311. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66312. * @param index agent index returned by addAgent
  66313. * @param destination targeted world position
  66314. */
  66315. agentGoto(index: number, destination: Vector3): void;
  66316. /**
  66317. * Teleport the agent to a new position
  66318. * @param index agent index returned by addAgent
  66319. * @param destination targeted world position
  66320. */
  66321. agentTeleport(index: number, destination: Vector3): void;
  66322. /**
  66323. * Update agent parameters
  66324. * @param index agent index returned by addAgent
  66325. * @param parameters agent parameters
  66326. */
  66327. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66328. /**
  66329. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66330. * The queries will try to find a solution within those bounds
  66331. * default is (1,1,1)
  66332. * @param extent x,y,z value that define the extent around the queries point of reference
  66333. */
  66334. setDefaultQueryExtent(extent: Vector3): void;
  66335. /**
  66336. * Get the Bounding box extent specified by setDefaultQueryExtent
  66337. * @returns the box extent values
  66338. */
  66339. getDefaultQueryExtent(): Vector3;
  66340. /**
  66341. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66342. * @param result output the box extent values
  66343. */
  66344. getDefaultQueryExtentToRef(result: Vector3): void;
  66345. /**
  66346. * Release all resources
  66347. */
  66348. dispose(): void;
  66349. }
  66350. /**
  66351. * Configures an agent
  66352. */
  66353. export interface IAgentParameters {
  66354. /**
  66355. * Agent radius. [Limit: >= 0]
  66356. */
  66357. radius: number;
  66358. /**
  66359. * Agent height. [Limit: > 0]
  66360. */
  66361. height: number;
  66362. /**
  66363. * Maximum allowed acceleration. [Limit: >= 0]
  66364. */
  66365. maxAcceleration: number;
  66366. /**
  66367. * Maximum allowed speed. [Limit: >= 0]
  66368. */
  66369. maxSpeed: number;
  66370. /**
  66371. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  66372. */
  66373. collisionQueryRange: number;
  66374. /**
  66375. * The path visibility optimization range. [Limit: > 0]
  66376. */
  66377. pathOptimizationRange: number;
  66378. /**
  66379. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  66380. */
  66381. separationWeight: number;
  66382. }
  66383. /**
  66384. * Configures the navigation mesh creation
  66385. */
  66386. export interface INavMeshParameters {
  66387. /**
  66388. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  66389. */
  66390. cs: number;
  66391. /**
  66392. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  66393. */
  66394. ch: number;
  66395. /**
  66396. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  66397. */
  66398. walkableSlopeAngle: number;
  66399. /**
  66400. * Minimum floor to 'ceiling' height that will still allow the floor area to
  66401. * be considered walkable. [Limit: >= 3] [Units: vx]
  66402. */
  66403. walkableHeight: number;
  66404. /**
  66405. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  66406. */
  66407. walkableClimb: number;
  66408. /**
  66409. * The distance to erode/shrink the walkable area of the heightfield away from
  66410. * obstructions. [Limit: >=0] [Units: vx]
  66411. */
  66412. walkableRadius: number;
  66413. /**
  66414. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  66415. */
  66416. maxEdgeLen: number;
  66417. /**
  66418. * The maximum distance a simplfied contour's border edges should deviate
  66419. * the original raw contour. [Limit: >=0] [Units: vx]
  66420. */
  66421. maxSimplificationError: number;
  66422. /**
  66423. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  66424. */
  66425. minRegionArea: number;
  66426. /**
  66427. * Any regions with a span count smaller than this value will, if possible,
  66428. * be merged with larger regions. [Limit: >=0] [Units: vx]
  66429. */
  66430. mergeRegionArea: number;
  66431. /**
  66432. * The maximum number of vertices allowed for polygons generated during the
  66433. * contour to polygon conversion process. [Limit: >= 3]
  66434. */
  66435. maxVertsPerPoly: number;
  66436. /**
  66437. * Sets the sampling distance to use when generating the detail mesh.
  66438. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  66439. */
  66440. detailSampleDist: number;
  66441. /**
  66442. * The maximum distance the detail mesh surface should deviate from heightfield
  66443. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  66444. */
  66445. detailSampleMaxError: number;
  66446. }
  66447. }
  66448. declare module BABYLON {
  66449. /**
  66450. * RecastJS navigation plugin
  66451. */
  66452. export class RecastJSPlugin implements INavigationEnginePlugin {
  66453. /**
  66454. * Reference to the Recast library
  66455. */
  66456. bjsRECAST: any;
  66457. /**
  66458. * plugin name
  66459. */
  66460. name: string;
  66461. /**
  66462. * the first navmesh created. We might extend this to support multiple navmeshes
  66463. */
  66464. navMesh: any;
  66465. /**
  66466. * Initializes the recastJS plugin
  66467. * @param recastInjection can be used to inject your own recast reference
  66468. */
  66469. constructor(recastInjection?: any);
  66470. /**
  66471. * Creates a navigation mesh
  66472. * @param meshes array of all the geometry used to compute the navigatio mesh
  66473. * @param parameters bunch of parameters used to filter geometry
  66474. */
  66475. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66476. /**
  66477. * Create a navigation mesh debug mesh
  66478. * @param scene is where the mesh will be added
  66479. * @returns debug display mesh
  66480. */
  66481. createDebugNavMesh(scene: Scene): Mesh;
  66482. /**
  66483. * Get a navigation mesh constrained position, closest to the parameter position
  66484. * @param position world position
  66485. * @returns the closest point to position constrained by the navigation mesh
  66486. */
  66487. getClosestPoint(position: Vector3): Vector3;
  66488. /**
  66489. * Get a navigation mesh constrained position, closest to the parameter position
  66490. * @param position world position
  66491. * @param result output the closest point to position constrained by the navigation mesh
  66492. */
  66493. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66494. /**
  66495. * Get a navigation mesh constrained position, within a particular radius
  66496. * @param position world position
  66497. * @param maxRadius the maximum distance to the constrained world position
  66498. * @returns the closest point to position constrained by the navigation mesh
  66499. */
  66500. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66501. /**
  66502. * Get a navigation mesh constrained position, within a particular radius
  66503. * @param position world position
  66504. * @param maxRadius the maximum distance to the constrained world position
  66505. * @param result output the closest point to position constrained by the navigation mesh
  66506. */
  66507. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66508. /**
  66509. * Compute the final position from a segment made of destination-position
  66510. * @param position world position
  66511. * @param destination world position
  66512. * @returns the resulting point along the navmesh
  66513. */
  66514. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66515. /**
  66516. * Compute the final position from a segment made of destination-position
  66517. * @param position world position
  66518. * @param destination world position
  66519. * @param result output the resulting point along the navmesh
  66520. */
  66521. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66522. /**
  66523. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66524. * @param start world position
  66525. * @param end world position
  66526. * @returns array containing world position composing the path
  66527. */
  66528. computePath(start: Vector3, end: Vector3): Vector3[];
  66529. /**
  66530. * Create a new Crowd so you can add agents
  66531. * @param maxAgents the maximum agent count in the crowd
  66532. * @param maxAgentRadius the maximum radius an agent can have
  66533. * @param scene to attach the crowd to
  66534. * @returns the crowd you can add agents to
  66535. */
  66536. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66537. /**
  66538. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66539. * The queries will try to find a solution within those bounds
  66540. * default is (1,1,1)
  66541. * @param extent x,y,z value that define the extent around the queries point of reference
  66542. */
  66543. setDefaultQueryExtent(extent: Vector3): void;
  66544. /**
  66545. * Get the Bounding box extent specified by setDefaultQueryExtent
  66546. * @returns the box extent values
  66547. */
  66548. getDefaultQueryExtent(): Vector3;
  66549. /**
  66550. * build the navmesh from a previously saved state using getNavmeshData
  66551. * @param data the Uint8Array returned by getNavmeshData
  66552. */
  66553. buildFromNavmeshData(data: Uint8Array): void;
  66554. /**
  66555. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66556. * @returns data the Uint8Array that can be saved and reused
  66557. */
  66558. getNavmeshData(): Uint8Array;
  66559. /**
  66560. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66561. * @param result output the box extent values
  66562. */
  66563. getDefaultQueryExtentToRef(result: Vector3): void;
  66564. /**
  66565. * Disposes
  66566. */
  66567. dispose(): void;
  66568. /**
  66569. * If this plugin is supported
  66570. * @returns true if plugin is supported
  66571. */
  66572. isSupported(): boolean;
  66573. }
  66574. /**
  66575. * Recast detour crowd implementation
  66576. */
  66577. export class RecastJSCrowd implements ICrowd {
  66578. /**
  66579. * Recast/detour plugin
  66580. */
  66581. bjsRECASTPlugin: RecastJSPlugin;
  66582. /**
  66583. * Link to the detour crowd
  66584. */
  66585. recastCrowd: any;
  66586. /**
  66587. * One transform per agent
  66588. */
  66589. transforms: TransformNode[];
  66590. /**
  66591. * All agents created
  66592. */
  66593. agents: number[];
  66594. /**
  66595. * Link to the scene is kept to unregister the crowd from the scene
  66596. */
  66597. private _scene;
  66598. /**
  66599. * Observer for crowd updates
  66600. */
  66601. private _onBeforeAnimationsObserver;
  66602. /**
  66603. * Constructor
  66604. * @param plugin recastJS plugin
  66605. * @param maxAgents the maximum agent count in the crowd
  66606. * @param maxAgentRadius the maximum radius an agent can have
  66607. * @param scene to attach the crowd to
  66608. * @returns the crowd you can add agents to
  66609. */
  66610. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  66611. /**
  66612. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  66613. * You can attach anything to that node. The node position is updated in the scene update tick.
  66614. * @param pos world position that will be constrained by the navigation mesh
  66615. * @param parameters agent parameters
  66616. * @param transform hooked to the agent that will be update by the scene
  66617. * @returns agent index
  66618. */
  66619. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66620. /**
  66621. * Returns the agent position in world space
  66622. * @param index agent index returned by addAgent
  66623. * @returns world space position
  66624. */
  66625. getAgentPosition(index: number): Vector3;
  66626. /**
  66627. * Returns the agent position result in world space
  66628. * @param index agent index returned by addAgent
  66629. * @param result output world space position
  66630. */
  66631. getAgentPositionToRef(index: number, result: Vector3): void;
  66632. /**
  66633. * Returns the agent velocity in world space
  66634. * @param index agent index returned by addAgent
  66635. * @returns world space velocity
  66636. */
  66637. getAgentVelocity(index: number): Vector3;
  66638. /**
  66639. * Returns the agent velocity result in world space
  66640. * @param index agent index returned by addAgent
  66641. * @param result output world space velocity
  66642. */
  66643. getAgentVelocityToRef(index: number, result: Vector3): void;
  66644. /**
  66645. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66646. * @param index agent index returned by addAgent
  66647. * @param destination targeted world position
  66648. */
  66649. agentGoto(index: number, destination: Vector3): void;
  66650. /**
  66651. * Teleport the agent to a new position
  66652. * @param index agent index returned by addAgent
  66653. * @param destination targeted world position
  66654. */
  66655. agentTeleport(index: number, destination: Vector3): void;
  66656. /**
  66657. * Update agent parameters
  66658. * @param index agent index returned by addAgent
  66659. * @param parameters agent parameters
  66660. */
  66661. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66662. /**
  66663. * remove a particular agent previously created
  66664. * @param index agent index returned by addAgent
  66665. */
  66666. removeAgent(index: number): void;
  66667. /**
  66668. * get the list of all agents attached to this crowd
  66669. * @returns list of agent indices
  66670. */
  66671. getAgents(): number[];
  66672. /**
  66673. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66674. * @param deltaTime in seconds
  66675. */
  66676. update(deltaTime: number): void;
  66677. /**
  66678. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66679. * The queries will try to find a solution within those bounds
  66680. * default is (1,1,1)
  66681. * @param extent x,y,z value that define the extent around the queries point of reference
  66682. */
  66683. setDefaultQueryExtent(extent: Vector3): void;
  66684. /**
  66685. * Get the Bounding box extent specified by setDefaultQueryExtent
  66686. * @returns the box extent values
  66687. */
  66688. getDefaultQueryExtent(): Vector3;
  66689. /**
  66690. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66691. * @param result output the box extent values
  66692. */
  66693. getDefaultQueryExtentToRef(result: Vector3): void;
  66694. /**
  66695. * Release all resources
  66696. */
  66697. dispose(): void;
  66698. }
  66699. }
  66700. declare module BABYLON {
  66701. /**
  66702. * Class used to enable access to IndexedDB
  66703. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  66704. */
  66705. export class Database implements IOfflineProvider {
  66706. private _callbackManifestChecked;
  66707. private _currentSceneUrl;
  66708. private _db;
  66709. private _enableSceneOffline;
  66710. private _enableTexturesOffline;
  66711. private _manifestVersionFound;
  66712. private _mustUpdateRessources;
  66713. private _hasReachedQuota;
  66714. private _isSupported;
  66715. private _idbFactory;
  66716. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  66717. private static IsUASupportingBlobStorage;
  66718. /**
  66719. * Gets a boolean indicating if Database storate is enabled (off by default)
  66720. */
  66721. static IDBStorageEnabled: boolean;
  66722. /**
  66723. * Gets a boolean indicating if scene must be saved in the database
  66724. */
  66725. get enableSceneOffline(): boolean;
  66726. /**
  66727. * Gets a boolean indicating if textures must be saved in the database
  66728. */
  66729. get enableTexturesOffline(): boolean;
  66730. /**
  66731. * Creates a new Database
  66732. * @param urlToScene defines the url to load the scene
  66733. * @param callbackManifestChecked defines the callback to use when manifest is checked
  66734. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  66735. */
  66736. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  66737. private static _ParseURL;
  66738. private static _ReturnFullUrlLocation;
  66739. private _checkManifestFile;
  66740. /**
  66741. * Open the database and make it available
  66742. * @param successCallback defines the callback to call on success
  66743. * @param errorCallback defines the callback to call on error
  66744. */
  66745. open(successCallback: () => void, errorCallback: () => void): void;
  66746. /**
  66747. * Loads an image from the database
  66748. * @param url defines the url to load from
  66749. * @param image defines the target DOM image
  66750. */
  66751. loadImage(url: string, image: HTMLImageElement): void;
  66752. private _loadImageFromDBAsync;
  66753. private _saveImageIntoDBAsync;
  66754. private _checkVersionFromDB;
  66755. private _loadVersionFromDBAsync;
  66756. private _saveVersionIntoDBAsync;
  66757. /**
  66758. * Loads a file from database
  66759. * @param url defines the URL to load from
  66760. * @param sceneLoaded defines a callback to call on success
  66761. * @param progressCallBack defines a callback to call when progress changed
  66762. * @param errorCallback defines a callback to call on error
  66763. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  66764. */
  66765. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  66766. private _loadFileAsync;
  66767. private _saveFileAsync;
  66768. /**
  66769. * Validates if xhr data is correct
  66770. * @param xhr defines the request to validate
  66771. * @param dataType defines the expected data type
  66772. * @returns true if data is correct
  66773. */
  66774. private static _ValidateXHRData;
  66775. }
  66776. }
  66777. declare module BABYLON {
  66778. /** @hidden */
  66779. export var gpuUpdateParticlesPixelShader: {
  66780. name: string;
  66781. shader: string;
  66782. };
  66783. }
  66784. declare module BABYLON {
  66785. /** @hidden */
  66786. export var gpuUpdateParticlesVertexShader: {
  66787. name: string;
  66788. shader: string;
  66789. };
  66790. }
  66791. declare module BABYLON {
  66792. /** @hidden */
  66793. export var clipPlaneFragmentDeclaration2: {
  66794. name: string;
  66795. shader: string;
  66796. };
  66797. }
  66798. declare module BABYLON {
  66799. /** @hidden */
  66800. export var gpuRenderParticlesPixelShader: {
  66801. name: string;
  66802. shader: string;
  66803. };
  66804. }
  66805. declare module BABYLON {
  66806. /** @hidden */
  66807. export var clipPlaneVertexDeclaration2: {
  66808. name: string;
  66809. shader: string;
  66810. };
  66811. }
  66812. declare module BABYLON {
  66813. /** @hidden */
  66814. export var gpuRenderParticlesVertexShader: {
  66815. name: string;
  66816. shader: string;
  66817. };
  66818. }
  66819. declare module BABYLON {
  66820. /**
  66821. * This represents a GPU particle system in Babylon
  66822. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  66823. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  66824. */
  66825. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  66826. /**
  66827. * The layer mask we are rendering the particles through.
  66828. */
  66829. layerMask: number;
  66830. private _capacity;
  66831. private _activeCount;
  66832. private _currentActiveCount;
  66833. private _accumulatedCount;
  66834. private _renderEffect;
  66835. private _updateEffect;
  66836. private _buffer0;
  66837. private _buffer1;
  66838. private _spriteBuffer;
  66839. private _updateVAO;
  66840. private _renderVAO;
  66841. private _targetIndex;
  66842. private _sourceBuffer;
  66843. private _targetBuffer;
  66844. private _engine;
  66845. private _currentRenderId;
  66846. private _started;
  66847. private _stopped;
  66848. private _timeDelta;
  66849. private _randomTexture;
  66850. private _randomTexture2;
  66851. private _attributesStrideSize;
  66852. private _updateEffectOptions;
  66853. private _randomTextureSize;
  66854. private _actualFrame;
  66855. private _customEffect;
  66856. private readonly _rawTextureWidth;
  66857. /**
  66858. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  66859. */
  66860. static get IsSupported(): boolean;
  66861. /**
  66862. * An event triggered when the system is disposed.
  66863. */
  66864. onDisposeObservable: Observable<IParticleSystem>;
  66865. /**
  66866. * Gets the maximum number of particles active at the same time.
  66867. * @returns The max number of active particles.
  66868. */
  66869. getCapacity(): number;
  66870. /**
  66871. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  66872. * to override the particles.
  66873. */
  66874. forceDepthWrite: boolean;
  66875. /**
  66876. * Gets or set the number of active particles
  66877. */
  66878. get activeParticleCount(): number;
  66879. set activeParticleCount(value: number);
  66880. private _preWarmDone;
  66881. /**
  66882. * Specifies if the particles are updated in emitter local space or world space.
  66883. */
  66884. isLocal: boolean;
  66885. /**
  66886. * Is this system ready to be used/rendered
  66887. * @return true if the system is ready
  66888. */
  66889. isReady(): boolean;
  66890. /**
  66891. * Gets if the system has been started. (Note: this will still be true after stop is called)
  66892. * @returns True if it has been started, otherwise false.
  66893. */
  66894. isStarted(): boolean;
  66895. /**
  66896. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  66897. * @returns True if it has been stopped, otherwise false.
  66898. */
  66899. isStopped(): boolean;
  66900. /**
  66901. * Gets a boolean indicating that the system is stopping
  66902. * @returns true if the system is currently stopping
  66903. */
  66904. isStopping(): boolean;
  66905. /**
  66906. * Gets the number of particles active at the same time.
  66907. * @returns The number of active particles.
  66908. */
  66909. getActiveCount(): number;
  66910. /**
  66911. * Starts the particle system and begins to emit
  66912. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  66913. */
  66914. start(delay?: number): void;
  66915. /**
  66916. * Stops the particle system.
  66917. */
  66918. stop(): void;
  66919. /**
  66920. * Remove all active particles
  66921. */
  66922. reset(): void;
  66923. /**
  66924. * Returns the string "GPUParticleSystem"
  66925. * @returns a string containing the class name
  66926. */
  66927. getClassName(): string;
  66928. /**
  66929. * Gets the custom effect used to render the particles
  66930. * @param blendMode Blend mode for which the effect should be retrieved
  66931. * @returns The effect
  66932. */
  66933. getCustomEffect(blendMode?: number): Nullable<Effect>;
  66934. /**
  66935. * Sets the custom effect used to render the particles
  66936. * @param effect The effect to set
  66937. * @param blendMode Blend mode for which the effect should be set
  66938. */
  66939. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  66940. /** @hidden */
  66941. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  66942. /**
  66943. * Observable that will be called just before the particles are drawn
  66944. */
  66945. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  66946. /**
  66947. * Gets the name of the particle vertex shader
  66948. */
  66949. get vertexShaderName(): string;
  66950. private _colorGradientsTexture;
  66951. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  66952. /**
  66953. * Adds a new color gradient
  66954. * @param gradient defines the gradient to use (between 0 and 1)
  66955. * @param color1 defines the color to affect to the specified gradient
  66956. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  66957. * @returns the current particle system
  66958. */
  66959. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  66960. private _refreshColorGradient;
  66961. /** Force the system to rebuild all gradients that need to be resync */
  66962. forceRefreshGradients(): void;
  66963. /**
  66964. * Remove a specific color gradient
  66965. * @param gradient defines the gradient to remove
  66966. * @returns the current particle system
  66967. */
  66968. removeColorGradient(gradient: number): GPUParticleSystem;
  66969. private _angularSpeedGradientsTexture;
  66970. private _sizeGradientsTexture;
  66971. private _velocityGradientsTexture;
  66972. private _limitVelocityGradientsTexture;
  66973. private _dragGradientsTexture;
  66974. private _addFactorGradient;
  66975. /**
  66976. * Adds a new size gradient
  66977. * @param gradient defines the gradient to use (between 0 and 1)
  66978. * @param factor defines the size factor to affect to the specified gradient
  66979. * @returns the current particle system
  66980. */
  66981. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  66982. /**
  66983. * Remove a specific size gradient
  66984. * @param gradient defines the gradient to remove
  66985. * @returns the current particle system
  66986. */
  66987. removeSizeGradient(gradient: number): GPUParticleSystem;
  66988. private _refreshFactorGradient;
  66989. /**
  66990. * Adds a new angular speed gradient
  66991. * @param gradient defines the gradient to use (between 0 and 1)
  66992. * @param factor defines the angular speed to affect to the specified gradient
  66993. * @returns the current particle system
  66994. */
  66995. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  66996. /**
  66997. * Remove a specific angular speed gradient
  66998. * @param gradient defines the gradient to remove
  66999. * @returns the current particle system
  67000. */
  67001. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  67002. /**
  67003. * Adds a new velocity gradient
  67004. * @param gradient defines the gradient to use (between 0 and 1)
  67005. * @param factor defines the velocity to affect to the specified gradient
  67006. * @returns the current particle system
  67007. */
  67008. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67009. /**
  67010. * Remove a specific velocity gradient
  67011. * @param gradient defines the gradient to remove
  67012. * @returns the current particle system
  67013. */
  67014. removeVelocityGradient(gradient: number): GPUParticleSystem;
  67015. /**
  67016. * Adds a new limit velocity gradient
  67017. * @param gradient defines the gradient to use (between 0 and 1)
  67018. * @param factor defines the limit velocity value to affect to the specified gradient
  67019. * @returns the current particle system
  67020. */
  67021. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67022. /**
  67023. * Remove a specific limit velocity gradient
  67024. * @param gradient defines the gradient to remove
  67025. * @returns the current particle system
  67026. */
  67027. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  67028. /**
  67029. * Adds a new drag gradient
  67030. * @param gradient defines the gradient to use (between 0 and 1)
  67031. * @param factor defines the drag value to affect to the specified gradient
  67032. * @returns the current particle system
  67033. */
  67034. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  67035. /**
  67036. * Remove a specific drag gradient
  67037. * @param gradient defines the gradient to remove
  67038. * @returns the current particle system
  67039. */
  67040. removeDragGradient(gradient: number): GPUParticleSystem;
  67041. /**
  67042. * Not supported by GPUParticleSystem
  67043. * @param gradient defines the gradient to use (between 0 and 1)
  67044. * @param factor defines the emit rate value to affect to the specified gradient
  67045. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67046. * @returns the current particle system
  67047. */
  67048. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67049. /**
  67050. * Not supported by GPUParticleSystem
  67051. * @param gradient defines the gradient to remove
  67052. * @returns the current particle system
  67053. */
  67054. removeEmitRateGradient(gradient: number): IParticleSystem;
  67055. /**
  67056. * Not supported by GPUParticleSystem
  67057. * @param gradient defines the gradient to use (between 0 and 1)
  67058. * @param factor defines the start size value to affect to the specified gradient
  67059. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67060. * @returns the current particle system
  67061. */
  67062. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67063. /**
  67064. * Not supported by GPUParticleSystem
  67065. * @param gradient defines the gradient to remove
  67066. * @returns the current particle system
  67067. */
  67068. removeStartSizeGradient(gradient: number): IParticleSystem;
  67069. /**
  67070. * Not supported by GPUParticleSystem
  67071. * @param gradient defines the gradient to use (between 0 and 1)
  67072. * @param min defines the color remap minimal range
  67073. * @param max defines the color remap maximal range
  67074. * @returns the current particle system
  67075. */
  67076. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67077. /**
  67078. * Not supported by GPUParticleSystem
  67079. * @param gradient defines the gradient to remove
  67080. * @returns the current particle system
  67081. */
  67082. removeColorRemapGradient(): IParticleSystem;
  67083. /**
  67084. * Not supported by GPUParticleSystem
  67085. * @param gradient defines the gradient to use (between 0 and 1)
  67086. * @param min defines the alpha remap minimal range
  67087. * @param max defines the alpha remap maximal range
  67088. * @returns the current particle system
  67089. */
  67090. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67091. /**
  67092. * Not supported by GPUParticleSystem
  67093. * @param gradient defines the gradient to remove
  67094. * @returns the current particle system
  67095. */
  67096. removeAlphaRemapGradient(): IParticleSystem;
  67097. /**
  67098. * Not supported by GPUParticleSystem
  67099. * @param gradient defines the gradient to use (between 0 and 1)
  67100. * @param color defines the color to affect to the specified gradient
  67101. * @returns the current particle system
  67102. */
  67103. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  67104. /**
  67105. * Not supported by GPUParticleSystem
  67106. * @param gradient defines the gradient to remove
  67107. * @returns the current particle system
  67108. */
  67109. removeRampGradient(): IParticleSystem;
  67110. /**
  67111. * Not supported by GPUParticleSystem
  67112. * @returns the list of ramp gradients
  67113. */
  67114. getRampGradients(): Nullable<Array<Color3Gradient>>;
  67115. /**
  67116. * Not supported by GPUParticleSystem
  67117. * Gets or sets a boolean indicating that ramp gradients must be used
  67118. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  67119. */
  67120. get useRampGradients(): boolean;
  67121. set useRampGradients(value: boolean);
  67122. /**
  67123. * Not supported by GPUParticleSystem
  67124. * @param gradient defines the gradient to use (between 0 and 1)
  67125. * @param factor defines the life time factor to affect to the specified gradient
  67126. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67127. * @returns the current particle system
  67128. */
  67129. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67130. /**
  67131. * Not supported by GPUParticleSystem
  67132. * @param gradient defines the gradient to remove
  67133. * @returns the current particle system
  67134. */
  67135. removeLifeTimeGradient(gradient: number): IParticleSystem;
  67136. /**
  67137. * Instantiates a GPU particle system.
  67138. * 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.
  67139. * @param name The name of the particle system
  67140. * @param options The options used to create the system
  67141. * @param scene The scene the particle system belongs to
  67142. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  67143. * @param customEffect a custom effect used to change the way particles are rendered by default
  67144. */
  67145. constructor(name: string, options: Partial<{
  67146. capacity: number;
  67147. randomTextureSize: number;
  67148. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  67149. protected _reset(): void;
  67150. private _createUpdateVAO;
  67151. private _createRenderVAO;
  67152. private _initialize;
  67153. /** @hidden */
  67154. _recreateUpdateEffect(): void;
  67155. private _getEffect;
  67156. /**
  67157. * Fill the defines array according to the current settings of the particle system
  67158. * @param defines Array to be updated
  67159. * @param blendMode blend mode to take into account when updating the array
  67160. */
  67161. fillDefines(defines: Array<string>, blendMode?: number): void;
  67162. /**
  67163. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  67164. * @param uniforms Uniforms array to fill
  67165. * @param attributes Attributes array to fill
  67166. * @param samplers Samplers array to fill
  67167. */
  67168. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  67169. /** @hidden */
  67170. _recreateRenderEffect(): Effect;
  67171. /**
  67172. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  67173. * @param preWarm defines if we are in the pre-warmimg phase
  67174. */
  67175. animate(preWarm?: boolean): void;
  67176. private _createFactorGradientTexture;
  67177. private _createSizeGradientTexture;
  67178. private _createAngularSpeedGradientTexture;
  67179. private _createVelocityGradientTexture;
  67180. private _createLimitVelocityGradientTexture;
  67181. private _createDragGradientTexture;
  67182. private _createColorGradientTexture;
  67183. /**
  67184. * Renders the particle system in its current state
  67185. * @param preWarm defines if the system should only update the particles but not render them
  67186. * @returns the current number of particles
  67187. */
  67188. render(preWarm?: boolean): number;
  67189. /**
  67190. * Rebuilds the particle system
  67191. */
  67192. rebuild(): void;
  67193. private _releaseBuffers;
  67194. private _releaseVAOs;
  67195. /**
  67196. * Disposes the particle system and free the associated resources
  67197. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  67198. */
  67199. dispose(disposeTexture?: boolean): void;
  67200. /**
  67201. * Clones the particle system.
  67202. * @param name The name of the cloned object
  67203. * @param newEmitter The new emitter to use
  67204. * @returns the cloned particle system
  67205. */
  67206. clone(name: string, newEmitter: any): GPUParticleSystem;
  67207. /**
  67208. * Serializes the particle system to a JSON object
  67209. * @param serializeTexture defines if the texture must be serialized as well
  67210. * @returns the JSON object
  67211. */
  67212. serialize(serializeTexture?: boolean): any;
  67213. /**
  67214. * Parses a JSON object to create a GPU particle system.
  67215. * @param parsedParticleSystem The JSON object to parse
  67216. * @param scene The scene to create the particle system in
  67217. * @param rootUrl The root url to use to load external dependencies like texture
  67218. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  67219. * @returns the parsed GPU particle system
  67220. */
  67221. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  67222. }
  67223. }
  67224. declare module BABYLON {
  67225. /**
  67226. * Represents a set of particle systems working together to create a specific effect
  67227. */
  67228. export class ParticleSystemSet implements IDisposable {
  67229. /**
  67230. * Gets or sets base Assets URL
  67231. */
  67232. static BaseAssetsUrl: string;
  67233. private _emitterCreationOptions;
  67234. private _emitterNode;
  67235. /**
  67236. * Gets the particle system list
  67237. */
  67238. systems: IParticleSystem[];
  67239. /**
  67240. * Gets the emitter node used with this set
  67241. */
  67242. get emitterNode(): Nullable<TransformNode>;
  67243. /**
  67244. * Creates a new emitter mesh as a sphere
  67245. * @param options defines the options used to create the sphere
  67246. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  67247. * @param scene defines the hosting scene
  67248. */
  67249. setEmitterAsSphere(options: {
  67250. diameter: number;
  67251. segments: number;
  67252. color: Color3;
  67253. }, renderingGroupId: number, scene: Scene): void;
  67254. /**
  67255. * Starts all particle systems of the set
  67256. * @param emitter defines an optional mesh to use as emitter for the particle systems
  67257. */
  67258. start(emitter?: AbstractMesh): void;
  67259. /**
  67260. * Release all associated resources
  67261. */
  67262. dispose(): void;
  67263. /**
  67264. * Serialize the set into a JSON compatible object
  67265. * @param serializeTexture defines if the texture must be serialized as well
  67266. * @returns a JSON compatible representation of the set
  67267. */
  67268. serialize(serializeTexture?: boolean): any;
  67269. /**
  67270. * Parse a new ParticleSystemSet from a serialized source
  67271. * @param data defines a JSON compatible representation of the set
  67272. * @param scene defines the hosting scene
  67273. * @param gpu defines if we want GPU particles or CPU particles
  67274. * @returns a new ParticleSystemSet
  67275. */
  67276. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  67277. }
  67278. }
  67279. declare module BABYLON {
  67280. /**
  67281. * This class is made for on one-liner static method to help creating particle system set.
  67282. */
  67283. export class ParticleHelper {
  67284. /**
  67285. * Gets or sets base Assets URL
  67286. */
  67287. static BaseAssetsUrl: string;
  67288. /** Define the Url to load snippets */
  67289. static SnippetUrl: string;
  67290. /**
  67291. * Create a default particle system that you can tweak
  67292. * @param emitter defines the emitter to use
  67293. * @param capacity defines the system capacity (default is 500 particles)
  67294. * @param scene defines the hosting scene
  67295. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  67296. * @returns the new Particle system
  67297. */
  67298. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  67299. /**
  67300. * This is the main static method (one-liner) of this helper to create different particle systems
  67301. * @param type This string represents the type to the particle system to create
  67302. * @param scene The scene where the particle system should live
  67303. * @param gpu If the system will use gpu
  67304. * @returns the ParticleSystemSet created
  67305. */
  67306. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  67307. /**
  67308. * Static function used to export a particle system to a ParticleSystemSet variable.
  67309. * Please note that the emitter shape is not exported
  67310. * @param systems defines the particle systems to export
  67311. * @returns the created particle system set
  67312. */
  67313. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  67314. /**
  67315. * Creates a particle system from a snippet saved in a remote file
  67316. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  67317. * @param url defines the url to load from
  67318. * @param scene defines the hosting scene
  67319. * @param gpu If the system will use gpu
  67320. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67321. * @returns a promise that will resolve to the new particle system
  67322. */
  67323. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  67324. /**
  67325. * Creates a particle system from a snippet saved by the particle system editor
  67326. * @param snippetId defines the snippet to load
  67327. * @param scene defines the hosting scene
  67328. * @param gpu If the system will use gpu
  67329. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67330. * @returns a promise that will resolve to the new particle system
  67331. */
  67332. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  67333. }
  67334. }
  67335. declare module BABYLON {
  67336. interface Engine {
  67337. /**
  67338. * Create an effect to use with particle systems.
  67339. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  67340. * the particle system for which you want to create a custom effect in the last parameter
  67341. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  67342. * @param uniformsNames defines a list of attribute names
  67343. * @param samplers defines an array of string used to represent textures
  67344. * @param defines defines the string containing the defines to use to compile the shaders
  67345. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  67346. * @param onCompiled defines a function to call when the effect creation is successful
  67347. * @param onError defines a function to call when the effect creation has failed
  67348. * @param particleSystem the particle system you want to create the effect for
  67349. * @returns the new Effect
  67350. */
  67351. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  67352. }
  67353. interface Mesh {
  67354. /**
  67355. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  67356. * @returns an array of IParticleSystem
  67357. */
  67358. getEmittedParticleSystems(): IParticleSystem[];
  67359. /**
  67360. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  67361. * @returns an array of IParticleSystem
  67362. */
  67363. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  67364. }
  67365. }
  67366. declare module BABYLON {
  67367. /** Defines the 4 color options */
  67368. export enum PointColor {
  67369. /** color value */
  67370. Color = 2,
  67371. /** uv value */
  67372. UV = 1,
  67373. /** random value */
  67374. Random = 0,
  67375. /** stated value */
  67376. Stated = 3
  67377. }
  67378. /**
  67379. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  67380. * 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.
  67381. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  67382. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  67383. *
  67384. * Full documentation here : TO BE ENTERED
  67385. */
  67386. export class PointsCloudSystem implements IDisposable {
  67387. /**
  67388. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  67389. * Example : var p = SPS.particles[i];
  67390. */
  67391. particles: CloudPoint[];
  67392. /**
  67393. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  67394. */
  67395. nbParticles: number;
  67396. /**
  67397. * This a counter for your own usage. It's not set by any SPS functions.
  67398. */
  67399. counter: number;
  67400. /**
  67401. * The PCS name. This name is also given to the underlying mesh.
  67402. */
  67403. name: string;
  67404. /**
  67405. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  67406. */
  67407. mesh: Mesh;
  67408. /**
  67409. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  67410. * Please read :
  67411. */
  67412. vars: any;
  67413. /**
  67414. * @hidden
  67415. */
  67416. _size: number;
  67417. private _scene;
  67418. private _promises;
  67419. private _positions;
  67420. private _indices;
  67421. private _normals;
  67422. private _colors;
  67423. private _uvs;
  67424. private _indices32;
  67425. private _positions32;
  67426. private _colors32;
  67427. private _uvs32;
  67428. private _updatable;
  67429. private _isVisibilityBoxLocked;
  67430. private _alwaysVisible;
  67431. private _groups;
  67432. private _groupCounter;
  67433. private _computeParticleColor;
  67434. private _computeParticleTexture;
  67435. private _computeParticleRotation;
  67436. private _computeBoundingBox;
  67437. private _isReady;
  67438. /**
  67439. * Creates a PCS (Points Cloud System) object
  67440. * @param name (String) is the PCS name, this will be the underlying mesh name
  67441. * @param pointSize (number) is the size for each point
  67442. * @param scene (Scene) is the scene in which the PCS is added
  67443. * @param options defines the options of the PCS e.g.
  67444. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  67445. */
  67446. constructor(name: string, pointSize: number, scene: Scene, options?: {
  67447. updatable?: boolean;
  67448. });
  67449. /**
  67450. * Builds the PCS underlying mesh. Returns a standard Mesh.
  67451. * If no points were added to the PCS, the returned mesh is just a single point.
  67452. * @returns a promise for the created mesh
  67453. */
  67454. buildMeshAsync(): Promise<Mesh>;
  67455. /**
  67456. * @hidden
  67457. */
  67458. private _buildMesh;
  67459. private _addParticle;
  67460. private _randomUnitVector;
  67461. private _getColorIndicesForCoord;
  67462. private _setPointsColorOrUV;
  67463. private _colorFromTexture;
  67464. private _calculateDensity;
  67465. /**
  67466. * Adds points to the PCS in random positions within a unit sphere
  67467. * @param nb (positive integer) the number of particles to be created from this model
  67468. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  67469. * @returns the number of groups in the system
  67470. */
  67471. addPoints(nb: number, pointFunction?: any): number;
  67472. /**
  67473. * Adds points to the PCS from the surface of the model shape
  67474. * @param mesh is any Mesh object that will be used as a surface model for the points
  67475. * @param nb (positive integer) the number of particles to be created from this model
  67476. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67477. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67478. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67479. * @returns the number of groups in the system
  67480. */
  67481. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67482. /**
  67483. * Adds points to the PCS inside the model shape
  67484. * @param mesh is any Mesh object that will be used as a surface model for the points
  67485. * @param nb (positive integer) the number of particles to be created from this model
  67486. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67487. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67488. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67489. * @returns the number of groups in the system
  67490. */
  67491. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67492. /**
  67493. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  67494. * This method calls `updateParticle()` for each particle of the SPS.
  67495. * For an animated SPS, it is usually called within the render loop.
  67496. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  67497. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  67498. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  67499. * @returns the PCS.
  67500. */
  67501. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  67502. /**
  67503. * Disposes the PCS.
  67504. */
  67505. dispose(): void;
  67506. /**
  67507. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  67508. * doc :
  67509. * @returns the PCS.
  67510. */
  67511. refreshVisibleSize(): PointsCloudSystem;
  67512. /**
  67513. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  67514. * @param size the size (float) of the visibility box
  67515. * note : this doesn't lock the PCS mesh bounding box.
  67516. * doc :
  67517. */
  67518. setVisibilityBox(size: number): void;
  67519. /**
  67520. * Gets whether the PCS is always visible or not
  67521. * doc :
  67522. */
  67523. get isAlwaysVisible(): boolean;
  67524. /**
  67525. * Sets the PCS as always visible or not
  67526. * doc :
  67527. */
  67528. set isAlwaysVisible(val: boolean);
  67529. /**
  67530. * Tells to `setParticles()` to compute the particle rotations or not
  67531. * Default value : false. The PCS is faster when it's set to false
  67532. * Note : particle rotations are only applied to parent particles
  67533. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  67534. */
  67535. set computeParticleRotation(val: boolean);
  67536. /**
  67537. * Tells to `setParticles()` to compute the particle colors or not.
  67538. * Default value : true. The PCS is faster when it's set to false.
  67539. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67540. */
  67541. set computeParticleColor(val: boolean);
  67542. set computeParticleTexture(val: boolean);
  67543. /**
  67544. * Gets if `setParticles()` computes the particle colors or not.
  67545. * Default value : false. The PCS is faster when it's set to false.
  67546. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67547. */
  67548. get computeParticleColor(): boolean;
  67549. /**
  67550. * Gets if `setParticles()` computes the particle textures or not.
  67551. * Default value : false. The PCS is faster when it's set to false.
  67552. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  67553. */
  67554. get computeParticleTexture(): boolean;
  67555. /**
  67556. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  67557. */
  67558. set computeBoundingBox(val: boolean);
  67559. /**
  67560. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  67561. */
  67562. get computeBoundingBox(): boolean;
  67563. /**
  67564. * This function does nothing. It may be overwritten to set all the particle first values.
  67565. * The PCS doesn't call this function, you may have to call it by your own.
  67566. * doc :
  67567. */
  67568. initParticles(): void;
  67569. /**
  67570. * This function does nothing. It may be overwritten to recycle a particle
  67571. * The PCS doesn't call this function, you can to call it
  67572. * doc :
  67573. * @param particle The particle to recycle
  67574. * @returns the recycled particle
  67575. */
  67576. recycleParticle(particle: CloudPoint): CloudPoint;
  67577. /**
  67578. * Updates a particle : this function should be overwritten by the user.
  67579. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  67580. * doc :
  67581. * @example : just set a particle position or velocity and recycle conditions
  67582. * @param particle The particle to update
  67583. * @returns the updated particle
  67584. */
  67585. updateParticle(particle: CloudPoint): CloudPoint;
  67586. /**
  67587. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  67588. * This does nothing and may be overwritten by the user.
  67589. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  67590. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  67591. * @param update the boolean update value actually passed to setParticles()
  67592. */
  67593. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67594. /**
  67595. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  67596. * This will be passed three parameters.
  67597. * This does nothing and may be overwritten by the user.
  67598. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  67599. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  67600. * @param update the boolean update value actually passed to setParticles()
  67601. */
  67602. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67603. }
  67604. }
  67605. declare module BABYLON {
  67606. /**
  67607. * Represents one particle of a points cloud system.
  67608. */
  67609. export class CloudPoint {
  67610. /**
  67611. * particle global index
  67612. */
  67613. idx: number;
  67614. /**
  67615. * The color of the particle
  67616. */
  67617. color: Nullable<Color4>;
  67618. /**
  67619. * The world space position of the particle.
  67620. */
  67621. position: Vector3;
  67622. /**
  67623. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  67624. */
  67625. rotation: Vector3;
  67626. /**
  67627. * The world space rotation quaternion of the particle.
  67628. */
  67629. rotationQuaternion: Nullable<Quaternion>;
  67630. /**
  67631. * The uv of the particle.
  67632. */
  67633. uv: Nullable<Vector2>;
  67634. /**
  67635. * The current speed of the particle.
  67636. */
  67637. velocity: Vector3;
  67638. /**
  67639. * The pivot point in the particle local space.
  67640. */
  67641. pivot: Vector3;
  67642. /**
  67643. * Must the particle be translated from its pivot point in its local space ?
  67644. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  67645. * Default : false
  67646. */
  67647. translateFromPivot: boolean;
  67648. /**
  67649. * Index of this particle in the global "positions" array (Internal use)
  67650. * @hidden
  67651. */
  67652. _pos: number;
  67653. /**
  67654. * @hidden Index of this particle in the global "indices" array (Internal use)
  67655. */
  67656. _ind: number;
  67657. /**
  67658. * Group this particle belongs to
  67659. */
  67660. _group: PointsGroup;
  67661. /**
  67662. * Group id of this particle
  67663. */
  67664. groupId: number;
  67665. /**
  67666. * Index of the particle in its group id (Internal use)
  67667. */
  67668. idxInGroup: number;
  67669. /**
  67670. * @hidden Particle BoundingInfo object (Internal use)
  67671. */
  67672. _boundingInfo: BoundingInfo;
  67673. /**
  67674. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  67675. */
  67676. _pcs: PointsCloudSystem;
  67677. /**
  67678. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  67679. */
  67680. _stillInvisible: boolean;
  67681. /**
  67682. * @hidden Last computed particle rotation matrix
  67683. */
  67684. _rotationMatrix: number[];
  67685. /**
  67686. * Parent particle Id, if any.
  67687. * Default null.
  67688. */
  67689. parentId: Nullable<number>;
  67690. /**
  67691. * @hidden Internal global position in the PCS.
  67692. */
  67693. _globalPosition: Vector3;
  67694. /**
  67695. * Creates a Point Cloud object.
  67696. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  67697. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  67698. * @param group (PointsGroup) is the group the particle belongs to
  67699. * @param groupId (integer) is the group identifier in the PCS.
  67700. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  67701. * @param pcs defines the PCS it is associated to
  67702. */
  67703. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  67704. /**
  67705. * get point size
  67706. */
  67707. get size(): Vector3;
  67708. /**
  67709. * Set point size
  67710. */
  67711. set size(scale: Vector3);
  67712. /**
  67713. * Legacy support, changed quaternion to rotationQuaternion
  67714. */
  67715. get quaternion(): Nullable<Quaternion>;
  67716. /**
  67717. * Legacy support, changed quaternion to rotationQuaternion
  67718. */
  67719. set quaternion(q: Nullable<Quaternion>);
  67720. /**
  67721. * Returns a boolean. True if the particle intersects a mesh, else false
  67722. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  67723. * @param target is the object (point or mesh) what the intersection is computed against
  67724. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  67725. * @returns true if it intersects
  67726. */
  67727. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  67728. /**
  67729. * get the rotation matrix of the particle
  67730. * @hidden
  67731. */
  67732. getRotationMatrix(m: Matrix): void;
  67733. }
  67734. /**
  67735. * Represents a group of points in a points cloud system
  67736. * * PCS internal tool, don't use it manually.
  67737. */
  67738. export class PointsGroup {
  67739. /**
  67740. * The group id
  67741. * @hidden
  67742. */
  67743. groupID: number;
  67744. /**
  67745. * image data for group (internal use)
  67746. * @hidden
  67747. */
  67748. _groupImageData: Nullable<ArrayBufferView>;
  67749. /**
  67750. * Image Width (internal use)
  67751. * @hidden
  67752. */
  67753. _groupImgWidth: number;
  67754. /**
  67755. * Image Height (internal use)
  67756. * @hidden
  67757. */
  67758. _groupImgHeight: number;
  67759. /**
  67760. * Custom position function (internal use)
  67761. * @hidden
  67762. */
  67763. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  67764. /**
  67765. * density per facet for surface points
  67766. * @hidden
  67767. */
  67768. _groupDensity: number[];
  67769. /**
  67770. * Only when points are colored by texture carries pointer to texture list array
  67771. * @hidden
  67772. */
  67773. _textureNb: number;
  67774. /**
  67775. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  67776. * PCS internal tool, don't use it manually.
  67777. * @hidden
  67778. */
  67779. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  67780. }
  67781. }
  67782. declare module BABYLON {
  67783. interface Scene {
  67784. /** @hidden (Backing field) */
  67785. _physicsEngine: Nullable<IPhysicsEngine>;
  67786. /** @hidden */
  67787. _physicsTimeAccumulator: number;
  67788. /**
  67789. * Gets the current physics engine
  67790. * @returns a IPhysicsEngine or null if none attached
  67791. */
  67792. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  67793. /**
  67794. * Enables physics to the current scene
  67795. * @param gravity defines the scene's gravity for the physics engine
  67796. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  67797. * @return a boolean indicating if the physics engine was initialized
  67798. */
  67799. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  67800. /**
  67801. * Disables and disposes the physics engine associated with the scene
  67802. */
  67803. disablePhysicsEngine(): void;
  67804. /**
  67805. * Gets a boolean indicating if there is an active physics engine
  67806. * @returns a boolean indicating if there is an active physics engine
  67807. */
  67808. isPhysicsEnabled(): boolean;
  67809. /**
  67810. * Deletes a physics compound impostor
  67811. * @param compound defines the compound to delete
  67812. */
  67813. deleteCompoundImpostor(compound: any): void;
  67814. /**
  67815. * An event triggered when physic simulation is about to be run
  67816. */
  67817. onBeforePhysicsObservable: Observable<Scene>;
  67818. /**
  67819. * An event triggered when physic simulation has been done
  67820. */
  67821. onAfterPhysicsObservable: Observable<Scene>;
  67822. }
  67823. interface AbstractMesh {
  67824. /** @hidden */
  67825. _physicsImpostor: Nullable<PhysicsImpostor>;
  67826. /**
  67827. * Gets or sets impostor used for physic simulation
  67828. * @see https://doc.babylonjs.com/features/physics_engine
  67829. */
  67830. physicsImpostor: Nullable<PhysicsImpostor>;
  67831. /**
  67832. * Gets the current physics impostor
  67833. * @see https://doc.babylonjs.com/features/physics_engine
  67834. * @returns a physics impostor or null
  67835. */
  67836. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  67837. /** Apply a physic impulse to the mesh
  67838. * @param force defines the force to apply
  67839. * @param contactPoint defines where to apply the force
  67840. * @returns the current mesh
  67841. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  67842. */
  67843. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  67844. /**
  67845. * Creates a physic joint between two meshes
  67846. * @param otherMesh defines the other mesh to use
  67847. * @param pivot1 defines the pivot to use on this mesh
  67848. * @param pivot2 defines the pivot to use on the other mesh
  67849. * @param options defines additional options (can be plugin dependent)
  67850. * @returns the current mesh
  67851. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  67852. */
  67853. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  67854. /** @hidden */
  67855. _disposePhysicsObserver: Nullable<Observer<Node>>;
  67856. }
  67857. /**
  67858. * Defines the physics engine scene component responsible to manage a physics engine
  67859. */
  67860. export class PhysicsEngineSceneComponent implements ISceneComponent {
  67861. /**
  67862. * The component name helpful to identify the component in the list of scene components.
  67863. */
  67864. readonly name: string;
  67865. /**
  67866. * The scene the component belongs to.
  67867. */
  67868. scene: Scene;
  67869. /**
  67870. * Creates a new instance of the component for the given scene
  67871. * @param scene Defines the scene to register the component in
  67872. */
  67873. constructor(scene: Scene);
  67874. /**
  67875. * Registers the component in a given scene
  67876. */
  67877. register(): void;
  67878. /**
  67879. * Rebuilds the elements related to this component in case of
  67880. * context lost for instance.
  67881. */
  67882. rebuild(): void;
  67883. /**
  67884. * Disposes the component and the associated ressources
  67885. */
  67886. dispose(): void;
  67887. }
  67888. }
  67889. declare module BABYLON {
  67890. /**
  67891. * A helper for physics simulations
  67892. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67893. */
  67894. export class PhysicsHelper {
  67895. private _scene;
  67896. private _physicsEngine;
  67897. /**
  67898. * Initializes the Physics helper
  67899. * @param scene Babylon.js scene
  67900. */
  67901. constructor(scene: Scene);
  67902. /**
  67903. * Applies a radial explosion impulse
  67904. * @param origin the origin of the explosion
  67905. * @param radiusOrEventOptions the radius or the options of radial explosion
  67906. * @param strength the explosion strength
  67907. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67908. * @returns A physics radial explosion event, or null
  67909. */
  67910. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67911. /**
  67912. * Applies a radial explosion force
  67913. * @param origin the origin of the explosion
  67914. * @param radiusOrEventOptions the radius or the options of radial explosion
  67915. * @param strength the explosion strength
  67916. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67917. * @returns A physics radial explosion event, or null
  67918. */
  67919. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67920. /**
  67921. * Creates a gravitational field
  67922. * @param origin the origin of the explosion
  67923. * @param radiusOrEventOptions the radius or the options of radial explosion
  67924. * @param strength the explosion strength
  67925. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67926. * @returns A physics gravitational field event, or null
  67927. */
  67928. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  67929. /**
  67930. * Creates a physics updraft event
  67931. * @param origin the origin of the updraft
  67932. * @param radiusOrEventOptions the radius or the options of the updraft
  67933. * @param strength the strength of the updraft
  67934. * @param height the height of the updraft
  67935. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  67936. * @returns A physics updraft event, or null
  67937. */
  67938. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  67939. /**
  67940. * Creates a physics vortex event
  67941. * @param origin the of the vortex
  67942. * @param radiusOrEventOptions the radius or the options of the vortex
  67943. * @param strength the strength of the vortex
  67944. * @param height the height of the vortex
  67945. * @returns a Physics vortex event, or null
  67946. * A physics vortex event or null
  67947. */
  67948. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  67949. }
  67950. /**
  67951. * Represents a physics radial explosion event
  67952. */
  67953. class PhysicsRadialExplosionEvent {
  67954. private _scene;
  67955. private _options;
  67956. private _sphere;
  67957. private _dataFetched;
  67958. /**
  67959. * Initializes a radial explosioin event
  67960. * @param _scene BabylonJS scene
  67961. * @param _options The options for the vortex event
  67962. */
  67963. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  67964. /**
  67965. * Returns the data related to the radial explosion event (sphere).
  67966. * @returns The radial explosion event data
  67967. */
  67968. getData(): PhysicsRadialExplosionEventData;
  67969. /**
  67970. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  67971. * @param impostor A physics imposter
  67972. * @param origin the origin of the explosion
  67973. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  67974. */
  67975. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  67976. /**
  67977. * Triggers affecterd impostors callbacks
  67978. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  67979. */
  67980. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  67981. /**
  67982. * Disposes the sphere.
  67983. * @param force Specifies if the sphere should be disposed by force
  67984. */
  67985. dispose(force?: boolean): void;
  67986. /*** Helpers ***/
  67987. private _prepareSphere;
  67988. private _intersectsWithSphere;
  67989. }
  67990. /**
  67991. * Represents a gravitational field event
  67992. */
  67993. class PhysicsGravitationalFieldEvent {
  67994. private _physicsHelper;
  67995. private _scene;
  67996. private _origin;
  67997. private _options;
  67998. private _tickCallback;
  67999. private _sphere;
  68000. private _dataFetched;
  68001. /**
  68002. * Initializes the physics gravitational field event
  68003. * @param _physicsHelper A physics helper
  68004. * @param _scene BabylonJS scene
  68005. * @param _origin The origin position of the gravitational field event
  68006. * @param _options The options for the vortex event
  68007. */
  68008. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  68009. /**
  68010. * Returns the data related to the gravitational field event (sphere).
  68011. * @returns A gravitational field event
  68012. */
  68013. getData(): PhysicsGravitationalFieldEventData;
  68014. /**
  68015. * Enables the gravitational field.
  68016. */
  68017. enable(): void;
  68018. /**
  68019. * Disables the gravitational field.
  68020. */
  68021. disable(): void;
  68022. /**
  68023. * Disposes the sphere.
  68024. * @param force The force to dispose from the gravitational field event
  68025. */
  68026. dispose(force?: boolean): void;
  68027. private _tick;
  68028. }
  68029. /**
  68030. * Represents a physics updraft event
  68031. */
  68032. class PhysicsUpdraftEvent {
  68033. private _scene;
  68034. private _origin;
  68035. private _options;
  68036. private _physicsEngine;
  68037. private _originTop;
  68038. private _originDirection;
  68039. private _tickCallback;
  68040. private _cylinder;
  68041. private _cylinderPosition;
  68042. private _dataFetched;
  68043. /**
  68044. * Initializes the physics updraft event
  68045. * @param _scene BabylonJS scene
  68046. * @param _origin The origin position of the updraft
  68047. * @param _options The options for the updraft event
  68048. */
  68049. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  68050. /**
  68051. * Returns the data related to the updraft event (cylinder).
  68052. * @returns A physics updraft event
  68053. */
  68054. getData(): PhysicsUpdraftEventData;
  68055. /**
  68056. * Enables the updraft.
  68057. */
  68058. enable(): void;
  68059. /**
  68060. * Disables the updraft.
  68061. */
  68062. disable(): void;
  68063. /**
  68064. * Disposes the cylinder.
  68065. * @param force Specifies if the updraft should be disposed by force
  68066. */
  68067. dispose(force?: boolean): void;
  68068. private getImpostorHitData;
  68069. private _tick;
  68070. /*** Helpers ***/
  68071. private _prepareCylinder;
  68072. private _intersectsWithCylinder;
  68073. }
  68074. /**
  68075. * Represents a physics vortex event
  68076. */
  68077. class PhysicsVortexEvent {
  68078. private _scene;
  68079. private _origin;
  68080. private _options;
  68081. private _physicsEngine;
  68082. private _originTop;
  68083. private _tickCallback;
  68084. private _cylinder;
  68085. private _cylinderPosition;
  68086. private _dataFetched;
  68087. /**
  68088. * Initializes the physics vortex event
  68089. * @param _scene The BabylonJS scene
  68090. * @param _origin The origin position of the vortex
  68091. * @param _options The options for the vortex event
  68092. */
  68093. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  68094. /**
  68095. * Returns the data related to the vortex event (cylinder).
  68096. * @returns The physics vortex event data
  68097. */
  68098. getData(): PhysicsVortexEventData;
  68099. /**
  68100. * Enables the vortex.
  68101. */
  68102. enable(): void;
  68103. /**
  68104. * Disables the cortex.
  68105. */
  68106. disable(): void;
  68107. /**
  68108. * Disposes the sphere.
  68109. * @param force
  68110. */
  68111. dispose(force?: boolean): void;
  68112. private getImpostorHitData;
  68113. private _tick;
  68114. /*** Helpers ***/
  68115. private _prepareCylinder;
  68116. private _intersectsWithCylinder;
  68117. }
  68118. /**
  68119. * Options fot the radial explosion event
  68120. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68121. */
  68122. export class PhysicsRadialExplosionEventOptions {
  68123. /**
  68124. * The radius of the sphere for the radial explosion.
  68125. */
  68126. radius: number;
  68127. /**
  68128. * The strenth of the explosion.
  68129. */
  68130. strength: number;
  68131. /**
  68132. * The strenght of the force in correspondence to the distance of the affected object
  68133. */
  68134. falloff: PhysicsRadialImpulseFalloff;
  68135. /**
  68136. * Sphere options for the radial explosion.
  68137. */
  68138. sphere: {
  68139. segments: number;
  68140. diameter: number;
  68141. };
  68142. /**
  68143. * Sphere options for the radial explosion.
  68144. */
  68145. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  68146. }
  68147. /**
  68148. * Options fot the updraft event
  68149. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68150. */
  68151. export class PhysicsUpdraftEventOptions {
  68152. /**
  68153. * The radius of the cylinder for the vortex
  68154. */
  68155. radius: number;
  68156. /**
  68157. * The strenth of the updraft.
  68158. */
  68159. strength: number;
  68160. /**
  68161. * The height of the cylinder for the updraft.
  68162. */
  68163. height: number;
  68164. /**
  68165. * The mode for the the updraft.
  68166. */
  68167. updraftMode: PhysicsUpdraftMode;
  68168. }
  68169. /**
  68170. * Options fot the vortex event
  68171. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68172. */
  68173. export class PhysicsVortexEventOptions {
  68174. /**
  68175. * The radius of the cylinder for the vortex
  68176. */
  68177. radius: number;
  68178. /**
  68179. * The strenth of the vortex.
  68180. */
  68181. strength: number;
  68182. /**
  68183. * The height of the cylinder for the vortex.
  68184. */
  68185. height: number;
  68186. /**
  68187. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  68188. */
  68189. centripetalForceThreshold: number;
  68190. /**
  68191. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  68192. */
  68193. centripetalForceMultiplier: number;
  68194. /**
  68195. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  68196. */
  68197. centrifugalForceMultiplier: number;
  68198. /**
  68199. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  68200. */
  68201. updraftForceMultiplier: number;
  68202. }
  68203. /**
  68204. * The strenght of the force in correspondence to the distance of the affected object
  68205. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68206. */
  68207. export enum PhysicsRadialImpulseFalloff {
  68208. /** Defines that impulse is constant in strength across it's whole radius */
  68209. Constant = 0,
  68210. /** Defines that impulse gets weaker if it's further from the origin */
  68211. Linear = 1
  68212. }
  68213. /**
  68214. * The strength of the force in correspondence to the distance of the affected object
  68215. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68216. */
  68217. export enum PhysicsUpdraftMode {
  68218. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  68219. Center = 0,
  68220. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  68221. Perpendicular = 1
  68222. }
  68223. /**
  68224. * Interface for a physics hit data
  68225. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68226. */
  68227. export interface PhysicsHitData {
  68228. /**
  68229. * The force applied at the contact point
  68230. */
  68231. force: Vector3;
  68232. /**
  68233. * The contact point
  68234. */
  68235. contactPoint: Vector3;
  68236. /**
  68237. * The distance from the origin to the contact point
  68238. */
  68239. distanceFromOrigin: number;
  68240. }
  68241. /**
  68242. * Interface for radial explosion event data
  68243. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68244. */
  68245. export interface PhysicsRadialExplosionEventData {
  68246. /**
  68247. * A sphere used for the radial explosion event
  68248. */
  68249. sphere: Mesh;
  68250. }
  68251. /**
  68252. * Interface for gravitational field event data
  68253. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68254. */
  68255. export interface PhysicsGravitationalFieldEventData {
  68256. /**
  68257. * A sphere mesh used for the gravitational field event
  68258. */
  68259. sphere: Mesh;
  68260. }
  68261. /**
  68262. * Interface for updraft event data
  68263. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68264. */
  68265. export interface PhysicsUpdraftEventData {
  68266. /**
  68267. * A cylinder used for the updraft event
  68268. */
  68269. cylinder: Mesh;
  68270. }
  68271. /**
  68272. * Interface for vortex event data
  68273. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68274. */
  68275. export interface PhysicsVortexEventData {
  68276. /**
  68277. * A cylinder used for the vortex event
  68278. */
  68279. cylinder: Mesh;
  68280. }
  68281. /**
  68282. * Interface for an affected physics impostor
  68283. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68284. */
  68285. export interface PhysicsAffectedImpostorWithData {
  68286. /**
  68287. * The impostor affected by the effect
  68288. */
  68289. impostor: PhysicsImpostor;
  68290. /**
  68291. * The data about the hit/horce from the explosion
  68292. */
  68293. hitData: PhysicsHitData;
  68294. }
  68295. }
  68296. declare module BABYLON {
  68297. /** @hidden */
  68298. export var blackAndWhitePixelShader: {
  68299. name: string;
  68300. shader: string;
  68301. };
  68302. }
  68303. declare module BABYLON {
  68304. /**
  68305. * Post process used to render in black and white
  68306. */
  68307. export class BlackAndWhitePostProcess extends PostProcess {
  68308. /**
  68309. * Linear about to convert he result to black and white (default: 1)
  68310. */
  68311. degree: number;
  68312. /**
  68313. * Creates a black and white post process
  68314. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  68315. * @param name The name of the effect.
  68316. * @param options The required width/height ratio to downsize to before computing the render pass.
  68317. * @param camera The camera to apply the render pass to.
  68318. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68319. * @param engine The engine which the post process will be applied. (default: current engine)
  68320. * @param reusable If the post process can be reused on the same frame. (default: false)
  68321. */
  68322. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68323. }
  68324. }
  68325. declare module BABYLON {
  68326. /**
  68327. * This represents a set of one or more post processes in Babylon.
  68328. * A post process can be used to apply a shader to a texture after it is rendered.
  68329. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68330. */
  68331. export class PostProcessRenderEffect {
  68332. private _postProcesses;
  68333. private _getPostProcesses;
  68334. private _singleInstance;
  68335. private _cameras;
  68336. private _indicesForCamera;
  68337. /**
  68338. * Name of the effect
  68339. * @hidden
  68340. */
  68341. _name: string;
  68342. /**
  68343. * Instantiates a post process render effect.
  68344. * A post process can be used to apply a shader to a texture after it is rendered.
  68345. * @param engine The engine the effect is tied to
  68346. * @param name The name of the effect
  68347. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  68348. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  68349. */
  68350. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  68351. /**
  68352. * Checks if all the post processes in the effect are supported.
  68353. */
  68354. get isSupported(): boolean;
  68355. /**
  68356. * Updates the current state of the effect
  68357. * @hidden
  68358. */
  68359. _update(): void;
  68360. /**
  68361. * Attaches the effect on cameras
  68362. * @param cameras The camera to attach to.
  68363. * @hidden
  68364. */
  68365. _attachCameras(cameras: Camera): void;
  68366. /**
  68367. * Attaches the effect on cameras
  68368. * @param cameras The camera to attach to.
  68369. * @hidden
  68370. */
  68371. _attachCameras(cameras: Camera[]): void;
  68372. /**
  68373. * Detaches the effect on cameras
  68374. * @param cameras The camera to detatch from.
  68375. * @hidden
  68376. */
  68377. _detachCameras(cameras: Camera): void;
  68378. /**
  68379. * Detatches the effect on cameras
  68380. * @param cameras The camera to detatch from.
  68381. * @hidden
  68382. */
  68383. _detachCameras(cameras: Camera[]): void;
  68384. /**
  68385. * Enables the effect on given cameras
  68386. * @param cameras The camera to enable.
  68387. * @hidden
  68388. */
  68389. _enable(cameras: Camera): void;
  68390. /**
  68391. * Enables the effect on given cameras
  68392. * @param cameras The camera to enable.
  68393. * @hidden
  68394. */
  68395. _enable(cameras: Nullable<Camera[]>): void;
  68396. /**
  68397. * Disables the effect on the given cameras
  68398. * @param cameras The camera to disable.
  68399. * @hidden
  68400. */
  68401. _disable(cameras: Camera): void;
  68402. /**
  68403. * Disables the effect on the given cameras
  68404. * @param cameras The camera to disable.
  68405. * @hidden
  68406. */
  68407. _disable(cameras: Nullable<Camera[]>): void;
  68408. /**
  68409. * Gets a list of the post processes contained in the effect.
  68410. * @param camera The camera to get the post processes on.
  68411. * @returns The list of the post processes in the effect.
  68412. */
  68413. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  68414. }
  68415. }
  68416. declare module BABYLON {
  68417. /** @hidden */
  68418. export var extractHighlightsPixelShader: {
  68419. name: string;
  68420. shader: string;
  68421. };
  68422. }
  68423. declare module BABYLON {
  68424. /**
  68425. * 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.
  68426. */
  68427. export class ExtractHighlightsPostProcess extends PostProcess {
  68428. /**
  68429. * The luminance threshold, pixels below this value will be set to black.
  68430. */
  68431. threshold: number;
  68432. /** @hidden */
  68433. _exposure: number;
  68434. /**
  68435. * Post process which has the input texture to be used when performing highlight extraction
  68436. * @hidden
  68437. */
  68438. _inputPostProcess: Nullable<PostProcess>;
  68439. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68440. }
  68441. }
  68442. declare module BABYLON {
  68443. /** @hidden */
  68444. export var bloomMergePixelShader: {
  68445. name: string;
  68446. shader: string;
  68447. };
  68448. }
  68449. declare module BABYLON {
  68450. /**
  68451. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68452. */
  68453. export class BloomMergePostProcess extends PostProcess {
  68454. /** Weight of the bloom to be added to the original input. */
  68455. weight: number;
  68456. /**
  68457. * Creates a new instance of @see BloomMergePostProcess
  68458. * @param name The name of the effect.
  68459. * @param originalFromInput Post process which's input will be used for the merge.
  68460. * @param blurred Blurred highlights post process which's output will be used.
  68461. * @param weight Weight of the bloom to be added to the original input.
  68462. * @param options The required width/height ratio to downsize to before computing the render pass.
  68463. * @param camera The camera to apply the render pass to.
  68464. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68465. * @param engine The engine which the post process will be applied. (default: current engine)
  68466. * @param reusable If the post process can be reused on the same frame. (default: false)
  68467. * @param textureType Type of textures used when performing the post process. (default: 0)
  68468. * @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)
  68469. */
  68470. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  68471. /** Weight of the bloom to be added to the original input. */
  68472. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68473. }
  68474. }
  68475. declare module BABYLON {
  68476. /**
  68477. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  68478. */
  68479. export class BloomEffect extends PostProcessRenderEffect {
  68480. private bloomScale;
  68481. /**
  68482. * @hidden Internal
  68483. */
  68484. _effects: Array<PostProcess>;
  68485. /**
  68486. * @hidden Internal
  68487. */
  68488. _downscale: ExtractHighlightsPostProcess;
  68489. private _blurX;
  68490. private _blurY;
  68491. private _merge;
  68492. /**
  68493. * The luminance threshold to find bright areas of the image to bloom.
  68494. */
  68495. get threshold(): number;
  68496. set threshold(value: number);
  68497. /**
  68498. * The strength of the bloom.
  68499. */
  68500. get weight(): number;
  68501. set weight(value: number);
  68502. /**
  68503. * Specifies the size of the bloom blur kernel, relative to the final output size
  68504. */
  68505. get kernel(): number;
  68506. set kernel(value: number);
  68507. /**
  68508. * Creates a new instance of @see BloomEffect
  68509. * @param scene The scene the effect belongs to.
  68510. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  68511. * @param bloomKernel The size of the kernel to be used when applying the blur.
  68512. * @param bloomWeight The the strength of bloom.
  68513. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68514. * @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)
  68515. */
  68516. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  68517. /**
  68518. * Disposes each of the internal effects for a given camera.
  68519. * @param camera The camera to dispose the effect on.
  68520. */
  68521. disposeEffects(camera: Camera): void;
  68522. /**
  68523. * @hidden Internal
  68524. */
  68525. _updateEffects(): void;
  68526. /**
  68527. * Internal
  68528. * @returns if all the contained post processes are ready.
  68529. * @hidden
  68530. */
  68531. _isReady(): boolean;
  68532. }
  68533. }
  68534. declare module BABYLON {
  68535. /** @hidden */
  68536. export var chromaticAberrationPixelShader: {
  68537. name: string;
  68538. shader: string;
  68539. };
  68540. }
  68541. declare module BABYLON {
  68542. /**
  68543. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  68544. */
  68545. export class ChromaticAberrationPostProcess extends PostProcess {
  68546. /**
  68547. * The amount of seperation of rgb channels (default: 30)
  68548. */
  68549. aberrationAmount: number;
  68550. /**
  68551. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  68552. */
  68553. radialIntensity: number;
  68554. /**
  68555. * 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))
  68556. */
  68557. direction: Vector2;
  68558. /**
  68559. * 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))
  68560. */
  68561. centerPosition: Vector2;
  68562. /**
  68563. * Creates a new instance ChromaticAberrationPostProcess
  68564. * @param name The name of the effect.
  68565. * @param screenWidth The width of the screen to apply the effect on.
  68566. * @param screenHeight The height of the screen to apply the effect on.
  68567. * @param options The required width/height ratio to downsize to before computing the render pass.
  68568. * @param camera The camera to apply the render pass to.
  68569. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68570. * @param engine The engine which the post process will be applied. (default: current engine)
  68571. * @param reusable If the post process can be reused on the same frame. (default: false)
  68572. * @param textureType Type of textures used when performing the post process. (default: 0)
  68573. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  68574. */
  68575. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68576. }
  68577. }
  68578. declare module BABYLON {
  68579. /** @hidden */
  68580. export var circleOfConfusionPixelShader: {
  68581. name: string;
  68582. shader: string;
  68583. };
  68584. }
  68585. declare module BABYLON {
  68586. /**
  68587. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  68588. */
  68589. export class CircleOfConfusionPostProcess extends PostProcess {
  68590. /**
  68591. * 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.
  68592. */
  68593. lensSize: number;
  68594. /**
  68595. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68596. */
  68597. fStop: number;
  68598. /**
  68599. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68600. */
  68601. focusDistance: number;
  68602. /**
  68603. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  68604. */
  68605. focalLength: number;
  68606. private _depthTexture;
  68607. /**
  68608. * Creates a new instance CircleOfConfusionPostProcess
  68609. * @param name The name of the effect.
  68610. * @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.
  68611. * @param options The required width/height ratio to downsize to before computing the render pass.
  68612. * @param camera The camera to apply the render pass to.
  68613. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68614. * @param engine The engine which the post process will be applied. (default: current engine)
  68615. * @param reusable If the post process can be reused on the same frame. (default: false)
  68616. * @param textureType Type of textures used when performing the post process. (default: 0)
  68617. * @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)
  68618. */
  68619. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68620. /**
  68621. * 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.
  68622. */
  68623. set depthTexture(value: RenderTargetTexture);
  68624. }
  68625. }
  68626. declare module BABYLON {
  68627. /** @hidden */
  68628. export var colorCorrectionPixelShader: {
  68629. name: string;
  68630. shader: string;
  68631. };
  68632. }
  68633. declare module BABYLON {
  68634. /**
  68635. *
  68636. * This post-process allows the modification of rendered colors by using
  68637. * a 'look-up table' (LUT). This effect is also called Color Grading.
  68638. *
  68639. * The object needs to be provided an url to a texture containing the color
  68640. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  68641. * Use an image editing software to tweak the LUT to match your needs.
  68642. *
  68643. * For an example of a color LUT, see here:
  68644. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  68645. * For explanations on color grading, see here:
  68646. * @see http://udn.epicgames.com/Three/ColorGrading.html
  68647. *
  68648. */
  68649. export class ColorCorrectionPostProcess extends PostProcess {
  68650. private _colorTableTexture;
  68651. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68652. }
  68653. }
  68654. declare module BABYLON {
  68655. /** @hidden */
  68656. export var convolutionPixelShader: {
  68657. name: string;
  68658. shader: string;
  68659. };
  68660. }
  68661. declare module BABYLON {
  68662. /**
  68663. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  68664. * input texture to perform effects such as edge detection or sharpening
  68665. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68666. */
  68667. export class ConvolutionPostProcess extends PostProcess {
  68668. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68669. kernel: number[];
  68670. /**
  68671. * Creates a new instance ConvolutionPostProcess
  68672. * @param name The name of the effect.
  68673. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  68674. * @param options The required width/height ratio to downsize to before computing the render pass.
  68675. * @param camera The camera to apply the render pass to.
  68676. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68677. * @param engine The engine which the post process will be applied. (default: current engine)
  68678. * @param reusable If the post process can be reused on the same frame. (default: false)
  68679. * @param textureType Type of textures used when performing the post process. (default: 0)
  68680. */
  68681. constructor(name: string,
  68682. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68683. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68684. /**
  68685. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68686. */
  68687. static EdgeDetect0Kernel: number[];
  68688. /**
  68689. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68690. */
  68691. static EdgeDetect1Kernel: number[];
  68692. /**
  68693. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68694. */
  68695. static EdgeDetect2Kernel: number[];
  68696. /**
  68697. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68698. */
  68699. static SharpenKernel: number[];
  68700. /**
  68701. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68702. */
  68703. static EmbossKernel: number[];
  68704. /**
  68705. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68706. */
  68707. static GaussianKernel: number[];
  68708. }
  68709. }
  68710. declare module BABYLON {
  68711. /**
  68712. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  68713. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  68714. * based on samples that have a large difference in distance than the center pixel.
  68715. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  68716. */
  68717. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  68718. direction: Vector2;
  68719. /**
  68720. * Creates a new instance CircleOfConfusionPostProcess
  68721. * @param name The name of the effect.
  68722. * @param scene The scene the effect belongs to.
  68723. * @param direction The direction the blur should be applied.
  68724. * @param kernel The size of the kernel used to blur.
  68725. * @param options The required width/height ratio to downsize to before computing the render pass.
  68726. * @param camera The camera to apply the render pass to.
  68727. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  68728. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  68729. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68730. * @param engine The engine which the post process will be applied. (default: current engine)
  68731. * @param reusable If the post process can be reused on the same frame. (default: false)
  68732. * @param textureType Type of textures used when performing the post process. (default: 0)
  68733. * @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)
  68734. */
  68735. 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);
  68736. }
  68737. }
  68738. declare module BABYLON {
  68739. /** @hidden */
  68740. export var depthOfFieldMergePixelShader: {
  68741. name: string;
  68742. shader: string;
  68743. };
  68744. }
  68745. declare module BABYLON {
  68746. /**
  68747. * Options to be set when merging outputs from the default pipeline.
  68748. */
  68749. export class DepthOfFieldMergePostProcessOptions {
  68750. /**
  68751. * The original image to merge on top of
  68752. */
  68753. originalFromInput: PostProcess;
  68754. /**
  68755. * Parameters to perform the merge of the depth of field effect
  68756. */
  68757. depthOfField?: {
  68758. circleOfConfusion: PostProcess;
  68759. blurSteps: Array<PostProcess>;
  68760. };
  68761. /**
  68762. * Parameters to perform the merge of bloom effect
  68763. */
  68764. bloom?: {
  68765. blurred: PostProcess;
  68766. weight: number;
  68767. };
  68768. }
  68769. /**
  68770. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68771. */
  68772. export class DepthOfFieldMergePostProcess extends PostProcess {
  68773. private blurSteps;
  68774. /**
  68775. * Creates a new instance of DepthOfFieldMergePostProcess
  68776. * @param name The name of the effect.
  68777. * @param originalFromInput Post process which's input will be used for the merge.
  68778. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  68779. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  68780. * @param options The required width/height ratio to downsize to before computing the render pass.
  68781. * @param camera The camera to apply the render pass to.
  68782. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68783. * @param engine The engine which the post process will be applied. (default: current engine)
  68784. * @param reusable If the post process can be reused on the same frame. (default: false)
  68785. * @param textureType Type of textures used when performing the post process. (default: 0)
  68786. * @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)
  68787. */
  68788. 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);
  68789. /**
  68790. * Updates the effect with the current post process compile time values and recompiles the shader.
  68791. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68792. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68793. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68794. * @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
  68795. * @param onCompiled Called when the shader has been compiled.
  68796. * @param onError Called if there is an error when compiling a shader.
  68797. */
  68798. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68799. }
  68800. }
  68801. declare module BABYLON {
  68802. /**
  68803. * Specifies the level of max blur that should be applied when using the depth of field effect
  68804. */
  68805. export enum DepthOfFieldEffectBlurLevel {
  68806. /**
  68807. * Subtle blur
  68808. */
  68809. Low = 0,
  68810. /**
  68811. * Medium blur
  68812. */
  68813. Medium = 1,
  68814. /**
  68815. * Large blur
  68816. */
  68817. High = 2
  68818. }
  68819. /**
  68820. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  68821. */
  68822. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  68823. private _circleOfConfusion;
  68824. /**
  68825. * @hidden Internal, blurs from high to low
  68826. */
  68827. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  68828. private _depthOfFieldBlurY;
  68829. private _dofMerge;
  68830. /**
  68831. * @hidden Internal post processes in depth of field effect
  68832. */
  68833. _effects: Array<PostProcess>;
  68834. /**
  68835. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  68836. */
  68837. set focalLength(value: number);
  68838. get focalLength(): number;
  68839. /**
  68840. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68841. */
  68842. set fStop(value: number);
  68843. get fStop(): number;
  68844. /**
  68845. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68846. */
  68847. set focusDistance(value: number);
  68848. get focusDistance(): number;
  68849. /**
  68850. * 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.
  68851. */
  68852. set lensSize(value: number);
  68853. get lensSize(): number;
  68854. /**
  68855. * Creates a new instance DepthOfFieldEffect
  68856. * @param scene The scene the effect belongs to.
  68857. * @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.
  68858. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68859. * @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)
  68860. */
  68861. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  68862. /**
  68863. * Get the current class name of the current effet
  68864. * @returns "DepthOfFieldEffect"
  68865. */
  68866. getClassName(): string;
  68867. /**
  68868. * 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.
  68869. */
  68870. set depthTexture(value: RenderTargetTexture);
  68871. /**
  68872. * Disposes each of the internal effects for a given camera.
  68873. * @param camera The camera to dispose the effect on.
  68874. */
  68875. disposeEffects(camera: Camera): void;
  68876. /**
  68877. * @hidden Internal
  68878. */
  68879. _updateEffects(): void;
  68880. /**
  68881. * Internal
  68882. * @returns if all the contained post processes are ready.
  68883. * @hidden
  68884. */
  68885. _isReady(): boolean;
  68886. }
  68887. }
  68888. declare module BABYLON {
  68889. /** @hidden */
  68890. export var displayPassPixelShader: {
  68891. name: string;
  68892. shader: string;
  68893. };
  68894. }
  68895. declare module BABYLON {
  68896. /**
  68897. * DisplayPassPostProcess which produces an output the same as it's input
  68898. */
  68899. export class DisplayPassPostProcess extends PostProcess {
  68900. /**
  68901. * Creates the DisplayPassPostProcess
  68902. * @param name The name of the effect.
  68903. * @param options The required width/height ratio to downsize to before computing the render pass.
  68904. * @param camera The camera to apply the render pass to.
  68905. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68906. * @param engine The engine which the post process will be applied. (default: current engine)
  68907. * @param reusable If the post process can be reused on the same frame. (default: false)
  68908. */
  68909. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68910. }
  68911. }
  68912. declare module BABYLON {
  68913. /** @hidden */
  68914. export var filterPixelShader: {
  68915. name: string;
  68916. shader: string;
  68917. };
  68918. }
  68919. declare module BABYLON {
  68920. /**
  68921. * Applies a kernel filter to the image
  68922. */
  68923. export class FilterPostProcess extends PostProcess {
  68924. /** The matrix to be applied to the image */
  68925. kernelMatrix: Matrix;
  68926. /**
  68927. *
  68928. * @param name The name of the effect.
  68929. * @param kernelMatrix The matrix to be applied to the image
  68930. * @param options The required width/height ratio to downsize to before computing the render pass.
  68931. * @param camera The camera to apply the render pass to.
  68932. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68933. * @param engine The engine which the post process will be applied. (default: current engine)
  68934. * @param reusable If the post process can be reused on the same frame. (default: false)
  68935. */
  68936. constructor(name: string,
  68937. /** The matrix to be applied to the image */
  68938. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68939. }
  68940. }
  68941. declare module BABYLON {
  68942. /** @hidden */
  68943. export var fxaaPixelShader: {
  68944. name: string;
  68945. shader: string;
  68946. };
  68947. }
  68948. declare module BABYLON {
  68949. /** @hidden */
  68950. export var fxaaVertexShader: {
  68951. name: string;
  68952. shader: string;
  68953. };
  68954. }
  68955. declare module BABYLON {
  68956. /**
  68957. * Fxaa post process
  68958. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  68959. */
  68960. export class FxaaPostProcess extends PostProcess {
  68961. /** @hidden */
  68962. texelWidth: number;
  68963. /** @hidden */
  68964. texelHeight: number;
  68965. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68966. private _getDefines;
  68967. }
  68968. }
  68969. declare module BABYLON {
  68970. /** @hidden */
  68971. export var grainPixelShader: {
  68972. name: string;
  68973. shader: string;
  68974. };
  68975. }
  68976. declare module BABYLON {
  68977. /**
  68978. * The GrainPostProcess adds noise to the image at mid luminance levels
  68979. */
  68980. export class GrainPostProcess extends PostProcess {
  68981. /**
  68982. * The intensity of the grain added (default: 30)
  68983. */
  68984. intensity: number;
  68985. /**
  68986. * If the grain should be randomized on every frame
  68987. */
  68988. animated: boolean;
  68989. /**
  68990. * Creates a new instance of @see GrainPostProcess
  68991. * @param name The name of the effect.
  68992. * @param options The required width/height ratio to downsize to before computing the render pass.
  68993. * @param camera The camera to apply the render pass to.
  68994. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68995. * @param engine The engine which the post process will be applied. (default: current engine)
  68996. * @param reusable If the post process can be reused on the same frame. (default: false)
  68997. * @param textureType Type of textures used when performing the post process. (default: 0)
  68998. * @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)
  68999. */
  69000. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69001. }
  69002. }
  69003. declare module BABYLON {
  69004. /** @hidden */
  69005. export var highlightsPixelShader: {
  69006. name: string;
  69007. shader: string;
  69008. };
  69009. }
  69010. declare module BABYLON {
  69011. /**
  69012. * Extracts highlights from the image
  69013. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69014. */
  69015. export class HighlightsPostProcess extends PostProcess {
  69016. /**
  69017. * Extracts highlights from the image
  69018. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69019. * @param name The name of the effect.
  69020. * @param options The required width/height ratio to downsize to before computing the render pass.
  69021. * @param camera The camera to apply the render pass to.
  69022. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69023. * @param engine The engine which the post process will be applied. (default: current engine)
  69024. * @param reusable If the post process can be reused on the same frame. (default: false)
  69025. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  69026. */
  69027. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69028. }
  69029. }
  69030. declare module BABYLON {
  69031. /** @hidden */
  69032. export var mrtFragmentDeclaration: {
  69033. name: string;
  69034. shader: string;
  69035. };
  69036. }
  69037. declare module BABYLON {
  69038. /** @hidden */
  69039. export var geometryPixelShader: {
  69040. name: string;
  69041. shader: string;
  69042. };
  69043. }
  69044. declare module BABYLON {
  69045. /** @hidden */
  69046. export var geometryVertexShader: {
  69047. name: string;
  69048. shader: string;
  69049. };
  69050. }
  69051. declare module BABYLON {
  69052. /** @hidden */
  69053. interface ISavedTransformationMatrix {
  69054. world: Matrix;
  69055. viewProjection: Matrix;
  69056. }
  69057. /**
  69058. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  69059. */
  69060. export class GeometryBufferRenderer {
  69061. /**
  69062. * Constant used to retrieve the position texture index in the G-Buffer textures array
  69063. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  69064. */
  69065. static readonly POSITION_TEXTURE_TYPE: number;
  69066. /**
  69067. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  69068. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  69069. */
  69070. static readonly VELOCITY_TEXTURE_TYPE: number;
  69071. /**
  69072. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  69073. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  69074. */
  69075. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  69076. /**
  69077. * Dictionary used to store the previous transformation matrices of each rendered mesh
  69078. * in order to compute objects velocities when enableVelocity is set to "true"
  69079. * @hidden
  69080. */
  69081. _previousTransformationMatrices: {
  69082. [index: number]: ISavedTransformationMatrix;
  69083. };
  69084. /**
  69085. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  69086. * in order to compute objects velocities when enableVelocity is set to "true"
  69087. * @hidden
  69088. */
  69089. _previousBonesTransformationMatrices: {
  69090. [index: number]: Float32Array;
  69091. };
  69092. /**
  69093. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  69094. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  69095. */
  69096. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  69097. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  69098. renderTransparentMeshes: boolean;
  69099. private _scene;
  69100. private _resizeObserver;
  69101. private _multiRenderTarget;
  69102. private _ratio;
  69103. private _enablePosition;
  69104. private _enableVelocity;
  69105. private _enableReflectivity;
  69106. private _positionIndex;
  69107. private _velocityIndex;
  69108. private _reflectivityIndex;
  69109. protected _effect: Effect;
  69110. protected _cachedDefines: string;
  69111. /**
  69112. * Set the render list (meshes to be rendered) used in the G buffer.
  69113. */
  69114. set renderList(meshes: Mesh[]);
  69115. /**
  69116. * Gets wether or not G buffer are supported by the running hardware.
  69117. * This requires draw buffer supports
  69118. */
  69119. get isSupported(): boolean;
  69120. /**
  69121. * Returns the index of the given texture type in the G-Buffer textures array
  69122. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  69123. * @returns the index of the given texture type in the G-Buffer textures array
  69124. */
  69125. getTextureIndex(textureType: number): number;
  69126. /**
  69127. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  69128. */
  69129. get enablePosition(): boolean;
  69130. /**
  69131. * Sets whether or not objects positions are enabled for the G buffer.
  69132. */
  69133. set enablePosition(enable: boolean);
  69134. /**
  69135. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  69136. */
  69137. get enableVelocity(): boolean;
  69138. /**
  69139. * Sets wether or not objects velocities are enabled for the G buffer.
  69140. */
  69141. set enableVelocity(enable: boolean);
  69142. /**
  69143. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  69144. */
  69145. get enableReflectivity(): boolean;
  69146. /**
  69147. * Sets wether or not objects roughness are enabled for the G buffer.
  69148. */
  69149. set enableReflectivity(enable: boolean);
  69150. /**
  69151. * Gets the scene associated with the buffer.
  69152. */
  69153. get scene(): Scene;
  69154. /**
  69155. * Gets the ratio used by the buffer during its creation.
  69156. * How big is the buffer related to the main canvas.
  69157. */
  69158. get ratio(): number;
  69159. /** @hidden */
  69160. static _SceneComponentInitialization: (scene: Scene) => void;
  69161. /**
  69162. * Creates a new G Buffer for the scene
  69163. * @param scene The scene the buffer belongs to
  69164. * @param ratio How big is the buffer related to the main canvas.
  69165. */
  69166. constructor(scene: Scene, ratio?: number);
  69167. /**
  69168. * Checks wether everything is ready to render a submesh to the G buffer.
  69169. * @param subMesh the submesh to check readiness for
  69170. * @param useInstances is the mesh drawn using instance or not
  69171. * @returns true if ready otherwise false
  69172. */
  69173. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69174. /**
  69175. * Gets the current underlying G Buffer.
  69176. * @returns the buffer
  69177. */
  69178. getGBuffer(): MultiRenderTarget;
  69179. /**
  69180. * Gets the number of samples used to render the buffer (anti aliasing).
  69181. */
  69182. get samples(): number;
  69183. /**
  69184. * Sets the number of samples used to render the buffer (anti aliasing).
  69185. */
  69186. set samples(value: number);
  69187. /**
  69188. * Disposes the renderer and frees up associated resources.
  69189. */
  69190. dispose(): void;
  69191. protected _createRenderTargets(): void;
  69192. private _copyBonesTransformationMatrices;
  69193. }
  69194. }
  69195. declare module BABYLON {
  69196. interface Scene {
  69197. /** @hidden (Backing field) */
  69198. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  69199. /**
  69200. * Gets or Sets the current geometry buffer associated to the scene.
  69201. */
  69202. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  69203. /**
  69204. * Enables a GeometryBufferRender and associates it with the scene
  69205. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  69206. * @returns the GeometryBufferRenderer
  69207. */
  69208. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  69209. /**
  69210. * Disables the GeometryBufferRender associated with the scene
  69211. */
  69212. disableGeometryBufferRenderer(): void;
  69213. }
  69214. /**
  69215. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  69216. * in several rendering techniques.
  69217. */
  69218. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  69219. /**
  69220. * The component name helpful to identify the component in the list of scene components.
  69221. */
  69222. readonly name: string;
  69223. /**
  69224. * The scene the component belongs to.
  69225. */
  69226. scene: Scene;
  69227. /**
  69228. * Creates a new instance of the component for the given scene
  69229. * @param scene Defines the scene to register the component in
  69230. */
  69231. constructor(scene: Scene);
  69232. /**
  69233. * Registers the component in a given scene
  69234. */
  69235. register(): void;
  69236. /**
  69237. * Rebuilds the elements related to this component in case of
  69238. * context lost for instance.
  69239. */
  69240. rebuild(): void;
  69241. /**
  69242. * Disposes the component and the associated ressources
  69243. */
  69244. dispose(): void;
  69245. private _gatherRenderTargets;
  69246. }
  69247. }
  69248. declare module BABYLON {
  69249. /** @hidden */
  69250. export var motionBlurPixelShader: {
  69251. name: string;
  69252. shader: string;
  69253. };
  69254. }
  69255. declare module BABYLON {
  69256. /**
  69257. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  69258. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  69259. * As an example, all you have to do is to create the post-process:
  69260. * var mb = new BABYLON.MotionBlurPostProcess(
  69261. * 'mb', // The name of the effect.
  69262. * scene, // The scene containing the objects to blur according to their velocity.
  69263. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  69264. * camera // The camera to apply the render pass to.
  69265. * );
  69266. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  69267. */
  69268. export class MotionBlurPostProcess extends PostProcess {
  69269. /**
  69270. * Defines how much the image is blurred by the movement. Default value is equal to 1
  69271. */
  69272. motionStrength: number;
  69273. /**
  69274. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  69275. */
  69276. get motionBlurSamples(): number;
  69277. /**
  69278. * Sets the number of iterations to be used for motion blur quality
  69279. */
  69280. set motionBlurSamples(samples: number);
  69281. private _motionBlurSamples;
  69282. private _geometryBufferRenderer;
  69283. /**
  69284. * Creates a new instance MotionBlurPostProcess
  69285. * @param name The name of the effect.
  69286. * @param scene The scene containing the objects to blur according to their velocity.
  69287. * @param options The required width/height ratio to downsize to before computing the render pass.
  69288. * @param camera The camera to apply the render pass to.
  69289. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69290. * @param engine The engine which the post process will be applied. (default: current engine)
  69291. * @param reusable If the post process can be reused on the same frame. (default: false)
  69292. * @param textureType Type of textures used when performing the post process. (default: 0)
  69293. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  69294. */
  69295. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69296. /**
  69297. * Excludes the given skinned mesh from computing bones velocities.
  69298. * 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.
  69299. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  69300. */
  69301. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69302. /**
  69303. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  69304. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  69305. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  69306. */
  69307. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69308. /**
  69309. * Disposes the post process.
  69310. * @param camera The camera to dispose the post process on.
  69311. */
  69312. dispose(camera?: Camera): void;
  69313. }
  69314. }
  69315. declare module BABYLON {
  69316. /** @hidden */
  69317. export var refractionPixelShader: {
  69318. name: string;
  69319. shader: string;
  69320. };
  69321. }
  69322. declare module BABYLON {
  69323. /**
  69324. * Post process which applies a refractin texture
  69325. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69326. */
  69327. export class RefractionPostProcess extends PostProcess {
  69328. /** the base color of the refraction (used to taint the rendering) */
  69329. color: Color3;
  69330. /** simulated refraction depth */
  69331. depth: number;
  69332. /** the coefficient of the base color (0 to remove base color tainting) */
  69333. colorLevel: number;
  69334. private _refTexture;
  69335. private _ownRefractionTexture;
  69336. /**
  69337. * Gets or sets the refraction texture
  69338. * Please note that you are responsible for disposing the texture if you set it manually
  69339. */
  69340. get refractionTexture(): Texture;
  69341. set refractionTexture(value: Texture);
  69342. /**
  69343. * Initializes the RefractionPostProcess
  69344. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69345. * @param name The name of the effect.
  69346. * @param refractionTextureUrl Url of the refraction texture to use
  69347. * @param color the base color of the refraction (used to taint the rendering)
  69348. * @param depth simulated refraction depth
  69349. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  69350. * @param camera The camera to apply the render pass to.
  69351. * @param options The required width/height ratio to downsize to before computing the render pass.
  69352. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69353. * @param engine The engine which the post process will be applied. (default: current engine)
  69354. * @param reusable If the post process can be reused on the same frame. (default: false)
  69355. */
  69356. constructor(name: string, refractionTextureUrl: string,
  69357. /** the base color of the refraction (used to taint the rendering) */
  69358. color: Color3,
  69359. /** simulated refraction depth */
  69360. depth: number,
  69361. /** the coefficient of the base color (0 to remove base color tainting) */
  69362. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69363. /**
  69364. * Disposes of the post process
  69365. * @param camera Camera to dispose post process on
  69366. */
  69367. dispose(camera: Camera): void;
  69368. }
  69369. }
  69370. declare module BABYLON {
  69371. /** @hidden */
  69372. export var sharpenPixelShader: {
  69373. name: string;
  69374. shader: string;
  69375. };
  69376. }
  69377. declare module BABYLON {
  69378. /**
  69379. * The SharpenPostProcess applies a sharpen kernel to every pixel
  69380. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69381. */
  69382. export class SharpenPostProcess extends PostProcess {
  69383. /**
  69384. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  69385. */
  69386. colorAmount: number;
  69387. /**
  69388. * How much sharpness should be applied (default: 0.3)
  69389. */
  69390. edgeAmount: number;
  69391. /**
  69392. * Creates a new instance ConvolutionPostProcess
  69393. * @param name The name of the effect.
  69394. * @param options The required width/height ratio to downsize to before computing the render pass.
  69395. * @param camera The camera to apply the render pass to.
  69396. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69397. * @param engine The engine which the post process will be applied. (default: current engine)
  69398. * @param reusable If the post process can be reused on the same frame. (default: false)
  69399. * @param textureType Type of textures used when performing the post process. (default: 0)
  69400. * @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)
  69401. */
  69402. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69403. }
  69404. }
  69405. declare module BABYLON {
  69406. /**
  69407. * PostProcessRenderPipeline
  69408. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69409. */
  69410. export class PostProcessRenderPipeline {
  69411. private engine;
  69412. private _renderEffects;
  69413. private _renderEffectsForIsolatedPass;
  69414. /**
  69415. * List of inspectable custom properties (used by the Inspector)
  69416. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  69417. */
  69418. inspectableCustomProperties: IInspectable[];
  69419. /**
  69420. * @hidden
  69421. */
  69422. protected _cameras: Camera[];
  69423. /** @hidden */
  69424. _name: string;
  69425. /**
  69426. * Gets pipeline name
  69427. */
  69428. get name(): string;
  69429. /** Gets the list of attached cameras */
  69430. get cameras(): Camera[];
  69431. /**
  69432. * Initializes a PostProcessRenderPipeline
  69433. * @param engine engine to add the pipeline to
  69434. * @param name name of the pipeline
  69435. */
  69436. constructor(engine: Engine, name: string);
  69437. /**
  69438. * Gets the class name
  69439. * @returns "PostProcessRenderPipeline"
  69440. */
  69441. getClassName(): string;
  69442. /**
  69443. * If all the render effects in the pipeline are supported
  69444. */
  69445. get isSupported(): boolean;
  69446. /**
  69447. * Adds an effect to the pipeline
  69448. * @param renderEffect the effect to add
  69449. */
  69450. addEffect(renderEffect: PostProcessRenderEffect): void;
  69451. /** @hidden */
  69452. _rebuild(): void;
  69453. /** @hidden */
  69454. _enableEffect(renderEffectName: string, cameras: Camera): void;
  69455. /** @hidden */
  69456. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  69457. /** @hidden */
  69458. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  69459. /** @hidden */
  69460. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  69461. /** @hidden */
  69462. _attachCameras(cameras: Camera, unique: boolean): void;
  69463. /** @hidden */
  69464. _attachCameras(cameras: Camera[], unique: boolean): void;
  69465. /** @hidden */
  69466. _detachCameras(cameras: Camera): void;
  69467. /** @hidden */
  69468. _detachCameras(cameras: Nullable<Camera[]>): void;
  69469. /** @hidden */
  69470. _update(): void;
  69471. /** @hidden */
  69472. _reset(): void;
  69473. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  69474. /**
  69475. * Sets the required values to the prepass renderer.
  69476. * @param prePassRenderer defines the prepass renderer to setup.
  69477. * @returns true if the pre pass is needed.
  69478. */
  69479. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  69480. /**
  69481. * Disposes of the pipeline
  69482. */
  69483. dispose(): void;
  69484. }
  69485. }
  69486. declare module BABYLON {
  69487. /**
  69488. * PostProcessRenderPipelineManager class
  69489. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69490. */
  69491. export class PostProcessRenderPipelineManager {
  69492. private _renderPipelines;
  69493. /**
  69494. * Initializes a PostProcessRenderPipelineManager
  69495. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69496. */
  69497. constructor();
  69498. /**
  69499. * Gets the list of supported render pipelines
  69500. */
  69501. get supportedPipelines(): PostProcessRenderPipeline[];
  69502. /**
  69503. * Adds a pipeline to the manager
  69504. * @param renderPipeline The pipeline to add
  69505. */
  69506. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  69507. /**
  69508. * Attaches a camera to the pipeline
  69509. * @param renderPipelineName The name of the pipeline to attach to
  69510. * @param cameras the camera to attach
  69511. * @param unique if the camera can be attached multiple times to the pipeline
  69512. */
  69513. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  69514. /**
  69515. * Detaches a camera from the pipeline
  69516. * @param renderPipelineName The name of the pipeline to detach from
  69517. * @param cameras the camera to detach
  69518. */
  69519. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  69520. /**
  69521. * Enables an effect by name on a pipeline
  69522. * @param renderPipelineName the name of the pipeline to enable the effect in
  69523. * @param renderEffectName the name of the effect to enable
  69524. * @param cameras the cameras that the effect should be enabled on
  69525. */
  69526. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69527. /**
  69528. * Disables an effect by name on a pipeline
  69529. * @param renderPipelineName the name of the pipeline to disable the effect in
  69530. * @param renderEffectName the name of the effect to disable
  69531. * @param cameras the cameras that the effect should be disabled on
  69532. */
  69533. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69534. /**
  69535. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  69536. */
  69537. update(): void;
  69538. /** @hidden */
  69539. _rebuild(): void;
  69540. /**
  69541. * Disposes of the manager and pipelines
  69542. */
  69543. dispose(): void;
  69544. }
  69545. }
  69546. declare module BABYLON {
  69547. interface Scene {
  69548. /** @hidden (Backing field) */
  69549. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69550. /**
  69551. * Gets the postprocess render pipeline manager
  69552. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69553. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69554. */
  69555. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69556. }
  69557. /**
  69558. * Defines the Render Pipeline scene component responsible to rendering pipelines
  69559. */
  69560. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  69561. /**
  69562. * The component name helpfull to identify the component in the list of scene components.
  69563. */
  69564. readonly name: string;
  69565. /**
  69566. * The scene the component belongs to.
  69567. */
  69568. scene: Scene;
  69569. /**
  69570. * Creates a new instance of the component for the given scene
  69571. * @param scene Defines the scene to register the component in
  69572. */
  69573. constructor(scene: Scene);
  69574. /**
  69575. * Registers the component in a given scene
  69576. */
  69577. register(): void;
  69578. /**
  69579. * Rebuilds the elements related to this component in case of
  69580. * context lost for instance.
  69581. */
  69582. rebuild(): void;
  69583. /**
  69584. * Disposes the component and the associated ressources
  69585. */
  69586. dispose(): void;
  69587. private _gatherRenderTargets;
  69588. }
  69589. }
  69590. declare module BABYLON {
  69591. /**
  69592. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  69593. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69594. */
  69595. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69596. private _scene;
  69597. private _camerasToBeAttached;
  69598. /**
  69599. * ID of the sharpen post process,
  69600. */
  69601. private readonly SharpenPostProcessId;
  69602. /**
  69603. * @ignore
  69604. * ID of the image processing post process;
  69605. */
  69606. readonly ImageProcessingPostProcessId: string;
  69607. /**
  69608. * @ignore
  69609. * ID of the Fast Approximate Anti-Aliasing post process;
  69610. */
  69611. readonly FxaaPostProcessId: string;
  69612. /**
  69613. * ID of the chromatic aberration post process,
  69614. */
  69615. private readonly ChromaticAberrationPostProcessId;
  69616. /**
  69617. * ID of the grain post process
  69618. */
  69619. private readonly GrainPostProcessId;
  69620. /**
  69621. * Sharpen post process which will apply a sharpen convolution to enhance edges
  69622. */
  69623. sharpen: SharpenPostProcess;
  69624. private _sharpenEffect;
  69625. private bloom;
  69626. /**
  69627. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  69628. */
  69629. depthOfField: DepthOfFieldEffect;
  69630. /**
  69631. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69632. */
  69633. fxaa: FxaaPostProcess;
  69634. /**
  69635. * Image post processing pass used to perform operations such as tone mapping or color grading.
  69636. */
  69637. imageProcessing: ImageProcessingPostProcess;
  69638. /**
  69639. * Chromatic aberration post process which will shift rgb colors in the image
  69640. */
  69641. chromaticAberration: ChromaticAberrationPostProcess;
  69642. private _chromaticAberrationEffect;
  69643. /**
  69644. * Grain post process which add noise to the image
  69645. */
  69646. grain: GrainPostProcess;
  69647. private _grainEffect;
  69648. /**
  69649. * Glow post process which adds a glow to emissive areas of the image
  69650. */
  69651. private _glowLayer;
  69652. /**
  69653. * Animations which can be used to tweak settings over a period of time
  69654. */
  69655. animations: Animation[];
  69656. private _imageProcessingConfigurationObserver;
  69657. private _sharpenEnabled;
  69658. private _bloomEnabled;
  69659. private _depthOfFieldEnabled;
  69660. private _depthOfFieldBlurLevel;
  69661. private _fxaaEnabled;
  69662. private _imageProcessingEnabled;
  69663. private _defaultPipelineTextureType;
  69664. private _bloomScale;
  69665. private _chromaticAberrationEnabled;
  69666. private _grainEnabled;
  69667. private _buildAllowed;
  69668. /**
  69669. * Gets active scene
  69670. */
  69671. get scene(): Scene;
  69672. /**
  69673. * Enable or disable the sharpen process from the pipeline
  69674. */
  69675. set sharpenEnabled(enabled: boolean);
  69676. get sharpenEnabled(): boolean;
  69677. private _resizeObserver;
  69678. private _hardwareScaleLevel;
  69679. private _bloomKernel;
  69680. /**
  69681. * Specifies the size of the bloom blur kernel, relative to the final output size
  69682. */
  69683. get bloomKernel(): number;
  69684. set bloomKernel(value: number);
  69685. /**
  69686. * Specifies the weight of the bloom in the final rendering
  69687. */
  69688. private _bloomWeight;
  69689. /**
  69690. * Specifies the luma threshold for the area that will be blurred by the bloom
  69691. */
  69692. private _bloomThreshold;
  69693. private _hdr;
  69694. /**
  69695. * The strength of the bloom.
  69696. */
  69697. set bloomWeight(value: number);
  69698. get bloomWeight(): number;
  69699. /**
  69700. * The strength of the bloom.
  69701. */
  69702. set bloomThreshold(value: number);
  69703. get bloomThreshold(): number;
  69704. /**
  69705. * The scale of the bloom, lower value will provide better performance.
  69706. */
  69707. set bloomScale(value: number);
  69708. get bloomScale(): number;
  69709. /**
  69710. * Enable or disable the bloom from the pipeline
  69711. */
  69712. set bloomEnabled(enabled: boolean);
  69713. get bloomEnabled(): boolean;
  69714. private _rebuildBloom;
  69715. /**
  69716. * If the depth of field is enabled.
  69717. */
  69718. get depthOfFieldEnabled(): boolean;
  69719. set depthOfFieldEnabled(enabled: boolean);
  69720. /**
  69721. * Blur level of the depth of field effect. (Higher blur will effect performance)
  69722. */
  69723. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  69724. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  69725. /**
  69726. * If the anti aliasing is enabled.
  69727. */
  69728. set fxaaEnabled(enabled: boolean);
  69729. get fxaaEnabled(): boolean;
  69730. private _samples;
  69731. /**
  69732. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69733. */
  69734. set samples(sampleCount: number);
  69735. get samples(): number;
  69736. /**
  69737. * If image processing is enabled.
  69738. */
  69739. set imageProcessingEnabled(enabled: boolean);
  69740. get imageProcessingEnabled(): boolean;
  69741. /**
  69742. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  69743. */
  69744. set glowLayerEnabled(enabled: boolean);
  69745. get glowLayerEnabled(): boolean;
  69746. /**
  69747. * Gets the glow layer (or null if not defined)
  69748. */
  69749. get glowLayer(): Nullable<GlowLayer>;
  69750. /**
  69751. * Enable or disable the chromaticAberration process from the pipeline
  69752. */
  69753. set chromaticAberrationEnabled(enabled: boolean);
  69754. get chromaticAberrationEnabled(): boolean;
  69755. /**
  69756. * Enable or disable the grain process from the pipeline
  69757. */
  69758. set grainEnabled(enabled: boolean);
  69759. get grainEnabled(): boolean;
  69760. /**
  69761. * @constructor
  69762. * @param name - The rendering pipeline name (default: "")
  69763. * @param hdr - If high dynamic range textures should be used (default: true)
  69764. * @param scene - The scene linked to this pipeline (default: the last created scene)
  69765. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  69766. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  69767. */
  69768. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  69769. /**
  69770. * Get the class name
  69771. * @returns "DefaultRenderingPipeline"
  69772. */
  69773. getClassName(): string;
  69774. /**
  69775. * Force the compilation of the entire pipeline.
  69776. */
  69777. prepare(): void;
  69778. private _hasCleared;
  69779. private _prevPostProcess;
  69780. private _prevPrevPostProcess;
  69781. private _setAutoClearAndTextureSharing;
  69782. private _depthOfFieldSceneObserver;
  69783. private _buildPipeline;
  69784. private _disposePostProcesses;
  69785. /**
  69786. * Adds a camera to the pipeline
  69787. * @param camera the camera to be added
  69788. */
  69789. addCamera(camera: Camera): void;
  69790. /**
  69791. * Removes a camera from the pipeline
  69792. * @param camera the camera to remove
  69793. */
  69794. removeCamera(camera: Camera): void;
  69795. /**
  69796. * Dispose of the pipeline and stop all post processes
  69797. */
  69798. dispose(): void;
  69799. /**
  69800. * Serialize the rendering pipeline (Used when exporting)
  69801. * @returns the serialized object
  69802. */
  69803. serialize(): any;
  69804. /**
  69805. * Parse the serialized pipeline
  69806. * @param source Source pipeline.
  69807. * @param scene The scene to load the pipeline to.
  69808. * @param rootUrl The URL of the serialized pipeline.
  69809. * @returns An instantiated pipeline from the serialized object.
  69810. */
  69811. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  69812. }
  69813. }
  69814. declare module BABYLON {
  69815. /** @hidden */
  69816. export var lensHighlightsPixelShader: {
  69817. name: string;
  69818. shader: string;
  69819. };
  69820. }
  69821. declare module BABYLON {
  69822. /** @hidden */
  69823. export var depthOfFieldPixelShader: {
  69824. name: string;
  69825. shader: string;
  69826. };
  69827. }
  69828. declare module BABYLON {
  69829. /**
  69830. * BABYLON.JS Chromatic Aberration GLSL Shader
  69831. * Author: Olivier Guyot
  69832. * Separates very slightly R, G and B colors on the edges of the screen
  69833. * Inspired by Francois Tarlier & Martins Upitis
  69834. */
  69835. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  69836. /**
  69837. * @ignore
  69838. * The chromatic aberration PostProcess id in the pipeline
  69839. */
  69840. LensChromaticAberrationEffect: string;
  69841. /**
  69842. * @ignore
  69843. * The highlights enhancing PostProcess id in the pipeline
  69844. */
  69845. HighlightsEnhancingEffect: string;
  69846. /**
  69847. * @ignore
  69848. * The depth-of-field PostProcess id in the pipeline
  69849. */
  69850. LensDepthOfFieldEffect: string;
  69851. private _scene;
  69852. private _depthTexture;
  69853. private _grainTexture;
  69854. private _chromaticAberrationPostProcess;
  69855. private _highlightsPostProcess;
  69856. private _depthOfFieldPostProcess;
  69857. private _edgeBlur;
  69858. private _grainAmount;
  69859. private _chromaticAberration;
  69860. private _distortion;
  69861. private _highlightsGain;
  69862. private _highlightsThreshold;
  69863. private _dofDistance;
  69864. private _dofAperture;
  69865. private _dofDarken;
  69866. private _dofPentagon;
  69867. private _blurNoise;
  69868. /**
  69869. * @constructor
  69870. *
  69871. * Effect parameters are as follow:
  69872. * {
  69873. * chromatic_aberration: number; // from 0 to x (1 for realism)
  69874. * edge_blur: number; // from 0 to x (1 for realism)
  69875. * distortion: number; // from 0 to x (1 for realism)
  69876. * grain_amount: number; // from 0 to 1
  69877. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  69878. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  69879. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  69880. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  69881. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  69882. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  69883. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  69884. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  69885. * }
  69886. * Note: if an effect parameter is unset, effect is disabled
  69887. *
  69888. * @param name The rendering pipeline name
  69889. * @param parameters - An object containing all parameters (see above)
  69890. * @param scene The scene linked to this pipeline
  69891. * @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)
  69892. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69893. */
  69894. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  69895. /**
  69896. * Get the class name
  69897. * @returns "LensRenderingPipeline"
  69898. */
  69899. getClassName(): string;
  69900. /**
  69901. * Gets associated scene
  69902. */
  69903. get scene(): Scene;
  69904. /**
  69905. * Gets or sets the edge blur
  69906. */
  69907. get edgeBlur(): number;
  69908. set edgeBlur(value: number);
  69909. /**
  69910. * Gets or sets the grain amount
  69911. */
  69912. get grainAmount(): number;
  69913. set grainAmount(value: number);
  69914. /**
  69915. * Gets or sets the chromatic aberration amount
  69916. */
  69917. get chromaticAberration(): number;
  69918. set chromaticAberration(value: number);
  69919. /**
  69920. * Gets or sets the depth of field aperture
  69921. */
  69922. get dofAperture(): number;
  69923. set dofAperture(value: number);
  69924. /**
  69925. * Gets or sets the edge distortion
  69926. */
  69927. get edgeDistortion(): number;
  69928. set edgeDistortion(value: number);
  69929. /**
  69930. * Gets or sets the depth of field distortion
  69931. */
  69932. get dofDistortion(): number;
  69933. set dofDistortion(value: number);
  69934. /**
  69935. * Gets or sets the darken out of focus amount
  69936. */
  69937. get darkenOutOfFocus(): number;
  69938. set darkenOutOfFocus(value: number);
  69939. /**
  69940. * Gets or sets a boolean indicating if blur noise is enabled
  69941. */
  69942. get blurNoise(): boolean;
  69943. set blurNoise(value: boolean);
  69944. /**
  69945. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  69946. */
  69947. get pentagonBokeh(): boolean;
  69948. set pentagonBokeh(value: boolean);
  69949. /**
  69950. * Gets or sets the highlight grain amount
  69951. */
  69952. get highlightsGain(): number;
  69953. set highlightsGain(value: number);
  69954. /**
  69955. * Gets or sets the highlight threshold
  69956. */
  69957. get highlightsThreshold(): number;
  69958. set highlightsThreshold(value: number);
  69959. /**
  69960. * Sets the amount of blur at the edges
  69961. * @param amount blur amount
  69962. */
  69963. setEdgeBlur(amount: number): void;
  69964. /**
  69965. * Sets edge blur to 0
  69966. */
  69967. disableEdgeBlur(): void;
  69968. /**
  69969. * Sets the amout of grain
  69970. * @param amount Amount of grain
  69971. */
  69972. setGrainAmount(amount: number): void;
  69973. /**
  69974. * Set grain amount to 0
  69975. */
  69976. disableGrain(): void;
  69977. /**
  69978. * Sets the chromatic aberration amount
  69979. * @param amount amount of chromatic aberration
  69980. */
  69981. setChromaticAberration(amount: number): void;
  69982. /**
  69983. * Sets chromatic aberration amount to 0
  69984. */
  69985. disableChromaticAberration(): void;
  69986. /**
  69987. * Sets the EdgeDistortion amount
  69988. * @param amount amount of EdgeDistortion
  69989. */
  69990. setEdgeDistortion(amount: number): void;
  69991. /**
  69992. * Sets edge distortion to 0
  69993. */
  69994. disableEdgeDistortion(): void;
  69995. /**
  69996. * Sets the FocusDistance amount
  69997. * @param amount amount of FocusDistance
  69998. */
  69999. setFocusDistance(amount: number): void;
  70000. /**
  70001. * Disables depth of field
  70002. */
  70003. disableDepthOfField(): void;
  70004. /**
  70005. * Sets the Aperture amount
  70006. * @param amount amount of Aperture
  70007. */
  70008. setAperture(amount: number): void;
  70009. /**
  70010. * Sets the DarkenOutOfFocus amount
  70011. * @param amount amount of DarkenOutOfFocus
  70012. */
  70013. setDarkenOutOfFocus(amount: number): void;
  70014. private _pentagonBokehIsEnabled;
  70015. /**
  70016. * Creates a pentagon bokeh effect
  70017. */
  70018. enablePentagonBokeh(): void;
  70019. /**
  70020. * Disables the pentagon bokeh effect
  70021. */
  70022. disablePentagonBokeh(): void;
  70023. /**
  70024. * Enables noise blur
  70025. */
  70026. enableNoiseBlur(): void;
  70027. /**
  70028. * Disables noise blur
  70029. */
  70030. disableNoiseBlur(): void;
  70031. /**
  70032. * Sets the HighlightsGain amount
  70033. * @param amount amount of HighlightsGain
  70034. */
  70035. setHighlightsGain(amount: number): void;
  70036. /**
  70037. * Sets the HighlightsThreshold amount
  70038. * @param amount amount of HighlightsThreshold
  70039. */
  70040. setHighlightsThreshold(amount: number): void;
  70041. /**
  70042. * Disables highlights
  70043. */
  70044. disableHighlights(): void;
  70045. /**
  70046. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  70047. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  70048. */
  70049. dispose(disableDepthRender?: boolean): void;
  70050. private _createChromaticAberrationPostProcess;
  70051. private _createHighlightsPostProcess;
  70052. private _createDepthOfFieldPostProcess;
  70053. private _createGrainTexture;
  70054. }
  70055. }
  70056. declare module BABYLON {
  70057. /** @hidden */
  70058. export var ssao2PixelShader: {
  70059. name: string;
  70060. shader: string;
  70061. };
  70062. }
  70063. declare module BABYLON {
  70064. /** @hidden */
  70065. export var ssaoCombinePixelShader: {
  70066. name: string;
  70067. shader: string;
  70068. };
  70069. }
  70070. declare module BABYLON {
  70071. /**
  70072. * Render pipeline to produce ssao effect
  70073. */
  70074. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  70075. /**
  70076. * @ignore
  70077. * The PassPostProcess id in the pipeline that contains the original scene color
  70078. */
  70079. SSAOOriginalSceneColorEffect: string;
  70080. /**
  70081. * @ignore
  70082. * The SSAO PostProcess id in the pipeline
  70083. */
  70084. SSAORenderEffect: string;
  70085. /**
  70086. * @ignore
  70087. * The horizontal blur PostProcess id in the pipeline
  70088. */
  70089. SSAOBlurHRenderEffect: string;
  70090. /**
  70091. * @ignore
  70092. * The vertical blur PostProcess id in the pipeline
  70093. */
  70094. SSAOBlurVRenderEffect: string;
  70095. /**
  70096. * @ignore
  70097. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70098. */
  70099. SSAOCombineRenderEffect: string;
  70100. /**
  70101. * The output strength of the SSAO post-process. Default value is 1.0.
  70102. */
  70103. totalStrength: number;
  70104. /**
  70105. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  70106. */
  70107. maxZ: number;
  70108. /**
  70109. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  70110. */
  70111. minZAspect: number;
  70112. private _samples;
  70113. /**
  70114. * Number of samples used for the SSAO calculations. Default value is 8
  70115. */
  70116. set samples(n: number);
  70117. get samples(): number;
  70118. private _textureSamples;
  70119. /**
  70120. * Number of samples to use for antialiasing
  70121. */
  70122. set textureSamples(n: number);
  70123. get textureSamples(): number;
  70124. /**
  70125. * Force rendering the geometry through geometry buffer
  70126. */
  70127. private _forceGeometryBuffer;
  70128. /**
  70129. * Ratio object used for SSAO ratio and blur ratio
  70130. */
  70131. private _ratio;
  70132. /**
  70133. * Dynamically generated sphere sampler.
  70134. */
  70135. private _sampleSphere;
  70136. /**
  70137. * Blur filter offsets
  70138. */
  70139. private _samplerOffsets;
  70140. private _expensiveBlur;
  70141. /**
  70142. * If bilateral blur should be used
  70143. */
  70144. set expensiveBlur(b: boolean);
  70145. get expensiveBlur(): boolean;
  70146. /**
  70147. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  70148. */
  70149. radius: number;
  70150. /**
  70151. * The base color of the SSAO post-process
  70152. * The final result is "base + ssao" between [0, 1]
  70153. */
  70154. base: number;
  70155. /**
  70156. * Support test.
  70157. */
  70158. static get IsSupported(): boolean;
  70159. private _scene;
  70160. private _randomTexture;
  70161. private _originalColorPostProcess;
  70162. private _ssaoPostProcess;
  70163. private _blurHPostProcess;
  70164. private _blurVPostProcess;
  70165. private _ssaoCombinePostProcess;
  70166. private _prePassRenderer;
  70167. /**
  70168. * Gets active scene
  70169. */
  70170. get scene(): Scene;
  70171. /**
  70172. * @constructor
  70173. * @param name The rendering pipeline name
  70174. * @param scene The scene linked to this pipeline
  70175. * @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 }
  70176. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70177. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  70178. */
  70179. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  70180. /**
  70181. * Get the class name
  70182. * @returns "SSAO2RenderingPipeline"
  70183. */
  70184. getClassName(): string;
  70185. /**
  70186. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70187. */
  70188. dispose(disableGeometryBufferRenderer?: boolean): void;
  70189. private _createBlurPostProcess;
  70190. /** @hidden */
  70191. _rebuild(): void;
  70192. private _bits;
  70193. private _radicalInverse_VdC;
  70194. private _hammersley;
  70195. private _hemisphereSample_uniform;
  70196. private _generateHemisphere;
  70197. private _getDefinesForSSAO;
  70198. private _createSSAOPostProcess;
  70199. private _createSSAOCombinePostProcess;
  70200. private _createRandomTexture;
  70201. /**
  70202. * Serialize the rendering pipeline (Used when exporting)
  70203. * @returns the serialized object
  70204. */
  70205. serialize(): any;
  70206. /**
  70207. * Parse the serialized pipeline
  70208. * @param source Source pipeline.
  70209. * @param scene The scene to load the pipeline to.
  70210. * @param rootUrl The URL of the serialized pipeline.
  70211. * @returns An instantiated pipeline from the serialized object.
  70212. */
  70213. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  70214. /**
  70215. * Sets the required values to the prepass renderer.
  70216. * @param prePassRenderer defines the prepass renderer to setup
  70217. * @returns true if the pre pass is needed.
  70218. */
  70219. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  70220. }
  70221. }
  70222. declare module BABYLON {
  70223. /** @hidden */
  70224. export var ssaoPixelShader: {
  70225. name: string;
  70226. shader: string;
  70227. };
  70228. }
  70229. declare module BABYLON {
  70230. /**
  70231. * Render pipeline to produce ssao effect
  70232. */
  70233. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  70234. /**
  70235. * @ignore
  70236. * The PassPostProcess id in the pipeline that contains the original scene color
  70237. */
  70238. SSAOOriginalSceneColorEffect: string;
  70239. /**
  70240. * @ignore
  70241. * The SSAO PostProcess id in the pipeline
  70242. */
  70243. SSAORenderEffect: string;
  70244. /**
  70245. * @ignore
  70246. * The horizontal blur PostProcess id in the pipeline
  70247. */
  70248. SSAOBlurHRenderEffect: string;
  70249. /**
  70250. * @ignore
  70251. * The vertical blur PostProcess id in the pipeline
  70252. */
  70253. SSAOBlurVRenderEffect: string;
  70254. /**
  70255. * @ignore
  70256. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70257. */
  70258. SSAOCombineRenderEffect: string;
  70259. /**
  70260. * The output strength of the SSAO post-process. Default value is 1.0.
  70261. */
  70262. totalStrength: number;
  70263. /**
  70264. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  70265. */
  70266. radius: number;
  70267. /**
  70268. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  70269. * Must not be equal to fallOff and superior to fallOff.
  70270. * Default value is 0.0075
  70271. */
  70272. area: number;
  70273. /**
  70274. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  70275. * Must not be equal to area and inferior to area.
  70276. * Default value is 0.000001
  70277. */
  70278. fallOff: number;
  70279. /**
  70280. * The base color of the SSAO post-process
  70281. * The final result is "base + ssao" between [0, 1]
  70282. */
  70283. base: number;
  70284. private _scene;
  70285. private _depthTexture;
  70286. private _randomTexture;
  70287. private _originalColorPostProcess;
  70288. private _ssaoPostProcess;
  70289. private _blurHPostProcess;
  70290. private _blurVPostProcess;
  70291. private _ssaoCombinePostProcess;
  70292. private _firstUpdate;
  70293. /**
  70294. * Gets active scene
  70295. */
  70296. get scene(): Scene;
  70297. /**
  70298. * @constructor
  70299. * @param name - The rendering pipeline name
  70300. * @param scene - The scene linked to this pipeline
  70301. * @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 }
  70302. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  70303. */
  70304. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  70305. /**
  70306. * Get the class name
  70307. * @returns "SSAORenderingPipeline"
  70308. */
  70309. getClassName(): string;
  70310. /**
  70311. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70312. */
  70313. dispose(disableDepthRender?: boolean): void;
  70314. private _createBlurPostProcess;
  70315. /** @hidden */
  70316. _rebuild(): void;
  70317. private _createSSAOPostProcess;
  70318. private _createSSAOCombinePostProcess;
  70319. private _createRandomTexture;
  70320. }
  70321. }
  70322. declare module BABYLON {
  70323. /** @hidden */
  70324. export var screenSpaceReflectionPixelShader: {
  70325. name: string;
  70326. shader: string;
  70327. };
  70328. }
  70329. declare module BABYLON {
  70330. /**
  70331. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  70332. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  70333. */
  70334. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  70335. /**
  70336. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  70337. */
  70338. threshold: number;
  70339. /**
  70340. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  70341. */
  70342. strength: number;
  70343. /**
  70344. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  70345. */
  70346. reflectionSpecularFalloffExponent: number;
  70347. /**
  70348. * 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]
  70349. */
  70350. step: number;
  70351. /**
  70352. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  70353. */
  70354. roughnessFactor: number;
  70355. private _geometryBufferRenderer;
  70356. private _enableSmoothReflections;
  70357. private _reflectionSamples;
  70358. private _smoothSteps;
  70359. /**
  70360. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  70361. * @param name The name of the effect.
  70362. * @param scene The scene containing the objects to calculate reflections.
  70363. * @param options The required width/height ratio to downsize to before computing the render pass.
  70364. * @param camera The camera to apply the render pass to.
  70365. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70366. * @param engine The engine which the post process will be applied. (default: current engine)
  70367. * @param reusable If the post process can be reused on the same frame. (default: false)
  70368. * @param textureType Type of textures used when performing the post process. (default: 0)
  70369. * @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)
  70370. */
  70371. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70372. /**
  70373. * Gets wether or not smoothing reflections is enabled.
  70374. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70375. */
  70376. get enableSmoothReflections(): boolean;
  70377. /**
  70378. * Sets wether or not smoothing reflections is enabled.
  70379. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70380. */
  70381. set enableSmoothReflections(enabled: boolean);
  70382. /**
  70383. * Gets the number of samples taken while computing reflections. More samples count is high,
  70384. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70385. */
  70386. get reflectionSamples(): number;
  70387. /**
  70388. * Sets the number of samples taken while computing reflections. More samples count is high,
  70389. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70390. */
  70391. set reflectionSamples(samples: number);
  70392. /**
  70393. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  70394. * more the post-process will require GPU power and can generate a drop in FPS.
  70395. * Default value (5.0) work pretty well in all cases but can be adjusted.
  70396. */
  70397. get smoothSteps(): number;
  70398. set smoothSteps(steps: number);
  70399. private _updateEffectDefines;
  70400. }
  70401. }
  70402. declare module BABYLON {
  70403. /** @hidden */
  70404. export var standardPixelShader: {
  70405. name: string;
  70406. shader: string;
  70407. };
  70408. }
  70409. declare module BABYLON {
  70410. /**
  70411. * Standard rendering pipeline
  70412. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70413. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  70414. */
  70415. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70416. /**
  70417. * Public members
  70418. */
  70419. /**
  70420. * Post-process which contains the original scene color before the pipeline applies all the effects
  70421. */
  70422. originalPostProcess: Nullable<PostProcess>;
  70423. /**
  70424. * Post-process used to down scale an image x4
  70425. */
  70426. downSampleX4PostProcess: Nullable<PostProcess>;
  70427. /**
  70428. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  70429. */
  70430. brightPassPostProcess: Nullable<PostProcess>;
  70431. /**
  70432. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  70433. */
  70434. blurHPostProcesses: PostProcess[];
  70435. /**
  70436. * Post-process array storing all the vertical blur post-processes used by the pipeline
  70437. */
  70438. blurVPostProcesses: PostProcess[];
  70439. /**
  70440. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  70441. */
  70442. textureAdderPostProcess: Nullable<PostProcess>;
  70443. /**
  70444. * Post-process used to create volumetric lighting effect
  70445. */
  70446. volumetricLightPostProcess: Nullable<PostProcess>;
  70447. /**
  70448. * Post-process used to smooth the previous volumetric light post-process on the X axis
  70449. */
  70450. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  70451. /**
  70452. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  70453. */
  70454. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  70455. /**
  70456. * Post-process used to merge the volumetric light effect and the real scene color
  70457. */
  70458. volumetricLightMergePostProces: Nullable<PostProcess>;
  70459. /**
  70460. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  70461. */
  70462. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  70463. /**
  70464. * Base post-process used to calculate the average luminance of the final image for HDR
  70465. */
  70466. luminancePostProcess: Nullable<PostProcess>;
  70467. /**
  70468. * Post-processes used to create down sample post-processes in order to get
  70469. * the average luminance of the final image for HDR
  70470. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  70471. */
  70472. luminanceDownSamplePostProcesses: PostProcess[];
  70473. /**
  70474. * Post-process used to create a HDR effect (light adaptation)
  70475. */
  70476. hdrPostProcess: Nullable<PostProcess>;
  70477. /**
  70478. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  70479. */
  70480. textureAdderFinalPostProcess: Nullable<PostProcess>;
  70481. /**
  70482. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  70483. */
  70484. lensFlareFinalPostProcess: Nullable<PostProcess>;
  70485. /**
  70486. * Post-process used to merge the final HDR post-process and the real scene color
  70487. */
  70488. hdrFinalPostProcess: Nullable<PostProcess>;
  70489. /**
  70490. * Post-process used to create a lens flare effect
  70491. */
  70492. lensFlarePostProcess: Nullable<PostProcess>;
  70493. /**
  70494. * Post-process that merges the result of the lens flare post-process and the real scene color
  70495. */
  70496. lensFlareComposePostProcess: Nullable<PostProcess>;
  70497. /**
  70498. * Post-process used to create a motion blur effect
  70499. */
  70500. motionBlurPostProcess: Nullable<PostProcess>;
  70501. /**
  70502. * Post-process used to create a depth of field effect
  70503. */
  70504. depthOfFieldPostProcess: Nullable<PostProcess>;
  70505. /**
  70506. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70507. */
  70508. fxaaPostProcess: Nullable<FxaaPostProcess>;
  70509. /**
  70510. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  70511. */
  70512. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  70513. /**
  70514. * Represents the brightness threshold in order to configure the illuminated surfaces
  70515. */
  70516. brightThreshold: number;
  70517. /**
  70518. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  70519. */
  70520. blurWidth: number;
  70521. /**
  70522. * Sets if the blur for highlighted surfaces must be only horizontal
  70523. */
  70524. horizontalBlur: boolean;
  70525. /**
  70526. * Gets the overall exposure used by the pipeline
  70527. */
  70528. get exposure(): number;
  70529. /**
  70530. * Sets the overall exposure used by the pipeline
  70531. */
  70532. set exposure(value: number);
  70533. /**
  70534. * Texture used typically to simulate "dirty" on camera lens
  70535. */
  70536. lensTexture: Nullable<Texture>;
  70537. /**
  70538. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  70539. */
  70540. volumetricLightCoefficient: number;
  70541. /**
  70542. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  70543. */
  70544. volumetricLightPower: number;
  70545. /**
  70546. * Used the set the blur intensity to smooth the volumetric lights
  70547. */
  70548. volumetricLightBlurScale: number;
  70549. /**
  70550. * Light (spot or directional) used to generate the volumetric lights rays
  70551. * The source light must have a shadow generate so the pipeline can get its
  70552. * depth map
  70553. */
  70554. sourceLight: Nullable<SpotLight | DirectionalLight>;
  70555. /**
  70556. * For eye adaptation, represents the minimum luminance the eye can see
  70557. */
  70558. hdrMinimumLuminance: number;
  70559. /**
  70560. * For eye adaptation, represents the decrease luminance speed
  70561. */
  70562. hdrDecreaseRate: number;
  70563. /**
  70564. * For eye adaptation, represents the increase luminance speed
  70565. */
  70566. hdrIncreaseRate: number;
  70567. /**
  70568. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70569. */
  70570. get hdrAutoExposure(): boolean;
  70571. /**
  70572. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70573. */
  70574. set hdrAutoExposure(value: boolean);
  70575. /**
  70576. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  70577. */
  70578. lensColorTexture: Nullable<Texture>;
  70579. /**
  70580. * The overall strengh for the lens flare effect
  70581. */
  70582. lensFlareStrength: number;
  70583. /**
  70584. * Dispersion coefficient for lens flare ghosts
  70585. */
  70586. lensFlareGhostDispersal: number;
  70587. /**
  70588. * Main lens flare halo width
  70589. */
  70590. lensFlareHaloWidth: number;
  70591. /**
  70592. * Based on the lens distortion effect, defines how much the lens flare result
  70593. * is distorted
  70594. */
  70595. lensFlareDistortionStrength: number;
  70596. /**
  70597. * Configures the blur intensity used for for lens flare (halo)
  70598. */
  70599. lensFlareBlurWidth: number;
  70600. /**
  70601. * Lens star texture must be used to simulate rays on the flares and is available
  70602. * in the documentation
  70603. */
  70604. lensStarTexture: Nullable<Texture>;
  70605. /**
  70606. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  70607. * flare effect by taking account of the dirt texture
  70608. */
  70609. lensFlareDirtTexture: Nullable<Texture>;
  70610. /**
  70611. * Represents the focal length for the depth of field effect
  70612. */
  70613. depthOfFieldDistance: number;
  70614. /**
  70615. * Represents the blur intensity for the blurred part of the depth of field effect
  70616. */
  70617. depthOfFieldBlurWidth: number;
  70618. /**
  70619. * Gets how much the image is blurred by the movement while using the motion blur post-process
  70620. */
  70621. get motionStrength(): number;
  70622. /**
  70623. * Sets how much the image is blurred by the movement while using the motion blur post-process
  70624. */
  70625. set motionStrength(strength: number);
  70626. /**
  70627. * Gets wether or not the motion blur post-process is object based or screen based.
  70628. */
  70629. get objectBasedMotionBlur(): boolean;
  70630. /**
  70631. * Sets wether or not the motion blur post-process should be object based or screen based
  70632. */
  70633. set objectBasedMotionBlur(value: boolean);
  70634. /**
  70635. * List of animations for the pipeline (IAnimatable implementation)
  70636. */
  70637. animations: Animation[];
  70638. /**
  70639. * Private members
  70640. */
  70641. private _scene;
  70642. private _currentDepthOfFieldSource;
  70643. private _basePostProcess;
  70644. private _fixedExposure;
  70645. private _currentExposure;
  70646. private _hdrAutoExposure;
  70647. private _hdrCurrentLuminance;
  70648. private _motionStrength;
  70649. private _isObjectBasedMotionBlur;
  70650. private _floatTextureType;
  70651. private _camerasToBeAttached;
  70652. private _ratio;
  70653. private _bloomEnabled;
  70654. private _depthOfFieldEnabled;
  70655. private _vlsEnabled;
  70656. private _lensFlareEnabled;
  70657. private _hdrEnabled;
  70658. private _motionBlurEnabled;
  70659. private _fxaaEnabled;
  70660. private _screenSpaceReflectionsEnabled;
  70661. private _motionBlurSamples;
  70662. private _volumetricLightStepsCount;
  70663. private _samples;
  70664. /**
  70665. * @ignore
  70666. * Specifies if the bloom pipeline is enabled
  70667. */
  70668. get BloomEnabled(): boolean;
  70669. set BloomEnabled(enabled: boolean);
  70670. /**
  70671. * @ignore
  70672. * Specifies if the depth of field pipeline is enabed
  70673. */
  70674. get DepthOfFieldEnabled(): boolean;
  70675. set DepthOfFieldEnabled(enabled: boolean);
  70676. /**
  70677. * @ignore
  70678. * Specifies if the lens flare pipeline is enabed
  70679. */
  70680. get LensFlareEnabled(): boolean;
  70681. set LensFlareEnabled(enabled: boolean);
  70682. /**
  70683. * @ignore
  70684. * Specifies if the HDR pipeline is enabled
  70685. */
  70686. get HDREnabled(): boolean;
  70687. set HDREnabled(enabled: boolean);
  70688. /**
  70689. * @ignore
  70690. * Specifies if the volumetric lights scattering effect is enabled
  70691. */
  70692. get VLSEnabled(): boolean;
  70693. set VLSEnabled(enabled: boolean);
  70694. /**
  70695. * @ignore
  70696. * Specifies if the motion blur effect is enabled
  70697. */
  70698. get MotionBlurEnabled(): boolean;
  70699. set MotionBlurEnabled(enabled: boolean);
  70700. /**
  70701. * Specifies if anti-aliasing is enabled
  70702. */
  70703. get fxaaEnabled(): boolean;
  70704. set fxaaEnabled(enabled: boolean);
  70705. /**
  70706. * Specifies if screen space reflections are enabled.
  70707. */
  70708. get screenSpaceReflectionsEnabled(): boolean;
  70709. set screenSpaceReflectionsEnabled(enabled: boolean);
  70710. /**
  70711. * Specifies the number of steps used to calculate the volumetric lights
  70712. * Typically in interval [50, 200]
  70713. */
  70714. get volumetricLightStepsCount(): number;
  70715. set volumetricLightStepsCount(count: number);
  70716. /**
  70717. * Specifies the number of samples used for the motion blur effect
  70718. * Typically in interval [16, 64]
  70719. */
  70720. get motionBlurSamples(): number;
  70721. set motionBlurSamples(samples: number);
  70722. /**
  70723. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70724. */
  70725. get samples(): number;
  70726. set samples(sampleCount: number);
  70727. /**
  70728. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70729. * @constructor
  70730. * @param name The rendering pipeline name
  70731. * @param scene The scene linked to this pipeline
  70732. * @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)
  70733. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  70734. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70735. */
  70736. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  70737. private _buildPipeline;
  70738. private _createDownSampleX4PostProcess;
  70739. private _createBrightPassPostProcess;
  70740. private _createBlurPostProcesses;
  70741. private _createTextureAdderPostProcess;
  70742. private _createVolumetricLightPostProcess;
  70743. private _createLuminancePostProcesses;
  70744. private _createHdrPostProcess;
  70745. private _createLensFlarePostProcess;
  70746. private _createDepthOfFieldPostProcess;
  70747. private _createMotionBlurPostProcess;
  70748. private _getDepthTexture;
  70749. private _disposePostProcesses;
  70750. /**
  70751. * Dispose of the pipeline and stop all post processes
  70752. */
  70753. dispose(): void;
  70754. /**
  70755. * Serialize the rendering pipeline (Used when exporting)
  70756. * @returns the serialized object
  70757. */
  70758. serialize(): any;
  70759. /**
  70760. * Parse the serialized pipeline
  70761. * @param source Source pipeline.
  70762. * @param scene The scene to load the pipeline to.
  70763. * @param rootUrl The URL of the serialized pipeline.
  70764. * @returns An instantiated pipeline from the serialized object.
  70765. */
  70766. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  70767. /**
  70768. * Luminance steps
  70769. */
  70770. static LuminanceSteps: number;
  70771. }
  70772. }
  70773. declare module BABYLON {
  70774. /** @hidden */
  70775. export var stereoscopicInterlacePixelShader: {
  70776. name: string;
  70777. shader: string;
  70778. };
  70779. }
  70780. declare module BABYLON {
  70781. /**
  70782. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  70783. */
  70784. export class StereoscopicInterlacePostProcessI extends PostProcess {
  70785. private _stepSize;
  70786. private _passedProcess;
  70787. /**
  70788. * Initializes a StereoscopicInterlacePostProcessI
  70789. * @param name The name of the effect.
  70790. * @param rigCameras The rig cameras to be appled to the post process
  70791. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  70792. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  70793. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70794. * @param engine The engine which the post process will be applied. (default: current engine)
  70795. * @param reusable If the post process can be reused on the same frame. (default: false)
  70796. */
  70797. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70798. }
  70799. /**
  70800. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  70801. */
  70802. export class StereoscopicInterlacePostProcess extends PostProcess {
  70803. private _stepSize;
  70804. private _passedProcess;
  70805. /**
  70806. * Initializes a StereoscopicInterlacePostProcess
  70807. * @param name The name of the effect.
  70808. * @param rigCameras The rig cameras to be appled to the post process
  70809. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  70810. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70811. * @param engine The engine which the post process will be applied. (default: current engine)
  70812. * @param reusable If the post process can be reused on the same frame. (default: false)
  70813. */
  70814. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70815. }
  70816. }
  70817. declare module BABYLON {
  70818. /** @hidden */
  70819. export var tonemapPixelShader: {
  70820. name: string;
  70821. shader: string;
  70822. };
  70823. }
  70824. declare module BABYLON {
  70825. /** Defines operator used for tonemapping */
  70826. export enum TonemappingOperator {
  70827. /** Hable */
  70828. Hable = 0,
  70829. /** Reinhard */
  70830. Reinhard = 1,
  70831. /** HejiDawson */
  70832. HejiDawson = 2,
  70833. /** Photographic */
  70834. Photographic = 3
  70835. }
  70836. /**
  70837. * Defines a post process to apply tone mapping
  70838. */
  70839. export class TonemapPostProcess extends PostProcess {
  70840. private _operator;
  70841. /** Defines the required exposure adjustement */
  70842. exposureAdjustment: number;
  70843. /**
  70844. * Creates a new TonemapPostProcess
  70845. * @param name defines the name of the postprocess
  70846. * @param _operator defines the operator to use
  70847. * @param exposureAdjustment defines the required exposure adjustement
  70848. * @param camera defines the camera to use (can be null)
  70849. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  70850. * @param engine defines the hosting engine (can be ignore if camera is set)
  70851. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  70852. */
  70853. constructor(name: string, _operator: TonemappingOperator,
  70854. /** Defines the required exposure adjustement */
  70855. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  70856. }
  70857. }
  70858. declare module BABYLON {
  70859. /** @hidden */
  70860. export var volumetricLightScatteringPixelShader: {
  70861. name: string;
  70862. shader: string;
  70863. };
  70864. }
  70865. declare module BABYLON {
  70866. /** @hidden */
  70867. export var volumetricLightScatteringPassVertexShader: {
  70868. name: string;
  70869. shader: string;
  70870. };
  70871. }
  70872. declare module BABYLON {
  70873. /** @hidden */
  70874. export var volumetricLightScatteringPassPixelShader: {
  70875. name: string;
  70876. shader: string;
  70877. };
  70878. }
  70879. declare module BABYLON {
  70880. /**
  70881. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  70882. */
  70883. export class VolumetricLightScatteringPostProcess extends PostProcess {
  70884. private _volumetricLightScatteringPass;
  70885. private _volumetricLightScatteringRTT;
  70886. private _viewPort;
  70887. private _screenCoordinates;
  70888. private _cachedDefines;
  70889. /**
  70890. * If not undefined, the mesh position is computed from the attached node position
  70891. */
  70892. attachedNode: {
  70893. position: Vector3;
  70894. };
  70895. /**
  70896. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  70897. */
  70898. customMeshPosition: Vector3;
  70899. /**
  70900. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  70901. */
  70902. useCustomMeshPosition: boolean;
  70903. /**
  70904. * If the post-process should inverse the light scattering direction
  70905. */
  70906. invert: boolean;
  70907. /**
  70908. * The internal mesh used by the post-process
  70909. */
  70910. mesh: Mesh;
  70911. /**
  70912. * @hidden
  70913. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  70914. */
  70915. get useDiffuseColor(): boolean;
  70916. set useDiffuseColor(useDiffuseColor: boolean);
  70917. /**
  70918. * Array containing the excluded meshes not rendered in the internal pass
  70919. */
  70920. excludedMeshes: AbstractMesh[];
  70921. /**
  70922. * Controls the overall intensity of the post-process
  70923. */
  70924. exposure: number;
  70925. /**
  70926. * Dissipates each sample's contribution in range [0, 1]
  70927. */
  70928. decay: number;
  70929. /**
  70930. * Controls the overall intensity of each sample
  70931. */
  70932. weight: number;
  70933. /**
  70934. * Controls the density of each sample
  70935. */
  70936. density: number;
  70937. /**
  70938. * @constructor
  70939. * @param name The post-process name
  70940. * @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)
  70941. * @param camera The camera that the post-process will be attached to
  70942. * @param mesh The mesh used to create the light scattering
  70943. * @param samples The post-process quality, default 100
  70944. * @param samplingModeThe post-process filtering mode
  70945. * @param engine The babylon engine
  70946. * @param reusable If the post-process is reusable
  70947. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  70948. */
  70949. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  70950. /**
  70951. * Returns the string "VolumetricLightScatteringPostProcess"
  70952. * @returns "VolumetricLightScatteringPostProcess"
  70953. */
  70954. getClassName(): string;
  70955. private _isReady;
  70956. /**
  70957. * Sets the new light position for light scattering effect
  70958. * @param position The new custom light position
  70959. */
  70960. setCustomMeshPosition(position: Vector3): void;
  70961. /**
  70962. * Returns the light position for light scattering effect
  70963. * @return Vector3 The custom light position
  70964. */
  70965. getCustomMeshPosition(): Vector3;
  70966. /**
  70967. * Disposes the internal assets and detaches the post-process from the camera
  70968. */
  70969. dispose(camera: Camera): void;
  70970. /**
  70971. * Returns the render target texture used by the post-process
  70972. * @return the render target texture used by the post-process
  70973. */
  70974. getPass(): RenderTargetTexture;
  70975. private _meshExcluded;
  70976. private _createPass;
  70977. private _updateMeshScreenCoordinates;
  70978. /**
  70979. * Creates a default mesh for the Volumeric Light Scattering post-process
  70980. * @param name The mesh name
  70981. * @param scene The scene where to create the mesh
  70982. * @return the default mesh
  70983. */
  70984. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  70985. }
  70986. }
  70987. declare module BABYLON {
  70988. /** @hidden */
  70989. export var screenSpaceCurvaturePixelShader: {
  70990. name: string;
  70991. shader: string;
  70992. };
  70993. }
  70994. declare module BABYLON {
  70995. /**
  70996. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  70997. */
  70998. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  70999. /**
  71000. * Defines how much ridge the curvature effect displays.
  71001. */
  71002. ridge: number;
  71003. /**
  71004. * Defines how much valley the curvature effect displays.
  71005. */
  71006. valley: number;
  71007. private _geometryBufferRenderer;
  71008. /**
  71009. * Creates a new instance ScreenSpaceCurvaturePostProcess
  71010. * @param name The name of the effect.
  71011. * @param scene The scene containing the objects to blur according to their velocity.
  71012. * @param options The required width/height ratio to downsize to before computing the render pass.
  71013. * @param camera The camera to apply the render pass to.
  71014. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71015. * @param engine The engine which the post process will be applied. (default: current engine)
  71016. * @param reusable If the post process can be reused on the same frame. (default: false)
  71017. * @param textureType Type of textures used when performing the post process. (default: 0)
  71018. * @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)
  71019. */
  71020. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71021. /**
  71022. * Support test.
  71023. */
  71024. static get IsSupported(): boolean;
  71025. }
  71026. }
  71027. declare module BABYLON {
  71028. interface Scene {
  71029. /** @hidden (Backing field) */
  71030. _boundingBoxRenderer: BoundingBoxRenderer;
  71031. /** @hidden (Backing field) */
  71032. _forceShowBoundingBoxes: boolean;
  71033. /**
  71034. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  71035. */
  71036. forceShowBoundingBoxes: boolean;
  71037. /**
  71038. * Gets the bounding box renderer associated with the scene
  71039. * @returns a BoundingBoxRenderer
  71040. */
  71041. getBoundingBoxRenderer(): BoundingBoxRenderer;
  71042. }
  71043. interface AbstractMesh {
  71044. /** @hidden (Backing field) */
  71045. _showBoundingBox: boolean;
  71046. /**
  71047. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  71048. */
  71049. showBoundingBox: boolean;
  71050. }
  71051. /**
  71052. * Component responsible of rendering the bounding box of the meshes in a scene.
  71053. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  71054. */
  71055. export class BoundingBoxRenderer implements ISceneComponent {
  71056. /**
  71057. * The component name helpfull to identify the component in the list of scene components.
  71058. */
  71059. readonly name: string;
  71060. /**
  71061. * The scene the component belongs to.
  71062. */
  71063. scene: Scene;
  71064. /**
  71065. * Color of the bounding box lines placed in front of an object
  71066. */
  71067. frontColor: Color3;
  71068. /**
  71069. * Color of the bounding box lines placed behind an object
  71070. */
  71071. backColor: Color3;
  71072. /**
  71073. * Defines if the renderer should show the back lines or not
  71074. */
  71075. showBackLines: boolean;
  71076. /**
  71077. * Observable raised before rendering a bounding box
  71078. */
  71079. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  71080. /**
  71081. * Observable raised after rendering a bounding box
  71082. */
  71083. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  71084. /**
  71085. * @hidden
  71086. */
  71087. renderList: SmartArray<BoundingBox>;
  71088. private _colorShader;
  71089. private _vertexBuffers;
  71090. private _indexBuffer;
  71091. private _fillIndexBuffer;
  71092. private _fillIndexData;
  71093. /**
  71094. * Instantiates a new bounding box renderer in a scene.
  71095. * @param scene the scene the renderer renders in
  71096. */
  71097. constructor(scene: Scene);
  71098. /**
  71099. * Registers the component in a given scene
  71100. */
  71101. register(): void;
  71102. private _evaluateSubMesh;
  71103. private _activeMesh;
  71104. private _prepareRessources;
  71105. private _createIndexBuffer;
  71106. /**
  71107. * Rebuilds the elements related to this component in case of
  71108. * context lost for instance.
  71109. */
  71110. rebuild(): void;
  71111. /**
  71112. * @hidden
  71113. */
  71114. reset(): void;
  71115. /**
  71116. * Render the bounding boxes of a specific rendering group
  71117. * @param renderingGroupId defines the rendering group to render
  71118. */
  71119. render(renderingGroupId: number): void;
  71120. /**
  71121. * In case of occlusion queries, we can render the occlusion bounding box through this method
  71122. * @param mesh Define the mesh to render the occlusion bounding box for
  71123. */
  71124. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  71125. /**
  71126. * Dispose and release the resources attached to this renderer.
  71127. */
  71128. dispose(): void;
  71129. }
  71130. }
  71131. declare module BABYLON {
  71132. interface Scene {
  71133. /** @hidden (Backing field) */
  71134. _depthRenderer: {
  71135. [id: string]: DepthRenderer;
  71136. };
  71137. /**
  71138. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  71139. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  71140. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  71141. * @returns the created depth renderer
  71142. */
  71143. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  71144. /**
  71145. * Disables a depth renderer for a given camera
  71146. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  71147. */
  71148. disableDepthRenderer(camera?: Nullable<Camera>): void;
  71149. }
  71150. /**
  71151. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  71152. * in several rendering techniques.
  71153. */
  71154. export class DepthRendererSceneComponent implements ISceneComponent {
  71155. /**
  71156. * The component name helpfull to identify the component in the list of scene components.
  71157. */
  71158. readonly name: string;
  71159. /**
  71160. * The scene the component belongs to.
  71161. */
  71162. scene: Scene;
  71163. /**
  71164. * Creates a new instance of the component for the given scene
  71165. * @param scene Defines the scene to register the component in
  71166. */
  71167. constructor(scene: Scene);
  71168. /**
  71169. * Registers the component in a given scene
  71170. */
  71171. register(): void;
  71172. /**
  71173. * Rebuilds the elements related to this component in case of
  71174. * context lost for instance.
  71175. */
  71176. rebuild(): void;
  71177. /**
  71178. * Disposes the component and the associated ressources
  71179. */
  71180. dispose(): void;
  71181. private _gatherRenderTargets;
  71182. private _gatherActiveCameraRenderTargets;
  71183. }
  71184. }
  71185. declare module BABYLON {
  71186. interface AbstractScene {
  71187. /** @hidden (Backing field) */
  71188. _prePassRenderer: Nullable<PrePassRenderer>;
  71189. /**
  71190. * Gets or Sets the current prepass renderer associated to the scene.
  71191. */
  71192. prePassRenderer: Nullable<PrePassRenderer>;
  71193. /**
  71194. * Enables the prepass and associates it with the scene
  71195. * @returns the PrePassRenderer
  71196. */
  71197. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  71198. /**
  71199. * Disables the prepass associated with the scene
  71200. */
  71201. disablePrePassRenderer(): void;
  71202. }
  71203. /**
  71204. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  71205. * in several rendering techniques.
  71206. */
  71207. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  71208. /**
  71209. * The component name helpful to identify the component in the list of scene components.
  71210. */
  71211. readonly name: string;
  71212. /**
  71213. * The scene the component belongs to.
  71214. */
  71215. scene: Scene;
  71216. /**
  71217. * Creates a new instance of the component for the given scene
  71218. * @param scene Defines the scene to register the component in
  71219. */
  71220. constructor(scene: Scene);
  71221. /**
  71222. * Registers the component in a given scene
  71223. */
  71224. register(): void;
  71225. private _beforeCameraDraw;
  71226. private _afterCameraDraw;
  71227. private _beforeClearStage;
  71228. /**
  71229. * Serializes the component data to the specified json object
  71230. * @param serializationObject The object to serialize to
  71231. */
  71232. serialize(serializationObject: any): void;
  71233. /**
  71234. * Adds all the elements from the container to the scene
  71235. * @param container the container holding the elements
  71236. */
  71237. addFromContainer(container: AbstractScene): void;
  71238. /**
  71239. * Removes all the elements in the container from the scene
  71240. * @param container contains the elements to remove
  71241. * @param dispose if the removed element should be disposed (default: false)
  71242. */
  71243. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  71244. /**
  71245. * Rebuilds the elements related to this component in case of
  71246. * context lost for instance.
  71247. */
  71248. rebuild(): void;
  71249. /**
  71250. * Disposes the component and the associated ressources
  71251. */
  71252. dispose(): void;
  71253. }
  71254. }
  71255. declare module BABYLON {
  71256. /** @hidden */
  71257. export var outlinePixelShader: {
  71258. name: string;
  71259. shader: string;
  71260. };
  71261. }
  71262. declare module BABYLON {
  71263. /** @hidden */
  71264. export var outlineVertexShader: {
  71265. name: string;
  71266. shader: string;
  71267. };
  71268. }
  71269. declare module BABYLON {
  71270. interface Scene {
  71271. /** @hidden */
  71272. _outlineRenderer: OutlineRenderer;
  71273. /**
  71274. * Gets the outline renderer associated with the scene
  71275. * @returns a OutlineRenderer
  71276. */
  71277. getOutlineRenderer(): OutlineRenderer;
  71278. }
  71279. interface AbstractMesh {
  71280. /** @hidden (Backing field) */
  71281. _renderOutline: boolean;
  71282. /**
  71283. * Gets or sets a boolean indicating if the outline must be rendered as well
  71284. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  71285. */
  71286. renderOutline: boolean;
  71287. /** @hidden (Backing field) */
  71288. _renderOverlay: boolean;
  71289. /**
  71290. * Gets or sets a boolean indicating if the overlay must be rendered as well
  71291. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  71292. */
  71293. renderOverlay: boolean;
  71294. }
  71295. /**
  71296. * This class is responsible to draw bothe outline/overlay of meshes.
  71297. * It should not be used directly but through the available method on mesh.
  71298. */
  71299. export class OutlineRenderer implements ISceneComponent {
  71300. /**
  71301. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  71302. */
  71303. private static _StencilReference;
  71304. /**
  71305. * The name of the component. Each component must have a unique name.
  71306. */
  71307. name: string;
  71308. /**
  71309. * The scene the component belongs to.
  71310. */
  71311. scene: Scene;
  71312. /**
  71313. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  71314. */
  71315. zOffset: number;
  71316. private _engine;
  71317. private _effect;
  71318. private _cachedDefines;
  71319. private _savedDepthWrite;
  71320. /**
  71321. * Instantiates a new outline renderer. (There could be only one per scene).
  71322. * @param scene Defines the scene it belongs to
  71323. */
  71324. constructor(scene: Scene);
  71325. /**
  71326. * Register the component to one instance of a scene.
  71327. */
  71328. register(): void;
  71329. /**
  71330. * Rebuilds the elements related to this component in case of
  71331. * context lost for instance.
  71332. */
  71333. rebuild(): void;
  71334. /**
  71335. * Disposes the component and the associated ressources.
  71336. */
  71337. dispose(): void;
  71338. /**
  71339. * Renders the outline in the canvas.
  71340. * @param subMesh Defines the sumesh to render
  71341. * @param batch Defines the batch of meshes in case of instances
  71342. * @param useOverlay Defines if the rendering is for the overlay or the outline
  71343. */
  71344. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  71345. /**
  71346. * Returns whether or not the outline renderer is ready for a given submesh.
  71347. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  71348. * @param subMesh Defines the submesh to check readyness for
  71349. * @param useInstances Defines wheter wee are trying to render instances or not
  71350. * @returns true if ready otherwise false
  71351. */
  71352. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  71353. private _beforeRenderingMesh;
  71354. private _afterRenderingMesh;
  71355. }
  71356. }
  71357. declare module BABYLON {
  71358. /**
  71359. * Defines the basic options interface of a Sprite Frame Source Size.
  71360. */
  71361. export interface ISpriteJSONSpriteSourceSize {
  71362. /**
  71363. * number of the original width of the Frame
  71364. */
  71365. w: number;
  71366. /**
  71367. * number of the original height of the Frame
  71368. */
  71369. h: number;
  71370. }
  71371. /**
  71372. * Defines the basic options interface of a Sprite Frame Data.
  71373. */
  71374. export interface ISpriteJSONSpriteFrameData {
  71375. /**
  71376. * number of the x offset of the Frame
  71377. */
  71378. x: number;
  71379. /**
  71380. * number of the y offset of the Frame
  71381. */
  71382. y: number;
  71383. /**
  71384. * number of the width of the Frame
  71385. */
  71386. w: number;
  71387. /**
  71388. * number of the height of the Frame
  71389. */
  71390. h: number;
  71391. }
  71392. /**
  71393. * Defines the basic options interface of a JSON Sprite.
  71394. */
  71395. export interface ISpriteJSONSprite {
  71396. /**
  71397. * string name of the Frame
  71398. */
  71399. filename: string;
  71400. /**
  71401. * ISpriteJSONSpriteFrame basic object of the frame data
  71402. */
  71403. frame: ISpriteJSONSpriteFrameData;
  71404. /**
  71405. * boolean to flag is the frame was rotated.
  71406. */
  71407. rotated: boolean;
  71408. /**
  71409. * boolean to flag is the frame was trimmed.
  71410. */
  71411. trimmed: boolean;
  71412. /**
  71413. * ISpriteJSONSpriteFrame basic object of the source data
  71414. */
  71415. spriteSourceSize: ISpriteJSONSpriteFrameData;
  71416. /**
  71417. * ISpriteJSONSpriteFrame basic object of the source data
  71418. */
  71419. sourceSize: ISpriteJSONSpriteSourceSize;
  71420. }
  71421. /**
  71422. * Defines the basic options interface of a JSON atlas.
  71423. */
  71424. export interface ISpriteJSONAtlas {
  71425. /**
  71426. * Array of objects that contain the frame data.
  71427. */
  71428. frames: Array<ISpriteJSONSprite>;
  71429. /**
  71430. * object basic object containing the sprite meta data.
  71431. */
  71432. meta?: object;
  71433. }
  71434. }
  71435. declare module BABYLON {
  71436. /** @hidden */
  71437. export var spriteMapPixelShader: {
  71438. name: string;
  71439. shader: string;
  71440. };
  71441. }
  71442. declare module BABYLON {
  71443. /** @hidden */
  71444. export var spriteMapVertexShader: {
  71445. name: string;
  71446. shader: string;
  71447. };
  71448. }
  71449. declare module BABYLON {
  71450. /**
  71451. * Defines the basic options interface of a SpriteMap
  71452. */
  71453. export interface ISpriteMapOptions {
  71454. /**
  71455. * Vector2 of the number of cells in the grid.
  71456. */
  71457. stageSize?: Vector2;
  71458. /**
  71459. * Vector2 of the size of the output plane in World Units.
  71460. */
  71461. outputSize?: Vector2;
  71462. /**
  71463. * Vector3 of the position of the output plane in World Units.
  71464. */
  71465. outputPosition?: Vector3;
  71466. /**
  71467. * Vector3 of the rotation of the output plane.
  71468. */
  71469. outputRotation?: Vector3;
  71470. /**
  71471. * number of layers that the system will reserve in resources.
  71472. */
  71473. layerCount?: number;
  71474. /**
  71475. * number of max animation frames a single cell will reserve in resources.
  71476. */
  71477. maxAnimationFrames?: number;
  71478. /**
  71479. * number cell index of the base tile when the system compiles.
  71480. */
  71481. baseTile?: number;
  71482. /**
  71483. * boolean flip the sprite after its been repositioned by the framing data.
  71484. */
  71485. flipU?: boolean;
  71486. /**
  71487. * Vector3 scalar of the global RGB values of the SpriteMap.
  71488. */
  71489. colorMultiply?: Vector3;
  71490. }
  71491. /**
  71492. * Defines the IDisposable interface in order to be cleanable from resources.
  71493. */
  71494. export interface ISpriteMap extends IDisposable {
  71495. /**
  71496. * String name of the SpriteMap.
  71497. */
  71498. name: string;
  71499. /**
  71500. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  71501. */
  71502. atlasJSON: ISpriteJSONAtlas;
  71503. /**
  71504. * Texture of the SpriteMap.
  71505. */
  71506. spriteSheet: Texture;
  71507. /**
  71508. * The parameters to initialize the SpriteMap with.
  71509. */
  71510. options: ISpriteMapOptions;
  71511. }
  71512. /**
  71513. * Class used to manage a grid restricted sprite deployment on an Output plane.
  71514. */
  71515. export class SpriteMap implements ISpriteMap {
  71516. /** The Name of the spriteMap */
  71517. name: string;
  71518. /** The JSON file with the frame and meta data */
  71519. atlasJSON: ISpriteJSONAtlas;
  71520. /** The systems Sprite Sheet Texture */
  71521. spriteSheet: Texture;
  71522. /** Arguments passed with the Constructor */
  71523. options: ISpriteMapOptions;
  71524. /** Public Sprite Storage array, parsed from atlasJSON */
  71525. sprites: Array<ISpriteJSONSprite>;
  71526. /** Returns the Number of Sprites in the System */
  71527. get spriteCount(): number;
  71528. /** Returns the Position of Output Plane*/
  71529. get position(): Vector3;
  71530. /** Returns the Position of Output Plane*/
  71531. set position(v: Vector3);
  71532. /** Returns the Rotation of Output Plane*/
  71533. get rotation(): Vector3;
  71534. /** Returns the Rotation of Output Plane*/
  71535. set rotation(v: Vector3);
  71536. /** Sets the AnimationMap*/
  71537. get animationMap(): RawTexture;
  71538. /** Sets the AnimationMap*/
  71539. set animationMap(v: RawTexture);
  71540. /** Scene that the SpriteMap was created in */
  71541. private _scene;
  71542. /** Texture Buffer of Float32 that holds tile frame data*/
  71543. private _frameMap;
  71544. /** Texture Buffers of Float32 that holds tileMap data*/
  71545. private _tileMaps;
  71546. /** Texture Buffer of Float32 that holds Animation Data*/
  71547. private _animationMap;
  71548. /** Custom ShaderMaterial Central to the System*/
  71549. private _material;
  71550. /** Custom ShaderMaterial Central to the System*/
  71551. private _output;
  71552. /** Systems Time Ticker*/
  71553. private _time;
  71554. /**
  71555. * Creates a new SpriteMap
  71556. * @param name defines the SpriteMaps Name
  71557. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  71558. * @param spriteSheet is the Texture that the Sprites are on.
  71559. * @param options a basic deployment configuration
  71560. * @param scene The Scene that the map is deployed on
  71561. */
  71562. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  71563. /**
  71564. * Returns tileID location
  71565. * @returns Vector2 the cell position ID
  71566. */
  71567. getTileID(): Vector2;
  71568. /**
  71569. * Gets the UV location of the mouse over the SpriteMap.
  71570. * @returns Vector2 the UV position of the mouse interaction
  71571. */
  71572. getMousePosition(): Vector2;
  71573. /**
  71574. * Creates the "frame" texture Buffer
  71575. * -------------------------------------
  71576. * Structure of frames
  71577. * "filename": "Falling-Water-2.png",
  71578. * "frame": {"x":69,"y":103,"w":24,"h":32},
  71579. * "rotated": true,
  71580. * "trimmed": true,
  71581. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  71582. * "sourceSize": {"w":32,"h":32}
  71583. * @returns RawTexture of the frameMap
  71584. */
  71585. private _createFrameBuffer;
  71586. /**
  71587. * Creates the tileMap texture Buffer
  71588. * @param buffer normally and array of numbers, or a false to generate from scratch
  71589. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  71590. * @returns RawTexture of the tileMap
  71591. */
  71592. private _createTileBuffer;
  71593. /**
  71594. * Modifies the data of the tileMaps
  71595. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  71596. * @param pos is the iVector2 Coordinates of the Tile
  71597. * @param tile The SpriteIndex of the new Tile
  71598. */
  71599. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  71600. /**
  71601. * Creates the animationMap texture Buffer
  71602. * @param buffer normally and array of numbers, or a false to generate from scratch
  71603. * @returns RawTexture of the animationMap
  71604. */
  71605. private _createTileAnimationBuffer;
  71606. /**
  71607. * Modifies the data of the animationMap
  71608. * @param cellID is the Index of the Sprite
  71609. * @param _frame is the target Animation frame
  71610. * @param toCell is the Target Index of the next frame of the animation
  71611. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  71612. * @param speed is a global scalar of the time variable on the map.
  71613. */
  71614. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  71615. /**
  71616. * Exports the .tilemaps file
  71617. */
  71618. saveTileMaps(): void;
  71619. /**
  71620. * Imports the .tilemaps file
  71621. * @param url of the .tilemaps file
  71622. */
  71623. loadTileMaps(url: string): void;
  71624. /**
  71625. * Release associated resources
  71626. */
  71627. dispose(): void;
  71628. }
  71629. }
  71630. declare module BABYLON {
  71631. /**
  71632. * Class used to manage multiple sprites of different sizes on the same spritesheet
  71633. * @see https://doc.babylonjs.com/babylon101/sprites
  71634. */
  71635. export class SpritePackedManager extends SpriteManager {
  71636. /** defines the packed manager's name */
  71637. name: string;
  71638. /**
  71639. * Creates a new sprite manager from a packed sprite sheet
  71640. * @param name defines the manager's name
  71641. * @param imgUrl defines the sprite sheet url
  71642. * @param capacity defines the maximum allowed number of sprites
  71643. * @param scene defines the hosting scene
  71644. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  71645. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71646. * @param samplingMode defines the smapling mode to use with spritesheet
  71647. * @param fromPacked set to true; do not alter
  71648. */
  71649. constructor(
  71650. /** defines the packed manager's name */
  71651. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  71652. }
  71653. }
  71654. declare module BABYLON {
  71655. /**
  71656. * Defines the list of states available for a task inside a AssetsManager
  71657. */
  71658. export enum AssetTaskState {
  71659. /**
  71660. * Initialization
  71661. */
  71662. INIT = 0,
  71663. /**
  71664. * Running
  71665. */
  71666. RUNNING = 1,
  71667. /**
  71668. * Done
  71669. */
  71670. DONE = 2,
  71671. /**
  71672. * Error
  71673. */
  71674. ERROR = 3
  71675. }
  71676. /**
  71677. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  71678. */
  71679. export abstract class AbstractAssetTask {
  71680. /**
  71681. * Task name
  71682. */ name: string;
  71683. /**
  71684. * Callback called when the task is successful
  71685. */
  71686. onSuccess: (task: any) => void;
  71687. /**
  71688. * Callback called when the task is not successful
  71689. */
  71690. onError: (task: any, message?: string, exception?: any) => void;
  71691. /**
  71692. * Creates a new AssetsManager
  71693. * @param name defines the name of the task
  71694. */
  71695. constructor(
  71696. /**
  71697. * Task name
  71698. */ name: string);
  71699. private _isCompleted;
  71700. private _taskState;
  71701. private _errorObject;
  71702. /**
  71703. * Get if the task is completed
  71704. */
  71705. get isCompleted(): boolean;
  71706. /**
  71707. * Gets the current state of the task
  71708. */
  71709. get taskState(): AssetTaskState;
  71710. /**
  71711. * Gets the current error object (if task is in error)
  71712. */
  71713. get errorObject(): {
  71714. message?: string;
  71715. exception?: any;
  71716. };
  71717. /**
  71718. * Internal only
  71719. * @hidden
  71720. */
  71721. _setErrorObject(message?: string, exception?: any): void;
  71722. /**
  71723. * Execute the current task
  71724. * @param scene defines the scene where you want your assets to be loaded
  71725. * @param onSuccess is a callback called when the task is successfully executed
  71726. * @param onError is a callback called if an error occurs
  71727. */
  71728. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71729. /**
  71730. * Execute the current task
  71731. * @param scene defines the scene where you want your assets to be loaded
  71732. * @param onSuccess is a callback called when the task is successfully executed
  71733. * @param onError is a callback called if an error occurs
  71734. */
  71735. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71736. /**
  71737. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  71738. * This can be used with failed tasks that have the reason for failure fixed.
  71739. */
  71740. reset(): void;
  71741. private onErrorCallback;
  71742. private onDoneCallback;
  71743. }
  71744. /**
  71745. * Define the interface used by progress events raised during assets loading
  71746. */
  71747. export interface IAssetsProgressEvent {
  71748. /**
  71749. * Defines the number of remaining tasks to process
  71750. */
  71751. remainingCount: number;
  71752. /**
  71753. * Defines the total number of tasks
  71754. */
  71755. totalCount: number;
  71756. /**
  71757. * Defines the task that was just processed
  71758. */
  71759. task: AbstractAssetTask;
  71760. }
  71761. /**
  71762. * Class used to share progress information about assets loading
  71763. */
  71764. export class AssetsProgressEvent implements IAssetsProgressEvent {
  71765. /**
  71766. * Defines the number of remaining tasks to process
  71767. */
  71768. remainingCount: number;
  71769. /**
  71770. * Defines the total number of tasks
  71771. */
  71772. totalCount: number;
  71773. /**
  71774. * Defines the task that was just processed
  71775. */
  71776. task: AbstractAssetTask;
  71777. /**
  71778. * Creates a AssetsProgressEvent
  71779. * @param remainingCount defines the number of remaining tasks to process
  71780. * @param totalCount defines the total number of tasks
  71781. * @param task defines the task that was just processed
  71782. */
  71783. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  71784. }
  71785. /**
  71786. * Define a task used by AssetsManager to load meshes
  71787. */
  71788. export class MeshAssetTask extends AbstractAssetTask {
  71789. /**
  71790. * Defines the name of the task
  71791. */
  71792. name: string;
  71793. /**
  71794. * Defines the list of mesh's names you want to load
  71795. */
  71796. meshesNames: any;
  71797. /**
  71798. * Defines the root url to use as a base to load your meshes and associated resources
  71799. */
  71800. rootUrl: string;
  71801. /**
  71802. * Defines the filename or File of the scene to load from
  71803. */
  71804. sceneFilename: string | File;
  71805. /**
  71806. * Gets the list of loaded meshes
  71807. */
  71808. loadedMeshes: Array<AbstractMesh>;
  71809. /**
  71810. * Gets the list of loaded particle systems
  71811. */
  71812. loadedParticleSystems: Array<IParticleSystem>;
  71813. /**
  71814. * Gets the list of loaded skeletons
  71815. */
  71816. loadedSkeletons: Array<Skeleton>;
  71817. /**
  71818. * Gets the list of loaded animation groups
  71819. */
  71820. loadedAnimationGroups: Array<AnimationGroup>;
  71821. /**
  71822. * Callback called when the task is successful
  71823. */
  71824. onSuccess: (task: MeshAssetTask) => void;
  71825. /**
  71826. * Callback called when the task is successful
  71827. */
  71828. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  71829. /**
  71830. * Creates a new MeshAssetTask
  71831. * @param name defines the name of the task
  71832. * @param meshesNames defines the list of mesh's names you want to load
  71833. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  71834. * @param sceneFilename defines the filename or File of the scene to load from
  71835. */
  71836. constructor(
  71837. /**
  71838. * Defines the name of the task
  71839. */
  71840. name: string,
  71841. /**
  71842. * Defines the list of mesh's names you want to load
  71843. */
  71844. meshesNames: any,
  71845. /**
  71846. * Defines the root url to use as a base to load your meshes and associated resources
  71847. */
  71848. rootUrl: string,
  71849. /**
  71850. * Defines the filename or File of the scene to load from
  71851. */
  71852. sceneFilename: string | File);
  71853. /**
  71854. * Execute the current task
  71855. * @param scene defines the scene where you want your assets to be loaded
  71856. * @param onSuccess is a callback called when the task is successfully executed
  71857. * @param onError is a callback called if an error occurs
  71858. */
  71859. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71860. }
  71861. /**
  71862. * Define a task used by AssetsManager to load text content
  71863. */
  71864. export class TextFileAssetTask extends AbstractAssetTask {
  71865. /**
  71866. * Defines the name of the task
  71867. */
  71868. name: string;
  71869. /**
  71870. * Defines the location of the file to load
  71871. */
  71872. url: string;
  71873. /**
  71874. * Gets the loaded text string
  71875. */
  71876. text: string;
  71877. /**
  71878. * Callback called when the task is successful
  71879. */
  71880. onSuccess: (task: TextFileAssetTask) => void;
  71881. /**
  71882. * Callback called when the task is successful
  71883. */
  71884. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  71885. /**
  71886. * Creates a new TextFileAssetTask object
  71887. * @param name defines the name of the task
  71888. * @param url defines the location of the file to load
  71889. */
  71890. constructor(
  71891. /**
  71892. * Defines the name of the task
  71893. */
  71894. name: string,
  71895. /**
  71896. * Defines the location of the file to load
  71897. */
  71898. url: string);
  71899. /**
  71900. * Execute the current task
  71901. * @param scene defines the scene where you want your assets to be loaded
  71902. * @param onSuccess is a callback called when the task is successfully executed
  71903. * @param onError is a callback called if an error occurs
  71904. */
  71905. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71906. }
  71907. /**
  71908. * Define a task used by AssetsManager to load binary data
  71909. */
  71910. export class BinaryFileAssetTask extends AbstractAssetTask {
  71911. /**
  71912. * Defines the name of the task
  71913. */
  71914. name: string;
  71915. /**
  71916. * Defines the location of the file to load
  71917. */
  71918. url: string;
  71919. /**
  71920. * Gets the lodaded data (as an array buffer)
  71921. */
  71922. data: ArrayBuffer;
  71923. /**
  71924. * Callback called when the task is successful
  71925. */
  71926. onSuccess: (task: BinaryFileAssetTask) => void;
  71927. /**
  71928. * Callback called when the task is successful
  71929. */
  71930. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  71931. /**
  71932. * Creates a new BinaryFileAssetTask object
  71933. * @param name defines the name of the new task
  71934. * @param url defines the location of the file to load
  71935. */
  71936. constructor(
  71937. /**
  71938. * Defines the name of the task
  71939. */
  71940. name: string,
  71941. /**
  71942. * Defines the location of the file to load
  71943. */
  71944. url: string);
  71945. /**
  71946. * Execute the current task
  71947. * @param scene defines the scene where you want your assets to be loaded
  71948. * @param onSuccess is a callback called when the task is successfully executed
  71949. * @param onError is a callback called if an error occurs
  71950. */
  71951. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71952. }
  71953. /**
  71954. * Define a task used by AssetsManager to load images
  71955. */
  71956. export class ImageAssetTask extends AbstractAssetTask {
  71957. /**
  71958. * Defines the name of the task
  71959. */
  71960. name: string;
  71961. /**
  71962. * Defines the location of the image to load
  71963. */
  71964. url: string;
  71965. /**
  71966. * Gets the loaded images
  71967. */
  71968. image: HTMLImageElement;
  71969. /**
  71970. * Callback called when the task is successful
  71971. */
  71972. onSuccess: (task: ImageAssetTask) => void;
  71973. /**
  71974. * Callback called when the task is successful
  71975. */
  71976. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  71977. /**
  71978. * Creates a new ImageAssetTask
  71979. * @param name defines the name of the task
  71980. * @param url defines the location of the image to load
  71981. */
  71982. constructor(
  71983. /**
  71984. * Defines the name of the task
  71985. */
  71986. name: string,
  71987. /**
  71988. * Defines the location of the image to load
  71989. */
  71990. url: string);
  71991. /**
  71992. * Execute the current task
  71993. * @param scene defines the scene where you want your assets to be loaded
  71994. * @param onSuccess is a callback called when the task is successfully executed
  71995. * @param onError is a callback called if an error occurs
  71996. */
  71997. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71998. }
  71999. /**
  72000. * Defines the interface used by texture loading tasks
  72001. */
  72002. export interface ITextureAssetTask<TEX extends BaseTexture> {
  72003. /**
  72004. * Gets the loaded texture
  72005. */
  72006. texture: TEX;
  72007. }
  72008. /**
  72009. * Define a task used by AssetsManager to load 2D textures
  72010. */
  72011. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  72012. /**
  72013. * Defines the name of the task
  72014. */
  72015. name: string;
  72016. /**
  72017. * Defines the location of the file to load
  72018. */
  72019. url: string;
  72020. /**
  72021. * Defines if mipmap should not be generated (default is false)
  72022. */
  72023. noMipmap?: boolean | undefined;
  72024. /**
  72025. * Defines if texture must be inverted on Y axis (default is true)
  72026. */
  72027. invertY: boolean;
  72028. /**
  72029. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72030. */
  72031. samplingMode: number;
  72032. /**
  72033. * Gets the loaded texture
  72034. */
  72035. texture: Texture;
  72036. /**
  72037. * Callback called when the task is successful
  72038. */
  72039. onSuccess: (task: TextureAssetTask) => void;
  72040. /**
  72041. * Callback called when the task is successful
  72042. */
  72043. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  72044. /**
  72045. * Creates a new TextureAssetTask object
  72046. * @param name defines the name of the task
  72047. * @param url defines the location of the file to load
  72048. * @param noMipmap defines if mipmap should not be generated (default is false)
  72049. * @param invertY defines if texture must be inverted on Y axis (default is true)
  72050. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72051. */
  72052. constructor(
  72053. /**
  72054. * Defines the name of the task
  72055. */
  72056. name: string,
  72057. /**
  72058. * Defines the location of the file to load
  72059. */
  72060. url: string,
  72061. /**
  72062. * Defines if mipmap should not be generated (default is false)
  72063. */
  72064. noMipmap?: boolean | undefined,
  72065. /**
  72066. * Defines if texture must be inverted on Y axis (default is true)
  72067. */
  72068. invertY?: boolean,
  72069. /**
  72070. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72071. */
  72072. samplingMode?: number);
  72073. /**
  72074. * Execute the current task
  72075. * @param scene defines the scene where you want your assets to be loaded
  72076. * @param onSuccess is a callback called when the task is successfully executed
  72077. * @param onError is a callback called if an error occurs
  72078. */
  72079. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72080. }
  72081. /**
  72082. * Define a task used by AssetsManager to load cube textures
  72083. */
  72084. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  72085. /**
  72086. * Defines the name of the task
  72087. */
  72088. name: string;
  72089. /**
  72090. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72091. */
  72092. url: string;
  72093. /**
  72094. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72095. */
  72096. extensions?: string[] | undefined;
  72097. /**
  72098. * Defines if mipmaps should not be generated (default is false)
  72099. */
  72100. noMipmap?: boolean | undefined;
  72101. /**
  72102. * Defines the explicit list of files (undefined by default)
  72103. */
  72104. files?: string[] | undefined;
  72105. /**
  72106. * Gets the loaded texture
  72107. */
  72108. texture: CubeTexture;
  72109. /**
  72110. * Callback called when the task is successful
  72111. */
  72112. onSuccess: (task: CubeTextureAssetTask) => void;
  72113. /**
  72114. * Callback called when the task is successful
  72115. */
  72116. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  72117. /**
  72118. * Creates a new CubeTextureAssetTask
  72119. * @param name defines the name of the task
  72120. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72121. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72122. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72123. * @param files defines the explicit list of files (undefined by default)
  72124. */
  72125. constructor(
  72126. /**
  72127. * Defines the name of the task
  72128. */
  72129. name: string,
  72130. /**
  72131. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72132. */
  72133. url: string,
  72134. /**
  72135. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72136. */
  72137. extensions?: string[] | undefined,
  72138. /**
  72139. * Defines if mipmaps should not be generated (default is false)
  72140. */
  72141. noMipmap?: boolean | undefined,
  72142. /**
  72143. * Defines the explicit list of files (undefined by default)
  72144. */
  72145. files?: string[] | undefined);
  72146. /**
  72147. * Execute the current task
  72148. * @param scene defines the scene where you want your assets to be loaded
  72149. * @param onSuccess is a callback called when the task is successfully executed
  72150. * @param onError is a callback called if an error occurs
  72151. */
  72152. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72153. }
  72154. /**
  72155. * Define a task used by AssetsManager to load HDR cube textures
  72156. */
  72157. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  72158. /**
  72159. * Defines the name of the task
  72160. */
  72161. name: string;
  72162. /**
  72163. * Defines the location of the file to load
  72164. */
  72165. url: string;
  72166. /**
  72167. * Defines the desired size (the more it increases the longer the generation will be)
  72168. */
  72169. size: number;
  72170. /**
  72171. * Defines if mipmaps should not be generated (default is false)
  72172. */
  72173. noMipmap: boolean;
  72174. /**
  72175. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72176. */
  72177. generateHarmonics: boolean;
  72178. /**
  72179. * 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)
  72180. */
  72181. gammaSpace: boolean;
  72182. /**
  72183. * Internal Use Only
  72184. */
  72185. reserved: boolean;
  72186. /**
  72187. * Gets the loaded texture
  72188. */
  72189. texture: HDRCubeTexture;
  72190. /**
  72191. * Callback called when the task is successful
  72192. */
  72193. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  72194. /**
  72195. * Callback called when the task is successful
  72196. */
  72197. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  72198. /**
  72199. * Creates a new HDRCubeTextureAssetTask object
  72200. * @param name defines the name of the task
  72201. * @param url defines the location of the file to load
  72202. * @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.
  72203. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72204. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72205. * @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)
  72206. * @param reserved Internal use only
  72207. */
  72208. constructor(
  72209. /**
  72210. * Defines the name of the task
  72211. */
  72212. name: string,
  72213. /**
  72214. * Defines the location of the file to load
  72215. */
  72216. url: string,
  72217. /**
  72218. * Defines the desired size (the more it increases the longer the generation will be)
  72219. */
  72220. size: number,
  72221. /**
  72222. * Defines if mipmaps should not be generated (default is false)
  72223. */
  72224. noMipmap?: boolean,
  72225. /**
  72226. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72227. */
  72228. generateHarmonics?: boolean,
  72229. /**
  72230. * 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)
  72231. */
  72232. gammaSpace?: boolean,
  72233. /**
  72234. * Internal Use Only
  72235. */
  72236. reserved?: boolean);
  72237. /**
  72238. * Execute the current task
  72239. * @param scene defines the scene where you want your assets to be loaded
  72240. * @param onSuccess is a callback called when the task is successfully executed
  72241. * @param onError is a callback called if an error occurs
  72242. */
  72243. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72244. }
  72245. /**
  72246. * Define a task used by AssetsManager to load Equirectangular cube textures
  72247. */
  72248. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  72249. /**
  72250. * Defines the name of the task
  72251. */
  72252. name: string;
  72253. /**
  72254. * Defines the location of the file to load
  72255. */
  72256. url: string;
  72257. /**
  72258. * Defines the desired size (the more it increases the longer the generation will be)
  72259. */
  72260. size: number;
  72261. /**
  72262. * Defines if mipmaps should not be generated (default is false)
  72263. */
  72264. noMipmap: boolean;
  72265. /**
  72266. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72267. * but the standard material would require them in Gamma space) (default is true)
  72268. */
  72269. gammaSpace: boolean;
  72270. /**
  72271. * Gets the loaded texture
  72272. */
  72273. texture: EquiRectangularCubeTexture;
  72274. /**
  72275. * Callback called when the task is successful
  72276. */
  72277. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  72278. /**
  72279. * Callback called when the task is successful
  72280. */
  72281. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  72282. /**
  72283. * Creates a new EquiRectangularCubeTextureAssetTask object
  72284. * @param name defines the name of the task
  72285. * @param url defines the location of the file to load
  72286. * @param size defines the desired size (the more it increases the longer the generation will be)
  72287. * If the size is omitted this implies you are using a preprocessed cubemap.
  72288. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72289. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  72290. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  72291. * (default is true)
  72292. */
  72293. constructor(
  72294. /**
  72295. * Defines the name of the task
  72296. */
  72297. name: string,
  72298. /**
  72299. * Defines the location of the file to load
  72300. */
  72301. url: string,
  72302. /**
  72303. * Defines the desired size (the more it increases the longer the generation will be)
  72304. */
  72305. size: number,
  72306. /**
  72307. * Defines if mipmaps should not be generated (default is false)
  72308. */
  72309. noMipmap?: boolean,
  72310. /**
  72311. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72312. * but the standard material would require them in Gamma space) (default is true)
  72313. */
  72314. gammaSpace?: boolean);
  72315. /**
  72316. * Execute the current task
  72317. * @param scene defines the scene where you want your assets to be loaded
  72318. * @param onSuccess is a callback called when the task is successfully executed
  72319. * @param onError is a callback called if an error occurs
  72320. */
  72321. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72322. }
  72323. /**
  72324. * This class can be used to easily import assets into a scene
  72325. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  72326. */
  72327. export class AssetsManager {
  72328. private _scene;
  72329. private _isLoading;
  72330. protected _tasks: AbstractAssetTask[];
  72331. protected _waitingTasksCount: number;
  72332. protected _totalTasksCount: number;
  72333. /**
  72334. * Callback called when all tasks are processed
  72335. */
  72336. onFinish: (tasks: AbstractAssetTask[]) => void;
  72337. /**
  72338. * Callback called when a task is successful
  72339. */
  72340. onTaskSuccess: (task: AbstractAssetTask) => void;
  72341. /**
  72342. * Callback called when a task had an error
  72343. */
  72344. onTaskError: (task: AbstractAssetTask) => void;
  72345. /**
  72346. * Callback called when a task is done (whatever the result is)
  72347. */
  72348. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  72349. /**
  72350. * Observable called when all tasks are processed
  72351. */
  72352. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  72353. /**
  72354. * Observable called when a task had an error
  72355. */
  72356. onTaskErrorObservable: Observable<AbstractAssetTask>;
  72357. /**
  72358. * Observable called when all tasks were executed
  72359. */
  72360. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  72361. /**
  72362. * Observable called when a task is done (whatever the result is)
  72363. */
  72364. onProgressObservable: Observable<IAssetsProgressEvent>;
  72365. /**
  72366. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  72367. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  72368. */
  72369. useDefaultLoadingScreen: boolean;
  72370. /**
  72371. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  72372. * when all assets have been downloaded.
  72373. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  72374. */
  72375. autoHideLoadingUI: boolean;
  72376. /**
  72377. * Creates a new AssetsManager
  72378. * @param scene defines the scene to work on
  72379. */
  72380. constructor(scene: Scene);
  72381. /**
  72382. * Add a MeshAssetTask to the list of active tasks
  72383. * @param taskName defines the name of the new task
  72384. * @param meshesNames defines the name of meshes to load
  72385. * @param rootUrl defines the root url to use to locate files
  72386. * @param sceneFilename defines the filename of the scene file
  72387. * @returns a new MeshAssetTask object
  72388. */
  72389. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  72390. /**
  72391. * Add a TextFileAssetTask to the list of active tasks
  72392. * @param taskName defines the name of the new task
  72393. * @param url defines the url of the file to load
  72394. * @returns a new TextFileAssetTask object
  72395. */
  72396. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  72397. /**
  72398. * Add a BinaryFileAssetTask to the list of active tasks
  72399. * @param taskName defines the name of the new task
  72400. * @param url defines the url of the file to load
  72401. * @returns a new BinaryFileAssetTask object
  72402. */
  72403. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  72404. /**
  72405. * Add a ImageAssetTask to the list of active tasks
  72406. * @param taskName defines the name of the new task
  72407. * @param url defines the url of the file to load
  72408. * @returns a new ImageAssetTask object
  72409. */
  72410. addImageTask(taskName: string, url: string): ImageAssetTask;
  72411. /**
  72412. * Add a TextureAssetTask to the list of active tasks
  72413. * @param taskName defines the name of the new task
  72414. * @param url defines the url of the file to load
  72415. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72416. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  72417. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  72418. * @returns a new TextureAssetTask object
  72419. */
  72420. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  72421. /**
  72422. * Add a CubeTextureAssetTask to the list of active tasks
  72423. * @param taskName defines the name of the new task
  72424. * @param url defines the url of the file to load
  72425. * @param extensions defines the extension to use to load the cube map (can be null)
  72426. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72427. * @param files defines the list of files to load (can be null)
  72428. * @returns a new CubeTextureAssetTask object
  72429. */
  72430. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  72431. /**
  72432. *
  72433. * Add a HDRCubeTextureAssetTask to the list of active tasks
  72434. * @param taskName defines the name of the new task
  72435. * @param url defines the url of the file to load
  72436. * @param size defines the size you want for the cubemap (can be null)
  72437. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72438. * @param generateHarmonics defines if you want to automatically generate (true by default)
  72439. * @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)
  72440. * @param reserved Internal use only
  72441. * @returns a new HDRCubeTextureAssetTask object
  72442. */
  72443. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  72444. /**
  72445. *
  72446. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  72447. * @param taskName defines the name of the new task
  72448. * @param url defines the url of the file to load
  72449. * @param size defines the size you want for the cubemap (can be null)
  72450. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72451. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  72452. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  72453. * @returns a new EquiRectangularCubeTextureAssetTask object
  72454. */
  72455. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  72456. /**
  72457. * Remove a task from the assets manager.
  72458. * @param task the task to remove
  72459. */
  72460. removeTask(task: AbstractAssetTask): void;
  72461. private _decreaseWaitingTasksCount;
  72462. private _runTask;
  72463. /**
  72464. * Reset the AssetsManager and remove all tasks
  72465. * @return the current instance of the AssetsManager
  72466. */
  72467. reset(): AssetsManager;
  72468. /**
  72469. * Start the loading process
  72470. * @return the current instance of the AssetsManager
  72471. */
  72472. load(): AssetsManager;
  72473. /**
  72474. * Start the loading process as an async operation
  72475. * @return a promise returning the list of failed tasks
  72476. */
  72477. loadAsync(): Promise<void>;
  72478. }
  72479. }
  72480. declare module BABYLON {
  72481. /**
  72482. * Wrapper class for promise with external resolve and reject.
  72483. */
  72484. export class Deferred<T> {
  72485. /**
  72486. * The promise associated with this deferred object.
  72487. */
  72488. readonly promise: Promise<T>;
  72489. private _resolve;
  72490. private _reject;
  72491. /**
  72492. * The resolve method of the promise associated with this deferred object.
  72493. */
  72494. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  72495. /**
  72496. * The reject method of the promise associated with this deferred object.
  72497. */
  72498. get reject(): (reason?: any) => void;
  72499. /**
  72500. * Constructor for this deferred object.
  72501. */
  72502. constructor();
  72503. }
  72504. }
  72505. declare module BABYLON {
  72506. /**
  72507. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  72508. */
  72509. export class MeshExploder {
  72510. private _centerMesh;
  72511. private _meshes;
  72512. private _meshesOrigins;
  72513. private _toCenterVectors;
  72514. private _scaledDirection;
  72515. private _newPosition;
  72516. private _centerPosition;
  72517. /**
  72518. * Explodes meshes from a center mesh.
  72519. * @param meshes The meshes to explode.
  72520. * @param centerMesh The mesh to be center of explosion.
  72521. */
  72522. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  72523. private _setCenterMesh;
  72524. /**
  72525. * Get class name
  72526. * @returns "MeshExploder"
  72527. */
  72528. getClassName(): string;
  72529. /**
  72530. * "Exploded meshes"
  72531. * @returns Array of meshes with the centerMesh at index 0.
  72532. */
  72533. getMeshes(): Array<Mesh>;
  72534. /**
  72535. * Explodes meshes giving a specific direction
  72536. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  72537. */
  72538. explode(direction?: number): void;
  72539. }
  72540. }
  72541. declare module BABYLON {
  72542. /**
  72543. * Class used to help managing file picking and drag'n'drop
  72544. */
  72545. export class FilesInput {
  72546. /**
  72547. * List of files ready to be loaded
  72548. */
  72549. static get FilesToLoad(): {
  72550. [key: string]: File;
  72551. };
  72552. /**
  72553. * Callback called when a file is processed
  72554. */
  72555. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  72556. private _engine;
  72557. private _currentScene;
  72558. private _sceneLoadedCallback;
  72559. private _progressCallback;
  72560. private _additionalRenderLoopLogicCallback;
  72561. private _textureLoadingCallback;
  72562. private _startingProcessingFilesCallback;
  72563. private _onReloadCallback;
  72564. private _errorCallback;
  72565. private _elementToMonitor;
  72566. private _sceneFileToLoad;
  72567. private _filesToLoad;
  72568. /**
  72569. * Creates a new FilesInput
  72570. * @param engine defines the rendering engine
  72571. * @param scene defines the hosting scene
  72572. * @param sceneLoadedCallback callback called when scene is loaded
  72573. * @param progressCallback callback called to track progress
  72574. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  72575. * @param textureLoadingCallback callback called when a texture is loading
  72576. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  72577. * @param onReloadCallback callback called when a reload is requested
  72578. * @param errorCallback callback call if an error occurs
  72579. */
  72580. 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>);
  72581. private _dragEnterHandler;
  72582. private _dragOverHandler;
  72583. private _dropHandler;
  72584. /**
  72585. * Calls this function to listen to drag'n'drop events on a specific DOM element
  72586. * @param elementToMonitor defines the DOM element to track
  72587. */
  72588. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  72589. /** Gets the current list of files to load */
  72590. get filesToLoad(): File[];
  72591. /**
  72592. * Release all associated resources
  72593. */
  72594. dispose(): void;
  72595. private renderFunction;
  72596. private drag;
  72597. private drop;
  72598. private _traverseFolder;
  72599. private _processFiles;
  72600. /**
  72601. * Load files from a drop event
  72602. * @param event defines the drop event to use as source
  72603. */
  72604. loadFiles(event: any): void;
  72605. private _processReload;
  72606. /**
  72607. * Reload the current scene from the loaded files
  72608. */
  72609. reload(): void;
  72610. }
  72611. }
  72612. declare module BABYLON {
  72613. /**
  72614. * Defines the root class used to create scene optimization to use with SceneOptimizer
  72615. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72616. */
  72617. export class SceneOptimization {
  72618. /**
  72619. * Defines the priority of this optimization (0 by default which means first in the list)
  72620. */
  72621. priority: number;
  72622. /**
  72623. * Gets a string describing the action executed by the current optimization
  72624. * @returns description string
  72625. */
  72626. getDescription(): string;
  72627. /**
  72628. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72629. * @param scene defines the current scene where to apply this optimization
  72630. * @param optimizer defines the current optimizer
  72631. * @returns true if everything that can be done was applied
  72632. */
  72633. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72634. /**
  72635. * Creates the SceneOptimization object
  72636. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72637. * @param desc defines the description associated with the optimization
  72638. */
  72639. constructor(
  72640. /**
  72641. * Defines the priority of this optimization (0 by default which means first in the list)
  72642. */
  72643. priority?: number);
  72644. }
  72645. /**
  72646. * Defines an optimization used to reduce the size of render target textures
  72647. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72648. */
  72649. export class TextureOptimization extends SceneOptimization {
  72650. /**
  72651. * Defines the priority of this optimization (0 by default which means first in the list)
  72652. */
  72653. priority: number;
  72654. /**
  72655. * 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
  72656. */
  72657. maximumSize: number;
  72658. /**
  72659. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72660. */
  72661. step: number;
  72662. /**
  72663. * Gets a string describing the action executed by the current optimization
  72664. * @returns description string
  72665. */
  72666. getDescription(): string;
  72667. /**
  72668. * Creates the TextureOptimization object
  72669. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72670. * @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
  72671. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72672. */
  72673. constructor(
  72674. /**
  72675. * Defines the priority of this optimization (0 by default which means first in the list)
  72676. */
  72677. priority?: number,
  72678. /**
  72679. * 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
  72680. */
  72681. maximumSize?: number,
  72682. /**
  72683. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72684. */
  72685. step?: number);
  72686. /**
  72687. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72688. * @param scene defines the current scene where to apply this optimization
  72689. * @param optimizer defines the current optimizer
  72690. * @returns true if everything that can be done was applied
  72691. */
  72692. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72693. }
  72694. /**
  72695. * Defines an optimization used to increase or decrease the rendering resolution
  72696. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72697. */
  72698. export class HardwareScalingOptimization extends SceneOptimization {
  72699. /**
  72700. * Defines the priority of this optimization (0 by default which means first in the list)
  72701. */
  72702. priority: number;
  72703. /**
  72704. * Defines the maximum scale to use (2 by default)
  72705. */
  72706. maximumScale: number;
  72707. /**
  72708. * Defines the step to use between two passes (0.5 by default)
  72709. */
  72710. step: number;
  72711. private _currentScale;
  72712. private _directionOffset;
  72713. /**
  72714. * Gets a string describing the action executed by the current optimization
  72715. * @return description string
  72716. */
  72717. getDescription(): string;
  72718. /**
  72719. * Creates the HardwareScalingOptimization object
  72720. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72721. * @param maximumScale defines the maximum scale to use (2 by default)
  72722. * @param step defines the step to use between two passes (0.5 by default)
  72723. */
  72724. constructor(
  72725. /**
  72726. * Defines the priority of this optimization (0 by default which means first in the list)
  72727. */
  72728. priority?: number,
  72729. /**
  72730. * Defines the maximum scale to use (2 by default)
  72731. */
  72732. maximumScale?: number,
  72733. /**
  72734. * Defines the step to use between two passes (0.5 by default)
  72735. */
  72736. step?: number);
  72737. /**
  72738. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72739. * @param scene defines the current scene where to apply this optimization
  72740. * @param optimizer defines the current optimizer
  72741. * @returns true if everything that can be done was applied
  72742. */
  72743. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72744. }
  72745. /**
  72746. * Defines an optimization used to remove shadows
  72747. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72748. */
  72749. export class ShadowsOptimization extends SceneOptimization {
  72750. /**
  72751. * Gets a string describing the action executed by the current optimization
  72752. * @return description string
  72753. */
  72754. getDescription(): string;
  72755. /**
  72756. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72757. * @param scene defines the current scene where to apply this optimization
  72758. * @param optimizer defines the current optimizer
  72759. * @returns true if everything that can be done was applied
  72760. */
  72761. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72762. }
  72763. /**
  72764. * Defines an optimization used to turn post-processes off
  72765. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72766. */
  72767. export class PostProcessesOptimization extends SceneOptimization {
  72768. /**
  72769. * Gets a string describing the action executed by the current optimization
  72770. * @return description string
  72771. */
  72772. getDescription(): string;
  72773. /**
  72774. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72775. * @param scene defines the current scene where to apply this optimization
  72776. * @param optimizer defines the current optimizer
  72777. * @returns true if everything that can be done was applied
  72778. */
  72779. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72780. }
  72781. /**
  72782. * Defines an optimization used to turn lens flares off
  72783. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72784. */
  72785. export class LensFlaresOptimization extends SceneOptimization {
  72786. /**
  72787. * Gets a string describing the action executed by the current optimization
  72788. * @return description string
  72789. */
  72790. getDescription(): string;
  72791. /**
  72792. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72793. * @param scene defines the current scene where to apply this optimization
  72794. * @param optimizer defines the current optimizer
  72795. * @returns true if everything that can be done was applied
  72796. */
  72797. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72798. }
  72799. /**
  72800. * Defines an optimization based on user defined callback.
  72801. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72802. */
  72803. export class CustomOptimization extends SceneOptimization {
  72804. /**
  72805. * Callback called to apply the custom optimization.
  72806. */
  72807. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  72808. /**
  72809. * Callback called to get custom description
  72810. */
  72811. onGetDescription: () => string;
  72812. /**
  72813. * Gets a string describing the action executed by the current optimization
  72814. * @returns description string
  72815. */
  72816. getDescription(): string;
  72817. /**
  72818. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72819. * @param scene defines the current scene where to apply this optimization
  72820. * @param optimizer defines the current optimizer
  72821. * @returns true if everything that can be done was applied
  72822. */
  72823. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72824. }
  72825. /**
  72826. * Defines an optimization used to turn particles off
  72827. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72828. */
  72829. export class ParticlesOptimization extends SceneOptimization {
  72830. /**
  72831. * Gets a string describing the action executed by the current optimization
  72832. * @return description string
  72833. */
  72834. getDescription(): string;
  72835. /**
  72836. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72837. * @param scene defines the current scene where to apply this optimization
  72838. * @param optimizer defines the current optimizer
  72839. * @returns true if everything that can be done was applied
  72840. */
  72841. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72842. }
  72843. /**
  72844. * Defines an optimization used to turn render targets off
  72845. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72846. */
  72847. export class RenderTargetsOptimization extends SceneOptimization {
  72848. /**
  72849. * Gets a string describing the action executed by the current optimization
  72850. * @return description string
  72851. */
  72852. getDescription(): string;
  72853. /**
  72854. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72855. * @param scene defines the current scene where to apply this optimization
  72856. * @param optimizer defines the current optimizer
  72857. * @returns true if everything that can be done was applied
  72858. */
  72859. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72860. }
  72861. /**
  72862. * Defines an optimization used to merge meshes with compatible materials
  72863. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72864. */
  72865. export class MergeMeshesOptimization extends SceneOptimization {
  72866. private static _UpdateSelectionTree;
  72867. /**
  72868. * Gets or sets a boolean which defines if optimization octree has to be updated
  72869. */
  72870. static get UpdateSelectionTree(): boolean;
  72871. /**
  72872. * Gets or sets a boolean which defines if optimization octree has to be updated
  72873. */
  72874. static set UpdateSelectionTree(value: boolean);
  72875. /**
  72876. * Gets a string describing the action executed by the current optimization
  72877. * @return description string
  72878. */
  72879. getDescription(): string;
  72880. private _canBeMerged;
  72881. /**
  72882. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72883. * @param scene defines the current scene where to apply this optimization
  72884. * @param optimizer defines the current optimizer
  72885. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  72886. * @returns true if everything that can be done was applied
  72887. */
  72888. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  72889. }
  72890. /**
  72891. * Defines a list of options used by SceneOptimizer
  72892. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72893. */
  72894. export class SceneOptimizerOptions {
  72895. /**
  72896. * Defines the target frame rate to reach (60 by default)
  72897. */
  72898. targetFrameRate: number;
  72899. /**
  72900. * Defines the interval between two checkes (2000ms by default)
  72901. */
  72902. trackerDuration: number;
  72903. /**
  72904. * Gets the list of optimizations to apply
  72905. */
  72906. optimizations: SceneOptimization[];
  72907. /**
  72908. * Creates a new list of options used by SceneOptimizer
  72909. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  72910. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  72911. */
  72912. constructor(
  72913. /**
  72914. * Defines the target frame rate to reach (60 by default)
  72915. */
  72916. targetFrameRate?: number,
  72917. /**
  72918. * Defines the interval between two checkes (2000ms by default)
  72919. */
  72920. trackerDuration?: number);
  72921. /**
  72922. * Add a new optimization
  72923. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  72924. * @returns the current SceneOptimizerOptions
  72925. */
  72926. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  72927. /**
  72928. * Add a new custom optimization
  72929. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  72930. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  72931. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72932. * @returns the current SceneOptimizerOptions
  72933. */
  72934. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  72935. /**
  72936. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  72937. * @param targetFrameRate defines the target frame rate (60 by default)
  72938. * @returns a SceneOptimizerOptions object
  72939. */
  72940. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72941. /**
  72942. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  72943. * @param targetFrameRate defines the target frame rate (60 by default)
  72944. * @returns a SceneOptimizerOptions object
  72945. */
  72946. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72947. /**
  72948. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  72949. * @param targetFrameRate defines the target frame rate (60 by default)
  72950. * @returns a SceneOptimizerOptions object
  72951. */
  72952. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72953. }
  72954. /**
  72955. * Class used to run optimizations in order to reach a target frame rate
  72956. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72957. */
  72958. export class SceneOptimizer implements IDisposable {
  72959. private _isRunning;
  72960. private _options;
  72961. private _scene;
  72962. private _currentPriorityLevel;
  72963. private _targetFrameRate;
  72964. private _trackerDuration;
  72965. private _currentFrameRate;
  72966. private _sceneDisposeObserver;
  72967. private _improvementMode;
  72968. /**
  72969. * Defines an observable called when the optimizer reaches the target frame rate
  72970. */
  72971. onSuccessObservable: Observable<SceneOptimizer>;
  72972. /**
  72973. * Defines an observable called when the optimizer enables an optimization
  72974. */
  72975. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  72976. /**
  72977. * Defines an observable called when the optimizer is not able to reach the target frame rate
  72978. */
  72979. onFailureObservable: Observable<SceneOptimizer>;
  72980. /**
  72981. * Gets a boolean indicating if the optimizer is in improvement mode
  72982. */
  72983. get isInImprovementMode(): boolean;
  72984. /**
  72985. * Gets the current priority level (0 at start)
  72986. */
  72987. get currentPriorityLevel(): number;
  72988. /**
  72989. * Gets the current frame rate checked by the SceneOptimizer
  72990. */
  72991. get currentFrameRate(): number;
  72992. /**
  72993. * Gets or sets the current target frame rate (60 by default)
  72994. */
  72995. get targetFrameRate(): number;
  72996. /**
  72997. * Gets or sets the current target frame rate (60 by default)
  72998. */
  72999. set targetFrameRate(value: number);
  73000. /**
  73001. * Gets or sets the current interval between two checks (every 2000ms by default)
  73002. */
  73003. get trackerDuration(): number;
  73004. /**
  73005. * Gets or sets the current interval between two checks (every 2000ms by default)
  73006. */
  73007. set trackerDuration(value: number);
  73008. /**
  73009. * Gets the list of active optimizations
  73010. */
  73011. get optimizations(): SceneOptimization[];
  73012. /**
  73013. * Creates a new SceneOptimizer
  73014. * @param scene defines the scene to work on
  73015. * @param options defines the options to use with the SceneOptimizer
  73016. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  73017. * @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)
  73018. */
  73019. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  73020. /**
  73021. * Stops the current optimizer
  73022. */
  73023. stop(): void;
  73024. /**
  73025. * Reset the optimizer to initial step (current priority level = 0)
  73026. */
  73027. reset(): void;
  73028. /**
  73029. * Start the optimizer. By default it will try to reach a specific framerate
  73030. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  73031. */
  73032. start(): void;
  73033. private _checkCurrentState;
  73034. /**
  73035. * Release all resources
  73036. */
  73037. dispose(): void;
  73038. /**
  73039. * Helper function to create a SceneOptimizer with one single line of code
  73040. * @param scene defines the scene to work on
  73041. * @param options defines the options to use with the SceneOptimizer
  73042. * @param onSuccess defines a callback to call on success
  73043. * @param onFailure defines a callback to call on failure
  73044. * @returns the new SceneOptimizer object
  73045. */
  73046. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  73047. }
  73048. }
  73049. declare module BABYLON {
  73050. /**
  73051. * Class used to serialize a scene into a string
  73052. */
  73053. export class SceneSerializer {
  73054. /**
  73055. * Clear cache used by a previous serialization
  73056. */
  73057. static ClearCache(): void;
  73058. /**
  73059. * Serialize a scene into a JSON compatible object
  73060. * @param scene defines the scene to serialize
  73061. * @returns a JSON compatible object
  73062. */
  73063. static Serialize(scene: Scene): any;
  73064. /**
  73065. * Serialize a mesh into a JSON compatible object
  73066. * @param toSerialize defines the mesh to serialize
  73067. * @param withParents defines if parents must be serialized as well
  73068. * @param withChildren defines if children must be serialized as well
  73069. * @returns a JSON compatible object
  73070. */
  73071. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  73072. }
  73073. }
  73074. declare module BABYLON {
  73075. /**
  73076. * Class used to host texture specific utilities
  73077. */
  73078. export class TextureTools {
  73079. /**
  73080. * Uses the GPU to create a copy texture rescaled at a given size
  73081. * @param texture Texture to copy from
  73082. * @param width defines the desired width
  73083. * @param height defines the desired height
  73084. * @param useBilinearMode defines if bilinear mode has to be used
  73085. * @return the generated texture
  73086. */
  73087. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  73088. }
  73089. }
  73090. declare module BABYLON {
  73091. /**
  73092. * This represents the different options available for the video capture.
  73093. */
  73094. export interface VideoRecorderOptions {
  73095. /** Defines the mime type of the video. */
  73096. mimeType: string;
  73097. /** Defines the FPS the video should be recorded at. */
  73098. fps: number;
  73099. /** Defines the chunk size for the recording data. */
  73100. recordChunckSize: number;
  73101. /** The audio tracks to attach to the recording. */
  73102. audioTracks?: MediaStreamTrack[];
  73103. }
  73104. /**
  73105. * This can help with recording videos from BabylonJS.
  73106. * This is based on the available WebRTC functionalities of the browser.
  73107. *
  73108. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  73109. */
  73110. export class VideoRecorder {
  73111. private static readonly _defaultOptions;
  73112. /**
  73113. * Returns whether or not the VideoRecorder is available in your browser.
  73114. * @param engine Defines the Babylon Engine.
  73115. * @returns true if supported otherwise false.
  73116. */
  73117. static IsSupported(engine: Engine): boolean;
  73118. private readonly _options;
  73119. private _canvas;
  73120. private _mediaRecorder;
  73121. private _recordedChunks;
  73122. private _fileName;
  73123. private _resolve;
  73124. private _reject;
  73125. /**
  73126. * True when a recording is already in progress.
  73127. */
  73128. get isRecording(): boolean;
  73129. /**
  73130. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  73131. * @param engine Defines the BabylonJS Engine you wish to record.
  73132. * @param options Defines options that can be used to customize the capture.
  73133. */
  73134. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  73135. /**
  73136. * Stops the current recording before the default capture timeout passed in the startRecording function.
  73137. */
  73138. stopRecording(): void;
  73139. /**
  73140. * Starts recording the canvas for a max duration specified in parameters.
  73141. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  73142. * If null no automatic download will start and you can rely on the promise to get the data back.
  73143. * @param maxDuration Defines the maximum recording time in seconds.
  73144. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  73145. * @return A promise callback at the end of the recording with the video data in Blob.
  73146. */
  73147. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  73148. /**
  73149. * Releases internal resources used during the recording.
  73150. */
  73151. dispose(): void;
  73152. private _handleDataAvailable;
  73153. private _handleError;
  73154. private _handleStop;
  73155. }
  73156. }
  73157. declare module BABYLON {
  73158. /**
  73159. * Class containing a set of static utilities functions for screenshots
  73160. */
  73161. export class ScreenshotTools {
  73162. /**
  73163. * Captures a screenshot of the current rendering
  73164. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73165. * @param engine defines the rendering engine
  73166. * @param camera defines the source camera
  73167. * @param size This parameter can be set to a single number or to an object with the
  73168. * following (optional) properties: precision, width, height. If a single number is passed,
  73169. * it will be used for both width and height. If an object is passed, the screenshot size
  73170. * will be derived from the parameters. The precision property is a multiplier allowing
  73171. * rendering at a higher or lower resolution
  73172. * @param successCallback defines the callback receives a single parameter which contains the
  73173. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  73174. * src parameter of an <img> to display it
  73175. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  73176. * Check your browser for supported MIME types
  73177. */
  73178. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  73179. /**
  73180. * Captures a screenshot of the current rendering
  73181. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73182. * @param engine defines the rendering engine
  73183. * @param camera defines the source camera
  73184. * @param size This parameter can be set to a single number or to an object with the
  73185. * following (optional) properties: precision, width, height. If a single number is passed,
  73186. * it will be used for both width and height. If an object is passed, the screenshot size
  73187. * will be derived from the parameters. The precision property is a multiplier allowing
  73188. * rendering at a higher or lower resolution
  73189. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  73190. * Check your browser for supported MIME types
  73191. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73192. * to the src parameter of an <img> to display it
  73193. */
  73194. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  73195. /**
  73196. * Generates an image screenshot from the specified camera.
  73197. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73198. * @param engine The engine to use for rendering
  73199. * @param camera The camera to use for rendering
  73200. * @param size This parameter can be set to a single number or to an object with the
  73201. * following (optional) properties: precision, width, height. If a single number is passed,
  73202. * it will be used for both width and height. If an object is passed, the screenshot size
  73203. * will be derived from the parameters. The precision property is a multiplier allowing
  73204. * rendering at a higher or lower resolution
  73205. * @param successCallback The callback receives a single parameter which contains the
  73206. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  73207. * src parameter of an <img> to display it
  73208. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73209. * Check your browser for supported MIME types
  73210. * @param samples Texture samples (default: 1)
  73211. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73212. * @param fileName A name for for the downloaded file.
  73213. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73214. */
  73215. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  73216. /**
  73217. * Generates an image screenshot from the specified camera.
  73218. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73219. * @param engine The engine to use for rendering
  73220. * @param camera The camera to use for rendering
  73221. * @param size This parameter can be set to a single number or to an object with the
  73222. * following (optional) properties: precision, width, height. If a single number is passed,
  73223. * it will be used for both width and height. If an object is passed, the screenshot size
  73224. * will be derived from the parameters. The precision property is a multiplier allowing
  73225. * rendering at a higher or lower resolution
  73226. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73227. * Check your browser for supported MIME types
  73228. * @param samples Texture samples (default: 1)
  73229. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73230. * @param fileName A name for for the downloaded file.
  73231. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73232. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73233. * to the src parameter of an <img> to display it
  73234. */
  73235. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  73236. /**
  73237. * Gets height and width for screenshot size
  73238. * @private
  73239. */
  73240. private static _getScreenshotSize;
  73241. }
  73242. }
  73243. declare module BABYLON {
  73244. /**
  73245. * Interface for a data buffer
  73246. */
  73247. export interface IDataBuffer {
  73248. /**
  73249. * Reads bytes from the data buffer.
  73250. * @param byteOffset The byte offset to read
  73251. * @param byteLength The byte length to read
  73252. * @returns A promise that resolves when the bytes are read
  73253. */
  73254. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  73255. /**
  73256. * The byte length of the buffer.
  73257. */
  73258. readonly byteLength: number;
  73259. }
  73260. /**
  73261. * Utility class for reading from a data buffer
  73262. */
  73263. export class DataReader {
  73264. /**
  73265. * The data buffer associated with this data reader.
  73266. */
  73267. readonly buffer: IDataBuffer;
  73268. /**
  73269. * The current byte offset from the beginning of the data buffer.
  73270. */
  73271. byteOffset: number;
  73272. private _dataView;
  73273. private _dataByteOffset;
  73274. /**
  73275. * Constructor
  73276. * @param buffer The buffer to read
  73277. */
  73278. constructor(buffer: IDataBuffer);
  73279. /**
  73280. * Loads the given byte length.
  73281. * @param byteLength The byte length to load
  73282. * @returns A promise that resolves when the load is complete
  73283. */
  73284. loadAsync(byteLength: number): Promise<void>;
  73285. /**
  73286. * Read a unsigned 32-bit integer from the currently loaded data range.
  73287. * @returns The 32-bit integer read
  73288. */
  73289. readUint32(): number;
  73290. /**
  73291. * Read a byte array from the currently loaded data range.
  73292. * @param byteLength The byte length to read
  73293. * @returns The byte array read
  73294. */
  73295. readUint8Array(byteLength: number): Uint8Array;
  73296. /**
  73297. * Read a string from the currently loaded data range.
  73298. * @param byteLength The byte length to read
  73299. * @returns The string read
  73300. */
  73301. readString(byteLength: number): string;
  73302. /**
  73303. * Skips the given byte length the currently loaded data range.
  73304. * @param byteLength The byte length to skip
  73305. */
  73306. skipBytes(byteLength: number): void;
  73307. }
  73308. }
  73309. declare module BABYLON {
  73310. /**
  73311. * Class for storing data to local storage if available or in-memory storage otherwise
  73312. */
  73313. export class DataStorage {
  73314. private static _Storage;
  73315. private static _GetStorage;
  73316. /**
  73317. * Reads a string from the data storage
  73318. * @param key The key to read
  73319. * @param defaultValue The value if the key doesn't exist
  73320. * @returns The string value
  73321. */
  73322. static ReadString(key: string, defaultValue: string): string;
  73323. /**
  73324. * Writes a string to the data storage
  73325. * @param key The key to write
  73326. * @param value The value to write
  73327. */
  73328. static WriteString(key: string, value: string): void;
  73329. /**
  73330. * Reads a boolean from the data storage
  73331. * @param key The key to read
  73332. * @param defaultValue The value if the key doesn't exist
  73333. * @returns The boolean value
  73334. */
  73335. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  73336. /**
  73337. * Writes a boolean to the data storage
  73338. * @param key The key to write
  73339. * @param value The value to write
  73340. */
  73341. static WriteBoolean(key: string, value: boolean): void;
  73342. /**
  73343. * Reads a number from the data storage
  73344. * @param key The key to read
  73345. * @param defaultValue The value if the key doesn't exist
  73346. * @returns The number value
  73347. */
  73348. static ReadNumber(key: string, defaultValue: number): number;
  73349. /**
  73350. * Writes a number to the data storage
  73351. * @param key The key to write
  73352. * @param value The value to write
  73353. */
  73354. static WriteNumber(key: string, value: number): void;
  73355. }
  73356. }
  73357. declare module BABYLON {
  73358. /**
  73359. * An interface for all Hit test features
  73360. */
  73361. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  73362. /**
  73363. * Triggered when new babylon (transformed) hit test results are available
  73364. */
  73365. onHitTestResultObservable: Observable<T[]>;
  73366. }
  73367. /**
  73368. * Options used for hit testing
  73369. */
  73370. export interface IWebXRLegacyHitTestOptions {
  73371. /**
  73372. * Only test when user interacted with the scene. Default - hit test every frame
  73373. */
  73374. testOnPointerDownOnly?: boolean;
  73375. /**
  73376. * The node to use to transform the local results to world coordinates
  73377. */
  73378. worldParentNode?: TransformNode;
  73379. }
  73380. /**
  73381. * Interface defining the babylon result of raycasting/hit-test
  73382. */
  73383. export interface IWebXRLegacyHitResult {
  73384. /**
  73385. * Transformation matrix that can be applied to a node that will put it in the hit point location
  73386. */
  73387. transformationMatrix: Matrix;
  73388. /**
  73389. * The native hit test result
  73390. */
  73391. xrHitResult: XRHitResult | XRHitTestResult;
  73392. }
  73393. /**
  73394. * The currently-working hit-test module.
  73395. * Hit test (or Ray-casting) is used to interact with the real world.
  73396. * For further information read here - https://github.com/immersive-web/hit-test
  73397. */
  73398. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  73399. /**
  73400. * options to use when constructing this feature
  73401. */
  73402. readonly options: IWebXRLegacyHitTestOptions;
  73403. private _direction;
  73404. private _mat;
  73405. private _onSelectEnabled;
  73406. private _origin;
  73407. /**
  73408. * The module's name
  73409. */
  73410. static readonly Name: string;
  73411. /**
  73412. * The (Babylon) version of this module.
  73413. * This is an integer representing the implementation version.
  73414. * This number does not correspond to the WebXR specs version
  73415. */
  73416. static readonly Version: number;
  73417. /**
  73418. * Populated with the last native XR Hit Results
  73419. */
  73420. lastNativeXRHitResults: XRHitResult[];
  73421. /**
  73422. * Triggered when new babylon (transformed) hit test results are available
  73423. */
  73424. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  73425. /**
  73426. * Creates a new instance of the (legacy version) hit test feature
  73427. * @param _xrSessionManager an instance of WebXRSessionManager
  73428. * @param options options to use when constructing this feature
  73429. */
  73430. constructor(_xrSessionManager: WebXRSessionManager,
  73431. /**
  73432. * options to use when constructing this feature
  73433. */
  73434. options?: IWebXRLegacyHitTestOptions);
  73435. /**
  73436. * execute a hit test with an XR Ray
  73437. *
  73438. * @param xrSession a native xrSession that will execute this hit test
  73439. * @param xrRay the ray (position and direction) to use for ray-casting
  73440. * @param referenceSpace native XR reference space to use for the hit-test
  73441. * @param filter filter function that will filter the results
  73442. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73443. */
  73444. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  73445. /**
  73446. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  73447. * @param event the (select) event to use to select with
  73448. * @param referenceSpace the reference space to use for this hit test
  73449. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73450. */
  73451. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  73452. /**
  73453. * attach this feature
  73454. * Will usually be called by the features manager
  73455. *
  73456. * @returns true if successful.
  73457. */
  73458. attach(): boolean;
  73459. /**
  73460. * detach this feature.
  73461. * Will usually be called by the features manager
  73462. *
  73463. * @returns true if successful.
  73464. */
  73465. detach(): boolean;
  73466. /**
  73467. * Dispose this feature and all of the resources attached
  73468. */
  73469. dispose(): void;
  73470. protected _onXRFrame(frame: XRFrame): void;
  73471. private _onHitTestResults;
  73472. private _onSelect;
  73473. }
  73474. }
  73475. declare module BABYLON {
  73476. /**
  73477. * Options used for hit testing (version 2)
  73478. */
  73479. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  73480. /**
  73481. * Do not create a permanent hit test. Will usually be used when only
  73482. * transient inputs are needed.
  73483. */
  73484. disablePermanentHitTest?: boolean;
  73485. /**
  73486. * Enable transient (for example touch-based) hit test inspections
  73487. */
  73488. enableTransientHitTest?: boolean;
  73489. /**
  73490. * Offset ray for the permanent hit test
  73491. */
  73492. offsetRay?: Vector3;
  73493. /**
  73494. * Offset ray for the transient hit test
  73495. */
  73496. transientOffsetRay?: Vector3;
  73497. /**
  73498. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  73499. */
  73500. useReferenceSpace?: boolean;
  73501. }
  73502. /**
  73503. * Interface defining the babylon result of hit-test
  73504. */
  73505. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  73506. /**
  73507. * The input source that generated this hit test (if transient)
  73508. */
  73509. inputSource?: XRInputSource;
  73510. /**
  73511. * Is this a transient hit test
  73512. */
  73513. isTransient?: boolean;
  73514. /**
  73515. * Position of the hit test result
  73516. */
  73517. position: Vector3;
  73518. /**
  73519. * Rotation of the hit test result
  73520. */
  73521. rotationQuaternion: Quaternion;
  73522. /**
  73523. * The native hit test result
  73524. */
  73525. xrHitResult: XRHitTestResult;
  73526. }
  73527. /**
  73528. * The currently-working hit-test module.
  73529. * Hit test (or Ray-casting) is used to interact with the real world.
  73530. * For further information read here - https://github.com/immersive-web/hit-test
  73531. *
  73532. * Tested on chrome (mobile) 80.
  73533. */
  73534. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  73535. /**
  73536. * options to use when constructing this feature
  73537. */
  73538. readonly options: IWebXRHitTestOptions;
  73539. private _tmpMat;
  73540. private _tmpPos;
  73541. private _tmpQuat;
  73542. private _transientXrHitTestSource;
  73543. private _xrHitTestSource;
  73544. private initHitTestSource;
  73545. /**
  73546. * The module's name
  73547. */
  73548. static readonly Name: string;
  73549. /**
  73550. * The (Babylon) version of this module.
  73551. * This is an integer representing the implementation version.
  73552. * This number does not correspond to the WebXR specs version
  73553. */
  73554. static readonly Version: number;
  73555. /**
  73556. * When set to true, each hit test will have its own position/rotation objects
  73557. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  73558. * the developers will clone them or copy them as they see fit.
  73559. */
  73560. autoCloneTransformation: boolean;
  73561. /**
  73562. * Triggered when new babylon (transformed) hit test results are available
  73563. */
  73564. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  73565. /**
  73566. * Use this to temporarily pause hit test checks.
  73567. */
  73568. paused: boolean;
  73569. /**
  73570. * Creates a new instance of the hit test feature
  73571. * @param _xrSessionManager an instance of WebXRSessionManager
  73572. * @param options options to use when constructing this feature
  73573. */
  73574. constructor(_xrSessionManager: WebXRSessionManager,
  73575. /**
  73576. * options to use when constructing this feature
  73577. */
  73578. options?: IWebXRHitTestOptions);
  73579. /**
  73580. * attach this feature
  73581. * Will usually be called by the features manager
  73582. *
  73583. * @returns true if successful.
  73584. */
  73585. attach(): boolean;
  73586. /**
  73587. * detach this feature.
  73588. * Will usually be called by the features manager
  73589. *
  73590. * @returns true if successful.
  73591. */
  73592. detach(): boolean;
  73593. /**
  73594. * Dispose this feature and all of the resources attached
  73595. */
  73596. dispose(): void;
  73597. protected _onXRFrame(frame: XRFrame): void;
  73598. private _processWebXRHitTestResult;
  73599. }
  73600. }
  73601. declare module BABYLON {
  73602. /**
  73603. * Configuration options of the anchor system
  73604. */
  73605. export interface IWebXRAnchorSystemOptions {
  73606. /**
  73607. * a node that will be used to convert local to world coordinates
  73608. */
  73609. worldParentNode?: TransformNode;
  73610. /**
  73611. * If set to true a reference of the created anchors will be kept until the next session starts
  73612. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  73613. */
  73614. doNotRemoveAnchorsOnSessionEnded?: boolean;
  73615. }
  73616. /**
  73617. * A babylon container for an XR Anchor
  73618. */
  73619. export interface IWebXRAnchor {
  73620. /**
  73621. * A babylon-assigned ID for this anchor
  73622. */
  73623. id: number;
  73624. /**
  73625. * Transformation matrix to apply to an object attached to this anchor
  73626. */
  73627. transformationMatrix: Matrix;
  73628. /**
  73629. * The native anchor object
  73630. */
  73631. xrAnchor: XRAnchor;
  73632. /**
  73633. * if defined, this object will be constantly updated by the anchor's position and rotation
  73634. */
  73635. attachedNode?: TransformNode;
  73636. }
  73637. /**
  73638. * An implementation of the anchor system for WebXR.
  73639. * For further information see https://github.com/immersive-web/anchors/
  73640. */
  73641. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  73642. private _options;
  73643. private _lastFrameDetected;
  73644. private _trackedAnchors;
  73645. private _referenceSpaceForFrameAnchors;
  73646. private _futureAnchors;
  73647. /**
  73648. * The module's name
  73649. */
  73650. static readonly Name: string;
  73651. /**
  73652. * The (Babylon) version of this module.
  73653. * This is an integer representing the implementation version.
  73654. * This number does not correspond to the WebXR specs version
  73655. */
  73656. static readonly Version: number;
  73657. /**
  73658. * Observers registered here will be executed when a new anchor was added to the session
  73659. */
  73660. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  73661. /**
  73662. * Observers registered here will be executed when an anchor was removed from the session
  73663. */
  73664. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  73665. /**
  73666. * Observers registered here will be executed when an existing anchor updates
  73667. * This can execute N times every frame
  73668. */
  73669. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  73670. /**
  73671. * Set the reference space to use for anchor creation, when not using a hit test.
  73672. * Will default to the session's reference space if not defined
  73673. */
  73674. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  73675. /**
  73676. * constructs a new anchor system
  73677. * @param _xrSessionManager an instance of WebXRSessionManager
  73678. * @param _options configuration object for this feature
  73679. */
  73680. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  73681. private _tmpVector;
  73682. private _tmpQuaternion;
  73683. private _populateTmpTransformation;
  73684. /**
  73685. * Create a new anchor point using a hit test result at a specific point in the scene
  73686. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  73687. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  73688. *
  73689. * @param hitTestResult The hit test result to use for this anchor creation
  73690. * @param position an optional position offset for this anchor
  73691. * @param rotationQuaternion an optional rotation offset for this anchor
  73692. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  73693. */
  73694. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  73695. /**
  73696. * Add a new anchor at a specific position and rotation
  73697. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  73698. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  73699. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  73700. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  73701. *
  73702. * @param position the position in which to add an anchor
  73703. * @param rotationQuaternion an optional rotation for the anchor transformation
  73704. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  73705. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  73706. */
  73707. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  73708. /**
  73709. * detach this feature.
  73710. * Will usually be called by the features manager
  73711. *
  73712. * @returns true if successful.
  73713. */
  73714. detach(): boolean;
  73715. /**
  73716. * Dispose this feature and all of the resources attached
  73717. */
  73718. dispose(): void;
  73719. protected _onXRFrame(frame: XRFrame): void;
  73720. /**
  73721. * avoiding using Array.find for global support.
  73722. * @param xrAnchor the plane to find in the array
  73723. */
  73724. private _findIndexInAnchorArray;
  73725. private _updateAnchorWithXRFrame;
  73726. private _createAnchorAtTransformation;
  73727. }
  73728. }
  73729. declare module BABYLON {
  73730. /**
  73731. * Options used in the plane detector module
  73732. */
  73733. export interface IWebXRPlaneDetectorOptions {
  73734. /**
  73735. * The node to use to transform the local results to world coordinates
  73736. */
  73737. worldParentNode?: TransformNode;
  73738. /**
  73739. * If set to true a reference of the created planes will be kept until the next session starts
  73740. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  73741. */
  73742. doNotRemovePlanesOnSessionEnded?: boolean;
  73743. }
  73744. /**
  73745. * A babylon interface for a WebXR plane.
  73746. * A Plane is actually a polygon, built from N points in space
  73747. *
  73748. * Supported in chrome 79, not supported in canary 81 ATM
  73749. */
  73750. export interface IWebXRPlane {
  73751. /**
  73752. * a babylon-assigned ID for this polygon
  73753. */
  73754. id: number;
  73755. /**
  73756. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  73757. */
  73758. polygonDefinition: Array<Vector3>;
  73759. /**
  73760. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  73761. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  73762. */
  73763. transformationMatrix: Matrix;
  73764. /**
  73765. * the native xr-plane object
  73766. */
  73767. xrPlane: XRPlane;
  73768. }
  73769. /**
  73770. * The plane detector is used to detect planes in the real world when in AR
  73771. * For more information see https://github.com/immersive-web/real-world-geometry/
  73772. */
  73773. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  73774. private _options;
  73775. private _detectedPlanes;
  73776. private _enabled;
  73777. private _lastFrameDetected;
  73778. /**
  73779. * The module's name
  73780. */
  73781. static readonly Name: string;
  73782. /**
  73783. * The (Babylon) version of this module.
  73784. * This is an integer representing the implementation version.
  73785. * This number does not correspond to the WebXR specs version
  73786. */
  73787. static readonly Version: number;
  73788. /**
  73789. * Observers registered here will be executed when a new plane was added to the session
  73790. */
  73791. onPlaneAddedObservable: Observable<IWebXRPlane>;
  73792. /**
  73793. * Observers registered here will be executed when a plane is no longer detected in the session
  73794. */
  73795. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  73796. /**
  73797. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  73798. * This can execute N times every frame
  73799. */
  73800. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  73801. /**
  73802. * construct a new Plane Detector
  73803. * @param _xrSessionManager an instance of xr Session manager
  73804. * @param _options configuration to use when constructing this feature
  73805. */
  73806. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  73807. /**
  73808. * detach this feature.
  73809. * Will usually be called by the features manager
  73810. *
  73811. * @returns true if successful.
  73812. */
  73813. detach(): boolean;
  73814. /**
  73815. * Dispose this feature and all of the resources attached
  73816. */
  73817. dispose(): void;
  73818. protected _onXRFrame(frame: XRFrame): void;
  73819. private _init;
  73820. private _updatePlaneWithXRPlane;
  73821. /**
  73822. * avoiding using Array.find for global support.
  73823. * @param xrPlane the plane to find in the array
  73824. */
  73825. private findIndexInPlaneArray;
  73826. }
  73827. }
  73828. declare module BABYLON {
  73829. /**
  73830. * Options interface for the background remover plugin
  73831. */
  73832. export interface IWebXRBackgroundRemoverOptions {
  73833. /**
  73834. * Further background meshes to disable when entering AR
  73835. */
  73836. backgroundMeshes?: AbstractMesh[];
  73837. /**
  73838. * flags to configure the removal of the environment helper.
  73839. * If not set, the entire background will be removed. If set, flags should be set as well.
  73840. */
  73841. environmentHelperRemovalFlags?: {
  73842. /**
  73843. * Should the skybox be removed (default false)
  73844. */
  73845. skyBox?: boolean;
  73846. /**
  73847. * Should the ground be removed (default false)
  73848. */
  73849. ground?: boolean;
  73850. };
  73851. /**
  73852. * don't disable the environment helper
  73853. */
  73854. ignoreEnvironmentHelper?: boolean;
  73855. }
  73856. /**
  73857. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  73858. */
  73859. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  73860. /**
  73861. * read-only options to be used in this module
  73862. */
  73863. readonly options: IWebXRBackgroundRemoverOptions;
  73864. /**
  73865. * The module's name
  73866. */
  73867. static readonly Name: string;
  73868. /**
  73869. * The (Babylon) version of this module.
  73870. * This is an integer representing the implementation version.
  73871. * This number does not correspond to the WebXR specs version
  73872. */
  73873. static readonly Version: number;
  73874. /**
  73875. * registered observers will be triggered when the background state changes
  73876. */
  73877. onBackgroundStateChangedObservable: Observable<boolean>;
  73878. /**
  73879. * constructs a new background remover module
  73880. * @param _xrSessionManager the session manager for this module
  73881. * @param options read-only options to be used in this module
  73882. */
  73883. constructor(_xrSessionManager: WebXRSessionManager,
  73884. /**
  73885. * read-only options to be used in this module
  73886. */
  73887. options?: IWebXRBackgroundRemoverOptions);
  73888. /**
  73889. * attach this feature
  73890. * Will usually be called by the features manager
  73891. *
  73892. * @returns true if successful.
  73893. */
  73894. attach(): boolean;
  73895. /**
  73896. * detach this feature.
  73897. * Will usually be called by the features manager
  73898. *
  73899. * @returns true if successful.
  73900. */
  73901. detach(): boolean;
  73902. /**
  73903. * Dispose this feature and all of the resources attached
  73904. */
  73905. dispose(): void;
  73906. protected _onXRFrame(_xrFrame: XRFrame): void;
  73907. private _setBackgroundState;
  73908. }
  73909. }
  73910. declare module BABYLON {
  73911. /**
  73912. * Options for the controller physics feature
  73913. */
  73914. export class IWebXRControllerPhysicsOptions {
  73915. /**
  73916. * Should the headset get its own impostor
  73917. */
  73918. enableHeadsetImpostor?: boolean;
  73919. /**
  73920. * Optional parameters for the headset impostor
  73921. */
  73922. headsetImpostorParams?: {
  73923. /**
  73924. * The type of impostor to create. Default is sphere
  73925. */
  73926. impostorType: number;
  73927. /**
  73928. * the size of the impostor. Defaults to 10cm
  73929. */
  73930. impostorSize?: number | {
  73931. width: number;
  73932. height: number;
  73933. depth: number;
  73934. };
  73935. /**
  73936. * Friction definitions
  73937. */
  73938. friction?: number;
  73939. /**
  73940. * Restitution
  73941. */
  73942. restitution?: number;
  73943. };
  73944. /**
  73945. * The physics properties of the future impostors
  73946. */
  73947. physicsProperties?: {
  73948. /**
  73949. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  73950. * Note that this requires a physics engine that supports mesh impostors!
  73951. */
  73952. useControllerMesh?: boolean;
  73953. /**
  73954. * The type of impostor to create. Default is sphere
  73955. */
  73956. impostorType?: number;
  73957. /**
  73958. * the size of the impostor. Defaults to 10cm
  73959. */
  73960. impostorSize?: number | {
  73961. width: number;
  73962. height: number;
  73963. depth: number;
  73964. };
  73965. /**
  73966. * Friction definitions
  73967. */
  73968. friction?: number;
  73969. /**
  73970. * Restitution
  73971. */
  73972. restitution?: number;
  73973. };
  73974. /**
  73975. * the xr input to use with this pointer selection
  73976. */
  73977. xrInput: WebXRInput;
  73978. }
  73979. /**
  73980. * Add physics impostor to your webxr controllers,
  73981. * including naive calculation of their linear and angular velocity
  73982. */
  73983. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  73984. private readonly _options;
  73985. private _attachController;
  73986. private _controllers;
  73987. private _debugMode;
  73988. private _delta;
  73989. private _headsetImpostor?;
  73990. private _headsetMesh?;
  73991. private _lastTimestamp;
  73992. private _tmpQuaternion;
  73993. private _tmpVector;
  73994. /**
  73995. * The module's name
  73996. */
  73997. static readonly Name: string;
  73998. /**
  73999. * The (Babylon) version of this module.
  74000. * This is an integer representing the implementation version.
  74001. * This number does not correspond to the webxr specs version
  74002. */
  74003. static readonly Version: number;
  74004. /**
  74005. * Construct a new Controller Physics Feature
  74006. * @param _xrSessionManager the corresponding xr session manager
  74007. * @param _options options to create this feature with
  74008. */
  74009. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  74010. /**
  74011. * @hidden
  74012. * enable debugging - will show console outputs and the impostor mesh
  74013. */
  74014. _enablePhysicsDebug(): void;
  74015. /**
  74016. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  74017. * @param xrController the controller to add
  74018. */
  74019. addController(xrController: WebXRInputSource): void;
  74020. /**
  74021. * attach this feature
  74022. * Will usually be called by the features manager
  74023. *
  74024. * @returns true if successful.
  74025. */
  74026. attach(): boolean;
  74027. /**
  74028. * detach this feature.
  74029. * Will usually be called by the features manager
  74030. *
  74031. * @returns true if successful.
  74032. */
  74033. detach(): boolean;
  74034. /**
  74035. * Get the headset impostor, if enabled
  74036. * @returns the impostor
  74037. */
  74038. getHeadsetImpostor(): PhysicsImpostor | undefined;
  74039. /**
  74040. * Get the physics impostor of a specific controller.
  74041. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  74042. * @param controller the controller or the controller id of which to get the impostor
  74043. * @returns the impostor or null
  74044. */
  74045. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  74046. /**
  74047. * Update the physics properties provided in the constructor
  74048. * @param newProperties the new properties object
  74049. */
  74050. setPhysicsProperties(newProperties: {
  74051. impostorType?: number;
  74052. impostorSize?: number | {
  74053. width: number;
  74054. height: number;
  74055. depth: number;
  74056. };
  74057. friction?: number;
  74058. restitution?: number;
  74059. }): void;
  74060. protected _onXRFrame(_xrFrame: any): void;
  74061. private _detachController;
  74062. }
  74063. }
  74064. declare module BABYLON {
  74065. /**
  74066. * The motion controller class for all microsoft mixed reality controllers
  74067. */
  74068. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  74069. protected readonly _mapping: {
  74070. defaultButton: {
  74071. valueNodeName: string;
  74072. unpressedNodeName: string;
  74073. pressedNodeName: string;
  74074. };
  74075. defaultAxis: {
  74076. valueNodeName: string;
  74077. minNodeName: string;
  74078. maxNodeName: string;
  74079. };
  74080. buttons: {
  74081. "xr-standard-trigger": {
  74082. rootNodeName: string;
  74083. componentProperty: string;
  74084. states: string[];
  74085. };
  74086. "xr-standard-squeeze": {
  74087. rootNodeName: string;
  74088. componentProperty: string;
  74089. states: string[];
  74090. };
  74091. "xr-standard-touchpad": {
  74092. rootNodeName: string;
  74093. labelAnchorNodeName: string;
  74094. touchPointNodeName: string;
  74095. };
  74096. "xr-standard-thumbstick": {
  74097. rootNodeName: string;
  74098. componentProperty: string;
  74099. states: string[];
  74100. };
  74101. };
  74102. axes: {
  74103. "xr-standard-touchpad": {
  74104. "x-axis": {
  74105. rootNodeName: string;
  74106. };
  74107. "y-axis": {
  74108. rootNodeName: string;
  74109. };
  74110. };
  74111. "xr-standard-thumbstick": {
  74112. "x-axis": {
  74113. rootNodeName: string;
  74114. };
  74115. "y-axis": {
  74116. rootNodeName: string;
  74117. };
  74118. };
  74119. };
  74120. };
  74121. /**
  74122. * The base url used to load the left and right controller models
  74123. */
  74124. static MODEL_BASE_URL: string;
  74125. /**
  74126. * The name of the left controller model file
  74127. */
  74128. static MODEL_LEFT_FILENAME: string;
  74129. /**
  74130. * The name of the right controller model file
  74131. */
  74132. static MODEL_RIGHT_FILENAME: string;
  74133. profileId: string;
  74134. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  74135. protected _getFilenameAndPath(): {
  74136. filename: string;
  74137. path: string;
  74138. };
  74139. protected _getModelLoadingConstraints(): boolean;
  74140. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74141. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74142. protected _updateModel(): void;
  74143. }
  74144. }
  74145. declare module BABYLON {
  74146. /**
  74147. * The motion controller class for oculus touch (quest, rift).
  74148. * This class supports legacy mapping as well the standard xr mapping
  74149. */
  74150. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  74151. private _forceLegacyControllers;
  74152. private _modelRootNode;
  74153. /**
  74154. * The base url used to load the left and right controller models
  74155. */
  74156. static MODEL_BASE_URL: string;
  74157. /**
  74158. * The name of the left controller model file
  74159. */
  74160. static MODEL_LEFT_FILENAME: string;
  74161. /**
  74162. * The name of the right controller model file
  74163. */
  74164. static MODEL_RIGHT_FILENAME: string;
  74165. /**
  74166. * Base Url for the Quest controller model.
  74167. */
  74168. static QUEST_MODEL_BASE_URL: string;
  74169. profileId: string;
  74170. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  74171. protected _getFilenameAndPath(): {
  74172. filename: string;
  74173. path: string;
  74174. };
  74175. protected _getModelLoadingConstraints(): boolean;
  74176. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74177. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74178. protected _updateModel(): void;
  74179. /**
  74180. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  74181. * between the touch and touch 2.
  74182. */
  74183. private _isQuest;
  74184. }
  74185. }
  74186. declare module BABYLON {
  74187. /**
  74188. * The motion controller class for the standard HTC-Vive controllers
  74189. */
  74190. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  74191. private _modelRootNode;
  74192. /**
  74193. * The base url used to load the left and right controller models
  74194. */
  74195. static MODEL_BASE_URL: string;
  74196. /**
  74197. * File name for the controller model.
  74198. */
  74199. static MODEL_FILENAME: string;
  74200. profileId: string;
  74201. /**
  74202. * Create a new Vive motion controller object
  74203. * @param scene the scene to use to create this controller
  74204. * @param gamepadObject the corresponding gamepad object
  74205. * @param handedness the handedness of the controller
  74206. */
  74207. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  74208. protected _getFilenameAndPath(): {
  74209. filename: string;
  74210. path: string;
  74211. };
  74212. protected _getModelLoadingConstraints(): boolean;
  74213. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74214. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74215. protected _updateModel(): void;
  74216. }
  74217. }
  74218. declare module BABYLON {
  74219. /**
  74220. * A cursor which tracks a point on a path
  74221. */
  74222. export class PathCursor {
  74223. private path;
  74224. /**
  74225. * Stores path cursor callbacks for when an onchange event is triggered
  74226. */
  74227. private _onchange;
  74228. /**
  74229. * The value of the path cursor
  74230. */
  74231. value: number;
  74232. /**
  74233. * The animation array of the path cursor
  74234. */
  74235. animations: Animation[];
  74236. /**
  74237. * Initializes the path cursor
  74238. * @param path The path to track
  74239. */
  74240. constructor(path: Path2);
  74241. /**
  74242. * Gets the cursor point on the path
  74243. * @returns A point on the path cursor at the cursor location
  74244. */
  74245. getPoint(): Vector3;
  74246. /**
  74247. * Moves the cursor ahead by the step amount
  74248. * @param step The amount to move the cursor forward
  74249. * @returns This path cursor
  74250. */
  74251. moveAhead(step?: number): PathCursor;
  74252. /**
  74253. * Moves the cursor behind by the step amount
  74254. * @param step The amount to move the cursor back
  74255. * @returns This path cursor
  74256. */
  74257. moveBack(step?: number): PathCursor;
  74258. /**
  74259. * Moves the cursor by the step amount
  74260. * If the step amount is greater than one, an exception is thrown
  74261. * @param step The amount to move the cursor
  74262. * @returns This path cursor
  74263. */
  74264. move(step: number): PathCursor;
  74265. /**
  74266. * Ensures that the value is limited between zero and one
  74267. * @returns This path cursor
  74268. */
  74269. private ensureLimits;
  74270. /**
  74271. * Runs onchange callbacks on change (used by the animation engine)
  74272. * @returns This path cursor
  74273. */
  74274. private raiseOnChange;
  74275. /**
  74276. * Executes a function on change
  74277. * @param f A path cursor onchange callback
  74278. * @returns This path cursor
  74279. */
  74280. onchange(f: (cursor: PathCursor) => void): PathCursor;
  74281. }
  74282. }
  74283. declare module BABYLON {
  74284. /** @hidden */
  74285. export var blurPixelShader: {
  74286. name: string;
  74287. shader: string;
  74288. };
  74289. }
  74290. declare module BABYLON {
  74291. /** @hidden */
  74292. export var pointCloudVertexDeclaration: {
  74293. name: string;
  74294. shader: string;
  74295. };
  74296. }
  74297. // Mixins
  74298. interface Window {
  74299. mozIndexedDB: IDBFactory;
  74300. webkitIndexedDB: IDBFactory;
  74301. msIndexedDB: IDBFactory;
  74302. webkitURL: typeof URL;
  74303. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  74304. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  74305. WebGLRenderingContext: WebGLRenderingContext;
  74306. MSGesture: MSGesture;
  74307. CANNON: any;
  74308. AudioContext: AudioContext;
  74309. webkitAudioContext: AudioContext;
  74310. PointerEvent: any;
  74311. Math: Math;
  74312. Uint8Array: Uint8ArrayConstructor;
  74313. Float32Array: Float32ArrayConstructor;
  74314. mozURL: typeof URL;
  74315. msURL: typeof URL;
  74316. VRFrameData: any; // WebVR, from specs 1.1
  74317. DracoDecoderModule: any;
  74318. setImmediate(handler: (...args: any[]) => void): number;
  74319. }
  74320. interface HTMLCanvasElement {
  74321. requestPointerLock(): void;
  74322. msRequestPointerLock?(): void;
  74323. mozRequestPointerLock?(): void;
  74324. webkitRequestPointerLock?(): void;
  74325. /** Track wether a record is in progress */
  74326. isRecording: boolean;
  74327. /** Capture Stream method defined by some browsers */
  74328. captureStream(fps?: number): MediaStream;
  74329. }
  74330. interface CanvasRenderingContext2D {
  74331. msImageSmoothingEnabled: boolean;
  74332. }
  74333. interface MouseEvent {
  74334. mozMovementX: number;
  74335. mozMovementY: number;
  74336. webkitMovementX: number;
  74337. webkitMovementY: number;
  74338. msMovementX: number;
  74339. msMovementY: number;
  74340. }
  74341. interface Navigator {
  74342. mozGetVRDevices: (any: any) => any;
  74343. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  74344. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  74345. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  74346. webkitGetGamepads(): Gamepad[];
  74347. msGetGamepads(): Gamepad[];
  74348. webkitGamepads(): Gamepad[];
  74349. }
  74350. interface HTMLVideoElement {
  74351. mozSrcObject: any;
  74352. }
  74353. interface Math {
  74354. fround(x: number): number;
  74355. imul(a: number, b: number): number;
  74356. }
  74357. interface WebGLRenderingContext {
  74358. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  74359. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  74360. vertexAttribDivisor(index: number, divisor: number): void;
  74361. createVertexArray(): any;
  74362. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  74363. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  74364. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  74365. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  74366. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  74367. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  74368. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  74369. // Queries
  74370. createQuery(): WebGLQuery;
  74371. deleteQuery(query: WebGLQuery): void;
  74372. beginQuery(target: number, query: WebGLQuery): void;
  74373. endQuery(target: number): void;
  74374. getQueryParameter(query: WebGLQuery, pname: number): any;
  74375. getQuery(target: number, pname: number): any;
  74376. MAX_SAMPLES: number;
  74377. RGBA8: number;
  74378. READ_FRAMEBUFFER: number;
  74379. DRAW_FRAMEBUFFER: number;
  74380. UNIFORM_BUFFER: number;
  74381. HALF_FLOAT_OES: number;
  74382. RGBA16F: number;
  74383. RGBA32F: number;
  74384. R32F: number;
  74385. RG32F: number;
  74386. RGB32F: number;
  74387. R16F: number;
  74388. RG16F: number;
  74389. RGB16F: number;
  74390. RED: number;
  74391. RG: number;
  74392. R8: number;
  74393. RG8: number;
  74394. UNSIGNED_INT_24_8: number;
  74395. DEPTH24_STENCIL8: number;
  74396. MIN: number;
  74397. MAX: number;
  74398. /* Multiple Render Targets */
  74399. drawBuffers(buffers: number[]): void;
  74400. readBuffer(src: number): void;
  74401. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  74402. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  74403. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  74404. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  74405. // Occlusion Query
  74406. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  74407. ANY_SAMPLES_PASSED: number;
  74408. QUERY_RESULT_AVAILABLE: number;
  74409. QUERY_RESULT: number;
  74410. }
  74411. interface WebGLProgram {
  74412. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  74413. }
  74414. interface EXT_disjoint_timer_query {
  74415. QUERY_COUNTER_BITS_EXT: number;
  74416. TIME_ELAPSED_EXT: number;
  74417. TIMESTAMP_EXT: number;
  74418. GPU_DISJOINT_EXT: number;
  74419. QUERY_RESULT_EXT: number;
  74420. QUERY_RESULT_AVAILABLE_EXT: number;
  74421. queryCounterEXT(query: WebGLQuery, target: number): void;
  74422. createQueryEXT(): WebGLQuery;
  74423. beginQueryEXT(target: number, query: WebGLQuery): void;
  74424. endQueryEXT(target: number): void;
  74425. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  74426. deleteQueryEXT(query: WebGLQuery): void;
  74427. }
  74428. interface WebGLUniformLocation {
  74429. _currentState: any;
  74430. }
  74431. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  74432. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  74433. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  74434. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  74435. interface WebGLRenderingContext {
  74436. readonly RASTERIZER_DISCARD: number;
  74437. readonly DEPTH_COMPONENT24: number;
  74438. readonly TEXTURE_3D: number;
  74439. readonly TEXTURE_2D_ARRAY: number;
  74440. readonly TEXTURE_COMPARE_FUNC: number;
  74441. readonly TEXTURE_COMPARE_MODE: number;
  74442. readonly COMPARE_REF_TO_TEXTURE: number;
  74443. readonly TEXTURE_WRAP_R: number;
  74444. readonly HALF_FLOAT: number;
  74445. readonly RGB8: number;
  74446. readonly RED_INTEGER: number;
  74447. readonly RG_INTEGER: number;
  74448. readonly RGB_INTEGER: number;
  74449. readonly RGBA_INTEGER: number;
  74450. readonly R8_SNORM: number;
  74451. readonly RG8_SNORM: number;
  74452. readonly RGB8_SNORM: number;
  74453. readonly RGBA8_SNORM: number;
  74454. readonly R8I: number;
  74455. readonly RG8I: number;
  74456. readonly RGB8I: number;
  74457. readonly RGBA8I: number;
  74458. readonly R8UI: number;
  74459. readonly RG8UI: number;
  74460. readonly RGB8UI: number;
  74461. readonly RGBA8UI: number;
  74462. readonly R16I: number;
  74463. readonly RG16I: number;
  74464. readonly RGB16I: number;
  74465. readonly RGBA16I: number;
  74466. readonly R16UI: number;
  74467. readonly RG16UI: number;
  74468. readonly RGB16UI: number;
  74469. readonly RGBA16UI: number;
  74470. readonly R32I: number;
  74471. readonly RG32I: number;
  74472. readonly RGB32I: number;
  74473. readonly RGBA32I: number;
  74474. readonly R32UI: number;
  74475. readonly RG32UI: number;
  74476. readonly RGB32UI: number;
  74477. readonly RGBA32UI: number;
  74478. readonly RGB10_A2UI: number;
  74479. readonly R11F_G11F_B10F: number;
  74480. readonly RGB9_E5: number;
  74481. readonly RGB10_A2: number;
  74482. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  74483. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  74484. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  74485. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  74486. readonly DEPTH_COMPONENT32F: number;
  74487. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  74488. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  74489. 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;
  74490. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  74491. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  74492. readonly TRANSFORM_FEEDBACK: number;
  74493. readonly INTERLEAVED_ATTRIBS: number;
  74494. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  74495. createTransformFeedback(): WebGLTransformFeedback;
  74496. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  74497. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  74498. beginTransformFeedback(primitiveMode: number): void;
  74499. endTransformFeedback(): void;
  74500. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  74501. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  74502. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  74503. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  74504. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  74505. }
  74506. interface ImageBitmap {
  74507. readonly width: number;
  74508. readonly height: number;
  74509. close(): void;
  74510. }
  74511. interface WebGLQuery extends WebGLObject {
  74512. }
  74513. declare var WebGLQuery: {
  74514. prototype: WebGLQuery;
  74515. new(): WebGLQuery;
  74516. };
  74517. interface WebGLSampler extends WebGLObject {
  74518. }
  74519. declare var WebGLSampler: {
  74520. prototype: WebGLSampler;
  74521. new(): WebGLSampler;
  74522. };
  74523. interface WebGLSync extends WebGLObject {
  74524. }
  74525. declare var WebGLSync: {
  74526. prototype: WebGLSync;
  74527. new(): WebGLSync;
  74528. };
  74529. interface WebGLTransformFeedback extends WebGLObject {
  74530. }
  74531. declare var WebGLTransformFeedback: {
  74532. prototype: WebGLTransformFeedback;
  74533. new(): WebGLTransformFeedback;
  74534. };
  74535. interface WebGLVertexArrayObject extends WebGLObject {
  74536. }
  74537. declare var WebGLVertexArrayObject: {
  74538. prototype: WebGLVertexArrayObject;
  74539. new(): WebGLVertexArrayObject;
  74540. };
  74541. // Type definitions for WebVR API
  74542. // Project: https://w3c.github.io/webvr/
  74543. // Definitions by: six a <https://github.com/lostfictions>
  74544. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  74545. interface VRDisplay extends EventTarget {
  74546. /**
  74547. * Dictionary of capabilities describing the VRDisplay.
  74548. */
  74549. readonly capabilities: VRDisplayCapabilities;
  74550. /**
  74551. * z-depth defining the far plane of the eye view frustum
  74552. * enables mapping of values in the render target depth
  74553. * attachment to scene coordinates. Initially set to 10000.0.
  74554. */
  74555. depthFar: number;
  74556. /**
  74557. * z-depth defining the near plane of the eye view frustum
  74558. * enables mapping of values in the render target depth
  74559. * attachment to scene coordinates. Initially set to 0.01.
  74560. */
  74561. depthNear: number;
  74562. /**
  74563. * An identifier for this distinct VRDisplay. Used as an
  74564. * association point in the Gamepad API.
  74565. */
  74566. readonly displayId: number;
  74567. /**
  74568. * A display name, a user-readable name identifying it.
  74569. */
  74570. readonly displayName: string;
  74571. readonly isConnected: boolean;
  74572. readonly isPresenting: boolean;
  74573. /**
  74574. * If this VRDisplay supports room-scale experiences, the optional
  74575. * stage attribute contains details on the room-scale parameters.
  74576. */
  74577. readonly stageParameters: VRStageParameters | null;
  74578. /**
  74579. * Passing the value returned by `requestAnimationFrame` to
  74580. * `cancelAnimationFrame` will unregister the callback.
  74581. * @param handle Define the hanle of the request to cancel
  74582. */
  74583. cancelAnimationFrame(handle: number): void;
  74584. /**
  74585. * Stops presenting to the VRDisplay.
  74586. * @returns a promise to know when it stopped
  74587. */
  74588. exitPresent(): Promise<void>;
  74589. /**
  74590. * Return the current VREyeParameters for the given eye.
  74591. * @param whichEye Define the eye we want the parameter for
  74592. * @returns the eye parameters
  74593. */
  74594. getEyeParameters(whichEye: string): VREyeParameters;
  74595. /**
  74596. * Populates the passed VRFrameData with the information required to render
  74597. * the current frame.
  74598. * @param frameData Define the data structure to populate
  74599. * @returns true if ok otherwise false
  74600. */
  74601. getFrameData(frameData: VRFrameData): boolean;
  74602. /**
  74603. * Get the layers currently being presented.
  74604. * @returns the list of VR layers
  74605. */
  74606. getLayers(): VRLayer[];
  74607. /**
  74608. * Return a VRPose containing the future predicted pose of the VRDisplay
  74609. * when the current frame will be presented. The value returned will not
  74610. * change until JavaScript has returned control to the browser.
  74611. *
  74612. * The VRPose will contain the position, orientation, velocity,
  74613. * and acceleration of each of these properties.
  74614. * @returns the pose object
  74615. */
  74616. getPose(): VRPose;
  74617. /**
  74618. * Return the current instantaneous pose of the VRDisplay, with no
  74619. * prediction applied.
  74620. * @returns the current instantaneous pose
  74621. */
  74622. getImmediatePose(): VRPose;
  74623. /**
  74624. * The callback passed to `requestAnimationFrame` will be called
  74625. * any time a new frame should be rendered. When the VRDisplay is
  74626. * presenting the callback will be called at the native refresh
  74627. * rate of the HMD. When not presenting this function acts
  74628. * identically to how window.requestAnimationFrame acts. Content should
  74629. * make no assumptions of frame rate or vsync behavior as the HMD runs
  74630. * asynchronously from other displays and at differing refresh rates.
  74631. * @param callback Define the eaction to run next frame
  74632. * @returns the request handle it
  74633. */
  74634. requestAnimationFrame(callback: FrameRequestCallback): number;
  74635. /**
  74636. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  74637. * Repeat calls while already presenting will update the VRLayers being displayed.
  74638. * @param layers Define the list of layer to present
  74639. * @returns a promise to know when the request has been fulfilled
  74640. */
  74641. requestPresent(layers: VRLayer[]): Promise<void>;
  74642. /**
  74643. * Reset the pose for this display, treating its current position and
  74644. * orientation as the "origin/zero" values. VRPose.position,
  74645. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  74646. * updated when calling resetPose(). This should be called in only
  74647. * sitting-space experiences.
  74648. */
  74649. resetPose(): void;
  74650. /**
  74651. * The VRLayer provided to the VRDisplay will be captured and presented
  74652. * in the HMD. Calling this function has the same effect on the source
  74653. * canvas as any other operation that uses its source image, and canvases
  74654. * created without preserveDrawingBuffer set to true will be cleared.
  74655. * @param pose Define the pose to submit
  74656. */
  74657. submitFrame(pose?: VRPose): void;
  74658. }
  74659. declare var VRDisplay: {
  74660. prototype: VRDisplay;
  74661. new(): VRDisplay;
  74662. };
  74663. interface VRLayer {
  74664. leftBounds?: number[] | Float32Array | null;
  74665. rightBounds?: number[] | Float32Array | null;
  74666. source?: HTMLCanvasElement | null;
  74667. }
  74668. interface VRDisplayCapabilities {
  74669. readonly canPresent: boolean;
  74670. readonly hasExternalDisplay: boolean;
  74671. readonly hasOrientation: boolean;
  74672. readonly hasPosition: boolean;
  74673. readonly maxLayers: number;
  74674. }
  74675. interface VREyeParameters {
  74676. /** @deprecated */
  74677. readonly fieldOfView: VRFieldOfView;
  74678. readonly offset: Float32Array;
  74679. readonly renderHeight: number;
  74680. readonly renderWidth: number;
  74681. }
  74682. interface VRFieldOfView {
  74683. readonly downDegrees: number;
  74684. readonly leftDegrees: number;
  74685. readonly rightDegrees: number;
  74686. readonly upDegrees: number;
  74687. }
  74688. interface VRFrameData {
  74689. readonly leftProjectionMatrix: Float32Array;
  74690. readonly leftViewMatrix: Float32Array;
  74691. readonly pose: VRPose;
  74692. readonly rightProjectionMatrix: Float32Array;
  74693. readonly rightViewMatrix: Float32Array;
  74694. readonly timestamp: number;
  74695. }
  74696. interface VRPose {
  74697. readonly angularAcceleration: Float32Array | null;
  74698. readonly angularVelocity: Float32Array | null;
  74699. readonly linearAcceleration: Float32Array | null;
  74700. readonly linearVelocity: Float32Array | null;
  74701. readonly orientation: Float32Array | null;
  74702. readonly position: Float32Array | null;
  74703. readonly timestamp: number;
  74704. }
  74705. interface VRStageParameters {
  74706. sittingToStandingTransform?: Float32Array;
  74707. sizeX?: number;
  74708. sizeY?: number;
  74709. }
  74710. interface Navigator {
  74711. getVRDisplays(): Promise<VRDisplay[]>;
  74712. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  74713. }
  74714. interface Window {
  74715. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  74716. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  74717. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  74718. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  74719. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  74720. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  74721. }
  74722. interface Gamepad {
  74723. readonly displayId: number;
  74724. }
  74725. type XRSessionMode =
  74726. | "inline"
  74727. | "immersive-vr"
  74728. | "immersive-ar";
  74729. type XRReferenceSpaceType =
  74730. | "viewer"
  74731. | "local"
  74732. | "local-floor"
  74733. | "bounded-floor"
  74734. | "unbounded";
  74735. type XREnvironmentBlendMode =
  74736. | "opaque"
  74737. | "additive"
  74738. | "alpha-blend";
  74739. type XRVisibilityState =
  74740. | "visible"
  74741. | "visible-blurred"
  74742. | "hidden";
  74743. type XRHandedness =
  74744. | "none"
  74745. | "left"
  74746. | "right";
  74747. type XRTargetRayMode =
  74748. | "gaze"
  74749. | "tracked-pointer"
  74750. | "screen";
  74751. type XREye =
  74752. | "none"
  74753. | "left"
  74754. | "right";
  74755. type XREventType =
  74756. | "devicechange"
  74757. | "visibilitychange"
  74758. | "end"
  74759. | "inputsourceschange"
  74760. | "select"
  74761. | "selectstart"
  74762. | "selectend"
  74763. | "squeeze"
  74764. | "squeezestart"
  74765. | "squeezeend"
  74766. | "reset";
  74767. interface XRSpace extends EventTarget {
  74768. }
  74769. interface XRRenderState {
  74770. depthNear?: number;
  74771. depthFar?: number;
  74772. inlineVerticalFieldOfView?: number;
  74773. baseLayer?: XRWebGLLayer;
  74774. }
  74775. interface XRInputSource {
  74776. handedness: XRHandedness;
  74777. targetRayMode: XRTargetRayMode;
  74778. targetRaySpace: XRSpace;
  74779. gripSpace: XRSpace | undefined;
  74780. gamepad: Gamepad | undefined;
  74781. profiles: Array<string>;
  74782. }
  74783. interface XRSessionInit {
  74784. optionalFeatures?: string[];
  74785. requiredFeatures?: string[];
  74786. }
  74787. interface XRSession {
  74788. addEventListener: Function;
  74789. removeEventListener: Function;
  74790. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  74791. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  74792. requestAnimationFrame: Function;
  74793. end(): Promise<void>;
  74794. renderState: XRRenderState;
  74795. inputSources: Array<XRInputSource>;
  74796. // hit test
  74797. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  74798. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  74799. // legacy AR hit test
  74800. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  74801. // legacy plane detection
  74802. updateWorldTrackingState(options: {
  74803. planeDetectionState?: { enabled: boolean; }
  74804. }): void;
  74805. }
  74806. interface XRReferenceSpace extends XRSpace {
  74807. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  74808. onreset: any;
  74809. }
  74810. type XRPlaneSet = Set<XRPlane>;
  74811. type XRAnchorSet = Set<XRAnchor>;
  74812. interface XRFrame {
  74813. session: XRSession;
  74814. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  74815. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  74816. // AR
  74817. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  74818. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  74819. // Anchors
  74820. trackedAnchors?: XRAnchorSet;
  74821. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  74822. // Planes
  74823. worldInformation: {
  74824. detectedPlanes?: XRPlaneSet;
  74825. };
  74826. }
  74827. interface XRViewerPose extends XRPose {
  74828. views: Array<XRView>;
  74829. }
  74830. interface XRPose {
  74831. transform: XRRigidTransform;
  74832. emulatedPosition: boolean;
  74833. }
  74834. interface XRWebGLLayerOptions {
  74835. antialias?: boolean;
  74836. depth?: boolean;
  74837. stencil?: boolean;
  74838. alpha?: boolean;
  74839. multiview?: boolean;
  74840. framebufferScaleFactor?: number;
  74841. }
  74842. declare var XRWebGLLayer: {
  74843. prototype: XRWebGLLayer;
  74844. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  74845. };
  74846. interface XRWebGLLayer {
  74847. framebuffer: WebGLFramebuffer;
  74848. framebufferWidth: number;
  74849. framebufferHeight: number;
  74850. getViewport: Function;
  74851. }
  74852. declare class XRRigidTransform {
  74853. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  74854. position: DOMPointReadOnly;
  74855. orientation: DOMPointReadOnly;
  74856. matrix: Float32Array;
  74857. inverse: XRRigidTransform;
  74858. }
  74859. interface XRView {
  74860. eye: XREye;
  74861. projectionMatrix: Float32Array;
  74862. transform: XRRigidTransform;
  74863. }
  74864. interface XRInputSourceChangeEvent {
  74865. session: XRSession;
  74866. removed: Array<XRInputSource>;
  74867. added: Array<XRInputSource>;
  74868. }
  74869. interface XRInputSourceEvent extends Event {
  74870. readonly frame: XRFrame;
  74871. readonly inputSource: XRInputSource;
  74872. }
  74873. // Experimental(er) features
  74874. declare class XRRay {
  74875. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  74876. origin: DOMPointReadOnly;
  74877. direction: DOMPointReadOnly;
  74878. matrix: Float32Array;
  74879. }
  74880. declare enum XRHitTestTrackableType {
  74881. "point",
  74882. "plane"
  74883. }
  74884. interface XRHitResult {
  74885. hitMatrix: Float32Array;
  74886. }
  74887. interface XRTransientInputHitTestResult {
  74888. readonly inputSource: XRInputSource;
  74889. readonly results: Array<XRHitTestResult>;
  74890. }
  74891. interface XRHitTestResult {
  74892. getPose(baseSpace: XRSpace): XRPose | undefined;
  74893. // When anchor system is enabled
  74894. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  74895. }
  74896. interface XRHitTestSource {
  74897. cancel(): void;
  74898. }
  74899. interface XRTransientInputHitTestSource {
  74900. cancel(): void;
  74901. }
  74902. interface XRHitTestOptionsInit {
  74903. space: XRSpace;
  74904. entityTypes?: Array<XRHitTestTrackableType>;
  74905. offsetRay?: XRRay;
  74906. }
  74907. interface XRTransientInputHitTestOptionsInit {
  74908. profile: string;
  74909. entityTypes?: Array<XRHitTestTrackableType>;
  74910. offsetRay?: XRRay;
  74911. }
  74912. interface XRAnchor {
  74913. anchorSpace: XRSpace;
  74914. delete(): void;
  74915. }
  74916. interface XRPlane {
  74917. orientation: "Horizontal" | "Vertical";
  74918. planeSpace: XRSpace;
  74919. polygon: Array<DOMPointReadOnly>;
  74920. lastChangedTime: number;
  74921. }
  74922. /**
  74923. * @ignore
  74924. */
  74925. declare module BABYLON.GLTF2.Exporter {
  74926. }
  74927. /**
  74928. * @ignore
  74929. */
  74930. declare module BABYLON.GLTF1 {
  74931. }
  74932. declare module BABYLON.GUI {
  74933. /**
  74934. * Class used to specific a value and its associated unit
  74935. */
  74936. export class ValueAndUnit {
  74937. /** defines the unit to store */
  74938. unit: number;
  74939. /** defines a boolean indicating if the value can be negative */
  74940. negativeValueAllowed: boolean;
  74941. private _value;
  74942. private _originalUnit;
  74943. /**
  74944. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  74945. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74946. */
  74947. ignoreAdaptiveScaling: boolean;
  74948. /**
  74949. * Creates a new ValueAndUnit
  74950. * @param value defines the value to store
  74951. * @param unit defines the unit to store
  74952. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  74953. */
  74954. constructor(value: number,
  74955. /** defines the unit to store */
  74956. unit?: number,
  74957. /** defines a boolean indicating if the value can be negative */
  74958. negativeValueAllowed?: boolean);
  74959. /** Gets a boolean indicating if the value is a percentage */
  74960. get isPercentage(): boolean;
  74961. /** Gets a boolean indicating if the value is store as pixel */
  74962. get isPixel(): boolean;
  74963. /** Gets direct internal value */
  74964. get internalValue(): number;
  74965. /**
  74966. * Gets value as pixel
  74967. * @param host defines the root host
  74968. * @param refValue defines the reference value for percentages
  74969. * @returns the value as pixel
  74970. */
  74971. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  74972. /**
  74973. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  74974. * @param value defines the value to store
  74975. * @param unit defines the unit to store
  74976. * @returns the current ValueAndUnit
  74977. */
  74978. updateInPlace(value: number, unit?: number): ValueAndUnit;
  74979. /**
  74980. * Gets the value accordingly to its unit
  74981. * @param host defines the root host
  74982. * @returns the value
  74983. */
  74984. getValue(host: AdvancedDynamicTexture): number;
  74985. /**
  74986. * Gets a string representation of the value
  74987. * @param host defines the root host
  74988. * @param decimals defines an optional number of decimals to display
  74989. * @returns a string
  74990. */
  74991. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  74992. /**
  74993. * Store a value parsed from a string
  74994. * @param source defines the source string
  74995. * @returns true if the value was successfully parsed
  74996. */
  74997. fromString(source: string | number): boolean;
  74998. private static _Regex;
  74999. private static _UNITMODE_PERCENTAGE;
  75000. private static _UNITMODE_PIXEL;
  75001. /** UNITMODE_PERCENTAGE */
  75002. static get UNITMODE_PERCENTAGE(): number;
  75003. /** UNITMODE_PIXEL */
  75004. static get UNITMODE_PIXEL(): number;
  75005. }
  75006. }
  75007. declare module BABYLON.GUI {
  75008. /**
  75009. * Define a style used by control to automatically setup properties based on a template.
  75010. * Only support font related properties so far
  75011. */
  75012. export class Style implements BABYLON.IDisposable {
  75013. private _fontFamily;
  75014. private _fontStyle;
  75015. private _fontWeight;
  75016. /** @hidden */
  75017. _host: AdvancedDynamicTexture;
  75018. /** @hidden */
  75019. _fontSize: ValueAndUnit;
  75020. /**
  75021. * BABYLON.Observable raised when the style values are changed
  75022. */
  75023. onChangedObservable: BABYLON.Observable<Style>;
  75024. /**
  75025. * Creates a new style object
  75026. * @param host defines the AdvancedDynamicTexture which hosts this style
  75027. */
  75028. constructor(host: AdvancedDynamicTexture);
  75029. /**
  75030. * Gets or sets the font size
  75031. */
  75032. get fontSize(): string | number;
  75033. set fontSize(value: string | number);
  75034. /**
  75035. * Gets or sets the font family
  75036. */
  75037. get fontFamily(): string;
  75038. set fontFamily(value: string);
  75039. /**
  75040. * Gets or sets the font style
  75041. */
  75042. get fontStyle(): string;
  75043. set fontStyle(value: string);
  75044. /** Gets or sets font weight */
  75045. get fontWeight(): string;
  75046. set fontWeight(value: string);
  75047. /** Dispose all associated resources */
  75048. dispose(): void;
  75049. }
  75050. }
  75051. declare module BABYLON.GUI {
  75052. /**
  75053. * Class used to transport BABYLON.Vector2 information for pointer events
  75054. */
  75055. export class Vector2WithInfo extends BABYLON.Vector2 {
  75056. /** defines the current mouse button index */
  75057. buttonIndex: number;
  75058. /**
  75059. * Creates a new Vector2WithInfo
  75060. * @param source defines the vector2 data to transport
  75061. * @param buttonIndex defines the current mouse button index
  75062. */
  75063. constructor(source: BABYLON.Vector2,
  75064. /** defines the current mouse button index */
  75065. buttonIndex?: number);
  75066. }
  75067. /** Class used to provide 2D matrix features */
  75068. export class Matrix2D {
  75069. /** Gets the internal array of 6 floats used to store matrix data */
  75070. m: Float32Array;
  75071. /**
  75072. * Creates a new matrix
  75073. * @param m00 defines value for (0, 0)
  75074. * @param m01 defines value for (0, 1)
  75075. * @param m10 defines value for (1, 0)
  75076. * @param m11 defines value for (1, 1)
  75077. * @param m20 defines value for (2, 0)
  75078. * @param m21 defines value for (2, 1)
  75079. */
  75080. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  75081. /**
  75082. * Fills the matrix from direct values
  75083. * @param m00 defines value for (0, 0)
  75084. * @param m01 defines value for (0, 1)
  75085. * @param m10 defines value for (1, 0)
  75086. * @param m11 defines value for (1, 1)
  75087. * @param m20 defines value for (2, 0)
  75088. * @param m21 defines value for (2, 1)
  75089. * @returns the current modified matrix
  75090. */
  75091. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  75092. /**
  75093. * Gets matrix determinant
  75094. * @returns the determinant
  75095. */
  75096. determinant(): number;
  75097. /**
  75098. * Inverses the matrix and stores it in a target matrix
  75099. * @param result defines the target matrix
  75100. * @returns the current matrix
  75101. */
  75102. invertToRef(result: Matrix2D): Matrix2D;
  75103. /**
  75104. * Multiplies the current matrix with another one
  75105. * @param other defines the second operand
  75106. * @param result defines the target matrix
  75107. * @returns the current matrix
  75108. */
  75109. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  75110. /**
  75111. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  75112. * @param x defines the x coordinate to transform
  75113. * @param y defines the x coordinate to transform
  75114. * @param result defines the target vector2
  75115. * @returns the current matrix
  75116. */
  75117. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  75118. /**
  75119. * Creates an identity matrix
  75120. * @returns a new matrix
  75121. */
  75122. static Identity(): Matrix2D;
  75123. /**
  75124. * Creates a translation matrix and stores it in a target matrix
  75125. * @param x defines the x coordinate of the translation
  75126. * @param y defines the y coordinate of the translation
  75127. * @param result defines the target matrix
  75128. */
  75129. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  75130. /**
  75131. * Creates a scaling matrix and stores it in a target matrix
  75132. * @param x defines the x coordinate of the scaling
  75133. * @param y defines the y coordinate of the scaling
  75134. * @param result defines the target matrix
  75135. */
  75136. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  75137. /**
  75138. * Creates a rotation matrix and stores it in a target matrix
  75139. * @param angle defines the rotation angle
  75140. * @param result defines the target matrix
  75141. */
  75142. static RotationToRef(angle: number, result: Matrix2D): void;
  75143. private static _TempPreTranslationMatrix;
  75144. private static _TempPostTranslationMatrix;
  75145. private static _TempRotationMatrix;
  75146. private static _TempScalingMatrix;
  75147. private static _TempCompose0;
  75148. private static _TempCompose1;
  75149. private static _TempCompose2;
  75150. /**
  75151. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  75152. * @param tx defines the x coordinate of the translation
  75153. * @param ty defines the y coordinate of the translation
  75154. * @param angle defines the rotation angle
  75155. * @param scaleX defines the x coordinate of the scaling
  75156. * @param scaleY defines the y coordinate of the scaling
  75157. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  75158. * @param result defines the target matrix
  75159. */
  75160. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  75161. }
  75162. }
  75163. declare module BABYLON.GUI {
  75164. /**
  75165. * Class used to store 2D control sizes
  75166. */
  75167. export class Measure {
  75168. /** defines left coordinate */
  75169. left: number;
  75170. /** defines top coordinate */
  75171. top: number;
  75172. /** defines width dimension */
  75173. width: number;
  75174. /** defines height dimension */
  75175. height: number;
  75176. /**
  75177. * Creates a new measure
  75178. * @param left defines left coordinate
  75179. * @param top defines top coordinate
  75180. * @param width defines width dimension
  75181. * @param height defines height dimension
  75182. */
  75183. constructor(
  75184. /** defines left coordinate */
  75185. left: number,
  75186. /** defines top coordinate */
  75187. top: number,
  75188. /** defines width dimension */
  75189. width: number,
  75190. /** defines height dimension */
  75191. height: number);
  75192. /**
  75193. * Copy from another measure
  75194. * @param other defines the other measure to copy from
  75195. */
  75196. copyFrom(other: Measure): void;
  75197. /**
  75198. * Copy from a group of 4 floats
  75199. * @param left defines left coordinate
  75200. * @param top defines top coordinate
  75201. * @param width defines width dimension
  75202. * @param height defines height dimension
  75203. */
  75204. copyFromFloats(left: number, top: number, width: number, height: number): void;
  75205. /**
  75206. * Computes the axis aligned bounding box measure for two given measures
  75207. * @param a Input measure
  75208. * @param b Input measure
  75209. * @param result the resulting bounding measure
  75210. */
  75211. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  75212. /**
  75213. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  75214. * @param transform the matrix to transform the measure before computing the AABB
  75215. * @param result the resulting AABB
  75216. */
  75217. transformToRef(transform: Matrix2D, result: Measure): void;
  75218. /**
  75219. * Check equality between this measure and another one
  75220. * @param other defines the other measures
  75221. * @returns true if both measures are equals
  75222. */
  75223. isEqualsTo(other: Measure): boolean;
  75224. /**
  75225. * Creates an empty measure
  75226. * @returns a new measure
  75227. */
  75228. static Empty(): Measure;
  75229. }
  75230. }
  75231. declare module BABYLON.GUI {
  75232. /**
  75233. * Interface used to define a control that can receive focus
  75234. */
  75235. export interface IFocusableControl {
  75236. /**
  75237. * Function called when the control receives the focus
  75238. */
  75239. onFocus(): void;
  75240. /**
  75241. * Function called when the control loses the focus
  75242. */
  75243. onBlur(): void;
  75244. /**
  75245. * Function called to let the control handle keyboard events
  75246. * @param evt defines the current keyboard event
  75247. */
  75248. processKeyboard(evt: KeyboardEvent): void;
  75249. /**
  75250. * Function called to get the list of controls that should not steal the focus from this control
  75251. * @returns an array of controls
  75252. */
  75253. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  75254. }
  75255. /**
  75256. * Class used to create texture to support 2D GUI elements
  75257. * @see https://doc.babylonjs.com/how_to/gui
  75258. */
  75259. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  75260. private _isDirty;
  75261. private _renderObserver;
  75262. private _resizeObserver;
  75263. private _preKeyboardObserver;
  75264. private _pointerMoveObserver;
  75265. private _pointerObserver;
  75266. private _canvasPointerOutObserver;
  75267. private _background;
  75268. /** @hidden */
  75269. _rootContainer: Container;
  75270. /** @hidden */
  75271. _lastPickedControl: Control;
  75272. /** @hidden */
  75273. _lastControlOver: {
  75274. [pointerId: number]: Control;
  75275. };
  75276. /** @hidden */
  75277. _lastControlDown: {
  75278. [pointerId: number]: Control;
  75279. };
  75280. /** @hidden */
  75281. _capturingControl: {
  75282. [pointerId: number]: Control;
  75283. };
  75284. /** @hidden */
  75285. _shouldBlockPointer: boolean;
  75286. /** @hidden */
  75287. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  75288. /** @hidden */
  75289. _linkedControls: Control[];
  75290. private _isFullscreen;
  75291. private _fullscreenViewport;
  75292. private _idealWidth;
  75293. private _idealHeight;
  75294. private _useSmallestIdeal;
  75295. private _renderAtIdealSize;
  75296. private _focusedControl;
  75297. private _blockNextFocusCheck;
  75298. private _renderScale;
  75299. private _rootElement;
  75300. private _cursorChanged;
  75301. private _defaultMousePointerId;
  75302. /** @hidden */
  75303. _numLayoutCalls: number;
  75304. /** Gets the number of layout calls made the last time the ADT has been rendered */
  75305. get numLayoutCalls(): number;
  75306. /** @hidden */
  75307. _numRenderCalls: number;
  75308. /** Gets the number of render calls made the last time the ADT has been rendered */
  75309. get numRenderCalls(): number;
  75310. /**
  75311. * Define type to string to ensure compatibility across browsers
  75312. * Safari doesn't support DataTransfer constructor
  75313. */
  75314. private _clipboardData;
  75315. /**
  75316. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  75317. */
  75318. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  75319. /**
  75320. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  75321. */
  75322. onControlPickedObservable: BABYLON.Observable<Control>;
  75323. /**
  75324. * BABYLON.Observable event triggered before layout is evaluated
  75325. */
  75326. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75327. /**
  75328. * BABYLON.Observable event triggered after the layout was evaluated
  75329. */
  75330. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75331. /**
  75332. * BABYLON.Observable event triggered before the texture is rendered
  75333. */
  75334. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75335. /**
  75336. * BABYLON.Observable event triggered after the texture was rendered
  75337. */
  75338. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75339. /**
  75340. * Gets or sets a boolean defining if alpha is stored as premultiplied
  75341. */
  75342. premulAlpha: boolean;
  75343. /**
  75344. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  75345. * Useful when you want more antialiasing
  75346. */
  75347. get renderScale(): number;
  75348. set renderScale(value: number);
  75349. /** Gets or sets the background color */
  75350. get background(): string;
  75351. set background(value: string);
  75352. /**
  75353. * Gets or sets the ideal width used to design controls.
  75354. * The GUI will then rescale everything accordingly
  75355. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75356. */
  75357. get idealWidth(): number;
  75358. set idealWidth(value: number);
  75359. /**
  75360. * Gets or sets the ideal height used to design controls.
  75361. * The GUI will then rescale everything accordingly
  75362. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75363. */
  75364. get idealHeight(): number;
  75365. set idealHeight(value: number);
  75366. /**
  75367. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  75368. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75369. */
  75370. get useSmallestIdeal(): boolean;
  75371. set useSmallestIdeal(value: boolean);
  75372. /**
  75373. * Gets or sets a boolean indicating if adaptive scaling must be used
  75374. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75375. */
  75376. get renderAtIdealSize(): boolean;
  75377. set renderAtIdealSize(value: boolean);
  75378. /**
  75379. * Gets the ratio used when in "ideal mode"
  75380. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75381. * */
  75382. get idealRatio(): number;
  75383. /**
  75384. * Gets the underlying layer used to render the texture when in fullscreen mode
  75385. */
  75386. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  75387. /**
  75388. * Gets the root container control
  75389. */
  75390. get rootContainer(): Container;
  75391. /**
  75392. * Returns an array containing the root container.
  75393. * This is mostly used to let the Inspector introspects the ADT
  75394. * @returns an array containing the rootContainer
  75395. */
  75396. getChildren(): Array<Container>;
  75397. /**
  75398. * Will return all controls that are inside this texture
  75399. * @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
  75400. * @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
  75401. * @return all child controls
  75402. */
  75403. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  75404. /**
  75405. * Gets or sets the current focused control
  75406. */
  75407. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  75408. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  75409. /**
  75410. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  75411. */
  75412. get isForeground(): boolean;
  75413. set isForeground(value: boolean);
  75414. /**
  75415. * Gets or set information about clipboardData
  75416. */
  75417. get clipboardData(): string;
  75418. set clipboardData(value: string);
  75419. /**
  75420. * Creates a new AdvancedDynamicTexture
  75421. * @param name defines the name of the texture
  75422. * @param width defines the width of the texture
  75423. * @param height defines the height of the texture
  75424. * @param scene defines the hosting scene
  75425. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  75426. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  75427. */
  75428. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  75429. /**
  75430. * Get the current class name of the texture useful for serialization or dynamic coding.
  75431. * @returns "AdvancedDynamicTexture"
  75432. */
  75433. getClassName(): string;
  75434. /**
  75435. * Function used to execute a function on all controls
  75436. * @param func defines the function to execute
  75437. * @param container defines the container where controls belong. If null the root container will be used
  75438. */
  75439. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  75440. private _useInvalidateRectOptimization;
  75441. /**
  75442. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  75443. */
  75444. get useInvalidateRectOptimization(): boolean;
  75445. set useInvalidateRectOptimization(value: boolean);
  75446. private _invalidatedRectangle;
  75447. /**
  75448. * Invalidates a rectangle area on the gui texture
  75449. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  75450. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  75451. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  75452. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  75453. */
  75454. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  75455. /**
  75456. * Marks the texture as dirty forcing a complete update
  75457. */
  75458. markAsDirty(): void;
  75459. /**
  75460. * Helper function used to create a new style
  75461. * @returns a new style
  75462. * @see https://doc.babylonjs.com/how_to/gui#styles
  75463. */
  75464. createStyle(): Style;
  75465. /**
  75466. * Adds a new control to the root container
  75467. * @param control defines the control to add
  75468. * @returns the current texture
  75469. */
  75470. addControl(control: Control): AdvancedDynamicTexture;
  75471. /**
  75472. * Removes a control from the root container
  75473. * @param control defines the control to remove
  75474. * @returns the current texture
  75475. */
  75476. removeControl(control: Control): AdvancedDynamicTexture;
  75477. /**
  75478. * Release all resources
  75479. */
  75480. dispose(): void;
  75481. private _onResize;
  75482. /** @hidden */
  75483. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  75484. /**
  75485. * Get screen coordinates for a vector3
  75486. * @param position defines the position to project
  75487. * @param worldMatrix defines the world matrix to use
  75488. * @returns the projected position
  75489. */
  75490. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  75491. private _checkUpdate;
  75492. private _clearMeasure;
  75493. private _render;
  75494. /** @hidden */
  75495. _changeCursor(cursor: string): void;
  75496. /** @hidden */
  75497. _registerLastControlDown(control: Control, pointerId: number): void;
  75498. private _doPicking;
  75499. /** @hidden */
  75500. _cleanControlAfterRemovalFromList(list: {
  75501. [pointerId: number]: Control;
  75502. }, control: Control): void;
  75503. /** @hidden */
  75504. _cleanControlAfterRemoval(control: Control): void;
  75505. /** Attach to all scene events required to support pointer events */
  75506. attach(): void;
  75507. /** @hidden */
  75508. private onClipboardCopy;
  75509. /** @hidden */
  75510. private onClipboardCut;
  75511. /** @hidden */
  75512. private onClipboardPaste;
  75513. /**
  75514. * Register the clipboard Events onto the canvas
  75515. */
  75516. registerClipboardEvents(): void;
  75517. /**
  75518. * Unregister the clipboard Events from the canvas
  75519. */
  75520. unRegisterClipboardEvents(): void;
  75521. /**
  75522. * Connect the texture to a hosting mesh to enable interactions
  75523. * @param mesh defines the mesh to attach to
  75524. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  75525. */
  75526. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  75527. /**
  75528. * Move the focus to a specific control
  75529. * @param control defines the control which will receive the focus
  75530. */
  75531. moveFocusToControl(control: IFocusableControl): void;
  75532. private _manageFocus;
  75533. private _attachToOnPointerOut;
  75534. /**
  75535. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  75536. * @param mesh defines the mesh which will receive the texture
  75537. * @param width defines the texture width (1024 by default)
  75538. * @param height defines the texture height (1024 by default)
  75539. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  75540. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  75541. * @returns a new AdvancedDynamicTexture
  75542. */
  75543. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  75544. /**
  75545. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  75546. * In this mode the texture will rely on a layer for its rendering.
  75547. * This allows it to be treated like any other layer.
  75548. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  75549. * LayerMask is set through advancedTexture.layer.layerMask
  75550. * @param name defines name for the texture
  75551. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  75552. * @param scene defines the hsoting scene
  75553. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  75554. * @returns a new AdvancedDynamicTexture
  75555. */
  75556. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  75557. }
  75558. }
  75559. declare module BABYLON.GUI {
  75560. /**
  75561. * Root class used for all 2D controls
  75562. * @see https://doc.babylonjs.com/how_to/gui#controls
  75563. */
  75564. export class Control {
  75565. /** defines the name of the control */
  75566. name?: string | undefined;
  75567. /**
  75568. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  75569. */
  75570. static AllowAlphaInheritance: boolean;
  75571. private _alpha;
  75572. private _alphaSet;
  75573. private _zIndex;
  75574. /** @hidden */
  75575. _host: AdvancedDynamicTexture;
  75576. /** Gets or sets the control parent */
  75577. parent: BABYLON.Nullable<Container>;
  75578. /** @hidden */
  75579. _currentMeasure: Measure;
  75580. private _fontFamily;
  75581. private _fontStyle;
  75582. private _fontWeight;
  75583. private _fontSize;
  75584. private _font;
  75585. /** @hidden */
  75586. _width: ValueAndUnit;
  75587. /** @hidden */
  75588. _height: ValueAndUnit;
  75589. /** @hidden */
  75590. protected _fontOffset: {
  75591. ascent: number;
  75592. height: number;
  75593. descent: number;
  75594. };
  75595. private _color;
  75596. private _style;
  75597. private _styleObserver;
  75598. /** @hidden */
  75599. protected _horizontalAlignment: number;
  75600. /** @hidden */
  75601. protected _verticalAlignment: number;
  75602. /** @hidden */
  75603. protected _isDirty: boolean;
  75604. /** @hidden */
  75605. protected _wasDirty: boolean;
  75606. /** @hidden */
  75607. _tempParentMeasure: Measure;
  75608. /** @hidden */
  75609. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  75610. /** @hidden */
  75611. protected _cachedParentMeasure: Measure;
  75612. private _paddingLeft;
  75613. private _paddingRight;
  75614. private _paddingTop;
  75615. private _paddingBottom;
  75616. /** @hidden */
  75617. _left: ValueAndUnit;
  75618. /** @hidden */
  75619. _top: ValueAndUnit;
  75620. private _scaleX;
  75621. private _scaleY;
  75622. private _rotation;
  75623. private _transformCenterX;
  75624. private _transformCenterY;
  75625. /** @hidden */
  75626. _transformMatrix: Matrix2D;
  75627. /** @hidden */
  75628. protected _invertTransformMatrix: Matrix2D;
  75629. /** @hidden */
  75630. protected _transformedPosition: BABYLON.Vector2;
  75631. private _isMatrixDirty;
  75632. private _cachedOffsetX;
  75633. private _cachedOffsetY;
  75634. private _isVisible;
  75635. private _isHighlighted;
  75636. /** @hidden */
  75637. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  75638. private _fontSet;
  75639. private _dummyVector2;
  75640. private _downCount;
  75641. private _enterCount;
  75642. private _doNotRender;
  75643. private _downPointerIds;
  75644. protected _isEnabled: boolean;
  75645. protected _disabledColor: string;
  75646. protected _disabledColorItem: string;
  75647. /** @hidden */
  75648. protected _rebuildLayout: boolean;
  75649. /** @hidden */
  75650. _customData: any;
  75651. /** @hidden */
  75652. _isClipped: boolean;
  75653. /** @hidden */
  75654. _automaticSize: boolean;
  75655. /** @hidden */
  75656. _tag: any;
  75657. /**
  75658. * 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
  75659. */
  75660. uniqueId: number;
  75661. /**
  75662. * Gets or sets an object used to store user defined information for the node
  75663. */
  75664. metadata: any;
  75665. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  75666. isHitTestVisible: boolean;
  75667. /** Gets or sets a boolean indicating if the control can block pointer events */
  75668. isPointerBlocker: boolean;
  75669. /** Gets or sets a boolean indicating if the control can be focusable */
  75670. isFocusInvisible: boolean;
  75671. /**
  75672. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  75673. * 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
  75674. */
  75675. clipChildren: boolean;
  75676. /**
  75677. * Gets or sets a boolean indicating that control content must be clipped
  75678. * 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
  75679. */
  75680. clipContent: boolean;
  75681. /**
  75682. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  75683. */
  75684. useBitmapCache: boolean;
  75685. private _cacheData;
  75686. private _shadowOffsetX;
  75687. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  75688. get shadowOffsetX(): number;
  75689. set shadowOffsetX(value: number);
  75690. private _shadowOffsetY;
  75691. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  75692. get shadowOffsetY(): number;
  75693. set shadowOffsetY(value: number);
  75694. private _shadowBlur;
  75695. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  75696. get shadowBlur(): number;
  75697. set shadowBlur(value: number);
  75698. private _shadowColor;
  75699. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  75700. get shadowColor(): string;
  75701. set shadowColor(value: string);
  75702. /** Gets or sets the cursor to use when the control is hovered */
  75703. hoverCursor: string;
  75704. /** @hidden */
  75705. protected _linkOffsetX: ValueAndUnit;
  75706. /** @hidden */
  75707. protected _linkOffsetY: ValueAndUnit;
  75708. /** Gets the control type name */
  75709. get typeName(): string;
  75710. /**
  75711. * Get the current class name of the control.
  75712. * @returns current class name
  75713. */
  75714. getClassName(): string;
  75715. /**
  75716. * An event triggered when pointer wheel is scrolled
  75717. */
  75718. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  75719. /**
  75720. * An event triggered when the pointer move over the control.
  75721. */
  75722. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  75723. /**
  75724. * An event triggered when the pointer move out of the control.
  75725. */
  75726. onPointerOutObservable: BABYLON.Observable<Control>;
  75727. /**
  75728. * An event triggered when the pointer taps the control
  75729. */
  75730. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  75731. /**
  75732. * An event triggered when pointer up
  75733. */
  75734. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  75735. /**
  75736. * An event triggered when a control is clicked on
  75737. */
  75738. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  75739. /**
  75740. * An event triggered when pointer enters the control
  75741. */
  75742. onPointerEnterObservable: BABYLON.Observable<Control>;
  75743. /**
  75744. * An event triggered when the control is marked as dirty
  75745. */
  75746. onDirtyObservable: BABYLON.Observable<Control>;
  75747. /**
  75748. * An event triggered before drawing the control
  75749. */
  75750. onBeforeDrawObservable: BABYLON.Observable<Control>;
  75751. /**
  75752. * An event triggered after the control was drawn
  75753. */
  75754. onAfterDrawObservable: BABYLON.Observable<Control>;
  75755. /**
  75756. * An event triggered when the control has been disposed
  75757. */
  75758. onDisposeObservable: BABYLON.Observable<Control>;
  75759. /**
  75760. * Get the hosting AdvancedDynamicTexture
  75761. */
  75762. get host(): AdvancedDynamicTexture;
  75763. /** Gets or set information about font offsets (used to render and align text) */
  75764. get fontOffset(): {
  75765. ascent: number;
  75766. height: number;
  75767. descent: number;
  75768. };
  75769. set fontOffset(offset: {
  75770. ascent: number;
  75771. height: number;
  75772. descent: number;
  75773. });
  75774. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  75775. get alpha(): number;
  75776. set alpha(value: number);
  75777. /**
  75778. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  75779. */
  75780. get isHighlighted(): boolean;
  75781. set isHighlighted(value: boolean);
  75782. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  75783. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75784. */
  75785. get scaleX(): number;
  75786. set scaleX(value: number);
  75787. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  75788. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75789. */
  75790. get scaleY(): number;
  75791. set scaleY(value: number);
  75792. /** Gets or sets the rotation angle (0 by default)
  75793. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75794. */
  75795. get rotation(): number;
  75796. set rotation(value: number);
  75797. /** Gets or sets the transformation center on Y axis (0 by default)
  75798. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75799. */
  75800. get transformCenterY(): number;
  75801. set transformCenterY(value: number);
  75802. /** Gets or sets the transformation center on X axis (0 by default)
  75803. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75804. */
  75805. get transformCenterX(): number;
  75806. set transformCenterX(value: number);
  75807. /**
  75808. * Gets or sets the horizontal alignment
  75809. * @see https://doc.babylonjs.com/how_to/gui#alignments
  75810. */
  75811. get horizontalAlignment(): number;
  75812. set horizontalAlignment(value: number);
  75813. /**
  75814. * Gets or sets the vertical alignment
  75815. * @see https://doc.babylonjs.com/how_to/gui#alignments
  75816. */
  75817. get verticalAlignment(): number;
  75818. set verticalAlignment(value: number);
  75819. /**
  75820. * Gets or sets control width
  75821. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75822. */
  75823. get width(): string | number;
  75824. set width(value: string | number);
  75825. /**
  75826. * Gets or sets the control width in pixel
  75827. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75828. */
  75829. get widthInPixels(): number;
  75830. set widthInPixels(value: number);
  75831. /**
  75832. * Gets or sets control height
  75833. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75834. */
  75835. get height(): string | number;
  75836. set height(value: string | number);
  75837. /**
  75838. * Gets or sets control height in pixel
  75839. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75840. */
  75841. get heightInPixels(): number;
  75842. set heightInPixels(value: number);
  75843. /** Gets or set font family */
  75844. get fontFamily(): string;
  75845. set fontFamily(value: string);
  75846. /** Gets or sets font style */
  75847. get fontStyle(): string;
  75848. set fontStyle(value: string);
  75849. /** Gets or sets font weight */
  75850. get fontWeight(): string;
  75851. set fontWeight(value: string);
  75852. /**
  75853. * Gets or sets style
  75854. * @see https://doc.babylonjs.com/how_to/gui#styles
  75855. */
  75856. get style(): BABYLON.Nullable<Style>;
  75857. set style(value: BABYLON.Nullable<Style>);
  75858. /** @hidden */
  75859. get _isFontSizeInPercentage(): boolean;
  75860. /** Gets or sets font size in pixels */
  75861. get fontSizeInPixels(): number;
  75862. set fontSizeInPixels(value: number);
  75863. /** Gets or sets font size */
  75864. get fontSize(): string | number;
  75865. set fontSize(value: string | number);
  75866. /** Gets or sets foreground color */
  75867. get color(): string;
  75868. set color(value: string);
  75869. /** Gets or sets z index which is used to reorder controls on the z axis */
  75870. get zIndex(): number;
  75871. set zIndex(value: number);
  75872. /** Gets or sets a boolean indicating if the control can be rendered */
  75873. get notRenderable(): boolean;
  75874. set notRenderable(value: boolean);
  75875. /** Gets or sets a boolean indicating if the control is visible */
  75876. get isVisible(): boolean;
  75877. set isVisible(value: boolean);
  75878. /** Gets a boolean indicating that the control needs to update its rendering */
  75879. get isDirty(): boolean;
  75880. /**
  75881. * Gets the current linked mesh (or null if none)
  75882. */
  75883. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  75884. /**
  75885. * Gets or sets a value indicating the padding to use on the left of the control
  75886. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75887. */
  75888. get paddingLeft(): string | number;
  75889. set paddingLeft(value: string | number);
  75890. /**
  75891. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  75892. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75893. */
  75894. get paddingLeftInPixels(): number;
  75895. set paddingLeftInPixels(value: number);
  75896. /**
  75897. * Gets or sets a value indicating the padding to use on the right of the control
  75898. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75899. */
  75900. get paddingRight(): string | number;
  75901. set paddingRight(value: string | number);
  75902. /**
  75903. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  75904. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75905. */
  75906. get paddingRightInPixels(): number;
  75907. set paddingRightInPixels(value: number);
  75908. /**
  75909. * Gets or sets a value indicating the padding to use on the top of the control
  75910. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75911. */
  75912. get paddingTop(): string | number;
  75913. set paddingTop(value: string | number);
  75914. /**
  75915. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  75916. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75917. */
  75918. get paddingTopInPixels(): number;
  75919. set paddingTopInPixels(value: number);
  75920. /**
  75921. * Gets or sets a value indicating the padding to use on the bottom of the control
  75922. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75923. */
  75924. get paddingBottom(): string | number;
  75925. set paddingBottom(value: string | number);
  75926. /**
  75927. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  75928. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75929. */
  75930. get paddingBottomInPixels(): number;
  75931. set paddingBottomInPixels(value: number);
  75932. /**
  75933. * Gets or sets a value indicating the left coordinate of the control
  75934. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75935. */
  75936. get left(): string | number;
  75937. set left(value: string | number);
  75938. /**
  75939. * Gets or sets a value indicating the left coordinate in pixels of the control
  75940. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75941. */
  75942. get leftInPixels(): number;
  75943. set leftInPixels(value: number);
  75944. /**
  75945. * Gets or sets a value indicating the top coordinate of the control
  75946. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75947. */
  75948. get top(): string | number;
  75949. set top(value: string | number);
  75950. /**
  75951. * Gets or sets a value indicating the top coordinate in pixels of the control
  75952. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75953. */
  75954. get topInPixels(): number;
  75955. set topInPixels(value: number);
  75956. /**
  75957. * Gets or sets a value indicating the offset on X axis to the linked mesh
  75958. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  75959. */
  75960. get linkOffsetX(): string | number;
  75961. set linkOffsetX(value: string | number);
  75962. /**
  75963. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  75964. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  75965. */
  75966. get linkOffsetXInPixels(): number;
  75967. set linkOffsetXInPixels(value: number);
  75968. /**
  75969. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  75970. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  75971. */
  75972. get linkOffsetY(): string | number;
  75973. set linkOffsetY(value: string | number);
  75974. /**
  75975. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  75976. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  75977. */
  75978. get linkOffsetYInPixels(): number;
  75979. set linkOffsetYInPixels(value: number);
  75980. /** Gets the center coordinate on X axis */
  75981. get centerX(): number;
  75982. /** Gets the center coordinate on Y axis */
  75983. get centerY(): number;
  75984. /** Gets or sets if control is Enabled*/
  75985. get isEnabled(): boolean;
  75986. set isEnabled(value: boolean);
  75987. /** Gets or sets background color of control if it's disabled*/
  75988. get disabledColor(): string;
  75989. set disabledColor(value: string);
  75990. /** Gets or sets front color of control if it's disabled*/
  75991. get disabledColorItem(): string;
  75992. set disabledColorItem(value: string);
  75993. /**
  75994. * Creates a new control
  75995. * @param name defines the name of the control
  75996. */
  75997. constructor(
  75998. /** defines the name of the control */
  75999. name?: string | undefined);
  76000. /** @hidden */
  76001. protected _getTypeName(): string;
  76002. /**
  76003. * Gets the first ascendant in the hierarchy of the given type
  76004. * @param className defines the required type
  76005. * @returns the ascendant or null if not found
  76006. */
  76007. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  76008. /** @hidden */
  76009. _resetFontCache(): void;
  76010. /**
  76011. * Determines if a container is an ascendant of the current control
  76012. * @param container defines the container to look for
  76013. * @returns true if the container is one of the ascendant of the control
  76014. */
  76015. isAscendant(container: Control): boolean;
  76016. /**
  76017. * Gets coordinates in local control space
  76018. * @param globalCoordinates defines the coordinates to transform
  76019. * @returns the new coordinates in local space
  76020. */
  76021. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  76022. /**
  76023. * Gets coordinates in local control space
  76024. * @param globalCoordinates defines the coordinates to transform
  76025. * @param result defines the target vector2 where to store the result
  76026. * @returns the current control
  76027. */
  76028. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  76029. /**
  76030. * Gets coordinates in parent local control space
  76031. * @param globalCoordinates defines the coordinates to transform
  76032. * @returns the new coordinates in parent local space
  76033. */
  76034. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  76035. /**
  76036. * Move the current control to a vector3 position projected onto the screen.
  76037. * @param position defines the target position
  76038. * @param scene defines the hosting scene
  76039. */
  76040. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  76041. /**
  76042. * Will store all controls that have this control as ascendant in a given array
  76043. * @param results defines the array where to store the descendants
  76044. * @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
  76045. * @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
  76046. */
  76047. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  76048. /**
  76049. * Will return all controls that have this control as ascendant
  76050. * @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
  76051. * @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
  76052. * @return all child controls
  76053. */
  76054. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  76055. /**
  76056. * Link current control with a target mesh
  76057. * @param mesh defines the mesh to link with
  76058. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  76059. */
  76060. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  76061. /** @hidden */
  76062. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  76063. /** @hidden */
  76064. _offsetLeft(offset: number): void;
  76065. /** @hidden */
  76066. _offsetTop(offset: number): void;
  76067. /** @hidden */
  76068. _markMatrixAsDirty(): void;
  76069. /** @hidden */
  76070. _flagDescendantsAsMatrixDirty(): void;
  76071. /** @hidden */
  76072. _intersectsRect(rect: Measure): boolean;
  76073. /** @hidden */
  76074. protected invalidateRect(): void;
  76075. /** @hidden */
  76076. _markAsDirty(force?: boolean): void;
  76077. /** @hidden */
  76078. _markAllAsDirty(): void;
  76079. /** @hidden */
  76080. _link(host: AdvancedDynamicTexture): void;
  76081. /** @hidden */
  76082. protected _transform(context?: CanvasRenderingContext2D): void;
  76083. /** @hidden */
  76084. _renderHighlight(context: CanvasRenderingContext2D): void;
  76085. /** @hidden */
  76086. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  76087. /** @hidden */
  76088. protected _applyStates(context: CanvasRenderingContext2D): void;
  76089. /** @hidden */
  76090. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  76091. /** @hidden */
  76092. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76093. protected _evaluateClippingState(parentMeasure: Measure): void;
  76094. /** @hidden */
  76095. _measure(): void;
  76096. /** @hidden */
  76097. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76098. /** @hidden */
  76099. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76100. /** @hidden */
  76101. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76102. /** @hidden */
  76103. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  76104. private static _ClipMeasure;
  76105. private _tmpMeasureA;
  76106. private _clip;
  76107. /** @hidden */
  76108. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  76109. /** @hidden */
  76110. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76111. /**
  76112. * Tests if a given coordinates belong to the current control
  76113. * @param x defines x coordinate to test
  76114. * @param y defines y coordinate to test
  76115. * @returns true if the coordinates are inside the control
  76116. */
  76117. contains(x: number, y: number): boolean;
  76118. /** @hidden */
  76119. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76120. /** @hidden */
  76121. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76122. /** @hidden */
  76123. _onPointerEnter(target: Control): boolean;
  76124. /** @hidden */
  76125. _onPointerOut(target: Control, force?: boolean): void;
  76126. /** @hidden */
  76127. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76128. /** @hidden */
  76129. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76130. /** @hidden */
  76131. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  76132. /** @hidden */
  76133. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  76134. /** @hidden */
  76135. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76136. private _prepareFont;
  76137. /** Releases associated resources */
  76138. dispose(): void;
  76139. private static _HORIZONTAL_ALIGNMENT_LEFT;
  76140. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  76141. private static _HORIZONTAL_ALIGNMENT_CENTER;
  76142. private static _VERTICAL_ALIGNMENT_TOP;
  76143. private static _VERTICAL_ALIGNMENT_BOTTOM;
  76144. private static _VERTICAL_ALIGNMENT_CENTER;
  76145. /** HORIZONTAL_ALIGNMENT_LEFT */
  76146. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  76147. /** HORIZONTAL_ALIGNMENT_RIGHT */
  76148. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  76149. /** HORIZONTAL_ALIGNMENT_CENTER */
  76150. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  76151. /** VERTICAL_ALIGNMENT_TOP */
  76152. static get VERTICAL_ALIGNMENT_TOP(): number;
  76153. /** VERTICAL_ALIGNMENT_BOTTOM */
  76154. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  76155. /** VERTICAL_ALIGNMENT_CENTER */
  76156. static get VERTICAL_ALIGNMENT_CENTER(): number;
  76157. private static _FontHeightSizes;
  76158. /** @hidden */
  76159. static _GetFontOffset(font: string): {
  76160. ascent: number;
  76161. height: number;
  76162. descent: number;
  76163. };
  76164. /**
  76165. * Creates a stack panel that can be used to render headers
  76166. * @param control defines the control to associate with the header
  76167. * @param text defines the text of the header
  76168. * @param size defines the size of the header
  76169. * @param options defines options used to configure the header
  76170. * @returns a new StackPanel
  76171. * @ignore
  76172. * @hidden
  76173. */
  76174. static AddHeader: (control: Control, text: string, size: string | number, options: {
  76175. isHorizontal: boolean;
  76176. controlFirst: boolean;
  76177. }) => any;
  76178. /** @hidden */
  76179. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  76180. }
  76181. }
  76182. declare module BABYLON.GUI {
  76183. /**
  76184. * Root class for 2D containers
  76185. * @see https://doc.babylonjs.com/how_to/gui#containers
  76186. */
  76187. export class Container extends Control {
  76188. name?: string | undefined;
  76189. /** @hidden */
  76190. _children: Control[];
  76191. /** @hidden */
  76192. protected _measureForChildren: Measure;
  76193. /** @hidden */
  76194. protected _background: string;
  76195. /** @hidden */
  76196. protected _adaptWidthToChildren: boolean;
  76197. /** @hidden */
  76198. protected _adaptHeightToChildren: boolean;
  76199. /**
  76200. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  76201. */
  76202. logLayoutCycleErrors: boolean;
  76203. /**
  76204. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  76205. */
  76206. maxLayoutCycle: number;
  76207. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  76208. get adaptHeightToChildren(): boolean;
  76209. set adaptHeightToChildren(value: boolean);
  76210. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  76211. get adaptWidthToChildren(): boolean;
  76212. set adaptWidthToChildren(value: boolean);
  76213. /** Gets or sets background color */
  76214. get background(): string;
  76215. set background(value: string);
  76216. /** Gets the list of children */
  76217. get children(): Control[];
  76218. /**
  76219. * Creates a new Container
  76220. * @param name defines the name of the container
  76221. */
  76222. constructor(name?: string | undefined);
  76223. protected _getTypeName(): string;
  76224. _flagDescendantsAsMatrixDirty(): void;
  76225. /**
  76226. * Gets a child using its name
  76227. * @param name defines the child name to look for
  76228. * @returns the child control if found
  76229. */
  76230. getChildByName(name: string): BABYLON.Nullable<Control>;
  76231. /**
  76232. * Gets a child using its type and its name
  76233. * @param name defines the child name to look for
  76234. * @param type defines the child type to look for
  76235. * @returns the child control if found
  76236. */
  76237. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  76238. /**
  76239. * Search for a specific control in children
  76240. * @param control defines the control to look for
  76241. * @returns true if the control is in child list
  76242. */
  76243. containsControl(control: Control): boolean;
  76244. /**
  76245. * Adds a new control to the current container
  76246. * @param control defines the control to add
  76247. * @returns the current container
  76248. */
  76249. addControl(control: BABYLON.Nullable<Control>): Container;
  76250. /**
  76251. * Removes all controls from the current container
  76252. * @returns the current container
  76253. */
  76254. clearControls(): Container;
  76255. /**
  76256. * Removes a control from the current container
  76257. * @param control defines the control to remove
  76258. * @returns the current container
  76259. */
  76260. removeControl(control: Control): Container;
  76261. /** @hidden */
  76262. _reOrderControl(control: Control): void;
  76263. /** @hidden */
  76264. _offsetLeft(offset: number): void;
  76265. /** @hidden */
  76266. _offsetTop(offset: number): void;
  76267. /** @hidden */
  76268. _markAllAsDirty(): void;
  76269. /** @hidden */
  76270. protected _localDraw(context: CanvasRenderingContext2D): void;
  76271. /** @hidden */
  76272. _link(host: AdvancedDynamicTexture): void;
  76273. /** @hidden */
  76274. protected _beforeLayout(): void;
  76275. /** @hidden */
  76276. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76277. /** @hidden */
  76278. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  76279. protected _postMeasure(): void;
  76280. /** @hidden */
  76281. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  76282. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  76283. /** @hidden */
  76284. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76285. /** @hidden */
  76286. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76287. /** Releases associated resources */
  76288. dispose(): void;
  76289. }
  76290. }
  76291. declare module BABYLON.GUI {
  76292. /** Class used to create rectangle container */
  76293. export class Rectangle extends Container {
  76294. name?: string | undefined;
  76295. private _thickness;
  76296. private _cornerRadius;
  76297. /** Gets or sets border thickness */
  76298. get thickness(): number;
  76299. set thickness(value: number);
  76300. /** Gets or sets the corner radius angle */
  76301. get cornerRadius(): number;
  76302. set cornerRadius(value: number);
  76303. /**
  76304. * Creates a new Rectangle
  76305. * @param name defines the control name
  76306. */
  76307. constructor(name?: string | undefined);
  76308. protected _getTypeName(): string;
  76309. protected _localDraw(context: CanvasRenderingContext2D): void;
  76310. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76311. private _drawRoundedRect;
  76312. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  76313. }
  76314. }
  76315. declare module BABYLON.GUI {
  76316. /**
  76317. * Enum that determines the text-wrapping mode to use.
  76318. */
  76319. export enum TextWrapping {
  76320. /**
  76321. * Clip the text when it's larger than Control.width; this is the default mode.
  76322. */
  76323. Clip = 0,
  76324. /**
  76325. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  76326. */
  76327. WordWrap = 1,
  76328. /**
  76329. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  76330. */
  76331. Ellipsis = 2
  76332. }
  76333. /**
  76334. * Class used to create text block control
  76335. */
  76336. export class TextBlock extends Control {
  76337. /**
  76338. * Defines the name of the control
  76339. */
  76340. name?: string | undefined;
  76341. private _text;
  76342. private _textWrapping;
  76343. private _textHorizontalAlignment;
  76344. private _textVerticalAlignment;
  76345. private _lines;
  76346. private _resizeToFit;
  76347. private _lineSpacing;
  76348. private _outlineWidth;
  76349. private _outlineColor;
  76350. /**
  76351. * An event triggered after the text is changed
  76352. */
  76353. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  76354. /**
  76355. * An event triggered after the text was broken up into lines
  76356. */
  76357. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  76358. /**
  76359. * Function used to split a string into words. By default, a string is split at each space character found
  76360. */
  76361. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  76362. /**
  76363. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  76364. */
  76365. get lines(): any[];
  76366. /**
  76367. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  76368. */
  76369. get resizeToFit(): boolean;
  76370. /**
  76371. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  76372. */
  76373. set resizeToFit(value: boolean);
  76374. /**
  76375. * Gets or sets a boolean indicating if text must be wrapped
  76376. */
  76377. get textWrapping(): TextWrapping | boolean;
  76378. /**
  76379. * Gets or sets a boolean indicating if text must be wrapped
  76380. */
  76381. set textWrapping(value: TextWrapping | boolean);
  76382. /**
  76383. * Gets or sets text to display
  76384. */
  76385. get text(): string;
  76386. /**
  76387. * Gets or sets text to display
  76388. */
  76389. set text(value: string);
  76390. /**
  76391. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  76392. */
  76393. get textHorizontalAlignment(): number;
  76394. /**
  76395. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  76396. */
  76397. set textHorizontalAlignment(value: number);
  76398. /**
  76399. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  76400. */
  76401. get textVerticalAlignment(): number;
  76402. /**
  76403. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  76404. */
  76405. set textVerticalAlignment(value: number);
  76406. /**
  76407. * Gets or sets line spacing value
  76408. */
  76409. set lineSpacing(value: string | number);
  76410. /**
  76411. * Gets or sets line spacing value
  76412. */
  76413. get lineSpacing(): string | number;
  76414. /**
  76415. * Gets or sets outlineWidth of the text to display
  76416. */
  76417. get outlineWidth(): number;
  76418. /**
  76419. * Gets or sets outlineWidth of the text to display
  76420. */
  76421. set outlineWidth(value: number);
  76422. /**
  76423. * Gets or sets outlineColor of the text to display
  76424. */
  76425. get outlineColor(): string;
  76426. /**
  76427. * Gets or sets outlineColor of the text to display
  76428. */
  76429. set outlineColor(value: string);
  76430. /**
  76431. * Creates a new TextBlock object
  76432. * @param name defines the name of the control
  76433. * @param text defines the text to display (emptry string by default)
  76434. */
  76435. constructor(
  76436. /**
  76437. * Defines the name of the control
  76438. */
  76439. name?: string | undefined, text?: string);
  76440. protected _getTypeName(): string;
  76441. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76442. private _drawText;
  76443. /** @hidden */
  76444. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76445. protected _applyStates(context: CanvasRenderingContext2D): void;
  76446. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  76447. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  76448. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  76449. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  76450. protected _renderLines(context: CanvasRenderingContext2D): void;
  76451. /**
  76452. * Given a width constraint applied on the text block, find the expected height
  76453. * @returns expected height
  76454. */
  76455. computeExpectedHeight(): number;
  76456. dispose(): void;
  76457. }
  76458. }
  76459. declare module BABYLON.GUI {
  76460. /**
  76461. * Class used to create 2D images
  76462. */
  76463. export class Image extends Control {
  76464. name?: string | undefined;
  76465. private _workingCanvas;
  76466. private _domImage;
  76467. private _imageWidth;
  76468. private _imageHeight;
  76469. private _loaded;
  76470. private _stretch;
  76471. private _source;
  76472. private _autoScale;
  76473. private _sourceLeft;
  76474. private _sourceTop;
  76475. private _sourceWidth;
  76476. private _sourceHeight;
  76477. private _svgAttributesComputationCompleted;
  76478. private _isSVG;
  76479. private _cellWidth;
  76480. private _cellHeight;
  76481. private _cellId;
  76482. private _populateNinePatchSlicesFromImage;
  76483. private _sliceLeft;
  76484. private _sliceRight;
  76485. private _sliceTop;
  76486. private _sliceBottom;
  76487. private _detectPointerOnOpaqueOnly;
  76488. /**
  76489. * BABYLON.Observable notified when the content is loaded
  76490. */
  76491. onImageLoadedObservable: BABYLON.Observable<Image>;
  76492. /**
  76493. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  76494. */
  76495. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  76496. /**
  76497. * Gets a boolean indicating that the content is loaded
  76498. */
  76499. get isLoaded(): boolean;
  76500. /**
  76501. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  76502. */
  76503. get populateNinePatchSlicesFromImage(): boolean;
  76504. set populateNinePatchSlicesFromImage(value: boolean);
  76505. /**
  76506. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  76507. * Beware using this as this will comsume more memory as the image has to be stored twice
  76508. */
  76509. get detectPointerOnOpaqueOnly(): boolean;
  76510. set detectPointerOnOpaqueOnly(value: boolean);
  76511. /**
  76512. * Gets or sets the left value for slicing (9-patch)
  76513. */
  76514. get sliceLeft(): number;
  76515. set sliceLeft(value: number);
  76516. /**
  76517. * Gets or sets the right value for slicing (9-patch)
  76518. */
  76519. get sliceRight(): number;
  76520. set sliceRight(value: number);
  76521. /**
  76522. * Gets or sets the top value for slicing (9-patch)
  76523. */
  76524. get sliceTop(): number;
  76525. set sliceTop(value: number);
  76526. /**
  76527. * Gets or sets the bottom value for slicing (9-patch)
  76528. */
  76529. get sliceBottom(): number;
  76530. set sliceBottom(value: number);
  76531. /**
  76532. * Gets or sets the left coordinate in the source image
  76533. */
  76534. get sourceLeft(): number;
  76535. set sourceLeft(value: number);
  76536. /**
  76537. * Gets or sets the top coordinate in the source image
  76538. */
  76539. get sourceTop(): number;
  76540. set sourceTop(value: number);
  76541. /**
  76542. * Gets or sets the width to capture in the source image
  76543. */
  76544. get sourceWidth(): number;
  76545. set sourceWidth(value: number);
  76546. /**
  76547. * Gets or sets the height to capture in the source image
  76548. */
  76549. get sourceHeight(): number;
  76550. set sourceHeight(value: number);
  76551. /** Indicates if the format of the image is SVG */
  76552. get isSVG(): boolean;
  76553. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  76554. get svgAttributesComputationCompleted(): boolean;
  76555. /**
  76556. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  76557. * @see https://doc.babylonjs.com/how_to/gui#image
  76558. */
  76559. get autoScale(): boolean;
  76560. set autoScale(value: boolean);
  76561. /** Gets or sets the streching mode used by the image */
  76562. get stretch(): number;
  76563. set stretch(value: number);
  76564. /** @hidden */
  76565. _rotate90(n: number, preserveProperties?: boolean): Image;
  76566. private _handleRotationForSVGImage;
  76567. private _rotate90SourceProperties;
  76568. /**
  76569. * Gets or sets the internal DOM image used to render the control
  76570. */
  76571. set domImage(value: HTMLImageElement);
  76572. get domImage(): HTMLImageElement;
  76573. private _onImageLoaded;
  76574. private _extractNinePatchSliceDataFromImage;
  76575. /**
  76576. * Gets or sets image source url
  76577. */
  76578. set source(value: BABYLON.Nullable<string>);
  76579. /**
  76580. * Checks for svg document with icon id present
  76581. */
  76582. private _svgCheck;
  76583. /**
  76584. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  76585. * given external svg file and icon id
  76586. */
  76587. private _getSVGAttribs;
  76588. /**
  76589. * Gets or sets the cell width to use when animation sheet is enabled
  76590. * @see https://doc.babylonjs.com/how_to/gui#image
  76591. */
  76592. get cellWidth(): number;
  76593. set cellWidth(value: number);
  76594. /**
  76595. * Gets or sets the cell height to use when animation sheet is enabled
  76596. * @see https://doc.babylonjs.com/how_to/gui#image
  76597. */
  76598. get cellHeight(): number;
  76599. set cellHeight(value: number);
  76600. /**
  76601. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  76602. * @see https://doc.babylonjs.com/how_to/gui#image
  76603. */
  76604. get cellId(): number;
  76605. set cellId(value: number);
  76606. /**
  76607. * Creates a new Image
  76608. * @param name defines the control name
  76609. * @param url defines the image url
  76610. */
  76611. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  76612. /**
  76613. * Tests if a given coordinates belong to the current control
  76614. * @param x defines x coordinate to test
  76615. * @param y defines y coordinate to test
  76616. * @returns true if the coordinates are inside the control
  76617. */
  76618. contains(x: number, y: number): boolean;
  76619. protected _getTypeName(): string;
  76620. /** Force the control to synchronize with its content */
  76621. synchronizeSizeWithContent(): void;
  76622. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76623. private _prepareWorkingCanvasForOpaqueDetection;
  76624. private _drawImage;
  76625. _draw(context: CanvasRenderingContext2D): void;
  76626. private _renderCornerPatch;
  76627. private _renderNinePatch;
  76628. dispose(): void;
  76629. /** STRETCH_NONE */
  76630. static readonly STRETCH_NONE: number;
  76631. /** STRETCH_FILL */
  76632. static readonly STRETCH_FILL: number;
  76633. /** STRETCH_UNIFORM */
  76634. static readonly STRETCH_UNIFORM: number;
  76635. /** STRETCH_EXTEND */
  76636. static readonly STRETCH_EXTEND: number;
  76637. /** NINE_PATCH */
  76638. static readonly STRETCH_NINE_PATCH: number;
  76639. }
  76640. }
  76641. declare module BABYLON.GUI {
  76642. /**
  76643. * Class used to create 2D buttons
  76644. */
  76645. export class Button extends Rectangle {
  76646. name?: string | undefined;
  76647. /**
  76648. * Function called to generate a pointer enter animation
  76649. */
  76650. pointerEnterAnimation: () => void;
  76651. /**
  76652. * Function called to generate a pointer out animation
  76653. */
  76654. pointerOutAnimation: () => void;
  76655. /**
  76656. * Function called to generate a pointer down animation
  76657. */
  76658. pointerDownAnimation: () => void;
  76659. /**
  76660. * Function called to generate a pointer up animation
  76661. */
  76662. pointerUpAnimation: () => void;
  76663. /**
  76664. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  76665. */
  76666. delegatePickingToChildren: boolean;
  76667. private _image;
  76668. /**
  76669. * Returns the image part of the button (if any)
  76670. */
  76671. get image(): BABYLON.Nullable<Image>;
  76672. private _textBlock;
  76673. /**
  76674. * Returns the image part of the button (if any)
  76675. */
  76676. get textBlock(): BABYLON.Nullable<TextBlock>;
  76677. /**
  76678. * Creates a new Button
  76679. * @param name defines the name of the button
  76680. */
  76681. constructor(name?: string | undefined);
  76682. protected _getTypeName(): string;
  76683. /** @hidden */
  76684. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76685. /** @hidden */
  76686. _onPointerEnter(target: Control): boolean;
  76687. /** @hidden */
  76688. _onPointerOut(target: Control, force?: boolean): void;
  76689. /** @hidden */
  76690. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76691. /** @hidden */
  76692. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76693. /**
  76694. * Creates a new button made with an image and a text
  76695. * @param name defines the name of the button
  76696. * @param text defines the text of the button
  76697. * @param imageUrl defines the url of the image
  76698. * @returns a new Button
  76699. */
  76700. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  76701. /**
  76702. * Creates a new button made with an image
  76703. * @param name defines the name of the button
  76704. * @param imageUrl defines the url of the image
  76705. * @returns a new Button
  76706. */
  76707. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  76708. /**
  76709. * Creates a new button made with a text
  76710. * @param name defines the name of the button
  76711. * @param text defines the text of the button
  76712. * @returns a new Button
  76713. */
  76714. static CreateSimpleButton(name: string, text: string): Button;
  76715. /**
  76716. * Creates a new button made with an image and a centered text
  76717. * @param name defines the name of the button
  76718. * @param text defines the text of the button
  76719. * @param imageUrl defines the url of the image
  76720. * @returns a new Button
  76721. */
  76722. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  76723. }
  76724. }
  76725. declare module BABYLON.GUI {
  76726. /**
  76727. * Class used to create a 2D stack panel container
  76728. */
  76729. export class StackPanel extends Container {
  76730. name?: string | undefined;
  76731. private _isVertical;
  76732. private _manualWidth;
  76733. private _manualHeight;
  76734. private _doNotTrackManualChanges;
  76735. /**
  76736. * Gets or sets a boolean indicating that layou warnings should be ignored
  76737. */
  76738. ignoreLayoutWarnings: boolean;
  76739. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  76740. get isVertical(): boolean;
  76741. set isVertical(value: boolean);
  76742. /**
  76743. * Gets or sets panel width.
  76744. * This value should not be set when in horizontal mode as it will be computed automatically
  76745. */
  76746. set width(value: string | number);
  76747. get width(): string | number;
  76748. /**
  76749. * Gets or sets panel height.
  76750. * This value should not be set when in vertical mode as it will be computed automatically
  76751. */
  76752. set height(value: string | number);
  76753. get height(): string | number;
  76754. /**
  76755. * Creates a new StackPanel
  76756. * @param name defines control name
  76757. */
  76758. constructor(name?: string | undefined);
  76759. protected _getTypeName(): string;
  76760. /** @hidden */
  76761. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76762. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76763. protected _postMeasure(): void;
  76764. }
  76765. }
  76766. declare module BABYLON.GUI {
  76767. /**
  76768. * Class used to represent a 2D checkbox
  76769. */
  76770. export class Checkbox extends Control {
  76771. name?: string | undefined;
  76772. private _isChecked;
  76773. private _background;
  76774. private _checkSizeRatio;
  76775. private _thickness;
  76776. /** Gets or sets border thickness */
  76777. get thickness(): number;
  76778. set thickness(value: number);
  76779. /**
  76780. * BABYLON.Observable raised when isChecked property changes
  76781. */
  76782. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  76783. /** Gets or sets a value indicating the ratio between overall size and check size */
  76784. get checkSizeRatio(): number;
  76785. set checkSizeRatio(value: number);
  76786. /** Gets or sets background color */
  76787. get background(): string;
  76788. set background(value: string);
  76789. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  76790. get isChecked(): boolean;
  76791. set isChecked(value: boolean);
  76792. /**
  76793. * Creates a new CheckBox
  76794. * @param name defines the control name
  76795. */
  76796. constructor(name?: string | undefined);
  76797. protected _getTypeName(): string;
  76798. /** @hidden */
  76799. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76800. /** @hidden */
  76801. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76802. /**
  76803. * Utility function to easily create a checkbox with a header
  76804. * @param title defines the label to use for the header
  76805. * @param onValueChanged defines the callback to call when value changes
  76806. * @returns a StackPanel containing the checkbox and a textBlock
  76807. */
  76808. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  76809. }
  76810. }
  76811. declare module BABYLON.GUI {
  76812. /**
  76813. * Class used to store key control properties
  76814. */
  76815. export class KeyPropertySet {
  76816. /** Width */
  76817. width?: string;
  76818. /** Height */
  76819. height?: string;
  76820. /** Left padding */
  76821. paddingLeft?: string;
  76822. /** Right padding */
  76823. paddingRight?: string;
  76824. /** Top padding */
  76825. paddingTop?: string;
  76826. /** Bottom padding */
  76827. paddingBottom?: string;
  76828. /** Foreground color */
  76829. color?: string;
  76830. /** Background color */
  76831. background?: string;
  76832. }
  76833. /**
  76834. * Class used to create virtual keyboard
  76835. */
  76836. export class VirtualKeyboard extends StackPanel {
  76837. /** BABYLON.Observable raised when a key is pressed */
  76838. onKeyPressObservable: BABYLON.Observable<string>;
  76839. /** Gets or sets default key button width */
  76840. defaultButtonWidth: string;
  76841. /** Gets or sets default key button height */
  76842. defaultButtonHeight: string;
  76843. /** Gets or sets default key button left padding */
  76844. defaultButtonPaddingLeft: string;
  76845. /** Gets or sets default key button right padding */
  76846. defaultButtonPaddingRight: string;
  76847. /** Gets or sets default key button top padding */
  76848. defaultButtonPaddingTop: string;
  76849. /** Gets or sets default key button bottom padding */
  76850. defaultButtonPaddingBottom: string;
  76851. /** Gets or sets default key button foreground color */
  76852. defaultButtonColor: string;
  76853. /** Gets or sets default key button background color */
  76854. defaultButtonBackground: string;
  76855. /** Gets or sets shift button foreground color */
  76856. shiftButtonColor: string;
  76857. /** Gets or sets shift button thickness*/
  76858. selectedShiftThickness: number;
  76859. /** Gets shift key state */
  76860. shiftState: number;
  76861. protected _getTypeName(): string;
  76862. private _createKey;
  76863. /**
  76864. * Adds a new row of keys
  76865. * @param keys defines the list of keys to add
  76866. * @param propertySets defines the associated property sets
  76867. */
  76868. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  76869. /**
  76870. * Set the shift key to a specific state
  76871. * @param shiftState defines the new shift state
  76872. */
  76873. applyShiftState(shiftState: number): void;
  76874. private _currentlyConnectedInputText;
  76875. private _connectedInputTexts;
  76876. private _onKeyPressObserver;
  76877. /** Gets the input text control currently attached to the keyboard */
  76878. get connectedInputText(): BABYLON.Nullable<InputText>;
  76879. /**
  76880. * Connects the keyboard with an input text control
  76881. *
  76882. * @param input defines the target control
  76883. */
  76884. connect(input: InputText): void;
  76885. /**
  76886. * Disconnects the keyboard from connected InputText controls
  76887. *
  76888. * @param input optionally defines a target control, otherwise all are disconnected
  76889. */
  76890. disconnect(input?: InputText): void;
  76891. private _removeConnectedInputObservables;
  76892. /**
  76893. * Release all resources
  76894. */
  76895. dispose(): void;
  76896. /**
  76897. * Creates a new keyboard using a default layout
  76898. *
  76899. * @param name defines control name
  76900. * @returns a new VirtualKeyboard
  76901. */
  76902. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  76903. }
  76904. }
  76905. declare module BABYLON.GUI {
  76906. /**
  76907. * Class used to create input text control
  76908. */
  76909. export class InputText extends Control implements IFocusableControl {
  76910. name?: string | undefined;
  76911. private _text;
  76912. private _placeholderText;
  76913. private _background;
  76914. private _focusedBackground;
  76915. private _focusedColor;
  76916. private _placeholderColor;
  76917. private _thickness;
  76918. private _margin;
  76919. private _autoStretchWidth;
  76920. private _maxWidth;
  76921. private _isFocused;
  76922. private _blinkTimeout;
  76923. private _blinkIsEven;
  76924. private _cursorOffset;
  76925. private _scrollLeft;
  76926. private _textWidth;
  76927. private _clickedCoordinate;
  76928. private _deadKey;
  76929. private _addKey;
  76930. private _currentKey;
  76931. private _isTextHighlightOn;
  76932. private _textHighlightColor;
  76933. private _highligherOpacity;
  76934. private _highlightedText;
  76935. private _startHighlightIndex;
  76936. private _endHighlightIndex;
  76937. private _cursorIndex;
  76938. private _onFocusSelectAll;
  76939. private _isPointerDown;
  76940. private _onClipboardObserver;
  76941. private _onPointerDblTapObserver;
  76942. /** @hidden */
  76943. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  76944. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  76945. promptMessage: string;
  76946. /** Force disable prompt on mobile device */
  76947. disableMobilePrompt: boolean;
  76948. /** BABYLON.Observable raised when the text changes */
  76949. onTextChangedObservable: BABYLON.Observable<InputText>;
  76950. /** BABYLON.Observable raised just before an entered character is to be added */
  76951. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  76952. /** BABYLON.Observable raised when the control gets the focus */
  76953. onFocusObservable: BABYLON.Observable<InputText>;
  76954. /** BABYLON.Observable raised when the control loses the focus */
  76955. onBlurObservable: BABYLON.Observable<InputText>;
  76956. /**Observable raised when the text is highlighted */
  76957. onTextHighlightObservable: BABYLON.Observable<InputText>;
  76958. /**Observable raised when copy event is triggered */
  76959. onTextCopyObservable: BABYLON.Observable<InputText>;
  76960. /** BABYLON.Observable raised when cut event is triggered */
  76961. onTextCutObservable: BABYLON.Observable<InputText>;
  76962. /** BABYLON.Observable raised when paste event is triggered */
  76963. onTextPasteObservable: BABYLON.Observable<InputText>;
  76964. /** BABYLON.Observable raised when a key event was processed */
  76965. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  76966. /** Gets or sets the maximum width allowed by the control */
  76967. get maxWidth(): string | number;
  76968. /** Gets the maximum width allowed by the control in pixels */
  76969. get maxWidthInPixels(): number;
  76970. set maxWidth(value: string | number);
  76971. /** Gets or sets the text highlighter transparency; default: 0.4 */
  76972. get highligherOpacity(): number;
  76973. set highligherOpacity(value: number);
  76974. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  76975. get onFocusSelectAll(): boolean;
  76976. set onFocusSelectAll(value: boolean);
  76977. /** Gets or sets the text hightlight color */
  76978. get textHighlightColor(): string;
  76979. set textHighlightColor(value: string);
  76980. /** Gets or sets control margin */
  76981. get margin(): string;
  76982. /** Gets control margin in pixels */
  76983. get marginInPixels(): number;
  76984. set margin(value: string);
  76985. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  76986. get autoStretchWidth(): boolean;
  76987. set autoStretchWidth(value: boolean);
  76988. /** Gets or sets border thickness */
  76989. get thickness(): number;
  76990. set thickness(value: number);
  76991. /** Gets or sets the background color when focused */
  76992. get focusedBackground(): string;
  76993. set focusedBackground(value: string);
  76994. /** Gets or sets the background color when focused */
  76995. get focusedColor(): string;
  76996. set focusedColor(value: string);
  76997. /** Gets or sets the background color */
  76998. get background(): string;
  76999. set background(value: string);
  77000. /** Gets or sets the placeholder color */
  77001. get placeholderColor(): string;
  77002. set placeholderColor(value: string);
  77003. /** Gets or sets the text displayed when the control is empty */
  77004. get placeholderText(): string;
  77005. set placeholderText(value: string);
  77006. /** Gets or sets the dead key flag */
  77007. get deadKey(): boolean;
  77008. set deadKey(flag: boolean);
  77009. /** Gets or sets the highlight text */
  77010. get highlightedText(): string;
  77011. set highlightedText(text: string);
  77012. /** Gets or sets if the current key should be added */
  77013. get addKey(): boolean;
  77014. set addKey(flag: boolean);
  77015. /** Gets or sets the value of the current key being entered */
  77016. get currentKey(): string;
  77017. set currentKey(key: string);
  77018. /** Gets or sets the text displayed in the control */
  77019. get text(): string;
  77020. set text(value: string);
  77021. /** Gets or sets control width */
  77022. get width(): string | number;
  77023. set width(value: string | number);
  77024. /**
  77025. * Creates a new InputText
  77026. * @param name defines the control name
  77027. * @param text defines the text of the control
  77028. */
  77029. constructor(name?: string | undefined, text?: string);
  77030. /** @hidden */
  77031. onBlur(): void;
  77032. /** @hidden */
  77033. onFocus(): void;
  77034. protected _getTypeName(): string;
  77035. /**
  77036. * Function called to get the list of controls that should not steal the focus from this control
  77037. * @returns an array of controls
  77038. */
  77039. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  77040. /** @hidden */
  77041. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  77042. /** @hidden */
  77043. private _updateValueFromCursorIndex;
  77044. /** @hidden */
  77045. private _processDblClick;
  77046. /** @hidden */
  77047. private _selectAllText;
  77048. /**
  77049. * Handles the keyboard event
  77050. * @param evt Defines the KeyboardEvent
  77051. */
  77052. processKeyboard(evt: KeyboardEvent): void;
  77053. /** @hidden */
  77054. private _onCopyText;
  77055. /** @hidden */
  77056. private _onCutText;
  77057. /** @hidden */
  77058. private _onPasteText;
  77059. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77060. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77061. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77062. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77063. protected _beforeRenderText(text: string): string;
  77064. dispose(): void;
  77065. }
  77066. }
  77067. declare module BABYLON.GUI {
  77068. /**
  77069. * Class used to create a 2D grid container
  77070. */
  77071. export class Grid extends Container {
  77072. name?: string | undefined;
  77073. private _rowDefinitions;
  77074. private _columnDefinitions;
  77075. private _cells;
  77076. private _childControls;
  77077. /**
  77078. * Gets the number of columns
  77079. */
  77080. get columnCount(): number;
  77081. /**
  77082. * Gets the number of rows
  77083. */
  77084. get rowCount(): number;
  77085. /** Gets the list of children */
  77086. get children(): Control[];
  77087. /** Gets the list of cells (e.g. the containers) */
  77088. get cells(): {
  77089. [key: string]: Container;
  77090. };
  77091. /**
  77092. * Gets the definition of a specific row
  77093. * @param index defines the index of the row
  77094. * @returns the row definition
  77095. */
  77096. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  77097. /**
  77098. * Gets the definition of a specific column
  77099. * @param index defines the index of the column
  77100. * @returns the column definition
  77101. */
  77102. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  77103. /**
  77104. * Adds a new row to the grid
  77105. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  77106. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  77107. * @returns the current grid
  77108. */
  77109. addRowDefinition(height: number, isPixel?: boolean): Grid;
  77110. /**
  77111. * Adds a new column to the grid
  77112. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  77113. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  77114. * @returns the current grid
  77115. */
  77116. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  77117. /**
  77118. * Update a row definition
  77119. * @param index defines the index of the row to update
  77120. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  77121. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  77122. * @returns the current grid
  77123. */
  77124. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  77125. /**
  77126. * Update a column definition
  77127. * @param index defines the index of the column to update
  77128. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  77129. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  77130. * @returns the current grid
  77131. */
  77132. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  77133. /**
  77134. * Gets the list of children stored in a specific cell
  77135. * @param row defines the row to check
  77136. * @param column defines the column to check
  77137. * @returns the list of controls
  77138. */
  77139. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  77140. /**
  77141. * Gets a string representing the child cell info (row x column)
  77142. * @param child defines the control to get info from
  77143. * @returns a string containing the child cell info (row x column)
  77144. */
  77145. getChildCellInfo(child: Control): string;
  77146. private _removeCell;
  77147. private _offsetCell;
  77148. /**
  77149. * Remove a column definition at specified index
  77150. * @param index defines the index of the column to remove
  77151. * @returns the current grid
  77152. */
  77153. removeColumnDefinition(index: number): Grid;
  77154. /**
  77155. * Remove a row definition at specified index
  77156. * @param index defines the index of the row to remove
  77157. * @returns the current grid
  77158. */
  77159. removeRowDefinition(index: number): Grid;
  77160. /**
  77161. * Adds a new control to the current grid
  77162. * @param control defines the control to add
  77163. * @param row defines the row where to add the control (0 by default)
  77164. * @param column defines the column where to add the control (0 by default)
  77165. * @returns the current grid
  77166. */
  77167. addControl(control: Control, row?: number, column?: number): Grid;
  77168. /**
  77169. * Removes a control from the current container
  77170. * @param control defines the control to remove
  77171. * @returns the current container
  77172. */
  77173. removeControl(control: Control): Container;
  77174. /**
  77175. * Creates a new Grid
  77176. * @param name defines control name
  77177. */
  77178. constructor(name?: string | undefined);
  77179. protected _getTypeName(): string;
  77180. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  77181. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77182. _flagDescendantsAsMatrixDirty(): void;
  77183. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  77184. /** Releases associated resources */
  77185. dispose(): void;
  77186. }
  77187. }
  77188. declare module BABYLON.GUI {
  77189. /** Class used to create color pickers */
  77190. export class ColorPicker extends Control {
  77191. name?: string | undefined;
  77192. private static _Epsilon;
  77193. private _colorWheelCanvas;
  77194. private _value;
  77195. private _tmpColor;
  77196. private _pointerStartedOnSquare;
  77197. private _pointerStartedOnWheel;
  77198. private _squareLeft;
  77199. private _squareTop;
  77200. private _squareSize;
  77201. private _h;
  77202. private _s;
  77203. private _v;
  77204. private _lastPointerDownID;
  77205. /**
  77206. * BABYLON.Observable raised when the value changes
  77207. */
  77208. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  77209. /** Gets or sets the color of the color picker */
  77210. get value(): BABYLON.Color3;
  77211. set value(value: BABYLON.Color3);
  77212. /**
  77213. * Gets or sets control width
  77214. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77215. */
  77216. get width(): string | number;
  77217. set width(value: string | number);
  77218. /**
  77219. * Gets or sets control height
  77220. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77221. */
  77222. get height(): string | number;
  77223. /** Gets or sets control height */
  77224. set height(value: string | number);
  77225. /** Gets or sets control size */
  77226. get size(): string | number;
  77227. set size(value: string | number);
  77228. /**
  77229. * Creates a new ColorPicker
  77230. * @param name defines the control name
  77231. */
  77232. constructor(name?: string | undefined);
  77233. protected _getTypeName(): string;
  77234. /** @hidden */
  77235. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77236. private _updateSquareProps;
  77237. private _drawGradientSquare;
  77238. private _drawCircle;
  77239. private _createColorWheelCanvas;
  77240. /** @hidden */
  77241. _draw(context: CanvasRenderingContext2D): void;
  77242. private _pointerIsDown;
  77243. private _updateValueFromPointer;
  77244. private _isPointOnSquare;
  77245. private _isPointOnWheel;
  77246. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77247. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77248. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77249. /**
  77250. * This function expands the color picker by creating a color picker dialog with manual
  77251. * color value input and the ability to save colors into an array to be used later in
  77252. * subsequent launches of the dialogue.
  77253. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  77254. * @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.
  77255. * @returns picked color as a hex string and the saved colors array as hex strings.
  77256. */
  77257. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  77258. pickerWidth?: string;
  77259. pickerHeight?: string;
  77260. headerHeight?: string;
  77261. lastColor?: string;
  77262. swatchLimit?: number;
  77263. numSwatchesPerLine?: number;
  77264. savedColors?: Array<string>;
  77265. }): Promise<{
  77266. savedColors?: string[];
  77267. pickedColor: string;
  77268. }>;
  77269. }
  77270. }
  77271. declare module BABYLON.GUI {
  77272. /** Class used to create 2D ellipse containers */
  77273. export class Ellipse extends Container {
  77274. name?: string | undefined;
  77275. private _thickness;
  77276. /** Gets or sets border thickness */
  77277. get thickness(): number;
  77278. set thickness(value: number);
  77279. /**
  77280. * Creates a new Ellipse
  77281. * @param name defines the control name
  77282. */
  77283. constructor(name?: string | undefined);
  77284. protected _getTypeName(): string;
  77285. protected _localDraw(context: CanvasRenderingContext2D): void;
  77286. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77287. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  77288. }
  77289. }
  77290. declare module BABYLON.GUI {
  77291. /**
  77292. * Class used to create a password control
  77293. */
  77294. export class InputPassword extends InputText {
  77295. protected _beforeRenderText(text: string): string;
  77296. }
  77297. }
  77298. declare module BABYLON.GUI {
  77299. /** Class used to render 2D lines */
  77300. export class Line extends Control {
  77301. name?: string | undefined;
  77302. private _lineWidth;
  77303. private _x1;
  77304. private _y1;
  77305. private _x2;
  77306. private _y2;
  77307. private _dash;
  77308. private _connectedControl;
  77309. private _connectedControlDirtyObserver;
  77310. /** Gets or sets the dash pattern */
  77311. get dash(): Array<number>;
  77312. set dash(value: Array<number>);
  77313. /** Gets or sets the control connected with the line end */
  77314. get connectedControl(): Control;
  77315. set connectedControl(value: Control);
  77316. /** Gets or sets start coordinates on X axis */
  77317. get x1(): string | number;
  77318. set x1(value: string | number);
  77319. /** Gets or sets start coordinates on Y axis */
  77320. get y1(): string | number;
  77321. set y1(value: string | number);
  77322. /** Gets or sets end coordinates on X axis */
  77323. get x2(): string | number;
  77324. set x2(value: string | number);
  77325. /** Gets or sets end coordinates on Y axis */
  77326. get y2(): string | number;
  77327. set y2(value: string | number);
  77328. /** Gets or sets line width */
  77329. get lineWidth(): number;
  77330. set lineWidth(value: number);
  77331. /** Gets or sets horizontal alignment */
  77332. set horizontalAlignment(value: number);
  77333. /** Gets or sets vertical alignment */
  77334. set verticalAlignment(value: number);
  77335. private get _effectiveX2();
  77336. private get _effectiveY2();
  77337. /**
  77338. * Creates a new Line
  77339. * @param name defines the control name
  77340. */
  77341. constructor(name?: string | undefined);
  77342. protected _getTypeName(): string;
  77343. _draw(context: CanvasRenderingContext2D): void;
  77344. _measure(): void;
  77345. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77346. /**
  77347. * Move one end of the line given 3D cartesian coordinates.
  77348. * @param position Targeted world position
  77349. * @param scene BABYLON.Scene
  77350. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  77351. */
  77352. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  77353. /**
  77354. * Move one end of the line to a position in screen absolute space.
  77355. * @param projectedPosition Position in screen absolute space (X, Y)
  77356. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  77357. */
  77358. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  77359. }
  77360. }
  77361. declare module BABYLON.GUI {
  77362. /**
  77363. * Class used to store a point for a MultiLine object.
  77364. * The point can be pure 2D coordinates, a mesh or a control
  77365. */
  77366. export class MultiLinePoint {
  77367. private _multiLine;
  77368. private _x;
  77369. private _y;
  77370. private _control;
  77371. private _mesh;
  77372. private _controlObserver;
  77373. private _meshObserver;
  77374. /** @hidden */
  77375. _point: BABYLON.Vector2;
  77376. /**
  77377. * Creates a new MultiLinePoint
  77378. * @param multiLine defines the source MultiLine object
  77379. */
  77380. constructor(multiLine: MultiLine);
  77381. /** Gets or sets x coordinate */
  77382. get x(): string | number;
  77383. set x(value: string | number);
  77384. /** Gets or sets y coordinate */
  77385. get y(): string | number;
  77386. set y(value: string | number);
  77387. /** Gets or sets the control associated with this point */
  77388. get control(): BABYLON.Nullable<Control>;
  77389. set control(value: BABYLON.Nullable<Control>);
  77390. /** Gets or sets the mesh associated with this point */
  77391. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77392. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  77393. /** Resets links */
  77394. resetLinks(): void;
  77395. /**
  77396. * Gets a translation vector
  77397. * @returns the translation vector
  77398. */
  77399. translate(): BABYLON.Vector2;
  77400. private _translatePoint;
  77401. /** Release associated resources */
  77402. dispose(): void;
  77403. }
  77404. }
  77405. declare module BABYLON.GUI {
  77406. /**
  77407. * Class used to create multi line control
  77408. */
  77409. export class MultiLine extends Control {
  77410. name?: string | undefined;
  77411. private _lineWidth;
  77412. private _dash;
  77413. private _points;
  77414. private _minX;
  77415. private _minY;
  77416. private _maxX;
  77417. private _maxY;
  77418. /**
  77419. * Creates a new MultiLine
  77420. * @param name defines the control name
  77421. */
  77422. constructor(name?: string | undefined);
  77423. /** Gets or sets dash pattern */
  77424. get dash(): Array<number>;
  77425. set dash(value: Array<number>);
  77426. /**
  77427. * Gets point stored at specified index
  77428. * @param index defines the index to look for
  77429. * @returns the requested point if found
  77430. */
  77431. getAt(index: number): MultiLinePoint;
  77432. /** Function called when a point is updated */
  77433. onPointUpdate: () => void;
  77434. /**
  77435. * Adds new points to the point collection
  77436. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  77437. * @returns the list of created MultiLinePoint
  77438. */
  77439. add(...items: (AbstractMesh | Control | {
  77440. x: string | number;
  77441. y: string | number;
  77442. })[]): MultiLinePoint[];
  77443. /**
  77444. * Adds a new point to the point collection
  77445. * @param item defines the item (mesh, control or 2d coordiantes) to add
  77446. * @returns the created MultiLinePoint
  77447. */
  77448. push(item?: (AbstractMesh | Control | {
  77449. x: string | number;
  77450. y: string | number;
  77451. })): MultiLinePoint;
  77452. /**
  77453. * Remove a specific value or point from the active point collection
  77454. * @param value defines the value or point to remove
  77455. */
  77456. remove(value: number | MultiLinePoint): void;
  77457. /**
  77458. * Resets this object to initial state (no point)
  77459. */
  77460. reset(): void;
  77461. /**
  77462. * Resets all links
  77463. */
  77464. resetLinks(): void;
  77465. /** Gets or sets line width */
  77466. get lineWidth(): number;
  77467. set lineWidth(value: number);
  77468. set horizontalAlignment(value: number);
  77469. set verticalAlignment(value: number);
  77470. protected _getTypeName(): string;
  77471. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77472. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77473. _measure(): void;
  77474. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77475. dispose(): void;
  77476. }
  77477. }
  77478. declare module BABYLON.GUI {
  77479. /**
  77480. * Class used to create radio button controls
  77481. */
  77482. export class RadioButton extends Control {
  77483. name?: string | undefined;
  77484. private _isChecked;
  77485. private _background;
  77486. private _checkSizeRatio;
  77487. private _thickness;
  77488. /** Gets or sets border thickness */
  77489. get thickness(): number;
  77490. set thickness(value: number);
  77491. /** Gets or sets group name */
  77492. group: string;
  77493. /** BABYLON.Observable raised when isChecked is changed */
  77494. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  77495. /** Gets or sets a value indicating the ratio between overall size and check size */
  77496. get checkSizeRatio(): number;
  77497. set checkSizeRatio(value: number);
  77498. /** Gets or sets background color */
  77499. get background(): string;
  77500. set background(value: string);
  77501. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  77502. get isChecked(): boolean;
  77503. set isChecked(value: boolean);
  77504. /**
  77505. * Creates a new RadioButton
  77506. * @param name defines the control name
  77507. */
  77508. constructor(name?: string | undefined);
  77509. protected _getTypeName(): string;
  77510. _draw(context: CanvasRenderingContext2D): void;
  77511. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77512. /**
  77513. * Utility function to easily create a radio button with a header
  77514. * @param title defines the label to use for the header
  77515. * @param group defines the group to use for the radio button
  77516. * @param isChecked defines the initial state of the radio button
  77517. * @param onValueChanged defines the callback to call when value changes
  77518. * @returns a StackPanel containing the radio button and a textBlock
  77519. */
  77520. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  77521. }
  77522. }
  77523. declare module BABYLON.GUI {
  77524. /**
  77525. * Class used to create slider controls
  77526. */
  77527. export class BaseSlider extends Control {
  77528. name?: string | undefined;
  77529. protected _thumbWidth: ValueAndUnit;
  77530. private _minimum;
  77531. private _maximum;
  77532. private _value;
  77533. private _isVertical;
  77534. protected _barOffset: ValueAndUnit;
  77535. private _isThumbClamped;
  77536. protected _displayThumb: boolean;
  77537. private _step;
  77538. private _lastPointerDownID;
  77539. protected _effectiveBarOffset: number;
  77540. protected _renderLeft: number;
  77541. protected _renderTop: number;
  77542. protected _renderWidth: number;
  77543. protected _renderHeight: number;
  77544. protected _backgroundBoxLength: number;
  77545. protected _backgroundBoxThickness: number;
  77546. protected _effectiveThumbThickness: number;
  77547. /** BABYLON.Observable raised when the sldier value changes */
  77548. onValueChangedObservable: BABYLON.Observable<number>;
  77549. /** Gets or sets a boolean indicating if the thumb must be rendered */
  77550. get displayThumb(): boolean;
  77551. set displayThumb(value: boolean);
  77552. /** Gets or sets a step to apply to values (0 by default) */
  77553. get step(): number;
  77554. set step(value: number);
  77555. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  77556. get barOffset(): string | number;
  77557. /** Gets main bar offset in pixels*/
  77558. get barOffsetInPixels(): number;
  77559. set barOffset(value: string | number);
  77560. /** Gets or sets thumb width */
  77561. get thumbWidth(): string | number;
  77562. /** Gets thumb width in pixels */
  77563. get thumbWidthInPixels(): number;
  77564. set thumbWidth(value: string | number);
  77565. /** Gets or sets minimum value */
  77566. get minimum(): number;
  77567. set minimum(value: number);
  77568. /** Gets or sets maximum value */
  77569. get maximum(): number;
  77570. set maximum(value: number);
  77571. /** Gets or sets current value */
  77572. get value(): number;
  77573. set value(value: number);
  77574. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  77575. get isVertical(): boolean;
  77576. set isVertical(value: boolean);
  77577. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  77578. get isThumbClamped(): boolean;
  77579. set isThumbClamped(value: boolean);
  77580. /**
  77581. * Creates a new BaseSlider
  77582. * @param name defines the control name
  77583. */
  77584. constructor(name?: string | undefined);
  77585. protected _getTypeName(): string;
  77586. protected _getThumbPosition(): number;
  77587. protected _getThumbThickness(type: string): number;
  77588. protected _prepareRenderingData(type: string): void;
  77589. private _pointerIsDown;
  77590. /** @hidden */
  77591. protected _updateValueFromPointer(x: number, y: number): void;
  77592. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77593. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77594. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77595. }
  77596. }
  77597. declare module BABYLON.GUI {
  77598. /**
  77599. * Class used to create slider controls
  77600. */
  77601. export class Slider extends BaseSlider {
  77602. name?: string | undefined;
  77603. private _background;
  77604. private _borderColor;
  77605. private _isThumbCircle;
  77606. protected _displayValueBar: boolean;
  77607. /** Gets or sets a boolean indicating if the value bar must be rendered */
  77608. get displayValueBar(): boolean;
  77609. set displayValueBar(value: boolean);
  77610. /** Gets or sets border color */
  77611. get borderColor(): string;
  77612. set borderColor(value: string);
  77613. /** Gets or sets background color */
  77614. get background(): string;
  77615. set background(value: string);
  77616. /** Gets or sets a boolean indicating if the thumb should be round or square */
  77617. get isThumbCircle(): boolean;
  77618. set isThumbCircle(value: boolean);
  77619. /**
  77620. * Creates a new Slider
  77621. * @param name defines the control name
  77622. */
  77623. constructor(name?: string | undefined);
  77624. protected _getTypeName(): string;
  77625. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77626. }
  77627. }
  77628. declare module BABYLON.GUI {
  77629. /** Class used to create a RadioGroup
  77630. * which contains groups of radio buttons
  77631. */
  77632. export class SelectorGroup {
  77633. /** name of SelectorGroup */
  77634. name: string;
  77635. private _groupPanel;
  77636. private _selectors;
  77637. private _groupHeader;
  77638. /**
  77639. * Creates a new SelectorGroup
  77640. * @param name of group, used as a group heading
  77641. */
  77642. constructor(
  77643. /** name of SelectorGroup */
  77644. name: string);
  77645. /** Gets the groupPanel of the SelectorGroup */
  77646. get groupPanel(): StackPanel;
  77647. /** Gets the selectors array */
  77648. get selectors(): StackPanel[];
  77649. /** Gets and sets the group header */
  77650. get header(): string;
  77651. set header(label: string);
  77652. /** @hidden */
  77653. private _addGroupHeader;
  77654. /** @hidden*/
  77655. _getSelector(selectorNb: number): StackPanel | undefined;
  77656. /** Removes the selector at the given position
  77657. * @param selectorNb the position of the selector within the group
  77658. */
  77659. removeSelector(selectorNb: number): void;
  77660. }
  77661. /** Class used to create a CheckboxGroup
  77662. * which contains groups of checkbox buttons
  77663. */
  77664. export class CheckboxGroup extends SelectorGroup {
  77665. /** Adds a checkbox as a control
  77666. * @param text is the label for the selector
  77667. * @param func is the function called when the Selector is checked
  77668. * @param checked is true when Selector is checked
  77669. */
  77670. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  77671. /** @hidden */
  77672. _setSelectorLabel(selectorNb: number, label: string): void;
  77673. /** @hidden */
  77674. _setSelectorLabelColor(selectorNb: number, color: string): void;
  77675. /** @hidden */
  77676. _setSelectorButtonColor(selectorNb: number, color: string): void;
  77677. /** @hidden */
  77678. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  77679. }
  77680. /** Class used to create a RadioGroup
  77681. * which contains groups of radio buttons
  77682. */
  77683. export class RadioGroup extends SelectorGroup {
  77684. private _selectNb;
  77685. /** Adds a radio button as a control
  77686. * @param label is the label for the selector
  77687. * @param func is the function called when the Selector is checked
  77688. * @param checked is true when Selector is checked
  77689. */
  77690. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  77691. /** @hidden */
  77692. _setSelectorLabel(selectorNb: number, label: string): void;
  77693. /** @hidden */
  77694. _setSelectorLabelColor(selectorNb: number, color: string): void;
  77695. /** @hidden */
  77696. _setSelectorButtonColor(selectorNb: number, color: string): void;
  77697. /** @hidden */
  77698. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  77699. }
  77700. /** Class used to create a SliderGroup
  77701. * which contains groups of slider buttons
  77702. */
  77703. export class SliderGroup extends SelectorGroup {
  77704. /**
  77705. * Adds a slider to the SelectorGroup
  77706. * @param label is the label for the SliderBar
  77707. * @param func is the function called when the Slider moves
  77708. * @param unit is a string describing the units used, eg degrees or metres
  77709. * @param min is the minimum value for the Slider
  77710. * @param max is the maximum value for the Slider
  77711. * @param value is the start value for the Slider between min and max
  77712. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  77713. */
  77714. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  77715. /** @hidden */
  77716. _setSelectorLabel(selectorNb: number, label: string): void;
  77717. /** @hidden */
  77718. _setSelectorLabelColor(selectorNb: number, color: string): void;
  77719. /** @hidden */
  77720. _setSelectorButtonColor(selectorNb: number, color: string): void;
  77721. /** @hidden */
  77722. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  77723. }
  77724. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  77725. * @see https://doc.babylonjs.com/how_to/selector
  77726. */
  77727. export class SelectionPanel extends Rectangle {
  77728. /** name of SelectionPanel */
  77729. name: string;
  77730. /** an array of SelectionGroups */
  77731. groups: SelectorGroup[];
  77732. private _panel;
  77733. private _buttonColor;
  77734. private _buttonBackground;
  77735. private _headerColor;
  77736. private _barColor;
  77737. private _barHeight;
  77738. private _spacerHeight;
  77739. private _labelColor;
  77740. private _groups;
  77741. private _bars;
  77742. /**
  77743. * Creates a new SelectionPanel
  77744. * @param name of SelectionPanel
  77745. * @param groups is an array of SelectionGroups
  77746. */
  77747. constructor(
  77748. /** name of SelectionPanel */
  77749. name: string,
  77750. /** an array of SelectionGroups */
  77751. groups?: SelectorGroup[]);
  77752. protected _getTypeName(): string;
  77753. /** Gets or sets the headerColor */
  77754. get headerColor(): string;
  77755. set headerColor(color: string);
  77756. private _setHeaderColor;
  77757. /** Gets or sets the button color */
  77758. get buttonColor(): string;
  77759. set buttonColor(color: string);
  77760. private _setbuttonColor;
  77761. /** Gets or sets the label color */
  77762. get labelColor(): string;
  77763. set labelColor(color: string);
  77764. private _setLabelColor;
  77765. /** Gets or sets the button background */
  77766. get buttonBackground(): string;
  77767. set buttonBackground(color: string);
  77768. private _setButtonBackground;
  77769. /** Gets or sets the color of separator bar */
  77770. get barColor(): string;
  77771. set barColor(color: string);
  77772. private _setBarColor;
  77773. /** Gets or sets the height of separator bar */
  77774. get barHeight(): string;
  77775. set barHeight(value: string);
  77776. private _setBarHeight;
  77777. /** Gets or sets the height of spacers*/
  77778. get spacerHeight(): string;
  77779. set spacerHeight(value: string);
  77780. private _setSpacerHeight;
  77781. /** Adds a bar between groups */
  77782. private _addSpacer;
  77783. /** Add a group to the selection panel
  77784. * @param group is the selector group to add
  77785. */
  77786. addGroup(group: SelectorGroup): void;
  77787. /** Remove the group from the given position
  77788. * @param groupNb is the position of the group in the list
  77789. */
  77790. removeGroup(groupNb: number): void;
  77791. /** Change a group header label
  77792. * @param label is the new group header label
  77793. * @param groupNb is the number of the group to relabel
  77794. * */
  77795. setHeaderName(label: string, groupNb: number): void;
  77796. /** Change selector label to the one given
  77797. * @param label is the new selector label
  77798. * @param groupNb is the number of the groupcontaining the selector
  77799. * @param selectorNb is the number of the selector within a group to relabel
  77800. * */
  77801. relabel(label: string, groupNb: number, selectorNb: number): void;
  77802. /** For a given group position remove the selector at the given position
  77803. * @param groupNb is the number of the group to remove the selector from
  77804. * @param selectorNb is the number of the selector within the group
  77805. */
  77806. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  77807. /** For a given group position of correct type add a checkbox button
  77808. * @param groupNb is the number of the group to remove the selector from
  77809. * @param label is the label for the selector
  77810. * @param func is the function called when the Selector is checked
  77811. * @param checked is true when Selector is checked
  77812. */
  77813. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  77814. /** For a given group position of correct type add a radio button
  77815. * @param groupNb is the number of the group to remove the selector from
  77816. * @param label is the label for the selector
  77817. * @param func is the function called when the Selector is checked
  77818. * @param checked is true when Selector is checked
  77819. */
  77820. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  77821. /**
  77822. * For a given slider group add a slider
  77823. * @param groupNb is the number of the group to add the slider to
  77824. * @param label is the label for the Slider
  77825. * @param func is the function called when the Slider moves
  77826. * @param unit is a string describing the units used, eg degrees or metres
  77827. * @param min is the minimum value for the Slider
  77828. * @param max is the maximum value for the Slider
  77829. * @param value is the start value for the Slider between min and max
  77830. * @param onVal is the function used to format the value displayed, eg radians to degrees
  77831. */
  77832. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  77833. }
  77834. }
  77835. declare module BABYLON.GUI {
  77836. /**
  77837. * Class used to hold a the container for ScrollViewer
  77838. * @hidden
  77839. */
  77840. export class _ScrollViewerWindow extends Container {
  77841. parentClientWidth: number;
  77842. parentClientHeight: number;
  77843. private _freezeControls;
  77844. private _parentMeasure;
  77845. private _oldLeft;
  77846. private _oldTop;
  77847. get freezeControls(): boolean;
  77848. set freezeControls(value: boolean);
  77849. private _bucketWidth;
  77850. private _bucketHeight;
  77851. private _buckets;
  77852. private _bucketLen;
  77853. get bucketWidth(): number;
  77854. get bucketHeight(): number;
  77855. setBucketSizes(width: number, height: number): void;
  77856. private _useBuckets;
  77857. private _makeBuckets;
  77858. private _dispatchInBuckets;
  77859. private _updateMeasures;
  77860. private _updateChildrenMeasures;
  77861. private _restoreMeasures;
  77862. /**
  77863. * Creates a new ScrollViewerWindow
  77864. * @param name of ScrollViewerWindow
  77865. */
  77866. constructor(name?: string);
  77867. protected _getTypeName(): string;
  77868. /** @hidden */
  77869. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77870. /** @hidden */
  77871. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  77872. private _scrollChildren;
  77873. private _scrollChildrenWithBuckets;
  77874. /** @hidden */
  77875. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  77876. protected _postMeasure(): void;
  77877. }
  77878. }
  77879. declare module BABYLON.GUI {
  77880. /**
  77881. * Class used to create slider controls
  77882. */
  77883. export class ScrollBar extends BaseSlider {
  77884. name?: string | undefined;
  77885. private _background;
  77886. private _borderColor;
  77887. private _tempMeasure;
  77888. /** Gets or sets border color */
  77889. get borderColor(): string;
  77890. set borderColor(value: string);
  77891. /** Gets or sets background color */
  77892. get background(): string;
  77893. set background(value: string);
  77894. /**
  77895. * Creates a new Slider
  77896. * @param name defines the control name
  77897. */
  77898. constructor(name?: string | undefined);
  77899. protected _getTypeName(): string;
  77900. protected _getThumbThickness(): number;
  77901. _draw(context: CanvasRenderingContext2D): void;
  77902. private _first;
  77903. private _originX;
  77904. private _originY;
  77905. /** @hidden */
  77906. protected _updateValueFromPointer(x: number, y: number): void;
  77907. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77908. }
  77909. }
  77910. declare module BABYLON.GUI {
  77911. /**
  77912. * Class used to create slider controls
  77913. */
  77914. export class ImageScrollBar extends BaseSlider {
  77915. name?: string | undefined;
  77916. private _backgroundBaseImage;
  77917. private _backgroundImage;
  77918. private _thumbImage;
  77919. private _thumbBaseImage;
  77920. private _thumbLength;
  77921. private _thumbHeight;
  77922. private _barImageHeight;
  77923. private _tempMeasure;
  77924. /** Number of 90° rotation to apply on the images when in vertical mode */
  77925. num90RotationInVerticalMode: number;
  77926. /**
  77927. * Gets or sets the image used to render the background for horizontal bar
  77928. */
  77929. get backgroundImage(): Image;
  77930. set backgroundImage(value: Image);
  77931. /**
  77932. * Gets or sets the image used to render the thumb
  77933. */
  77934. get thumbImage(): Image;
  77935. set thumbImage(value: Image);
  77936. /**
  77937. * Gets or sets the length of the thumb
  77938. */
  77939. get thumbLength(): number;
  77940. set thumbLength(value: number);
  77941. /**
  77942. * Gets or sets the height of the thumb
  77943. */
  77944. get thumbHeight(): number;
  77945. set thumbHeight(value: number);
  77946. /**
  77947. * Gets or sets the height of the bar image
  77948. */
  77949. get barImageHeight(): number;
  77950. set barImageHeight(value: number);
  77951. /**
  77952. * Creates a new ImageScrollBar
  77953. * @param name defines the control name
  77954. */
  77955. constructor(name?: string | undefined);
  77956. protected _getTypeName(): string;
  77957. protected _getThumbThickness(): number;
  77958. _draw(context: CanvasRenderingContext2D): void;
  77959. private _first;
  77960. private _originX;
  77961. private _originY;
  77962. /** @hidden */
  77963. protected _updateValueFromPointer(x: number, y: number): void;
  77964. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77965. }
  77966. }
  77967. declare module BABYLON.GUI {
  77968. /**
  77969. * Class used to hold a viewer window and sliders in a grid
  77970. */
  77971. export class ScrollViewer extends Rectangle {
  77972. private _grid;
  77973. private _horizontalBarSpace;
  77974. private _verticalBarSpace;
  77975. private _dragSpace;
  77976. private _horizontalBar;
  77977. private _verticalBar;
  77978. private _barColor;
  77979. private _barBackground;
  77980. private _barImage;
  77981. private _horizontalBarImage;
  77982. private _verticalBarImage;
  77983. private _barBackgroundImage;
  77984. private _horizontalBarBackgroundImage;
  77985. private _verticalBarBackgroundImage;
  77986. private _barSize;
  77987. private _window;
  77988. private _pointerIsOver;
  77989. private _wheelPrecision;
  77990. private _onWheelObserver;
  77991. private _clientWidth;
  77992. private _clientHeight;
  77993. private _useImageBar;
  77994. private _thumbLength;
  77995. private _thumbHeight;
  77996. private _barImageHeight;
  77997. private _horizontalBarImageHeight;
  77998. private _verticalBarImageHeight;
  77999. private _oldWindowContentsWidth;
  78000. private _oldWindowContentsHeight;
  78001. /**
  78002. * Gets the horizontal scrollbar
  78003. */
  78004. get horizontalBar(): ScrollBar | ImageScrollBar;
  78005. /**
  78006. * Gets the vertical scrollbar
  78007. */
  78008. get verticalBar(): ScrollBar | ImageScrollBar;
  78009. /**
  78010. * Adds a new control to the current container
  78011. * @param control defines the control to add
  78012. * @returns the current container
  78013. */
  78014. addControl(control: BABYLON.Nullable<Control>): Container;
  78015. /**
  78016. * Removes a control from the current container
  78017. * @param control defines the control to remove
  78018. * @returns the current container
  78019. */
  78020. removeControl(control: Control): Container;
  78021. /** Gets the list of children */
  78022. get children(): Control[];
  78023. _flagDescendantsAsMatrixDirty(): void;
  78024. /**
  78025. * Freezes or unfreezes the controls in the window.
  78026. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  78027. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  78028. */
  78029. get freezeControls(): boolean;
  78030. set freezeControls(value: boolean);
  78031. /** Gets the bucket width */
  78032. get bucketWidth(): number;
  78033. /** Gets the bucket height */
  78034. get bucketHeight(): number;
  78035. /**
  78036. * Sets the bucket sizes.
  78037. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  78038. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  78039. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  78040. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  78041. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  78042. * used), that's why it is not enabled by default.
  78043. * @param width width of the bucket
  78044. * @param height height of the bucket
  78045. */
  78046. setBucketSizes(width: number, height: number): void;
  78047. private _forceHorizontalBar;
  78048. private _forceVerticalBar;
  78049. /**
  78050. * Forces the horizontal scroll bar to be displayed
  78051. */
  78052. get forceHorizontalBar(): boolean;
  78053. set forceHorizontalBar(value: boolean);
  78054. /**
  78055. * Forces the vertical scroll bar to be displayed
  78056. */
  78057. get forceVerticalBar(): boolean;
  78058. set forceVerticalBar(value: boolean);
  78059. /**
  78060. * Creates a new ScrollViewer
  78061. * @param name of ScrollViewer
  78062. */
  78063. constructor(name?: string, isImageBased?: boolean);
  78064. /** Reset the scroll viewer window to initial size */
  78065. resetWindow(): void;
  78066. protected _getTypeName(): string;
  78067. private _buildClientSizes;
  78068. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78069. protected _postMeasure(): void;
  78070. /**
  78071. * Gets or sets the mouse wheel precision
  78072. * from 0 to 1 with a default value of 0.05
  78073. * */
  78074. get wheelPrecision(): number;
  78075. set wheelPrecision(value: number);
  78076. /** Gets or sets the scroll bar container background color */
  78077. get scrollBackground(): string;
  78078. set scrollBackground(color: string);
  78079. /** Gets or sets the bar color */
  78080. get barColor(): string;
  78081. set barColor(color: string);
  78082. /** Gets or sets the bar image */
  78083. get thumbImage(): Image;
  78084. set thumbImage(value: Image);
  78085. /** Gets or sets the horizontal bar image */
  78086. get horizontalThumbImage(): Image;
  78087. set horizontalThumbImage(value: Image);
  78088. /** Gets or sets the vertical bar image */
  78089. get verticalThumbImage(): Image;
  78090. set verticalThumbImage(value: Image);
  78091. /** Gets or sets the size of the bar */
  78092. get barSize(): number;
  78093. set barSize(value: number);
  78094. /** Gets or sets the length of the thumb */
  78095. get thumbLength(): number;
  78096. set thumbLength(value: number);
  78097. /** Gets or sets the height of the thumb */
  78098. get thumbHeight(): number;
  78099. set thumbHeight(value: number);
  78100. /** Gets or sets the height of the bar image */
  78101. get barImageHeight(): number;
  78102. set barImageHeight(value: number);
  78103. /** Gets or sets the height of the horizontal bar image */
  78104. get horizontalBarImageHeight(): number;
  78105. set horizontalBarImageHeight(value: number);
  78106. /** Gets or sets the height of the vertical bar image */
  78107. get verticalBarImageHeight(): number;
  78108. set verticalBarImageHeight(value: number);
  78109. /** Gets or sets the bar background */
  78110. get barBackground(): string;
  78111. set barBackground(color: string);
  78112. /** Gets or sets the bar background image */
  78113. get barImage(): Image;
  78114. set barImage(value: Image);
  78115. /** Gets or sets the horizontal bar background image */
  78116. get horizontalBarImage(): Image;
  78117. set horizontalBarImage(value: Image);
  78118. /** Gets or sets the vertical bar background image */
  78119. get verticalBarImage(): Image;
  78120. set verticalBarImage(value: Image);
  78121. private _setWindowPosition;
  78122. /** @hidden */
  78123. private _updateScroller;
  78124. _link(host: AdvancedDynamicTexture): void;
  78125. /** @hidden */
  78126. private _addBar;
  78127. /** @hidden */
  78128. private _attachWheel;
  78129. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  78130. /** Releases associated resources */
  78131. dispose(): void;
  78132. }
  78133. }
  78134. declare module BABYLON.GUI {
  78135. /** Class used to render a grid */
  78136. export class DisplayGrid extends Control {
  78137. name?: string | undefined;
  78138. private _cellWidth;
  78139. private _cellHeight;
  78140. private _minorLineTickness;
  78141. private _minorLineColor;
  78142. private _majorLineTickness;
  78143. private _majorLineColor;
  78144. private _majorLineFrequency;
  78145. private _background;
  78146. private _displayMajorLines;
  78147. private _displayMinorLines;
  78148. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  78149. get displayMinorLines(): boolean;
  78150. set displayMinorLines(value: boolean);
  78151. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  78152. get displayMajorLines(): boolean;
  78153. set displayMajorLines(value: boolean);
  78154. /** Gets or sets background color (Black by default) */
  78155. get background(): string;
  78156. set background(value: string);
  78157. /** Gets or sets the width of each cell (20 by default) */
  78158. get cellWidth(): number;
  78159. set cellWidth(value: number);
  78160. /** Gets or sets the height of each cell (20 by default) */
  78161. get cellHeight(): number;
  78162. set cellHeight(value: number);
  78163. /** Gets or sets the tickness of minor lines (1 by default) */
  78164. get minorLineTickness(): number;
  78165. set minorLineTickness(value: number);
  78166. /** Gets or sets the color of minor lines (DarkGray by default) */
  78167. get minorLineColor(): string;
  78168. set minorLineColor(value: string);
  78169. /** Gets or sets the tickness of major lines (2 by default) */
  78170. get majorLineTickness(): number;
  78171. set majorLineTickness(value: number);
  78172. /** Gets or sets the color of major lines (White by default) */
  78173. get majorLineColor(): string;
  78174. set majorLineColor(value: string);
  78175. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  78176. get majorLineFrequency(): number;
  78177. set majorLineFrequency(value: number);
  78178. /**
  78179. * Creates a new GridDisplayRectangle
  78180. * @param name defines the control name
  78181. */
  78182. constructor(name?: string | undefined);
  78183. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78184. protected _getTypeName(): string;
  78185. }
  78186. }
  78187. declare module BABYLON.GUI {
  78188. /**
  78189. * Class used to create slider controls based on images
  78190. */
  78191. export class ImageBasedSlider extends BaseSlider {
  78192. name?: string | undefined;
  78193. private _backgroundImage;
  78194. private _thumbImage;
  78195. private _valueBarImage;
  78196. private _tempMeasure;
  78197. get displayThumb(): boolean;
  78198. set displayThumb(value: boolean);
  78199. /**
  78200. * Gets or sets the image used to render the background
  78201. */
  78202. get backgroundImage(): Image;
  78203. set backgroundImage(value: Image);
  78204. /**
  78205. * Gets or sets the image used to render the value bar
  78206. */
  78207. get valueBarImage(): Image;
  78208. set valueBarImage(value: Image);
  78209. /**
  78210. * Gets or sets the image used to render the thumb
  78211. */
  78212. get thumbImage(): Image;
  78213. set thumbImage(value: Image);
  78214. /**
  78215. * Creates a new ImageBasedSlider
  78216. * @param name defines the control name
  78217. */
  78218. constructor(name?: string | undefined);
  78219. protected _getTypeName(): string;
  78220. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78221. }
  78222. }
  78223. declare module BABYLON.GUI {
  78224. /**
  78225. * Forcing an export so that this code will execute
  78226. * @hidden
  78227. */
  78228. const name = "Statics";
  78229. }
  78230. declare module BABYLON.GUI {
  78231. /**
  78232. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  78233. */
  78234. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  78235. /**
  78236. * Define the instrumented AdvancedDynamicTexture.
  78237. */
  78238. texture: AdvancedDynamicTexture;
  78239. private _captureRenderTime;
  78240. private _renderTime;
  78241. private _captureLayoutTime;
  78242. private _layoutTime;
  78243. private _onBeginRenderObserver;
  78244. private _onEndRenderObserver;
  78245. private _onBeginLayoutObserver;
  78246. private _onEndLayoutObserver;
  78247. /**
  78248. * Gets the perf counter used to capture render time
  78249. */
  78250. get renderTimeCounter(): BABYLON.PerfCounter;
  78251. /**
  78252. * Gets the perf counter used to capture layout time
  78253. */
  78254. get layoutTimeCounter(): BABYLON.PerfCounter;
  78255. /**
  78256. * Enable or disable the render time capture
  78257. */
  78258. get captureRenderTime(): boolean;
  78259. set captureRenderTime(value: boolean);
  78260. /**
  78261. * Enable or disable the layout time capture
  78262. */
  78263. get captureLayoutTime(): boolean;
  78264. set captureLayoutTime(value: boolean);
  78265. /**
  78266. * Instantiates a new advanced dynamic texture instrumentation.
  78267. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  78268. * @param texture Defines the AdvancedDynamicTexture to instrument
  78269. */
  78270. constructor(
  78271. /**
  78272. * Define the instrumented AdvancedDynamicTexture.
  78273. */
  78274. texture: AdvancedDynamicTexture);
  78275. /**
  78276. * Dispose and release associated resources.
  78277. */
  78278. dispose(): void;
  78279. }
  78280. }
  78281. declare module BABYLON.GUI {
  78282. /**
  78283. * Class used to load GUI via XML.
  78284. */
  78285. export class XmlLoader {
  78286. private _nodes;
  78287. private _nodeTypes;
  78288. private _isLoaded;
  78289. private _objectAttributes;
  78290. private _parentClass;
  78291. /**
  78292. * Create a new xml loader
  78293. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  78294. */
  78295. constructor(parentClass?: null);
  78296. private _getChainElement;
  78297. private _getClassAttribute;
  78298. private _createGuiElement;
  78299. private _parseGrid;
  78300. private _parseElement;
  78301. private _prepareSourceElement;
  78302. private _parseElementsFromSource;
  78303. private _parseXml;
  78304. /**
  78305. * Gets if the loading has finished.
  78306. * @returns whether the loading has finished or not
  78307. */
  78308. isLoaded(): boolean;
  78309. /**
  78310. * Gets a loaded node / control by id.
  78311. * @param id the Controls id set in the xml
  78312. * @returns element of type Control
  78313. */
  78314. getNodeById(id: string): any;
  78315. /**
  78316. * Gets all loaded nodes / controls
  78317. * @returns Array of controls
  78318. */
  78319. getNodes(): any;
  78320. /**
  78321. * Initiates the xml layout loading
  78322. * @param xmlFile defines the xml layout to load
  78323. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  78324. * @param callback defines the callback called on layout load.
  78325. */
  78326. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  78327. }
  78328. }
  78329. declare module BABYLON.GUI {
  78330. /**
  78331. * Class used to create containers for controls
  78332. */
  78333. export class Container3D extends Control3D {
  78334. private _blockLayout;
  78335. /**
  78336. * Gets the list of child controls
  78337. */
  78338. protected _children: Control3D[];
  78339. /**
  78340. * Gets the list of child controls
  78341. */
  78342. get children(): Array<Control3D>;
  78343. /**
  78344. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  78345. * This is helpful to optimize layout operation when adding multiple children in a row
  78346. */
  78347. get blockLayout(): boolean;
  78348. set blockLayout(value: boolean);
  78349. /**
  78350. * Creates a new container
  78351. * @param name defines the container name
  78352. */
  78353. constructor(name?: string);
  78354. /**
  78355. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  78356. * @returns the current container
  78357. */
  78358. updateLayout(): Container3D;
  78359. /**
  78360. * Gets a boolean indicating if the given control is in the children of this control
  78361. * @param control defines the control to check
  78362. * @returns true if the control is in the child list
  78363. */
  78364. containsControl(control: Control3D): boolean;
  78365. /**
  78366. * Adds a control to the children of this control
  78367. * @param control defines the control to add
  78368. * @returns the current container
  78369. */
  78370. addControl(control: Control3D): Container3D;
  78371. /**
  78372. * This function will be called everytime a new control is added
  78373. */
  78374. protected _arrangeChildren(): void;
  78375. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  78376. /**
  78377. * Removes a control from the children of this control
  78378. * @param control defines the control to remove
  78379. * @returns the current container
  78380. */
  78381. removeControl(control: Control3D): Container3D;
  78382. protected _getTypeName(): string;
  78383. /**
  78384. * Releases all associated resources
  78385. */
  78386. dispose(): void;
  78387. /** Control rotation will remain unchanged */
  78388. static readonly UNSET_ORIENTATION: number;
  78389. /** Control will rotate to make it look at sphere central axis */
  78390. static readonly FACEORIGIN_ORIENTATION: number;
  78391. /** Control will rotate to make it look back at sphere central axis */
  78392. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  78393. /** Control will rotate to look at z axis (0, 0, 1) */
  78394. static readonly FACEFORWARD_ORIENTATION: number;
  78395. /** Control will rotate to look at negative z axis (0, 0, -1) */
  78396. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  78397. }
  78398. }
  78399. declare module BABYLON.GUI {
  78400. /**
  78401. * Class used to manage 3D user interface
  78402. * @see https://doc.babylonjs.com/how_to/gui3d
  78403. */
  78404. export class GUI3DManager implements BABYLON.IDisposable {
  78405. private _scene;
  78406. private _sceneDisposeObserver;
  78407. private _utilityLayer;
  78408. private _rootContainer;
  78409. private _pointerObserver;
  78410. private _pointerOutObserver;
  78411. /** @hidden */
  78412. _lastPickedControl: Control3D;
  78413. /** @hidden */
  78414. _lastControlOver: {
  78415. [pointerId: number]: Control3D;
  78416. };
  78417. /** @hidden */
  78418. _lastControlDown: {
  78419. [pointerId: number]: Control3D;
  78420. };
  78421. /**
  78422. * BABYLON.Observable raised when the point picked by the pointer events changed
  78423. */
  78424. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  78425. /** @hidden */
  78426. _sharedMaterials: {
  78427. [key: string]: BABYLON.Material;
  78428. };
  78429. /** Gets the hosting scene */
  78430. get scene(): BABYLON.Scene;
  78431. /** Gets associated utility layer */
  78432. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  78433. /**
  78434. * Creates a new GUI3DManager
  78435. * @param scene
  78436. */
  78437. constructor(scene?: BABYLON.Scene);
  78438. private _handlePointerOut;
  78439. private _doPicking;
  78440. /**
  78441. * Gets the root container
  78442. */
  78443. get rootContainer(): Container3D;
  78444. /**
  78445. * Gets a boolean indicating if the given control is in the root child list
  78446. * @param control defines the control to check
  78447. * @returns true if the control is in the root child list
  78448. */
  78449. containsControl(control: Control3D): boolean;
  78450. /**
  78451. * Adds a control to the root child list
  78452. * @param control defines the control to add
  78453. * @returns the current manager
  78454. */
  78455. addControl(control: Control3D): GUI3DManager;
  78456. /**
  78457. * Removes a control from the root child list
  78458. * @param control defines the control to remove
  78459. * @returns the current container
  78460. */
  78461. removeControl(control: Control3D): GUI3DManager;
  78462. /**
  78463. * Releases all associated resources
  78464. */
  78465. dispose(): void;
  78466. }
  78467. }
  78468. declare module BABYLON.GUI {
  78469. /**
  78470. * Class used to transport BABYLON.Vector3 information for pointer events
  78471. */
  78472. export class Vector3WithInfo extends BABYLON.Vector3 {
  78473. /** defines the current mouse button index */
  78474. buttonIndex: number;
  78475. /**
  78476. * Creates a new Vector3WithInfo
  78477. * @param source defines the vector3 data to transport
  78478. * @param buttonIndex defines the current mouse button index
  78479. */
  78480. constructor(source: BABYLON.Vector3,
  78481. /** defines the current mouse button index */
  78482. buttonIndex?: number);
  78483. }
  78484. }
  78485. declare module BABYLON.GUI {
  78486. /**
  78487. * Class used as base class for controls
  78488. */
  78489. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  78490. /** Defines the control name */
  78491. name?: string | undefined;
  78492. /** @hidden */
  78493. _host: GUI3DManager;
  78494. private _node;
  78495. private _downCount;
  78496. private _enterCount;
  78497. private _downPointerIds;
  78498. private _isVisible;
  78499. /** Gets or sets the control position in world space */
  78500. get position(): BABYLON.Vector3;
  78501. set position(value: BABYLON.Vector3);
  78502. /** Gets or sets the control scaling in world space */
  78503. get scaling(): BABYLON.Vector3;
  78504. set scaling(value: BABYLON.Vector3);
  78505. /** Callback used to start pointer enter animation */
  78506. pointerEnterAnimation: () => void;
  78507. /** Callback used to start pointer out animation */
  78508. pointerOutAnimation: () => void;
  78509. /** Callback used to start pointer down animation */
  78510. pointerDownAnimation: () => void;
  78511. /** Callback used to start pointer up animation */
  78512. pointerUpAnimation: () => void;
  78513. /**
  78514. * An event triggered when the pointer move over the control
  78515. */
  78516. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  78517. /**
  78518. * An event triggered when the pointer move out of the control
  78519. */
  78520. onPointerOutObservable: BABYLON.Observable<Control3D>;
  78521. /**
  78522. * An event triggered when the pointer taps the control
  78523. */
  78524. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  78525. /**
  78526. * An event triggered when pointer is up
  78527. */
  78528. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  78529. /**
  78530. * An event triggered when a control is clicked on (with a mouse)
  78531. */
  78532. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  78533. /**
  78534. * An event triggered when pointer enters the control
  78535. */
  78536. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  78537. /**
  78538. * Gets or sets the parent container
  78539. */
  78540. parent: BABYLON.Nullable<Container3D>;
  78541. private _behaviors;
  78542. /**
  78543. * Gets the list of attached behaviors
  78544. * @see https://doc.babylonjs.com/features/behaviour
  78545. */
  78546. get behaviors(): BABYLON.Behavior<Control3D>[];
  78547. /**
  78548. * Attach a behavior to the control
  78549. * @see https://doc.babylonjs.com/features/behaviour
  78550. * @param behavior defines the behavior to attach
  78551. * @returns the current control
  78552. */
  78553. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  78554. /**
  78555. * Remove an attached behavior
  78556. * @see https://doc.babylonjs.com/features/behaviour
  78557. * @param behavior defines the behavior to attach
  78558. * @returns the current control
  78559. */
  78560. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  78561. /**
  78562. * Gets an attached behavior by name
  78563. * @param name defines the name of the behavior to look for
  78564. * @see https://doc.babylonjs.com/features/behaviour
  78565. * @returns null if behavior was not found else the requested behavior
  78566. */
  78567. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  78568. /** Gets or sets a boolean indicating if the control is visible */
  78569. get isVisible(): boolean;
  78570. set isVisible(value: boolean);
  78571. /**
  78572. * Creates a new control
  78573. * @param name defines the control name
  78574. */
  78575. constructor(
  78576. /** Defines the control name */
  78577. name?: string | undefined);
  78578. /**
  78579. * Gets a string representing the class name
  78580. */
  78581. get typeName(): string;
  78582. /**
  78583. * Get the current class name of the control.
  78584. * @returns current class name
  78585. */
  78586. getClassName(): string;
  78587. protected _getTypeName(): string;
  78588. /**
  78589. * Gets the transform node used by this control
  78590. */
  78591. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  78592. /**
  78593. * Gets the mesh used to render this control
  78594. */
  78595. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  78596. /**
  78597. * Link the control as child of the given node
  78598. * @param node defines the node to link to. Use null to unlink the control
  78599. * @returns the current control
  78600. */
  78601. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  78602. /** @hidden **/
  78603. _prepareNode(scene: BABYLON.Scene): void;
  78604. /**
  78605. * Node creation.
  78606. * Can be overriden by children
  78607. * @param scene defines the scene where the node must be attached
  78608. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  78609. */
  78610. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  78611. /**
  78612. * Affect a material to the given mesh
  78613. * @param mesh defines the mesh which will represent the control
  78614. */
  78615. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  78616. /** @hidden */
  78617. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  78618. /** @hidden */
  78619. _onPointerEnter(target: Control3D): boolean;
  78620. /** @hidden */
  78621. _onPointerOut(target: Control3D): void;
  78622. /** @hidden */
  78623. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  78624. /** @hidden */
  78625. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78626. /** @hidden */
  78627. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  78628. /** @hidden */
  78629. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  78630. /** @hidden */
  78631. _disposeNode(): void;
  78632. /**
  78633. * Releases all associated resources
  78634. */
  78635. dispose(): void;
  78636. }
  78637. }
  78638. declare module BABYLON.GUI {
  78639. /**
  78640. * Class used as a root to all buttons
  78641. */
  78642. export class AbstractButton3D extends Control3D {
  78643. /**
  78644. * Creates a new button
  78645. * @param name defines the control name
  78646. */
  78647. constructor(name?: string);
  78648. protected _getTypeName(): string;
  78649. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78650. }
  78651. }
  78652. declare module BABYLON.GUI {
  78653. /**
  78654. * Class used to create a button in 3D
  78655. */
  78656. export class Button3D extends AbstractButton3D {
  78657. /** @hidden */
  78658. protected _currentMaterial: BABYLON.Material;
  78659. private _facadeTexture;
  78660. private _content;
  78661. private _contentResolution;
  78662. private _contentScaleRatio;
  78663. /**
  78664. * Gets or sets the texture resolution used to render content (512 by default)
  78665. */
  78666. get contentResolution(): BABYLON.int;
  78667. set contentResolution(value: BABYLON.int);
  78668. /**
  78669. * Gets or sets the texture scale ratio used to render content (2 by default)
  78670. */
  78671. get contentScaleRatio(): number;
  78672. set contentScaleRatio(value: number);
  78673. protected _disposeFacadeTexture(): void;
  78674. protected _resetContent(): void;
  78675. /**
  78676. * Creates a new button
  78677. * @param name defines the control name
  78678. */
  78679. constructor(name?: string);
  78680. /**
  78681. * Gets or sets the GUI 2D content used to display the button's facade
  78682. */
  78683. get content(): Control;
  78684. set content(value: Control);
  78685. /**
  78686. * Apply the facade texture (created from the content property).
  78687. * This function can be overloaded by child classes
  78688. * @param facadeTexture defines the AdvancedDynamicTexture to use
  78689. */
  78690. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  78691. protected _getTypeName(): string;
  78692. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78693. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  78694. /**
  78695. * Releases all associated resources
  78696. */
  78697. dispose(): void;
  78698. }
  78699. }
  78700. declare module BABYLON.GUI {
  78701. /**
  78702. * Abstract class used to create a container panel deployed on the surface of a volume
  78703. */
  78704. export abstract class VolumeBasedPanel extends Container3D {
  78705. private _columns;
  78706. private _rows;
  78707. private _rowThenColum;
  78708. private _orientation;
  78709. protected _cellWidth: number;
  78710. protected _cellHeight: number;
  78711. /**
  78712. * Gets or sets the distance between elements
  78713. */
  78714. margin: number;
  78715. /**
  78716. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  78717. * | Value | Type | Description |
  78718. * | ----- | ----------------------------------- | ----------- |
  78719. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  78720. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  78721. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  78722. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  78723. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  78724. */
  78725. get orientation(): number;
  78726. set orientation(value: number);
  78727. /**
  78728. * Gets or sets the number of columns requested (10 by default).
  78729. * The panel will automatically compute the number of rows based on number of child controls.
  78730. */
  78731. get columns(): BABYLON.int;
  78732. set columns(value: BABYLON.int);
  78733. /**
  78734. * Gets or sets a the number of rows requested.
  78735. * The panel will automatically compute the number of columns based on number of child controls.
  78736. */
  78737. get rows(): BABYLON.int;
  78738. set rows(value: BABYLON.int);
  78739. /**
  78740. * Creates new VolumeBasedPanel
  78741. */
  78742. constructor();
  78743. protected _arrangeChildren(): void;
  78744. /** Child classes must implement this function to provide correct control positioning */
  78745. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78746. /** Child classes can implement this function to provide additional processing */
  78747. protected _finalProcessing(): void;
  78748. }
  78749. }
  78750. declare module BABYLON.GUI {
  78751. /**
  78752. * Class used to create a container panel deployed on the surface of a cylinder
  78753. */
  78754. export class CylinderPanel extends VolumeBasedPanel {
  78755. private _radius;
  78756. /**
  78757. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  78758. */
  78759. get radius(): BABYLON.float;
  78760. set radius(value: BABYLON.float);
  78761. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78762. private _cylindricalMapping;
  78763. }
  78764. }
  78765. declare module BABYLON.GUI {
  78766. /** @hidden */
  78767. export var fluentVertexShader: {
  78768. name: string;
  78769. shader: string;
  78770. };
  78771. }
  78772. declare module BABYLON.GUI {
  78773. /** @hidden */
  78774. export var fluentPixelShader: {
  78775. name: string;
  78776. shader: string;
  78777. };
  78778. }
  78779. declare module BABYLON.GUI {
  78780. /** @hidden */
  78781. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  78782. INNERGLOW: boolean;
  78783. BORDER: boolean;
  78784. HOVERLIGHT: boolean;
  78785. TEXTURE: boolean;
  78786. constructor();
  78787. }
  78788. /**
  78789. * Class used to render controls with fluent desgin
  78790. */
  78791. export class FluentMaterial extends BABYLON.PushMaterial {
  78792. /**
  78793. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  78794. */
  78795. innerGlowColorIntensity: number;
  78796. /**
  78797. * Gets or sets the inner glow color (white by default)
  78798. */
  78799. innerGlowColor: BABYLON.Color3;
  78800. /**
  78801. * Gets or sets alpha value (default is 1.0)
  78802. */
  78803. alpha: number;
  78804. /**
  78805. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  78806. */
  78807. albedoColor: BABYLON.Color3;
  78808. /**
  78809. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  78810. */
  78811. renderBorders: boolean;
  78812. /**
  78813. * Gets or sets border width (default is 0.5)
  78814. */
  78815. borderWidth: number;
  78816. /**
  78817. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  78818. */
  78819. edgeSmoothingValue: number;
  78820. /**
  78821. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  78822. */
  78823. borderMinValue: number;
  78824. /**
  78825. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  78826. */
  78827. renderHoverLight: boolean;
  78828. /**
  78829. * Gets or sets the radius used to render the hover light (default is 1.0)
  78830. */
  78831. hoverRadius: number;
  78832. /**
  78833. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  78834. */
  78835. hoverColor: BABYLON.Color4;
  78836. /**
  78837. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  78838. */
  78839. hoverPosition: BABYLON.Vector3;
  78840. private _albedoTexture;
  78841. /** Gets or sets the texture to use for albedo color */
  78842. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78843. /**
  78844. * Creates a new Fluent material
  78845. * @param name defines the name of the material
  78846. * @param scene defines the hosting scene
  78847. */
  78848. constructor(name: string, scene: BABYLON.Scene);
  78849. needAlphaBlending(): boolean;
  78850. needAlphaTesting(): boolean;
  78851. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78852. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78853. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78854. getActiveTextures(): BABYLON.BaseTexture[];
  78855. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78856. dispose(forceDisposeEffect?: boolean): void;
  78857. clone(name: string): FluentMaterial;
  78858. serialize(): any;
  78859. getClassName(): string;
  78860. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  78861. }
  78862. }
  78863. declare module BABYLON.GUI {
  78864. /**
  78865. * Class used to create a holographic button in 3D
  78866. */
  78867. export class HolographicButton extends Button3D {
  78868. private _backPlate;
  78869. private _textPlate;
  78870. private _frontPlate;
  78871. private _text;
  78872. private _imageUrl;
  78873. private _shareMaterials;
  78874. private _frontMaterial;
  78875. private _backMaterial;
  78876. private _plateMaterial;
  78877. private _pickedPointObserver;
  78878. private _tooltipFade;
  78879. private _tooltipTextBlock;
  78880. private _tooltipTexture;
  78881. private _tooltipMesh;
  78882. private _tooltipHoverObserver;
  78883. private _tooltipOutObserver;
  78884. private _disposeTooltip;
  78885. /**
  78886. * Rendering ground id of all the mesh in the button
  78887. */
  78888. set renderingGroupId(id: number);
  78889. get renderingGroupId(): number;
  78890. /**
  78891. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  78892. */
  78893. set tooltipText(text: BABYLON.Nullable<string>);
  78894. get tooltipText(): BABYLON.Nullable<string>;
  78895. /**
  78896. * Gets or sets text for the button
  78897. */
  78898. get text(): string;
  78899. set text(value: string);
  78900. /**
  78901. * Gets or sets the image url for the button
  78902. */
  78903. get imageUrl(): string;
  78904. set imageUrl(value: string);
  78905. /**
  78906. * Gets the back material used by this button
  78907. */
  78908. get backMaterial(): FluentMaterial;
  78909. /**
  78910. * Gets the front material used by this button
  78911. */
  78912. get frontMaterial(): FluentMaterial;
  78913. /**
  78914. * Gets the plate material used by this button
  78915. */
  78916. get plateMaterial(): BABYLON.StandardMaterial;
  78917. /**
  78918. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  78919. */
  78920. get shareMaterials(): boolean;
  78921. /**
  78922. * Creates a new button
  78923. * @param name defines the control name
  78924. */
  78925. constructor(name?: string, shareMaterials?: boolean);
  78926. protected _getTypeName(): string;
  78927. private _rebuildContent;
  78928. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78929. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  78930. private _createBackMaterial;
  78931. private _createFrontMaterial;
  78932. private _createPlateMaterial;
  78933. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  78934. /**
  78935. * Releases all associated resources
  78936. */
  78937. dispose(): void;
  78938. }
  78939. }
  78940. declare module BABYLON.GUI {
  78941. /**
  78942. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  78943. */
  78944. export class MeshButton3D extends Button3D {
  78945. /** @hidden */
  78946. protected _currentMesh: BABYLON.Mesh;
  78947. /**
  78948. * Creates a new 3D button based on a mesh
  78949. * @param mesh mesh to become a 3D button
  78950. * @param name defines the control name
  78951. */
  78952. constructor(mesh: BABYLON.Mesh, name?: string);
  78953. protected _getTypeName(): string;
  78954. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78955. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  78956. }
  78957. }
  78958. declare module BABYLON.GUI {
  78959. /**
  78960. * Class used to create a container panel deployed on the surface of a plane
  78961. */
  78962. export class PlanePanel extends VolumeBasedPanel {
  78963. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78964. }
  78965. }
  78966. declare module BABYLON.GUI {
  78967. /**
  78968. * Class used to create a container panel where items get randomized planar mapping
  78969. */
  78970. export class ScatterPanel extends VolumeBasedPanel {
  78971. private _iteration;
  78972. /**
  78973. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  78974. */
  78975. get iteration(): BABYLON.float;
  78976. set iteration(value: BABYLON.float);
  78977. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78978. private _scatterMapping;
  78979. protected _finalProcessing(): void;
  78980. }
  78981. }
  78982. declare module BABYLON.GUI {
  78983. /**
  78984. * Class used to create a container panel deployed on the surface of a sphere
  78985. */
  78986. export class SpherePanel extends VolumeBasedPanel {
  78987. private _radius;
  78988. /**
  78989. * Gets or sets the radius of the sphere where to project controls (5 by default)
  78990. */
  78991. get radius(): BABYLON.float;
  78992. set radius(value: BABYLON.float);
  78993. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78994. private _sphericalMapping;
  78995. }
  78996. }
  78997. declare module BABYLON.GUI {
  78998. /**
  78999. * Class used to create a stack panel in 3D on XY plane
  79000. */
  79001. export class StackPanel3D extends Container3D {
  79002. private _isVertical;
  79003. /**
  79004. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  79005. */
  79006. get isVertical(): boolean;
  79007. set isVertical(value: boolean);
  79008. /**
  79009. * Gets or sets the distance between elements
  79010. */
  79011. margin: number;
  79012. /**
  79013. * Creates new StackPanel
  79014. * @param isVertical
  79015. */
  79016. constructor(isVertical?: boolean);
  79017. protected _arrangeChildren(): void;
  79018. }
  79019. }
  79020. declare module BABYLON {
  79021. /**
  79022. * Configuration for glTF validation
  79023. */
  79024. export interface IGLTFValidationConfiguration {
  79025. /**
  79026. * The url of the glTF validator.
  79027. */
  79028. url: string;
  79029. }
  79030. /**
  79031. * glTF validation
  79032. */
  79033. export class GLTFValidation {
  79034. /**
  79035. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  79036. */
  79037. static Configuration: IGLTFValidationConfiguration;
  79038. private static _LoadScriptPromise;
  79039. /**
  79040. * Validate a glTF asset using the glTF-Validator.
  79041. * @param data The JSON of a glTF or the array buffer of a binary glTF
  79042. * @param rootUrl The root url for the glTF
  79043. * @param fileName The file name for the glTF
  79044. * @param getExternalResource The callback to get external resources for the glTF validator
  79045. * @returns A promise that resolves with the glTF validation results once complete
  79046. */
  79047. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  79048. }
  79049. }
  79050. declare module BABYLON {
  79051. /**
  79052. * Mode that determines the coordinate system to use.
  79053. */
  79054. export enum GLTFLoaderCoordinateSystemMode {
  79055. /**
  79056. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  79057. */
  79058. AUTO = 0,
  79059. /**
  79060. * Sets the useRightHandedSystem flag on the scene.
  79061. */
  79062. FORCE_RIGHT_HANDED = 1
  79063. }
  79064. /**
  79065. * Mode that determines what animations will start.
  79066. */
  79067. export enum GLTFLoaderAnimationStartMode {
  79068. /**
  79069. * No animation will start.
  79070. */
  79071. NONE = 0,
  79072. /**
  79073. * The first animation will start.
  79074. */
  79075. FIRST = 1,
  79076. /**
  79077. * All animations will start.
  79078. */
  79079. ALL = 2
  79080. }
  79081. /**
  79082. * Interface that contains the data for the glTF asset.
  79083. */
  79084. export interface IGLTFLoaderData {
  79085. /**
  79086. * The object that represents the glTF JSON.
  79087. */
  79088. json: Object;
  79089. /**
  79090. * The BIN chunk of a binary glTF.
  79091. */
  79092. bin: Nullable<IDataBuffer>;
  79093. }
  79094. /**
  79095. * Interface for extending the loader.
  79096. */
  79097. export interface IGLTFLoaderExtension {
  79098. /**
  79099. * The name of this extension.
  79100. */
  79101. readonly name: string;
  79102. /**
  79103. * Defines whether this extension is enabled.
  79104. */
  79105. enabled: boolean;
  79106. /**
  79107. * Defines the order of this extension.
  79108. * The loader sorts the extensions using these values when loading.
  79109. */
  79110. order?: number;
  79111. }
  79112. /**
  79113. * Loader state.
  79114. */
  79115. export enum GLTFLoaderState {
  79116. /**
  79117. * The asset is loading.
  79118. */
  79119. LOADING = 0,
  79120. /**
  79121. * The asset is ready for rendering.
  79122. */
  79123. READY = 1,
  79124. /**
  79125. * The asset is completely loaded.
  79126. */
  79127. COMPLETE = 2
  79128. }
  79129. /** @hidden */
  79130. export interface IImportMeshAsyncOutput {
  79131. meshes: AbstractMesh[];
  79132. particleSystems: IParticleSystem[];
  79133. skeletons: Skeleton[];
  79134. animationGroups: AnimationGroup[];
  79135. lights: Light[];
  79136. transformNodes: TransformNode[];
  79137. }
  79138. /** @hidden */
  79139. export interface IGLTFLoader extends IDisposable {
  79140. readonly state: Nullable<GLTFLoaderState>;
  79141. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  79142. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  79143. }
  79144. /**
  79145. * File loader for loading glTF files into a scene.
  79146. */
  79147. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  79148. /** @hidden */
  79149. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  79150. /** @hidden */
  79151. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  79152. /**
  79153. * Raised when the asset has been parsed
  79154. */
  79155. onParsedObservable: Observable<IGLTFLoaderData>;
  79156. private _onParsedObserver;
  79157. /**
  79158. * Raised when the asset has been parsed
  79159. */
  79160. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  79161. /**
  79162. * 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.
  79163. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  79164. * Defaults to true.
  79165. * @hidden
  79166. */
  79167. static IncrementalLoading: boolean;
  79168. /**
  79169. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  79170. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  79171. * @hidden
  79172. */
  79173. static HomogeneousCoordinates: boolean;
  79174. /**
  79175. * The coordinate system mode. Defaults to AUTO.
  79176. */
  79177. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  79178. /**
  79179. * The animation start mode. Defaults to FIRST.
  79180. */
  79181. animationStartMode: GLTFLoaderAnimationStartMode;
  79182. /**
  79183. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  79184. */
  79185. compileMaterials: boolean;
  79186. /**
  79187. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  79188. */
  79189. useClipPlane: boolean;
  79190. /**
  79191. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  79192. */
  79193. compileShadowGenerators: boolean;
  79194. /**
  79195. * Defines if the Alpha blended materials are only applied as coverage.
  79196. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  79197. * If true, no extra effects are applied to transparent pixels.
  79198. */
  79199. transparencyAsCoverage: boolean;
  79200. /**
  79201. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  79202. * Enabling will disable offline support and glTF validator.
  79203. * Defaults to false.
  79204. */
  79205. useRangeRequests: boolean;
  79206. /**
  79207. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  79208. */
  79209. createInstances: boolean;
  79210. /**
  79211. * 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.
  79212. */
  79213. alwaysComputeBoundingBox: boolean;
  79214. /**
  79215. * Function called before loading a url referenced by the asset.
  79216. */
  79217. preprocessUrlAsync: (url: string) => Promise<string>;
  79218. /**
  79219. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  79220. */
  79221. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  79222. private _onMeshLoadedObserver;
  79223. /**
  79224. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  79225. */
  79226. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  79227. /**
  79228. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  79229. */
  79230. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  79231. private _onTextureLoadedObserver;
  79232. /**
  79233. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  79234. */
  79235. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  79236. /**
  79237. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  79238. */
  79239. readonly onMaterialLoadedObservable: Observable<Material>;
  79240. private _onMaterialLoadedObserver;
  79241. /**
  79242. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  79243. */
  79244. set onMaterialLoaded(callback: (material: Material) => void);
  79245. /**
  79246. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  79247. */
  79248. readonly onCameraLoadedObservable: Observable<Camera>;
  79249. private _onCameraLoadedObserver;
  79250. /**
  79251. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  79252. */
  79253. set onCameraLoaded(callback: (camera: Camera) => void);
  79254. /**
  79255. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  79256. * For assets with LODs, raised when all of the LODs are complete.
  79257. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  79258. */
  79259. readonly onCompleteObservable: Observable<void>;
  79260. private _onCompleteObserver;
  79261. /**
  79262. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  79263. * For assets with LODs, raised when all of the LODs are complete.
  79264. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  79265. */
  79266. set onComplete(callback: () => void);
  79267. /**
  79268. * Observable raised when an error occurs.
  79269. */
  79270. readonly onErrorObservable: Observable<any>;
  79271. private _onErrorObserver;
  79272. /**
  79273. * Callback raised when an error occurs.
  79274. */
  79275. set onError(callback: (reason: any) => void);
  79276. /**
  79277. * Observable raised after the loader is disposed.
  79278. */
  79279. readonly onDisposeObservable: Observable<void>;
  79280. private _onDisposeObserver;
  79281. /**
  79282. * Callback raised after the loader is disposed.
  79283. */
  79284. set onDispose(callback: () => void);
  79285. /**
  79286. * Observable raised after a loader extension is created.
  79287. * Set additional options for a loader extension in this event.
  79288. */
  79289. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  79290. private _onExtensionLoadedObserver;
  79291. /**
  79292. * Callback raised after a loader extension is created.
  79293. */
  79294. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  79295. /**
  79296. * Defines if the loader logging is enabled.
  79297. */
  79298. get loggingEnabled(): boolean;
  79299. set loggingEnabled(value: boolean);
  79300. /**
  79301. * Defines if the loader should capture performance counters.
  79302. */
  79303. get capturePerformanceCounters(): boolean;
  79304. set capturePerformanceCounters(value: boolean);
  79305. /**
  79306. * Defines if the loader should validate the asset.
  79307. */
  79308. validate: boolean;
  79309. /**
  79310. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  79311. */
  79312. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  79313. private _onValidatedObserver;
  79314. /**
  79315. * Callback raised after a loader extension is created.
  79316. */
  79317. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  79318. private _loader;
  79319. private _progressCallback?;
  79320. private _requests;
  79321. private static magicBase64Encoded;
  79322. /**
  79323. * Name of the loader ("gltf")
  79324. */
  79325. name: string;
  79326. /** @hidden */
  79327. extensions: ISceneLoaderPluginExtensions;
  79328. /**
  79329. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  79330. */
  79331. dispose(): void;
  79332. /** @hidden */
  79333. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  79334. /** @hidden */
  79335. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  79336. /** @hidden */
  79337. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  79338. meshes: AbstractMesh[];
  79339. particleSystems: IParticleSystem[];
  79340. skeletons: Skeleton[];
  79341. animationGroups: AnimationGroup[];
  79342. }>;
  79343. /** @hidden */
  79344. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  79345. /** @hidden */
  79346. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  79347. /** @hidden */
  79348. canDirectLoad(data: string): boolean;
  79349. /** @hidden */
  79350. directLoad(scene: Scene, data: string): Promise<any>;
  79351. /**
  79352. * The callback that allows custom handling of the root url based on the response url.
  79353. * @param rootUrl the original root url
  79354. * @param responseURL the response url if available
  79355. * @returns the new root url
  79356. */
  79357. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  79358. /** @hidden */
  79359. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  79360. /**
  79361. * The loader state or null if the loader is not active.
  79362. */
  79363. get loaderState(): Nullable<GLTFLoaderState>;
  79364. /**
  79365. * Returns a promise that resolves when the asset is completely loaded.
  79366. * @returns a promise that resolves when the asset is completely loaded.
  79367. */
  79368. whenCompleteAsync(): Promise<void>;
  79369. /** @hidden */
  79370. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  79371. /** @hidden */
  79372. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  79373. private _onProgress;
  79374. private _validate;
  79375. private _getLoader;
  79376. private _parseJson;
  79377. private _unpackBinaryAsync;
  79378. private _unpackBinaryV1Async;
  79379. private _unpackBinaryV2Async;
  79380. private static _parseVersion;
  79381. private static _compareVersion;
  79382. private static readonly _logSpaces;
  79383. private _logIndentLevel;
  79384. private _loggingEnabled;
  79385. /** @hidden */
  79386. _log: (message: string) => void;
  79387. /** @hidden */
  79388. _logOpen(message: string): void;
  79389. /** @hidden */
  79390. _logClose(): void;
  79391. private _logEnabled;
  79392. private _logDisabled;
  79393. private _capturePerformanceCounters;
  79394. /** @hidden */
  79395. _startPerformanceCounter: (counterName: string) => void;
  79396. /** @hidden */
  79397. _endPerformanceCounter: (counterName: string) => void;
  79398. private _startPerformanceCounterEnabled;
  79399. private _startPerformanceCounterDisabled;
  79400. private _endPerformanceCounterEnabled;
  79401. private _endPerformanceCounterDisabled;
  79402. }
  79403. }
  79404. declare module BABYLON.GLTF1 {
  79405. /**
  79406. * Enums
  79407. * @hidden
  79408. */
  79409. export enum EComponentType {
  79410. BYTE = 5120,
  79411. UNSIGNED_BYTE = 5121,
  79412. SHORT = 5122,
  79413. UNSIGNED_SHORT = 5123,
  79414. FLOAT = 5126
  79415. }
  79416. /** @hidden */
  79417. export enum EShaderType {
  79418. FRAGMENT = 35632,
  79419. VERTEX = 35633
  79420. }
  79421. /** @hidden */
  79422. export enum EParameterType {
  79423. BYTE = 5120,
  79424. UNSIGNED_BYTE = 5121,
  79425. SHORT = 5122,
  79426. UNSIGNED_SHORT = 5123,
  79427. INT = 5124,
  79428. UNSIGNED_INT = 5125,
  79429. FLOAT = 5126,
  79430. FLOAT_VEC2 = 35664,
  79431. FLOAT_VEC3 = 35665,
  79432. FLOAT_VEC4 = 35666,
  79433. INT_VEC2 = 35667,
  79434. INT_VEC3 = 35668,
  79435. INT_VEC4 = 35669,
  79436. BOOL = 35670,
  79437. BOOL_VEC2 = 35671,
  79438. BOOL_VEC3 = 35672,
  79439. BOOL_VEC4 = 35673,
  79440. FLOAT_MAT2 = 35674,
  79441. FLOAT_MAT3 = 35675,
  79442. FLOAT_MAT4 = 35676,
  79443. SAMPLER_2D = 35678
  79444. }
  79445. /** @hidden */
  79446. export enum ETextureWrapMode {
  79447. CLAMP_TO_EDGE = 33071,
  79448. MIRRORED_REPEAT = 33648,
  79449. REPEAT = 10497
  79450. }
  79451. /** @hidden */
  79452. export enum ETextureFilterType {
  79453. NEAREST = 9728,
  79454. LINEAR = 9728,
  79455. NEAREST_MIPMAP_NEAREST = 9984,
  79456. LINEAR_MIPMAP_NEAREST = 9985,
  79457. NEAREST_MIPMAP_LINEAR = 9986,
  79458. LINEAR_MIPMAP_LINEAR = 9987
  79459. }
  79460. /** @hidden */
  79461. export enum ETextureFormat {
  79462. ALPHA = 6406,
  79463. RGB = 6407,
  79464. RGBA = 6408,
  79465. LUMINANCE = 6409,
  79466. LUMINANCE_ALPHA = 6410
  79467. }
  79468. /** @hidden */
  79469. export enum ECullingType {
  79470. FRONT = 1028,
  79471. BACK = 1029,
  79472. FRONT_AND_BACK = 1032
  79473. }
  79474. /** @hidden */
  79475. export enum EBlendingFunction {
  79476. ZERO = 0,
  79477. ONE = 1,
  79478. SRC_COLOR = 768,
  79479. ONE_MINUS_SRC_COLOR = 769,
  79480. DST_COLOR = 774,
  79481. ONE_MINUS_DST_COLOR = 775,
  79482. SRC_ALPHA = 770,
  79483. ONE_MINUS_SRC_ALPHA = 771,
  79484. DST_ALPHA = 772,
  79485. ONE_MINUS_DST_ALPHA = 773,
  79486. CONSTANT_COLOR = 32769,
  79487. ONE_MINUS_CONSTANT_COLOR = 32770,
  79488. CONSTANT_ALPHA = 32771,
  79489. ONE_MINUS_CONSTANT_ALPHA = 32772,
  79490. SRC_ALPHA_SATURATE = 776
  79491. }
  79492. /** @hidden */
  79493. export interface IGLTFProperty {
  79494. extensions?: {
  79495. [key: string]: any;
  79496. };
  79497. extras?: Object;
  79498. }
  79499. /** @hidden */
  79500. export interface IGLTFChildRootProperty extends IGLTFProperty {
  79501. name?: string;
  79502. }
  79503. /** @hidden */
  79504. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  79505. bufferView: string;
  79506. byteOffset: number;
  79507. byteStride: number;
  79508. count: number;
  79509. type: string;
  79510. componentType: EComponentType;
  79511. max?: number[];
  79512. min?: number[];
  79513. name?: string;
  79514. }
  79515. /** @hidden */
  79516. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  79517. buffer: string;
  79518. byteOffset: number;
  79519. byteLength: number;
  79520. byteStride: number;
  79521. target?: number;
  79522. }
  79523. /** @hidden */
  79524. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  79525. uri: string;
  79526. byteLength?: number;
  79527. type?: string;
  79528. }
  79529. /** @hidden */
  79530. export interface IGLTFShader extends IGLTFChildRootProperty {
  79531. uri: string;
  79532. type: EShaderType;
  79533. }
  79534. /** @hidden */
  79535. export interface IGLTFProgram extends IGLTFChildRootProperty {
  79536. attributes: string[];
  79537. fragmentShader: string;
  79538. vertexShader: string;
  79539. }
  79540. /** @hidden */
  79541. export interface IGLTFTechniqueParameter {
  79542. type: number;
  79543. count?: number;
  79544. semantic?: string;
  79545. node?: string;
  79546. value?: number | boolean | string | Array<any>;
  79547. source?: string;
  79548. babylonValue?: any;
  79549. }
  79550. /** @hidden */
  79551. export interface IGLTFTechniqueCommonProfile {
  79552. lightingModel: string;
  79553. texcoordBindings: Object;
  79554. parameters?: Array<any>;
  79555. }
  79556. /** @hidden */
  79557. export interface IGLTFTechniqueStatesFunctions {
  79558. blendColor?: number[];
  79559. blendEquationSeparate?: number[];
  79560. blendFuncSeparate?: number[];
  79561. colorMask: boolean[];
  79562. cullFace: number[];
  79563. }
  79564. /** @hidden */
  79565. export interface IGLTFTechniqueStates {
  79566. enable: number[];
  79567. functions: IGLTFTechniqueStatesFunctions;
  79568. }
  79569. /** @hidden */
  79570. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  79571. parameters: {
  79572. [key: string]: IGLTFTechniqueParameter;
  79573. };
  79574. program: string;
  79575. attributes: {
  79576. [key: string]: string;
  79577. };
  79578. uniforms: {
  79579. [key: string]: string;
  79580. };
  79581. states: IGLTFTechniqueStates;
  79582. }
  79583. /** @hidden */
  79584. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  79585. technique?: string;
  79586. values: string[];
  79587. }
  79588. /** @hidden */
  79589. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  79590. attributes: {
  79591. [key: string]: string;
  79592. };
  79593. indices: string;
  79594. material: string;
  79595. mode?: number;
  79596. }
  79597. /** @hidden */
  79598. export interface IGLTFMesh extends IGLTFChildRootProperty {
  79599. primitives: IGLTFMeshPrimitive[];
  79600. }
  79601. /** @hidden */
  79602. export interface IGLTFImage extends IGLTFChildRootProperty {
  79603. uri: string;
  79604. }
  79605. /** @hidden */
  79606. export interface IGLTFSampler extends IGLTFChildRootProperty {
  79607. magFilter?: number;
  79608. minFilter?: number;
  79609. wrapS?: number;
  79610. wrapT?: number;
  79611. }
  79612. /** @hidden */
  79613. export interface IGLTFTexture extends IGLTFChildRootProperty {
  79614. sampler: string;
  79615. source: string;
  79616. format?: ETextureFormat;
  79617. internalFormat?: ETextureFormat;
  79618. target?: number;
  79619. type?: number;
  79620. babylonTexture?: Texture;
  79621. }
  79622. /** @hidden */
  79623. export interface IGLTFAmbienLight {
  79624. color?: number[];
  79625. }
  79626. /** @hidden */
  79627. export interface IGLTFDirectionalLight {
  79628. color?: number[];
  79629. }
  79630. /** @hidden */
  79631. export interface IGLTFPointLight {
  79632. color?: number[];
  79633. constantAttenuation?: number;
  79634. linearAttenuation?: number;
  79635. quadraticAttenuation?: number;
  79636. }
  79637. /** @hidden */
  79638. export interface IGLTFSpotLight {
  79639. color?: number[];
  79640. constantAttenuation?: number;
  79641. fallOfAngle?: number;
  79642. fallOffExponent?: number;
  79643. linearAttenuation?: number;
  79644. quadraticAttenuation?: number;
  79645. }
  79646. /** @hidden */
  79647. export interface IGLTFLight extends IGLTFChildRootProperty {
  79648. type: string;
  79649. }
  79650. /** @hidden */
  79651. export interface IGLTFCameraOrthographic {
  79652. xmag: number;
  79653. ymag: number;
  79654. zfar: number;
  79655. znear: number;
  79656. }
  79657. /** @hidden */
  79658. export interface IGLTFCameraPerspective {
  79659. aspectRatio: number;
  79660. yfov: number;
  79661. zfar: number;
  79662. znear: number;
  79663. }
  79664. /** @hidden */
  79665. export interface IGLTFCamera extends IGLTFChildRootProperty {
  79666. type: string;
  79667. }
  79668. /** @hidden */
  79669. export interface IGLTFAnimationChannelTarget {
  79670. id: string;
  79671. path: string;
  79672. }
  79673. /** @hidden */
  79674. export interface IGLTFAnimationChannel {
  79675. sampler: string;
  79676. target: IGLTFAnimationChannelTarget;
  79677. }
  79678. /** @hidden */
  79679. export interface IGLTFAnimationSampler {
  79680. input: string;
  79681. output: string;
  79682. interpolation?: string;
  79683. }
  79684. /** @hidden */
  79685. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  79686. channels?: IGLTFAnimationChannel[];
  79687. parameters?: {
  79688. [key: string]: string;
  79689. };
  79690. samplers?: {
  79691. [key: string]: IGLTFAnimationSampler;
  79692. };
  79693. }
  79694. /** @hidden */
  79695. export interface IGLTFNodeInstanceSkin {
  79696. skeletons: string[];
  79697. skin: string;
  79698. meshes: string[];
  79699. }
  79700. /** @hidden */
  79701. export interface IGLTFSkins extends IGLTFChildRootProperty {
  79702. bindShapeMatrix: number[];
  79703. inverseBindMatrices: string;
  79704. jointNames: string[];
  79705. babylonSkeleton?: Skeleton;
  79706. }
  79707. /** @hidden */
  79708. export interface IGLTFNode extends IGLTFChildRootProperty {
  79709. camera?: string;
  79710. children: string[];
  79711. skin?: string;
  79712. jointName?: string;
  79713. light?: string;
  79714. matrix: number[];
  79715. mesh?: string;
  79716. meshes?: string[];
  79717. rotation?: number[];
  79718. scale?: number[];
  79719. translation?: number[];
  79720. babylonNode?: Node;
  79721. }
  79722. /** @hidden */
  79723. export interface IGLTFScene extends IGLTFChildRootProperty {
  79724. nodes: string[];
  79725. }
  79726. /** @hidden */
  79727. export interface IGLTFRuntime {
  79728. extensions: {
  79729. [key: string]: any;
  79730. };
  79731. accessors: {
  79732. [key: string]: IGLTFAccessor;
  79733. };
  79734. buffers: {
  79735. [key: string]: IGLTFBuffer;
  79736. };
  79737. bufferViews: {
  79738. [key: string]: IGLTFBufferView;
  79739. };
  79740. meshes: {
  79741. [key: string]: IGLTFMesh;
  79742. };
  79743. lights: {
  79744. [key: string]: IGLTFLight;
  79745. };
  79746. cameras: {
  79747. [key: string]: IGLTFCamera;
  79748. };
  79749. nodes: {
  79750. [key: string]: IGLTFNode;
  79751. };
  79752. images: {
  79753. [key: string]: IGLTFImage;
  79754. };
  79755. textures: {
  79756. [key: string]: IGLTFTexture;
  79757. };
  79758. shaders: {
  79759. [key: string]: IGLTFShader;
  79760. };
  79761. programs: {
  79762. [key: string]: IGLTFProgram;
  79763. };
  79764. samplers: {
  79765. [key: string]: IGLTFSampler;
  79766. };
  79767. techniques: {
  79768. [key: string]: IGLTFTechnique;
  79769. };
  79770. materials: {
  79771. [key: string]: IGLTFMaterial;
  79772. };
  79773. animations: {
  79774. [key: string]: IGLTFAnimation;
  79775. };
  79776. skins: {
  79777. [key: string]: IGLTFSkins;
  79778. };
  79779. currentScene?: Object;
  79780. scenes: {
  79781. [key: string]: IGLTFScene;
  79782. };
  79783. extensionsUsed: string[];
  79784. extensionsRequired?: string[];
  79785. buffersCount: number;
  79786. shaderscount: number;
  79787. scene: Scene;
  79788. rootUrl: string;
  79789. loadedBufferCount: number;
  79790. loadedBufferViews: {
  79791. [name: string]: ArrayBufferView;
  79792. };
  79793. loadedShaderCount: number;
  79794. importOnlyMeshes: boolean;
  79795. importMeshesNames?: string[];
  79796. dummyNodes: Node[];
  79797. forAssetContainer: boolean;
  79798. }
  79799. /** @hidden */
  79800. export interface INodeToRoot {
  79801. bone: Bone;
  79802. node: IGLTFNode;
  79803. id: string;
  79804. }
  79805. /** @hidden */
  79806. export interface IJointNode {
  79807. node: IGLTFNode;
  79808. id: string;
  79809. }
  79810. }
  79811. declare module BABYLON.GLTF1 {
  79812. /**
  79813. * Utils functions for GLTF
  79814. * @hidden
  79815. */
  79816. export class GLTFUtils {
  79817. /**
  79818. * Sets the given "parameter" matrix
  79819. * @param scene: the Scene object
  79820. * @param source: the source node where to pick the matrix
  79821. * @param parameter: the GLTF technique parameter
  79822. * @param uniformName: the name of the shader's uniform
  79823. * @param shaderMaterial: the shader material
  79824. */
  79825. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  79826. /**
  79827. * Sets the given "parameter" matrix
  79828. * @param shaderMaterial: the shader material
  79829. * @param uniform: the name of the shader's uniform
  79830. * @param value: the value of the uniform
  79831. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  79832. */
  79833. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  79834. /**
  79835. * Returns the wrap mode of the texture
  79836. * @param mode: the mode value
  79837. */
  79838. static GetWrapMode(mode: number): number;
  79839. /**
  79840. * Returns the byte stride giving an accessor
  79841. * @param accessor: the GLTF accessor objet
  79842. */
  79843. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  79844. /**
  79845. * Returns the texture filter mode giving a mode value
  79846. * @param mode: the filter mode value
  79847. */
  79848. static GetTextureFilterMode(mode: number): ETextureFilterType;
  79849. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  79850. /**
  79851. * Returns a buffer from its accessor
  79852. * @param gltfRuntime: the GLTF runtime
  79853. * @param accessor: the GLTF accessor
  79854. */
  79855. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  79856. /**
  79857. * Decodes a buffer view into a string
  79858. * @param view: the buffer view
  79859. */
  79860. static DecodeBufferToText(view: ArrayBufferView): string;
  79861. /**
  79862. * Returns the default material of gltf. Related to
  79863. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  79864. * @param scene: the Babylon.js scene
  79865. */
  79866. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  79867. private static _DefaultMaterial;
  79868. }
  79869. }
  79870. declare module BABYLON.GLTF1 {
  79871. /**
  79872. * Implementation of the base glTF spec
  79873. * @hidden
  79874. */
  79875. export class GLTFLoaderBase {
  79876. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  79877. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  79878. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  79879. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  79880. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  79881. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  79882. }
  79883. /**
  79884. * glTF V1 Loader
  79885. * @hidden
  79886. */
  79887. export class GLTFLoader implements IGLTFLoader {
  79888. static Extensions: {
  79889. [name: string]: GLTFLoaderExtension;
  79890. };
  79891. static RegisterExtension(extension: GLTFLoaderExtension): void;
  79892. state: Nullable<GLTFLoaderState>;
  79893. dispose(): void;
  79894. private _importMeshAsync;
  79895. /**
  79896. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  79897. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  79898. * @param scene the scene the meshes should be added to
  79899. * @param forAssetContainer defines if the entities must be stored in the scene
  79900. * @param data gltf data containing information of the meshes in a loaded file
  79901. * @param rootUrl root url to load from
  79902. * @param onProgress event that fires when loading progress has occured
  79903. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  79904. */
  79905. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  79906. private _loadAsync;
  79907. /**
  79908. * Imports all objects from a loaded gltf file and adds them to the scene
  79909. * @param scene the scene the objects should be added to
  79910. * @param data gltf data containing information of the meshes in a loaded file
  79911. * @param rootUrl root url to load from
  79912. * @param onProgress event that fires when loading progress has occured
  79913. * @returns a promise which completes when objects have been loaded to the scene
  79914. */
  79915. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  79916. private _loadShadersAsync;
  79917. private _loadBuffersAsync;
  79918. private _createNodes;
  79919. }
  79920. /** @hidden */
  79921. export abstract class GLTFLoaderExtension {
  79922. private _name;
  79923. constructor(name: string);
  79924. get name(): string;
  79925. /**
  79926. * Defines an override for loading the runtime
  79927. * Return true to stop further extensions from loading the runtime
  79928. */
  79929. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  79930. /**
  79931. * Defines an onverride for creating gltf runtime
  79932. * Return true to stop further extensions from creating the runtime
  79933. */
  79934. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  79935. /**
  79936. * Defines an override for loading buffers
  79937. * Return true to stop further extensions from loading this buffer
  79938. */
  79939. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  79940. /**
  79941. * Defines an override for loading texture buffers
  79942. * Return true to stop further extensions from loading this texture data
  79943. */
  79944. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79945. /**
  79946. * Defines an override for creating textures
  79947. * Return true to stop further extensions from loading this texture
  79948. */
  79949. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  79950. /**
  79951. * Defines an override for loading shader strings
  79952. * Return true to stop further extensions from loading this shader data
  79953. */
  79954. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  79955. /**
  79956. * Defines an override for loading materials
  79957. * Return true to stop further extensions from loading this material
  79958. */
  79959. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  79960. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  79961. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  79962. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  79963. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  79964. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  79965. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  79966. private static LoadTextureBufferAsync;
  79967. private static CreateTextureAsync;
  79968. private static ApplyExtensions;
  79969. }
  79970. }
  79971. declare module BABYLON.GLTF1 {
  79972. /** @hidden */
  79973. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  79974. private _bin;
  79975. constructor();
  79976. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  79977. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79978. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79979. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  79980. }
  79981. }
  79982. declare module BABYLON.GLTF1 {
  79983. /** @hidden */
  79984. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  79985. constructor();
  79986. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  79987. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  79988. private _loadTexture;
  79989. }
  79990. }
  79991. declare module BABYLON.GLTF2.Loader {
  79992. /**
  79993. * Loader interface with an index field.
  79994. */
  79995. export interface IArrayItem {
  79996. /**
  79997. * The index of this item in the array.
  79998. */
  79999. index: number;
  80000. }
  80001. /**
  80002. * Loader interface with additional members.
  80003. */
  80004. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  80005. /** @hidden */
  80006. _data?: Promise<ArrayBufferView>;
  80007. /** @hidden */
  80008. _babylonVertexBuffer?: Promise<VertexBuffer>;
  80009. }
  80010. /**
  80011. * Loader interface with additional members.
  80012. */
  80013. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  80014. }
  80015. /** @hidden */
  80016. export interface _IAnimationSamplerData {
  80017. input: Float32Array;
  80018. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  80019. output: Float32Array;
  80020. }
  80021. /**
  80022. * Loader interface with additional members.
  80023. */
  80024. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  80025. /** @hidden */
  80026. _data?: Promise<_IAnimationSamplerData>;
  80027. }
  80028. /**
  80029. * Loader interface with additional members.
  80030. */
  80031. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  80032. channels: IAnimationChannel[];
  80033. samplers: IAnimationSampler[];
  80034. /** @hidden */
  80035. _babylonAnimationGroup?: AnimationGroup;
  80036. }
  80037. /**
  80038. * Loader interface with additional members.
  80039. */
  80040. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  80041. /** @hidden */
  80042. _data?: Promise<ArrayBufferView>;
  80043. }
  80044. /**
  80045. * Loader interface with additional members.
  80046. */
  80047. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  80048. /** @hidden */
  80049. _data?: Promise<ArrayBufferView>;
  80050. /** @hidden */
  80051. _babylonBuffer?: Promise<Buffer>;
  80052. }
  80053. /**
  80054. * Loader interface with additional members.
  80055. */
  80056. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  80057. }
  80058. /**
  80059. * Loader interface with additional members.
  80060. */
  80061. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  80062. /** @hidden */
  80063. _data?: Promise<ArrayBufferView>;
  80064. }
  80065. /**
  80066. * Loader interface with additional members.
  80067. */
  80068. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  80069. }
  80070. /**
  80071. * Loader interface with additional members.
  80072. */
  80073. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  80074. }
  80075. /**
  80076. * Loader interface with additional members.
  80077. */
  80078. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  80079. baseColorTexture?: ITextureInfo;
  80080. metallicRoughnessTexture?: ITextureInfo;
  80081. }
  80082. /**
  80083. * Loader interface with additional members.
  80084. */
  80085. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  80086. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  80087. normalTexture?: IMaterialNormalTextureInfo;
  80088. occlusionTexture?: IMaterialOcclusionTextureInfo;
  80089. emissiveTexture?: ITextureInfo;
  80090. /** @hidden */
  80091. _data?: {
  80092. [babylonDrawMode: number]: {
  80093. babylonMaterial: Material;
  80094. babylonMeshes: AbstractMesh[];
  80095. promise: Promise<void>;
  80096. };
  80097. };
  80098. }
  80099. /**
  80100. * Loader interface with additional members.
  80101. */
  80102. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  80103. primitives: IMeshPrimitive[];
  80104. }
  80105. /**
  80106. * Loader interface with additional members.
  80107. */
  80108. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  80109. /** @hidden */
  80110. _instanceData?: {
  80111. babylonSourceMesh: Mesh;
  80112. promise: Promise<any>;
  80113. };
  80114. }
  80115. /**
  80116. * Loader interface with additional members.
  80117. */
  80118. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  80119. /**
  80120. * The parent glTF node.
  80121. */
  80122. parent?: INode;
  80123. /** @hidden */
  80124. _babylonTransformNode?: TransformNode;
  80125. /** @hidden */
  80126. _primitiveBabylonMeshes?: AbstractMesh[];
  80127. /** @hidden */
  80128. _babylonBones?: Bone[];
  80129. /** @hidden */
  80130. _numMorphTargets?: number;
  80131. }
  80132. /** @hidden */
  80133. export interface _ISamplerData {
  80134. noMipMaps: boolean;
  80135. samplingMode: number;
  80136. wrapU: number;
  80137. wrapV: number;
  80138. }
  80139. /**
  80140. * Loader interface with additional members.
  80141. */
  80142. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  80143. /** @hidden */
  80144. _data?: _ISamplerData;
  80145. }
  80146. /**
  80147. * Loader interface with additional members.
  80148. */
  80149. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  80150. }
  80151. /**
  80152. * Loader interface with additional members.
  80153. */
  80154. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  80155. /** @hidden */
  80156. _data?: {
  80157. babylonSkeleton: Skeleton;
  80158. promise: Promise<void>;
  80159. };
  80160. }
  80161. /**
  80162. * Loader interface with additional members.
  80163. */
  80164. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  80165. }
  80166. /**
  80167. * Loader interface with additional members.
  80168. */
  80169. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  80170. }
  80171. /**
  80172. * Loader interface with additional members.
  80173. */
  80174. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  80175. accessors?: IAccessor[];
  80176. animations?: IAnimation[];
  80177. buffers?: IBuffer[];
  80178. bufferViews?: IBufferView[];
  80179. cameras?: ICamera[];
  80180. images?: IImage[];
  80181. materials?: IMaterial[];
  80182. meshes?: IMesh[];
  80183. nodes?: INode[];
  80184. samplers?: ISampler[];
  80185. scenes?: IScene[];
  80186. skins?: ISkin[];
  80187. textures?: ITexture[];
  80188. }
  80189. }
  80190. declare module BABYLON.GLTF2 {
  80191. /**
  80192. * Interface for a glTF loader extension.
  80193. */
  80194. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  80195. /**
  80196. * Called after the loader state changes to LOADING.
  80197. */
  80198. onLoading?(): void;
  80199. /**
  80200. * Called after the loader state changes to READY.
  80201. */
  80202. onReady?(): void;
  80203. /**
  80204. * Define this method to modify the default behavior when loading scenes.
  80205. * @param context The context when loading the asset
  80206. * @param scene The glTF scene property
  80207. * @returns A promise that resolves when the load is complete or null if not handled
  80208. */
  80209. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  80210. /**
  80211. * Define this method to modify the default behavior when loading nodes.
  80212. * @param context The context when loading the asset
  80213. * @param node The glTF node property
  80214. * @param assign A function called synchronously after parsing the glTF properties
  80215. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  80216. */
  80217. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80218. /**
  80219. * Define this method to modify the default behavior when loading cameras.
  80220. * @param context The context when loading the asset
  80221. * @param camera The glTF camera property
  80222. * @param assign A function called synchronously after parsing the glTF properties
  80223. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  80224. */
  80225. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  80226. /**
  80227. * @hidden
  80228. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  80229. * @param context The context when loading the asset
  80230. * @param primitive The glTF mesh primitive property
  80231. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  80232. */
  80233. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  80234. /**
  80235. * @hidden
  80236. * Define this method to modify the default behavior when loading data for mesh primitives.
  80237. * @param context The context when loading the asset
  80238. * @param name The mesh name when loading the asset
  80239. * @param node The glTF node when loading the asset
  80240. * @param mesh The glTF mesh when loading the asset
  80241. * @param primitive The glTF mesh primitive property
  80242. * @param assign A function called synchronously after parsing the glTF properties
  80243. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  80244. */
  80245. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  80246. /**
  80247. * @hidden
  80248. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  80249. * @param context The context when loading the asset
  80250. * @param material The glTF material property
  80251. * @param assign A function called synchronously after parsing the glTF properties
  80252. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  80253. */
  80254. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  80255. /**
  80256. * Define this method to modify the default behavior when creating materials.
  80257. * @param context The context when loading the asset
  80258. * @param material The glTF material property
  80259. * @param babylonDrawMode The draw mode for the Babylon material
  80260. * @returns The Babylon material or null if not handled
  80261. */
  80262. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  80263. /**
  80264. * Define this method to modify the default behavior when loading material properties.
  80265. * @param context The context when loading the asset
  80266. * @param material The glTF material property
  80267. * @param babylonMaterial The Babylon material
  80268. * @returns A promise that resolves when the load is complete or null if not handled
  80269. */
  80270. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80271. /**
  80272. * Define this method to modify the default behavior when loading texture infos.
  80273. * @param context The context when loading the asset
  80274. * @param textureInfo The glTF texture info property
  80275. * @param assign A function called synchronously after parsing the glTF properties
  80276. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  80277. */
  80278. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80279. /**
  80280. * @hidden
  80281. * Define this method to modify the default behavior when loading textures.
  80282. * @param context The context when loading the asset
  80283. * @param texture The glTF texture property
  80284. * @param assign A function called synchronously after parsing the glTF properties
  80285. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  80286. */
  80287. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80288. /**
  80289. * Define this method to modify the default behavior when loading animations.
  80290. * @param context The context when loading the asset
  80291. * @param animation The glTF animation property
  80292. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  80293. */
  80294. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  80295. /**
  80296. * @hidden
  80297. * Define this method to modify the default behavior when loading skins.
  80298. * @param context The context when loading the asset
  80299. * @param node The glTF node property
  80300. * @param skin The glTF skin property
  80301. * @returns A promise that resolves when the load is complete or null if not handled
  80302. */
  80303. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  80304. /**
  80305. * @hidden
  80306. * Define this method to modify the default behavior when loading uris.
  80307. * @param context The context when loading the asset
  80308. * @param property The glTF property associated with the uri
  80309. * @param uri The uri to load
  80310. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  80311. */
  80312. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  80313. /**
  80314. * Define this method to modify the default behavior when loading buffer views.
  80315. * @param context The context when loading the asset
  80316. * @param bufferView The glTF buffer view property
  80317. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  80318. */
  80319. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  80320. /**
  80321. * Define this method to modify the default behavior when loading buffers.
  80322. * @param context The context when loading the asset
  80323. * @param buffer The glTF buffer property
  80324. * @param byteOffset The byte offset to load
  80325. * @param byteLength The byte length to load
  80326. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  80327. */
  80328. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  80329. }
  80330. }
  80331. declare module BABYLON.GLTF2 {
  80332. /**
  80333. * Helper class for working with arrays when loading the glTF asset
  80334. */
  80335. export class ArrayItem {
  80336. /**
  80337. * Gets an item from the given array.
  80338. * @param context The context when loading the asset
  80339. * @param array The array to get the item from
  80340. * @param index The index to the array
  80341. * @returns The array item
  80342. */
  80343. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  80344. /**
  80345. * Assign an `index` field to each item of the given array.
  80346. * @param array The array of items
  80347. */
  80348. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  80349. }
  80350. /**
  80351. * The glTF 2.0 loader
  80352. */
  80353. export class GLTFLoader implements IGLTFLoader {
  80354. /** @hidden */
  80355. _completePromises: Promise<any>[];
  80356. /** @hidden */
  80357. _forAssetContainer: boolean;
  80358. /** Storage */
  80359. _babylonLights: Light[];
  80360. /** @hidden */
  80361. _disableInstancedMesh: number;
  80362. private _disposed;
  80363. private _parent;
  80364. private _state;
  80365. private _extensions;
  80366. private _rootUrl;
  80367. private _fileName;
  80368. private _uniqueRootUrl;
  80369. private _gltf;
  80370. private _bin;
  80371. private _babylonScene;
  80372. private _rootBabylonMesh;
  80373. private _defaultBabylonMaterialData;
  80374. private static _RegisteredExtensions;
  80375. /**
  80376. * The default glTF sampler.
  80377. */
  80378. static readonly DefaultSampler: ISampler;
  80379. /**
  80380. * Registers a loader extension.
  80381. * @param name The name of the loader extension.
  80382. * @param factory The factory function that creates the loader extension.
  80383. */
  80384. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  80385. /**
  80386. * Unregisters a loader extension.
  80387. * @param name The name of the loader extension.
  80388. * @returns A boolean indicating whether the extension has been unregistered
  80389. */
  80390. static UnregisterExtension(name: string): boolean;
  80391. /**
  80392. * The loader state.
  80393. */
  80394. get state(): Nullable<GLTFLoaderState>;
  80395. /**
  80396. * The object that represents the glTF JSON.
  80397. */
  80398. get gltf(): IGLTF;
  80399. /**
  80400. * The BIN chunk of a binary glTF.
  80401. */
  80402. get bin(): Nullable<IDataBuffer>;
  80403. /**
  80404. * The parent file loader.
  80405. */
  80406. get parent(): GLTFFileLoader;
  80407. /**
  80408. * The Babylon scene when loading the asset.
  80409. */
  80410. get babylonScene(): Scene;
  80411. /**
  80412. * The root Babylon mesh when loading the asset.
  80413. */
  80414. get rootBabylonMesh(): Mesh;
  80415. /** @hidden */
  80416. constructor(parent: GLTFFileLoader);
  80417. /** @hidden */
  80418. dispose(): void;
  80419. /** @hidden */
  80420. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  80421. /** @hidden */
  80422. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  80423. private _loadAsync;
  80424. private _loadData;
  80425. private _setupData;
  80426. private _loadExtensions;
  80427. private _checkExtensions;
  80428. private _setState;
  80429. private _createRootNode;
  80430. /**
  80431. * Loads a glTF scene.
  80432. * @param context The context when loading the asset
  80433. * @param scene The glTF scene property
  80434. * @returns A promise that resolves when the load is complete
  80435. */
  80436. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  80437. private _forEachPrimitive;
  80438. private _getMeshes;
  80439. private _getTransformNodes;
  80440. private _getSkeletons;
  80441. private _getAnimationGroups;
  80442. private _startAnimations;
  80443. /**
  80444. * Loads a glTF node.
  80445. * @param context The context when loading the asset
  80446. * @param node The glTF node property
  80447. * @param assign A function called synchronously after parsing the glTF properties
  80448. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  80449. */
  80450. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  80451. private _loadMeshAsync;
  80452. /**
  80453. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  80454. * @param context The context when loading the asset
  80455. * @param name The mesh name when loading the asset
  80456. * @param node The glTF node when loading the asset
  80457. * @param mesh The glTF mesh when loading the asset
  80458. * @param primitive The glTF mesh primitive property
  80459. * @param assign A function called synchronously after parsing the glTF properties
  80460. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  80461. */
  80462. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  80463. private _loadVertexDataAsync;
  80464. private _createMorphTargets;
  80465. private _loadMorphTargetsAsync;
  80466. private _loadMorphTargetVertexDataAsync;
  80467. private static _LoadTransform;
  80468. private _loadSkinAsync;
  80469. private _loadBones;
  80470. private _loadBone;
  80471. private _loadSkinInverseBindMatricesDataAsync;
  80472. private _updateBoneMatrices;
  80473. private _getNodeMatrix;
  80474. /**
  80475. * Loads a glTF camera.
  80476. * @param context The context when loading the asset
  80477. * @param camera The glTF camera property
  80478. * @param assign A function called synchronously after parsing the glTF properties
  80479. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  80480. */
  80481. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  80482. private _loadAnimationsAsync;
  80483. /**
  80484. * Loads a glTF animation.
  80485. * @param context The context when loading the asset
  80486. * @param animation The glTF animation property
  80487. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  80488. */
  80489. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  80490. /**
  80491. * @hidden Loads a glTF animation channel.
  80492. * @param context The context when loading the asset
  80493. * @param animationContext The context of the animation when loading the asset
  80494. * @param animation The glTF animation property
  80495. * @param channel The glTF animation channel property
  80496. * @param babylonAnimationGroup The babylon animation group property
  80497. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  80498. * @returns A void promise when the channel load is complete
  80499. */
  80500. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  80501. private _loadAnimationSamplerAsync;
  80502. private _loadBufferAsync;
  80503. /**
  80504. * Loads a glTF buffer view.
  80505. * @param context The context when loading the asset
  80506. * @param bufferView The glTF buffer view property
  80507. * @returns A promise that resolves with the loaded data when the load is complete
  80508. */
  80509. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  80510. private _loadAccessorAsync;
  80511. /** @hidden */
  80512. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  80513. private _loadIndicesAccessorAsync;
  80514. private _loadVertexBufferViewAsync;
  80515. private _loadVertexAccessorAsync;
  80516. private _loadMaterialMetallicRoughnessPropertiesAsync;
  80517. /** @hidden */
  80518. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  80519. private _createDefaultMaterial;
  80520. /**
  80521. * Creates a Babylon material from a glTF material.
  80522. * @param context The context when loading the asset
  80523. * @param material The glTF material property
  80524. * @param babylonDrawMode The draw mode for the Babylon material
  80525. * @returns The Babylon material
  80526. */
  80527. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  80528. /**
  80529. * Loads properties from a glTF material into a Babylon material.
  80530. * @param context The context when loading the asset
  80531. * @param material The glTF material property
  80532. * @param babylonMaterial The Babylon material
  80533. * @returns A promise that resolves when the load is complete
  80534. */
  80535. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  80536. /**
  80537. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  80538. * @param context The context when loading the asset
  80539. * @param material The glTF material property
  80540. * @param babylonMaterial The Babylon material
  80541. * @returns A promise that resolves when the load is complete
  80542. */
  80543. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  80544. /**
  80545. * Loads the alpha properties from a glTF material into a Babylon material.
  80546. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  80547. * @param context The context when loading the asset
  80548. * @param material The glTF material property
  80549. * @param babylonMaterial The Babylon material
  80550. */
  80551. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  80552. /**
  80553. * Loads a glTF texture info.
  80554. * @param context The context when loading the asset
  80555. * @param textureInfo The glTF texture info property
  80556. * @param assign A function called synchronously after parsing the glTF properties
  80557. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  80558. */
  80559. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  80560. /** @hidden */
  80561. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  80562. /** @hidden */
  80563. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  80564. private _loadSampler;
  80565. /**
  80566. * Loads a glTF image.
  80567. * @param context The context when loading the asset
  80568. * @param image The glTF image property
  80569. * @returns A promise that resolves with the loaded data when the load is complete
  80570. */
  80571. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  80572. /**
  80573. * Loads a glTF uri.
  80574. * @param context The context when loading the asset
  80575. * @param property The glTF property associated with the uri
  80576. * @param uri The base64 or relative uri
  80577. * @returns A promise that resolves with the loaded data when the load is complete
  80578. */
  80579. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  80580. /**
  80581. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  80582. * @param babylonObject the Babylon object with metadata
  80583. * @param pointer the JSON pointer
  80584. */
  80585. static AddPointerMetadata(babylonObject: {
  80586. metadata: any;
  80587. }, pointer: string): void;
  80588. private static _GetTextureWrapMode;
  80589. private static _GetTextureSamplingMode;
  80590. private static _GetTypedArrayConstructor;
  80591. private static _GetTypedArray;
  80592. private static _GetNumComponents;
  80593. private static _ValidateUri;
  80594. /** @hidden */
  80595. static _GetDrawMode(context: string, mode: number | undefined): number;
  80596. private _compileMaterialsAsync;
  80597. private _compileShadowGeneratorsAsync;
  80598. private _forEachExtensions;
  80599. private _applyExtensions;
  80600. private _extensionsOnLoading;
  80601. private _extensionsOnReady;
  80602. private _extensionsLoadSceneAsync;
  80603. private _extensionsLoadNodeAsync;
  80604. private _extensionsLoadCameraAsync;
  80605. private _extensionsLoadVertexDataAsync;
  80606. private _extensionsLoadMeshPrimitiveAsync;
  80607. private _extensionsLoadMaterialAsync;
  80608. private _extensionsCreateMaterial;
  80609. private _extensionsLoadMaterialPropertiesAsync;
  80610. private _extensionsLoadTextureInfoAsync;
  80611. private _extensionsLoadTextureAsync;
  80612. private _extensionsLoadAnimationAsync;
  80613. private _extensionsLoadSkinAsync;
  80614. private _extensionsLoadUriAsync;
  80615. private _extensionsLoadBufferViewAsync;
  80616. private _extensionsLoadBufferAsync;
  80617. /**
  80618. * Helper method called by a loader extension to load an glTF extension.
  80619. * @param context The context when loading the asset
  80620. * @param property The glTF property to load the extension from
  80621. * @param extensionName The name of the extension to load
  80622. * @param actionAsync The action to run
  80623. * @returns The promise returned by actionAsync or null if the extension does not exist
  80624. */
  80625. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  80626. /**
  80627. * Helper method called by a loader extension to load a glTF extra.
  80628. * @param context The context when loading the asset
  80629. * @param property The glTF property to load the extra from
  80630. * @param extensionName The name of the extension to load
  80631. * @param actionAsync The action to run
  80632. * @returns The promise returned by actionAsync or null if the extra does not exist
  80633. */
  80634. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  80635. /**
  80636. * Checks for presence of an extension.
  80637. * @param name The name of the extension to check
  80638. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  80639. */
  80640. isExtensionUsed(name: string): boolean;
  80641. /**
  80642. * Increments the indentation level and logs a message.
  80643. * @param message The message to log
  80644. */
  80645. logOpen(message: string): void;
  80646. /**
  80647. * Decrements the indentation level.
  80648. */
  80649. logClose(): void;
  80650. /**
  80651. * Logs a message
  80652. * @param message The message to log
  80653. */
  80654. log(message: string): void;
  80655. /**
  80656. * Starts a performance counter.
  80657. * @param counterName The name of the performance counter
  80658. */
  80659. startPerformanceCounter(counterName: string): void;
  80660. /**
  80661. * Ends a performance counter.
  80662. * @param counterName The name of the performance counter
  80663. */
  80664. endPerformanceCounter(counterName: string): void;
  80665. }
  80666. }
  80667. declare module BABYLON.GLTF2.Loader.Extensions {
  80668. /** @hidden */
  80669. interface IEXTLightsImageBased_LightImageBased {
  80670. _babylonTexture?: BaseTexture;
  80671. _loaded?: Promise<void>;
  80672. }
  80673. /**
  80674. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  80675. */
  80676. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  80677. /**
  80678. * The name of this extension.
  80679. */
  80680. readonly name: string;
  80681. /**
  80682. * Defines whether this extension is enabled.
  80683. */
  80684. enabled: boolean;
  80685. private _loader;
  80686. private _lights?;
  80687. /** @hidden */
  80688. constructor(loader: GLTFLoader);
  80689. /** @hidden */
  80690. dispose(): void;
  80691. /** @hidden */
  80692. onLoading(): void;
  80693. /** @hidden */
  80694. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  80695. private _loadLightAsync;
  80696. }
  80697. }
  80698. declare module BABYLON.GLTF2.Loader.Extensions {
  80699. /**
  80700. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  80701. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  80702. * !!! Experimental Extension Subject to Changes !!!
  80703. */
  80704. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  80705. /**
  80706. * The name of this extension.
  80707. */
  80708. readonly name: string;
  80709. /**
  80710. * Defines whether this extension is enabled.
  80711. */
  80712. enabled: boolean;
  80713. private _loader;
  80714. /** @hidden */
  80715. constructor(loader: GLTFLoader);
  80716. /** @hidden */
  80717. dispose(): void;
  80718. /** @hidden */
  80719. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80720. }
  80721. }
  80722. declare module BABYLON.GLTF2.Loader.Extensions {
  80723. /**
  80724. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  80725. */
  80726. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  80727. /**
  80728. * The name of this extension.
  80729. */
  80730. readonly name: string;
  80731. /**
  80732. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  80733. */
  80734. dracoCompression?: DracoCompression;
  80735. /**
  80736. * Defines whether this extension is enabled.
  80737. */
  80738. enabled: boolean;
  80739. private _loader;
  80740. /** @hidden */
  80741. constructor(loader: GLTFLoader);
  80742. /** @hidden */
  80743. dispose(): void;
  80744. /** @hidden */
  80745. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  80746. }
  80747. }
  80748. declare module BABYLON.GLTF2.Loader.Extensions {
  80749. /**
  80750. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  80751. */
  80752. export class KHR_lights implements IGLTFLoaderExtension {
  80753. /**
  80754. * The name of this extension.
  80755. */
  80756. readonly name: string;
  80757. /**
  80758. * Defines whether this extension is enabled.
  80759. */
  80760. enabled: boolean;
  80761. private _loader;
  80762. private _lights?;
  80763. /** @hidden */
  80764. constructor(loader: GLTFLoader);
  80765. /** @hidden */
  80766. dispose(): void;
  80767. /** @hidden */
  80768. onLoading(): void;
  80769. /** @hidden */
  80770. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80771. }
  80772. }
  80773. declare module BABYLON.GLTF2.Loader.Extensions {
  80774. /**
  80775. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  80776. */
  80777. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  80778. /**
  80779. * The name of this extension.
  80780. */
  80781. readonly name: string;
  80782. /**
  80783. * Defines whether this extension is enabled.
  80784. */
  80785. enabled: boolean;
  80786. /**
  80787. * Defines a number that determines the order the extensions are applied.
  80788. */
  80789. order: number;
  80790. private _loader;
  80791. /** @hidden */
  80792. constructor(loader: GLTFLoader);
  80793. /** @hidden */
  80794. dispose(): void;
  80795. /** @hidden */
  80796. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80797. private _loadSpecularGlossinessPropertiesAsync;
  80798. }
  80799. }
  80800. declare module BABYLON.GLTF2.Loader.Extensions {
  80801. /**
  80802. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  80803. */
  80804. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  80805. /**
  80806. * The name of this extension.
  80807. */
  80808. readonly name: string;
  80809. /**
  80810. * Defines whether this extension is enabled.
  80811. */
  80812. enabled: boolean;
  80813. /**
  80814. * Defines a number that determines the order the extensions are applied.
  80815. */
  80816. order: number;
  80817. private _loader;
  80818. /** @hidden */
  80819. constructor(loader: GLTFLoader);
  80820. /** @hidden */
  80821. dispose(): void;
  80822. /** @hidden */
  80823. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80824. private _loadUnlitPropertiesAsync;
  80825. }
  80826. }
  80827. declare module BABYLON.GLTF2.Loader.Extensions {
  80828. /**
  80829. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  80830. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  80831. * !!! Experimental Extension Subject to Changes !!!
  80832. */
  80833. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  80834. /**
  80835. * The name of this extension.
  80836. */
  80837. readonly name: string;
  80838. /**
  80839. * Defines whether this extension is enabled.
  80840. */
  80841. enabled: boolean;
  80842. /**
  80843. * Defines a number that determines the order the extensions are applied.
  80844. */
  80845. order: number;
  80846. private _loader;
  80847. /** @hidden */
  80848. constructor(loader: GLTFLoader);
  80849. /** @hidden */
  80850. dispose(): void;
  80851. /** @hidden */
  80852. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80853. private _loadClearCoatPropertiesAsync;
  80854. }
  80855. }
  80856. declare module BABYLON.GLTF2.Loader.Extensions {
  80857. /**
  80858. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  80859. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  80860. * !!! Experimental Extension Subject to Changes !!!
  80861. */
  80862. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  80863. /**
  80864. * The name of this extension.
  80865. */
  80866. readonly name: string;
  80867. /**
  80868. * Defines whether this extension is enabled.
  80869. */
  80870. enabled: boolean;
  80871. /**
  80872. * Defines a number that determines the order the extensions are applied.
  80873. */
  80874. order: number;
  80875. private _loader;
  80876. /** @hidden */
  80877. constructor(loader: GLTFLoader);
  80878. /** @hidden */
  80879. dispose(): void;
  80880. /** @hidden */
  80881. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80882. private _loadSheenPropertiesAsync;
  80883. }
  80884. }
  80885. declare module BABYLON.GLTF2.Loader.Extensions {
  80886. /**
  80887. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  80888. * !!! Experimental Extension Subject to Changes !!!
  80889. */
  80890. export class KHR_materials_specular implements IGLTFLoaderExtension {
  80891. /**
  80892. * The name of this extension.
  80893. */
  80894. readonly name: string;
  80895. /**
  80896. * Defines whether this extension is enabled.
  80897. */
  80898. enabled: boolean;
  80899. /**
  80900. * Defines a number that determines the order the extensions are applied.
  80901. */
  80902. order: number;
  80903. private _loader;
  80904. /** @hidden */
  80905. constructor(loader: GLTFLoader);
  80906. /** @hidden */
  80907. dispose(): void;
  80908. /** @hidden */
  80909. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80910. private _loadSpecularPropertiesAsync;
  80911. }
  80912. }
  80913. declare module BABYLON.GLTF2.Loader.Extensions {
  80914. /**
  80915. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  80916. * !!! Experimental Extension Subject to Changes !!!
  80917. */
  80918. export class KHR_materials_ior implements IGLTFLoaderExtension {
  80919. /**
  80920. * Default ior Value from the spec.
  80921. */
  80922. private static readonly _DEFAULT_IOR;
  80923. /**
  80924. * The name of this extension.
  80925. */
  80926. readonly name: string;
  80927. /**
  80928. * Defines whether this extension is enabled.
  80929. */
  80930. enabled: boolean;
  80931. /**
  80932. * Defines a number that determines the order the extensions are applied.
  80933. */
  80934. order: number;
  80935. private _loader;
  80936. /** @hidden */
  80937. constructor(loader: GLTFLoader);
  80938. /** @hidden */
  80939. dispose(): void;
  80940. /** @hidden */
  80941. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80942. private _loadIorPropertiesAsync;
  80943. }
  80944. }
  80945. declare module BABYLON.GLTF2.Loader.Extensions {
  80946. /**
  80947. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  80948. * !!! Experimental Extension Subject to Changes !!!
  80949. */
  80950. export class KHR_materials_variants implements IGLTFLoaderExtension {
  80951. /**
  80952. * The name of this extension.
  80953. */
  80954. readonly name: string;
  80955. /**
  80956. * Defines whether this extension is enabled.
  80957. */
  80958. enabled: boolean;
  80959. private _loader;
  80960. /** @hidden */
  80961. constructor(loader: GLTFLoader);
  80962. /** @hidden */
  80963. dispose(): void;
  80964. /**
  80965. * Gets the list of available variant tag names for this asset.
  80966. * @param rootMesh The glTF root mesh
  80967. * @returns the list of all the variant names for this model
  80968. */
  80969. static GetAvailableVariants(rootMesh: Mesh): string[];
  80970. /**
  80971. * Gets the list of available variant tag names for this asset.
  80972. * @param rootMesh The glTF root mesh
  80973. * @returns the list of all the variant names for this model
  80974. */
  80975. getAvailableVariants(rootMesh: Mesh): string[];
  80976. /**
  80977. * Select a variant given a variant tag name or a list of variant tag names.
  80978. * @param rootMesh The glTF root mesh
  80979. * @param variantName The variant name(s) to select.
  80980. */
  80981. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  80982. /**
  80983. * Select a variant given a variant tag name or a list of variant tag names.
  80984. * @param rootMesh The glTF root mesh
  80985. * @param variantName The variant name(s) to select.
  80986. */
  80987. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  80988. /**
  80989. * Reset back to the original before selecting a variant.
  80990. * @param rootMesh The glTF root mesh
  80991. */
  80992. static Reset(rootMesh: Mesh): void;
  80993. /**
  80994. * Reset back to the original before selecting a variant.
  80995. * @param rootMesh The glTF root mesh
  80996. */
  80997. reset(rootMesh: Mesh): void;
  80998. /**
  80999. * Gets the last selected variant tag name(s) or null if original.
  81000. * @param rootMesh The glTF root mesh
  81001. * @returns The selected variant tag name(s).
  81002. */
  81003. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  81004. /**
  81005. * Gets the last selected variant tag name(s) or null if original.
  81006. * @param rootMesh The glTF root mesh
  81007. * @returns The selected variant tag name(s).
  81008. */
  81009. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  81010. private static _GetExtensionMetadata;
  81011. /** @hidden */
  81012. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  81013. }
  81014. }
  81015. declare module BABYLON.GLTF2.Loader.Extensions {
  81016. /**
  81017. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  81018. * !!! Experimental Extension Subject to Changes !!!
  81019. */
  81020. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  81021. /**
  81022. * The name of this extension.
  81023. */
  81024. readonly name: string;
  81025. /**
  81026. * Defines whether this extension is enabled.
  81027. */
  81028. enabled: boolean;
  81029. /**
  81030. * Defines a number that determines the order the extensions are applied.
  81031. */
  81032. order: number;
  81033. private _loader;
  81034. /** @hidden */
  81035. constructor(loader: GLTFLoader);
  81036. /** @hidden */
  81037. dispose(): void;
  81038. /** @hidden */
  81039. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81040. private _loadTransparentPropertiesAsync;
  81041. }
  81042. }
  81043. declare module BABYLON.GLTF2.Loader.Extensions {
  81044. /**
  81045. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  81046. */
  81047. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  81048. /**
  81049. * The name of this extension.
  81050. */
  81051. readonly name: string;
  81052. /**
  81053. * Defines whether this extension is enabled.
  81054. */
  81055. enabled: boolean;
  81056. /** @hidden */
  81057. constructor(loader: GLTFLoader);
  81058. /** @hidden */
  81059. dispose(): void;
  81060. }
  81061. }
  81062. declare module BABYLON.GLTF2.Loader.Extensions {
  81063. /**
  81064. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  81065. * !!! Experimental Extension Subject to Changes !!!
  81066. */
  81067. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  81068. /** The name of this extension. */
  81069. readonly name: string;
  81070. /** Defines whether this extension is enabled. */
  81071. enabled: boolean;
  81072. private _loader;
  81073. /** @hidden */
  81074. constructor(loader: GLTFLoader);
  81075. /** @hidden */
  81076. dispose(): void;
  81077. /** @hidden */
  81078. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81079. }
  81080. }
  81081. declare module BABYLON.GLTF2.Loader.Extensions {
  81082. /**
  81083. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  81084. */
  81085. export class KHR_texture_transform implements IGLTFLoaderExtension {
  81086. /**
  81087. * The name of this extension.
  81088. */
  81089. readonly name: string;
  81090. /**
  81091. * Defines whether this extension is enabled.
  81092. */
  81093. enabled: boolean;
  81094. private _loader;
  81095. /** @hidden */
  81096. constructor(loader: GLTFLoader);
  81097. /** @hidden */
  81098. dispose(): void;
  81099. /** @hidden */
  81100. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81101. }
  81102. }
  81103. declare module BABYLON.GLTF2.Loader.Extensions {
  81104. /**
  81105. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  81106. * !!! Experimental Extension Subject to Changes !!!
  81107. */
  81108. export class KHR_xmp implements IGLTFLoaderExtension {
  81109. /**
  81110. * The name of this extension.
  81111. */
  81112. readonly name: string;
  81113. /**
  81114. * Defines whether this extension is enabled.
  81115. */
  81116. enabled: boolean;
  81117. /**
  81118. * Defines a number that determines the order the extensions are applied.
  81119. */
  81120. order: number;
  81121. private _loader;
  81122. /** @hidden */
  81123. constructor(loader: GLTFLoader);
  81124. /** @hidden */
  81125. dispose(): void;
  81126. /**
  81127. * Called after the loader state changes to LOADING.
  81128. */
  81129. onLoading(): void;
  81130. }
  81131. }
  81132. declare module BABYLON.GLTF2.Loader.Extensions {
  81133. /**
  81134. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  81135. */
  81136. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  81137. /**
  81138. * The name of this extension.
  81139. */
  81140. readonly name: string;
  81141. /**
  81142. * Defines whether this extension is enabled.
  81143. */
  81144. enabled: boolean;
  81145. private _loader;
  81146. private _clips;
  81147. private _emitters;
  81148. /** @hidden */
  81149. constructor(loader: GLTFLoader);
  81150. /** @hidden */
  81151. dispose(): void;
  81152. /** @hidden */
  81153. onLoading(): void;
  81154. /** @hidden */
  81155. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  81156. /** @hidden */
  81157. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81158. /** @hidden */
  81159. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  81160. private _loadClipAsync;
  81161. private _loadEmitterAsync;
  81162. private _getEventAction;
  81163. private _loadAnimationEventAsync;
  81164. }
  81165. }
  81166. declare module BABYLON.GLTF2.Loader.Extensions {
  81167. /**
  81168. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  81169. */
  81170. export class MSFT_lod implements IGLTFLoaderExtension {
  81171. /**
  81172. * The name of this extension.
  81173. */
  81174. readonly name: string;
  81175. /**
  81176. * Defines whether this extension is enabled.
  81177. */
  81178. enabled: boolean;
  81179. /**
  81180. * Defines a number that determines the order the extensions are applied.
  81181. */
  81182. order: number;
  81183. /**
  81184. * Maximum number of LODs to load, starting from the lowest LOD.
  81185. */
  81186. maxLODsToLoad: number;
  81187. /**
  81188. * Observable raised when all node LODs of one level are loaded.
  81189. * The event data is the index of the loaded LOD starting from zero.
  81190. * Dispose the loader to cancel the loading of the next level of LODs.
  81191. */
  81192. onNodeLODsLoadedObservable: Observable<number>;
  81193. /**
  81194. * Observable raised when all material LODs of one level are loaded.
  81195. * The event data is the index of the loaded LOD starting from zero.
  81196. * Dispose the loader to cancel the loading of the next level of LODs.
  81197. */
  81198. onMaterialLODsLoadedObservable: Observable<number>;
  81199. private _loader;
  81200. private _bufferLODs;
  81201. private _nodeIndexLOD;
  81202. private _nodeSignalLODs;
  81203. private _nodePromiseLODs;
  81204. private _nodeBufferLODs;
  81205. private _materialIndexLOD;
  81206. private _materialSignalLODs;
  81207. private _materialPromiseLODs;
  81208. private _materialBufferLODs;
  81209. /** @hidden */
  81210. constructor(loader: GLTFLoader);
  81211. /** @hidden */
  81212. dispose(): void;
  81213. /** @hidden */
  81214. onReady(): void;
  81215. /** @hidden */
  81216. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  81217. /** @hidden */
  81218. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81219. /** @hidden */
  81220. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  81221. /** @hidden */
  81222. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  81223. /** @hidden */
  81224. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  81225. private _loadBufferLOD;
  81226. /**
  81227. * Gets an array of LOD properties from lowest to highest.
  81228. */
  81229. private _getLODs;
  81230. private _disposeTransformNode;
  81231. private _disposeMaterials;
  81232. }
  81233. }
  81234. declare module BABYLON.GLTF2.Loader.Extensions {
  81235. /** @hidden */
  81236. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  81237. readonly name: string;
  81238. enabled: boolean;
  81239. private _loader;
  81240. constructor(loader: GLTFLoader);
  81241. dispose(): void;
  81242. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81243. }
  81244. }
  81245. declare module BABYLON.GLTF2.Loader.Extensions {
  81246. /** @hidden */
  81247. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  81248. readonly name: string;
  81249. enabled: boolean;
  81250. private _loader;
  81251. constructor(loader: GLTFLoader);
  81252. dispose(): void;
  81253. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81254. }
  81255. }
  81256. declare module BABYLON.GLTF2.Loader.Extensions {
  81257. /**
  81258. * Store glTF extras (if present) in BJS objects' metadata
  81259. */
  81260. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  81261. /**
  81262. * The name of this extension.
  81263. */
  81264. readonly name: string;
  81265. /**
  81266. * Defines whether this extension is enabled.
  81267. */
  81268. enabled: boolean;
  81269. private _loader;
  81270. private _assignExtras;
  81271. /** @hidden */
  81272. constructor(loader: GLTFLoader);
  81273. /** @hidden */
  81274. dispose(): void;
  81275. /** @hidden */
  81276. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81277. /** @hidden */
  81278. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  81279. /** @hidden */
  81280. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  81281. }
  81282. }
  81283. declare module BABYLON {
  81284. /**
  81285. * Class reading and parsing the MTL file bundled with the obj file.
  81286. */
  81287. export class MTLFileLoader {
  81288. /**
  81289. * Invert Y-Axis of referenced textures on load
  81290. */
  81291. static INVERT_TEXTURE_Y: boolean;
  81292. /**
  81293. * All material loaded from the mtl will be set here
  81294. */
  81295. materials: StandardMaterial[];
  81296. /**
  81297. * This function will read the mtl file and create each material described inside
  81298. * This function could be improve by adding :
  81299. * -some component missing (Ni, Tf...)
  81300. * -including the specific options available
  81301. *
  81302. * @param scene defines the scene the material will be created in
  81303. * @param data defines the mtl data to parse
  81304. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  81305. * @param forAssetContainer defines if the material should be registered in the scene
  81306. */
  81307. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  81308. /**
  81309. * Gets the texture for the material.
  81310. *
  81311. * If the material is imported from input file,
  81312. * We sanitize the url to ensure it takes the textre from aside the material.
  81313. *
  81314. * @param rootUrl The root url to load from
  81315. * @param value The value stored in the mtl
  81316. * @return The Texture
  81317. */
  81318. private static _getTexture;
  81319. }
  81320. }
  81321. declare module BABYLON {
  81322. /**
  81323. * Options for loading OBJ/MTL files
  81324. */
  81325. type MeshLoadOptions = {
  81326. /**
  81327. * Defines if UVs are optimized by default during load.
  81328. */
  81329. OptimizeWithUV: boolean;
  81330. /**
  81331. * Defines custom scaling of UV coordinates of loaded meshes.
  81332. */
  81333. UVScaling: Vector2;
  81334. /**
  81335. * Invert model on y-axis (does a model scaling inversion)
  81336. */
  81337. InvertY: boolean;
  81338. /**
  81339. * Invert Y-Axis of referenced textures on load
  81340. */
  81341. InvertTextureY: boolean;
  81342. /**
  81343. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  81344. */
  81345. ImportVertexColors: boolean;
  81346. /**
  81347. * Compute the normals for the model, even if normals are present in the file.
  81348. */
  81349. ComputeNormals: boolean;
  81350. /**
  81351. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  81352. */
  81353. SkipMaterials: boolean;
  81354. /**
  81355. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  81356. */
  81357. MaterialLoadingFailsSilently: boolean;
  81358. };
  81359. /**
  81360. * OBJ file type loader.
  81361. * This is a babylon scene loader plugin.
  81362. */
  81363. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  81364. /**
  81365. * Defines if UVs are optimized by default during load.
  81366. */
  81367. static OPTIMIZE_WITH_UV: boolean;
  81368. /**
  81369. * Invert model on y-axis (does a model scaling inversion)
  81370. */
  81371. static INVERT_Y: boolean;
  81372. /**
  81373. * Invert Y-Axis of referenced textures on load
  81374. */
  81375. static get INVERT_TEXTURE_Y(): boolean;
  81376. static set INVERT_TEXTURE_Y(value: boolean);
  81377. /**
  81378. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  81379. */
  81380. static IMPORT_VERTEX_COLORS: boolean;
  81381. /**
  81382. * Compute the normals for the model, even if normals are present in the file.
  81383. */
  81384. static COMPUTE_NORMALS: boolean;
  81385. /**
  81386. * Defines custom scaling of UV coordinates of loaded meshes.
  81387. */
  81388. static UV_SCALING: Vector2;
  81389. /**
  81390. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  81391. */
  81392. static SKIP_MATERIALS: boolean;
  81393. /**
  81394. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  81395. *
  81396. * Defaults to true for backwards compatibility.
  81397. */
  81398. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  81399. /**
  81400. * Defines the name of the plugin.
  81401. */
  81402. name: string;
  81403. /**
  81404. * Defines the extension the plugin is able to load.
  81405. */
  81406. extensions: string;
  81407. /** @hidden */
  81408. obj: RegExp;
  81409. /** @hidden */
  81410. group: RegExp;
  81411. /** @hidden */
  81412. mtllib: RegExp;
  81413. /** @hidden */
  81414. usemtl: RegExp;
  81415. /** @hidden */
  81416. smooth: RegExp;
  81417. /** @hidden */
  81418. vertexPattern: RegExp;
  81419. /** @hidden */
  81420. normalPattern: RegExp;
  81421. /** @hidden */
  81422. uvPattern: RegExp;
  81423. /** @hidden */
  81424. facePattern1: RegExp;
  81425. /** @hidden */
  81426. facePattern2: RegExp;
  81427. /** @hidden */
  81428. facePattern3: RegExp;
  81429. /** @hidden */
  81430. facePattern4: RegExp;
  81431. /** @hidden */
  81432. facePattern5: RegExp;
  81433. private _forAssetContainer;
  81434. private _meshLoadOptions;
  81435. /**
  81436. * Creates loader for .OBJ files
  81437. *
  81438. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  81439. */
  81440. constructor(meshLoadOptions?: MeshLoadOptions);
  81441. private static get currentMeshLoadOptions();
  81442. /**
  81443. * Calls synchronously the MTL file attached to this obj.
  81444. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  81445. * Without this function materials are not displayed in the first frame (but displayed after).
  81446. * In consequence it is impossible to get material information in your HTML file
  81447. *
  81448. * @param url The URL of the MTL file
  81449. * @param rootUrl
  81450. * @param onSuccess Callback function to be called when the MTL file is loaded
  81451. * @private
  81452. */
  81453. private _loadMTL;
  81454. /**
  81455. * Instantiates a OBJ file loader plugin.
  81456. * @returns the created plugin
  81457. */
  81458. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  81459. /**
  81460. * If the data string can be loaded directly.
  81461. *
  81462. * @param data string containing the file data
  81463. * @returns if the data can be loaded directly
  81464. */
  81465. canDirectLoad(data: string): boolean;
  81466. /**
  81467. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  81468. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  81469. * @param scene the scene the meshes should be added to
  81470. * @param data the OBJ data to load
  81471. * @param rootUrl root url to load from
  81472. * @param onProgress event that fires when loading progress has occured
  81473. * @param fileName Defines the name of the file to load
  81474. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  81475. */
  81476. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  81477. meshes: AbstractMesh[];
  81478. particleSystems: IParticleSystem[];
  81479. skeletons: Skeleton[];
  81480. animationGroups: AnimationGroup[];
  81481. }>;
  81482. /**
  81483. * Imports all objects from the loaded OBJ data and adds them to the scene
  81484. * @param scene the scene the objects should be added to
  81485. * @param data the OBJ data to load
  81486. * @param rootUrl root url to load from
  81487. * @param onProgress event that fires when loading progress has occured
  81488. * @param fileName Defines the name of the file to load
  81489. * @returns a promise which completes when objects have been loaded to the scene
  81490. */
  81491. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  81492. /**
  81493. * Load into an asset container.
  81494. * @param scene The scene to load into
  81495. * @param data The data to import
  81496. * @param rootUrl The root url for scene and resources
  81497. * @param onProgress The callback when the load progresses
  81498. * @param fileName Defines the name of the file to load
  81499. * @returns The loaded asset container
  81500. */
  81501. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  81502. /**
  81503. * Read the OBJ file and create an Array of meshes.
  81504. * Each mesh contains all information given by the OBJ and the MTL file.
  81505. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  81506. *
  81507. * @param meshesNames
  81508. * @param scene Scene The scene where are displayed the data
  81509. * @param data String The content of the obj file
  81510. * @param rootUrl String The path to the folder
  81511. * @returns Array<AbstractMesh>
  81512. * @private
  81513. */
  81514. private _parseSolid;
  81515. }
  81516. }
  81517. declare module BABYLON {
  81518. /**
  81519. * STL file type loader.
  81520. * This is a babylon scene loader plugin.
  81521. */
  81522. export class STLFileLoader implements ISceneLoaderPlugin {
  81523. /** @hidden */
  81524. solidPattern: RegExp;
  81525. /** @hidden */
  81526. facetsPattern: RegExp;
  81527. /** @hidden */
  81528. normalPattern: RegExp;
  81529. /** @hidden */
  81530. vertexPattern: RegExp;
  81531. /**
  81532. * Defines the name of the plugin.
  81533. */
  81534. name: string;
  81535. /**
  81536. * Defines the extensions the stl loader is able to load.
  81537. * force data to come in as an ArrayBuffer
  81538. * we'll convert to string if it looks like it's an ASCII .stl
  81539. */
  81540. extensions: ISceneLoaderPluginExtensions;
  81541. /**
  81542. * Import meshes into a scene.
  81543. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  81544. * @param scene The scene to import into
  81545. * @param data The data to import
  81546. * @param rootUrl The root url for scene and resources
  81547. * @param meshes The meshes array to import into
  81548. * @param particleSystems The particle systems array to import into
  81549. * @param skeletons The skeletons array to import into
  81550. * @param onError The callback when import fails
  81551. * @returns True if successful or false otherwise
  81552. */
  81553. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  81554. /**
  81555. * Load into a scene.
  81556. * @param scene The scene to load into
  81557. * @param data The data to import
  81558. * @param rootUrl The root url for scene and resources
  81559. * @param onError The callback when import fails
  81560. * @returns true if successful or false otherwise
  81561. */
  81562. load(scene: Scene, data: any, rootUrl: string): boolean;
  81563. /**
  81564. * Load into an asset container.
  81565. * @param scene The scene to load into
  81566. * @param data The data to import
  81567. * @param rootUrl The root url for scene and resources
  81568. * @param onError The callback when import fails
  81569. * @returns The loaded asset container
  81570. */
  81571. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  81572. private _isBinary;
  81573. private _parseBinary;
  81574. private _parseASCII;
  81575. }
  81576. }
  81577. declare module BABYLON {
  81578. /**
  81579. * Class for generating OBJ data from a Babylon scene.
  81580. */
  81581. export class OBJExport {
  81582. /**
  81583. * Exports the geometry of a Mesh array in .OBJ file format (text)
  81584. * @param mesh defines the list of meshes to serialize
  81585. * @param materials defines if materials should be exported
  81586. * @param matlibname defines the name of the associated mtl file
  81587. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  81588. * @returns the OBJ content
  81589. */
  81590. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  81591. /**
  81592. * Exports the material(s) of a mesh in .MTL file format (text)
  81593. * @param mesh defines the mesh to extract the material from
  81594. * @returns the mtl content
  81595. */
  81596. static MTL(mesh: Mesh): string;
  81597. }
  81598. }
  81599. declare module BABYLON {
  81600. /** @hidden */
  81601. export var __IGLTFExporterExtension: number;
  81602. /**
  81603. * Interface for extending the exporter
  81604. * @hidden
  81605. */
  81606. export interface IGLTFExporterExtension {
  81607. /**
  81608. * The name of this extension
  81609. */
  81610. readonly name: string;
  81611. /**
  81612. * Defines whether this extension is enabled
  81613. */
  81614. enabled: boolean;
  81615. /**
  81616. * Defines whether this extension is required
  81617. */
  81618. required: boolean;
  81619. }
  81620. }
  81621. declare module BABYLON.GLTF2.Exporter {
  81622. /** @hidden */
  81623. export var __IGLTFExporterExtensionV2: number;
  81624. /**
  81625. * Interface for a glTF exporter extension
  81626. * @hidden
  81627. */
  81628. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  81629. /**
  81630. * Define this method to modify the default behavior before exporting a texture
  81631. * @param context The context when loading the asset
  81632. * @param babylonTexture The Babylon.js texture
  81633. * @param mimeType The mime-type of the generated image
  81634. * @returns A promise that resolves with the exported texture
  81635. */
  81636. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  81637. /**
  81638. * Define this method to get notified when a texture info is created
  81639. * @param context The context when loading the asset
  81640. * @param textureInfo The glTF texture info
  81641. * @param babylonTexture The Babylon.js texture
  81642. */
  81643. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  81644. /**
  81645. * Define this method to modify the default behavior when exporting texture info
  81646. * @param context The context when loading the asset
  81647. * @param meshPrimitive glTF mesh primitive
  81648. * @param babylonSubMesh Babylon submesh
  81649. * @param binaryWriter glTF serializer binary writer instance
  81650. * @returns nullable IMeshPrimitive promise
  81651. */
  81652. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  81653. /**
  81654. * Define this method to modify the default behavior when exporting a node
  81655. * @param context The context when exporting the node
  81656. * @param node glTF node
  81657. * @param babylonNode BabylonJS node
  81658. * @returns nullable INode promise
  81659. */
  81660. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81661. [key: number]: number;
  81662. }): Promise<Nullable<INode>>;
  81663. /**
  81664. * Define this method to modify the default behavior when exporting a material
  81665. * @param material glTF material
  81666. * @param babylonMaterial BabylonJS material
  81667. * @returns nullable IMaterial promise
  81668. */
  81669. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  81670. /**
  81671. * Define this method to return additional textures to export from a material
  81672. * @param material glTF material
  81673. * @param babylonMaterial BabylonJS material
  81674. * @returns List of textures
  81675. */
  81676. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  81677. /** Gets a boolean indicating that this extension was used */
  81678. wasUsed: boolean;
  81679. /** Gets a boolean indicating that this extension is required for the file to work */
  81680. required: boolean;
  81681. /**
  81682. * Called after the exporter state changes to EXPORTING
  81683. */
  81684. onExporting?(): void;
  81685. }
  81686. }
  81687. declare module BABYLON.GLTF2.Exporter {
  81688. /**
  81689. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  81690. * @hidden
  81691. */
  81692. export class _GLTFMaterialExporter {
  81693. /**
  81694. * Represents the dielectric specular values for R, G and B
  81695. */
  81696. private static readonly _DielectricSpecular;
  81697. /**
  81698. * Allows the maximum specular power to be defined for material calculations
  81699. */
  81700. private static readonly _MaxSpecularPower;
  81701. /**
  81702. * Mapping to store textures
  81703. */
  81704. private _textureMap;
  81705. /**
  81706. * Numeric tolerance value
  81707. */
  81708. private static readonly _Epsilon;
  81709. /**
  81710. * Reference to the glTF Exporter
  81711. */
  81712. private _exporter;
  81713. constructor(exporter: _Exporter);
  81714. /**
  81715. * Specifies if two colors are approximately equal in value
  81716. * @param color1 first color to compare to
  81717. * @param color2 second color to compare to
  81718. * @param epsilon threshold value
  81719. */
  81720. private static FuzzyEquals;
  81721. /**
  81722. * Gets the materials from a Babylon scene and converts them to glTF materials
  81723. * @param scene babylonjs scene
  81724. * @param mimeType texture mime type
  81725. * @param images array of images
  81726. * @param textures array of textures
  81727. * @param materials array of materials
  81728. * @param imageData mapping of texture names to base64 textures
  81729. * @param hasTextureCoords specifies if texture coordinates are present on the material
  81730. */
  81731. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  81732. /**
  81733. * Makes a copy of the glTF material without the texture parameters
  81734. * @param originalMaterial original glTF material
  81735. * @returns glTF material without texture parameters
  81736. */
  81737. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  81738. /**
  81739. * Specifies if the material has any texture parameters present
  81740. * @param material glTF Material
  81741. * @returns boolean specifying if texture parameters are present
  81742. */
  81743. _hasTexturesPresent(material: IMaterial): boolean;
  81744. /**
  81745. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  81746. * @param babylonStandardMaterial
  81747. * @returns glTF Metallic Roughness Material representation
  81748. */
  81749. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  81750. /**
  81751. * Computes the metallic factor
  81752. * @param diffuse diffused value
  81753. * @param specular specular value
  81754. * @param oneMinusSpecularStrength one minus the specular strength
  81755. * @returns metallic value
  81756. */
  81757. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  81758. /**
  81759. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  81760. * @param glTFMaterial glTF material
  81761. * @param babylonMaterial Babylon material
  81762. */
  81763. private static _SetAlphaMode;
  81764. /**
  81765. * Converts a Babylon Standard Material to a glTF Material
  81766. * @param babylonStandardMaterial BJS Standard Material
  81767. * @param mimeType mime type to use for the textures
  81768. * @param images array of glTF image interfaces
  81769. * @param textures array of glTF texture interfaces
  81770. * @param materials array of glTF material interfaces
  81771. * @param imageData map of image file name to data
  81772. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81773. */
  81774. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81775. private _finishMaterial;
  81776. /**
  81777. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  81778. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  81779. * @param mimeType mime type to use for the textures
  81780. * @param images array of glTF image interfaces
  81781. * @param textures array of glTF texture interfaces
  81782. * @param materials array of glTF material interfaces
  81783. * @param imageData map of image file name to data
  81784. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81785. */
  81786. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81787. /**
  81788. * Converts an image typed array buffer to a base64 image
  81789. * @param buffer typed array buffer
  81790. * @param width width of the image
  81791. * @param height height of the image
  81792. * @param mimeType mimetype of the image
  81793. * @returns base64 image string
  81794. */
  81795. private _createBase64FromCanvasAsync;
  81796. /**
  81797. * Generates a white texture based on the specified width and height
  81798. * @param width width of the texture in pixels
  81799. * @param height height of the texture in pixels
  81800. * @param scene babylonjs scene
  81801. * @returns white texture
  81802. */
  81803. private _createWhiteTexture;
  81804. /**
  81805. * 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
  81806. * @param texture1 first texture to resize
  81807. * @param texture2 second texture to resize
  81808. * @param scene babylonjs scene
  81809. * @returns resized textures or null
  81810. */
  81811. private _resizeTexturesToSameDimensions;
  81812. /**
  81813. * Converts an array of pixels to a Float32Array
  81814. * Throws an error if the pixel format is not supported
  81815. * @param pixels - array buffer containing pixel values
  81816. * @returns Float32 of pixels
  81817. */
  81818. private _convertPixelArrayToFloat32;
  81819. /**
  81820. * Convert Specular Glossiness Textures to Metallic Roughness
  81821. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  81822. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  81823. * @param diffuseTexture texture used to store diffuse information
  81824. * @param specularGlossinessTexture texture used to store specular and glossiness information
  81825. * @param factors specular glossiness material factors
  81826. * @param mimeType the mime type to use for the texture
  81827. * @returns pbr metallic roughness interface or null
  81828. */
  81829. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  81830. /**
  81831. * Converts specular glossiness material properties to metallic roughness
  81832. * @param specularGlossiness interface with specular glossiness material properties
  81833. * @returns interface with metallic roughness material properties
  81834. */
  81835. private _convertSpecularGlossinessToMetallicRoughness;
  81836. /**
  81837. * Calculates the surface reflectance, independent of lighting conditions
  81838. * @param color Color source to calculate brightness from
  81839. * @returns number representing the perceived brightness, or zero if color is undefined
  81840. */
  81841. private _getPerceivedBrightness;
  81842. /**
  81843. * Returns the maximum color component value
  81844. * @param color
  81845. * @returns maximum color component value, or zero if color is null or undefined
  81846. */
  81847. private _getMaxComponent;
  81848. /**
  81849. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  81850. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81851. * @param mimeType mime type to use for the textures
  81852. * @param images array of glTF image interfaces
  81853. * @param textures array of glTF texture interfaces
  81854. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  81855. * @param imageData map of image file name to data
  81856. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81857. * @returns glTF PBR Metallic Roughness factors
  81858. */
  81859. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  81860. private _getGLTFTextureSampler;
  81861. private _getGLTFTextureWrapMode;
  81862. private _getGLTFTextureWrapModesSampler;
  81863. /**
  81864. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  81865. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81866. * @param mimeType mime type to use for the textures
  81867. * @param images array of glTF image interfaces
  81868. * @param textures array of glTF texture interfaces
  81869. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  81870. * @param imageData map of image file name to data
  81871. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81872. * @returns glTF PBR Metallic Roughness factors
  81873. */
  81874. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  81875. /**
  81876. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  81877. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81878. * @param mimeType mime type to use for the textures
  81879. * @param images array of glTF image interfaces
  81880. * @param textures array of glTF texture interfaces
  81881. * @param materials array of glTF material interfaces
  81882. * @param imageData map of image file name to data
  81883. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81884. */
  81885. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81886. private setMetallicRoughnessPbrMaterial;
  81887. private getPixelsFromTexture;
  81888. /**
  81889. * Extracts a texture from a Babylon texture into file data and glTF data
  81890. * @param babylonTexture Babylon texture to extract
  81891. * @param mimeType Mime Type of the babylonTexture
  81892. * @return glTF texture info, or null if the texture format is not supported
  81893. */
  81894. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  81895. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  81896. /**
  81897. * Builds a texture from base64 string
  81898. * @param base64Texture base64 texture string
  81899. * @param baseTextureName Name to use for the texture
  81900. * @param mimeType image mime type for the texture
  81901. * @param images array of images
  81902. * @param textures array of textures
  81903. * @param imageData map of image data
  81904. * @returns glTF texture info, or null if the texture format is not supported
  81905. */
  81906. private _getTextureInfoFromBase64;
  81907. }
  81908. }
  81909. declare module BABYLON {
  81910. /**
  81911. * Class for holding and downloading glTF file data
  81912. */
  81913. export class GLTFData {
  81914. /**
  81915. * Object which contains the file name as the key and its data as the value
  81916. */
  81917. glTFFiles: {
  81918. [fileName: string]: string | Blob;
  81919. };
  81920. /**
  81921. * Initializes the glTF file object
  81922. */
  81923. constructor();
  81924. /**
  81925. * Downloads the glTF data as files based on their names and data
  81926. */
  81927. downloadFiles(): void;
  81928. }
  81929. }
  81930. declare module BABYLON {
  81931. /**
  81932. * Holds a collection of exporter options and parameters
  81933. */
  81934. export interface IExportOptions {
  81935. /**
  81936. * Function which indicates whether a babylon node should be exported or not
  81937. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  81938. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  81939. */
  81940. shouldExportNode?(node: Node): boolean;
  81941. /**
  81942. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  81943. * @param metadata source metadata to read from
  81944. * @returns the data to store to glTF node extras
  81945. */
  81946. metadataSelector?(metadata: any): any;
  81947. /**
  81948. * The sample rate to bake animation curves
  81949. */
  81950. animationSampleRate?: number;
  81951. /**
  81952. * Begin serialization without waiting for the scene to be ready
  81953. */
  81954. exportWithoutWaitingForScene?: boolean;
  81955. /**
  81956. * Indicates if coordinate system swapping root nodes should be included in export
  81957. */
  81958. includeCoordinateSystemConversionNodes?: boolean;
  81959. }
  81960. /**
  81961. * Class for generating glTF data from a Babylon scene.
  81962. */
  81963. export class GLTF2Export {
  81964. /**
  81965. * Exports the geometry of the scene to .gltf file format asynchronously
  81966. * @param scene Babylon scene with scene hierarchy information
  81967. * @param filePrefix File prefix to use when generating the glTF file
  81968. * @param options Exporter options
  81969. * @returns Returns an object with a .gltf file and associates texture names
  81970. * as keys and their data and paths as values
  81971. */
  81972. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  81973. private static _PreExportAsync;
  81974. private static _PostExportAsync;
  81975. /**
  81976. * Exports the geometry of the scene to .glb file format asychronously
  81977. * @param scene Babylon scene with scene hierarchy information
  81978. * @param filePrefix File prefix to use when generating glb file
  81979. * @param options Exporter options
  81980. * @returns Returns an object with a .glb filename as key and data as value
  81981. */
  81982. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  81983. }
  81984. }
  81985. declare module BABYLON.GLTF2.Exporter {
  81986. /**
  81987. * @hidden
  81988. */
  81989. export class _GLTFUtilities {
  81990. /**
  81991. * Creates a buffer view based on the supplied arguments
  81992. * @param bufferIndex index value of the specified buffer
  81993. * @param byteOffset byte offset value
  81994. * @param byteLength byte length of the bufferView
  81995. * @param byteStride byte distance between conequential elements
  81996. * @param name name of the buffer view
  81997. * @returns bufferView for glTF
  81998. */
  81999. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  82000. /**
  82001. * Creates an accessor based on the supplied arguments
  82002. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  82003. * @param name The name of the accessor
  82004. * @param type The type of the accessor
  82005. * @param componentType The datatype of components in the attribute
  82006. * @param count The number of attributes referenced by this accessor
  82007. * @param byteOffset The offset relative to the start of the bufferView in bytes
  82008. * @param min Minimum value of each component in this attribute
  82009. * @param max Maximum value of each component in this attribute
  82010. * @returns accessor for glTF
  82011. */
  82012. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  82013. /**
  82014. * Calculates the minimum and maximum values of an array of position floats
  82015. * @param positions Positions array of a mesh
  82016. * @param vertexStart Starting vertex offset to calculate min and max values
  82017. * @param vertexCount Number of vertices to check for min and max values
  82018. * @returns min number array and max number array
  82019. */
  82020. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  82021. min: number[];
  82022. max: number[];
  82023. };
  82024. /**
  82025. * Converts a new right-handed Vector3
  82026. * @param vector vector3 array
  82027. * @returns right-handed Vector3
  82028. */
  82029. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  82030. /**
  82031. * Converts a Vector3 to right-handed
  82032. * @param vector Vector3 to convert to right-handed
  82033. */
  82034. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  82035. /**
  82036. * Converts a three element number array to right-handed
  82037. * @param vector number array to convert to right-handed
  82038. */
  82039. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  82040. /**
  82041. * Converts a new right-handed Vector3
  82042. * @param vector vector3 array
  82043. * @returns right-handed Vector3
  82044. */
  82045. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  82046. /**
  82047. * Converts a Vector3 to right-handed
  82048. * @param vector Vector3 to convert to right-handed
  82049. */
  82050. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  82051. /**
  82052. * Converts a three element number array to right-handed
  82053. * @param vector number array to convert to right-handed
  82054. */
  82055. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  82056. /**
  82057. * Converts a Vector4 to right-handed
  82058. * @param vector Vector4 to convert to right-handed
  82059. */
  82060. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  82061. /**
  82062. * Converts a Vector4 to right-handed
  82063. * @param vector Vector4 to convert to right-handed
  82064. */
  82065. static _GetRightHandedArray4FromRef(vector: number[]): void;
  82066. /**
  82067. * Converts a Quaternion to right-handed
  82068. * @param quaternion Source quaternion to convert to right-handed
  82069. */
  82070. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  82071. /**
  82072. * Converts a Quaternion to right-handed
  82073. * @param quaternion Source quaternion to convert to right-handed
  82074. */
  82075. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  82076. static _NormalizeTangentFromRef(tangent: Vector4): void;
  82077. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  82078. }
  82079. }
  82080. declare module BABYLON.GLTF2.Exporter {
  82081. /**
  82082. * Converts Babylon Scene into glTF 2.0.
  82083. * @hidden
  82084. */
  82085. export class _Exporter {
  82086. /**
  82087. * Stores the glTF to export
  82088. */
  82089. _glTF: IGLTF;
  82090. /**
  82091. * Stores all generated buffer views, which represents views into the main glTF buffer data
  82092. */
  82093. _bufferViews: IBufferView[];
  82094. /**
  82095. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  82096. */
  82097. _accessors: IAccessor[];
  82098. /**
  82099. * Stores all the generated nodes, which contains transform and/or mesh information per node
  82100. */
  82101. _nodes: INode[];
  82102. /**
  82103. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  82104. */
  82105. private _scenes;
  82106. /**
  82107. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  82108. */
  82109. private _meshes;
  82110. /**
  82111. * Stores all the generated material information, which represents the appearance of each primitive
  82112. */
  82113. _materials: IMaterial[];
  82114. _materialMap: {
  82115. [materialID: number]: number;
  82116. };
  82117. /**
  82118. * Stores all the generated texture information, which is referenced by glTF materials
  82119. */
  82120. _textures: ITexture[];
  82121. /**
  82122. * Stores all the generated image information, which is referenced by glTF textures
  82123. */
  82124. _images: IImage[];
  82125. /**
  82126. * Stores all the texture samplers
  82127. */
  82128. _samplers: ISampler[];
  82129. /**
  82130. * Stores all the generated glTF skins
  82131. */
  82132. _skins: ISkin[];
  82133. /**
  82134. * Stores all the generated animation samplers, which is referenced by glTF animations
  82135. */
  82136. /**
  82137. * Stores the animations for glTF models
  82138. */
  82139. private _animations;
  82140. /**
  82141. * Stores the total amount of bytes stored in the glTF buffer
  82142. */
  82143. private _totalByteLength;
  82144. /**
  82145. * Stores a reference to the Babylon scene containing the source geometry and material information
  82146. */
  82147. _babylonScene: Scene;
  82148. /**
  82149. * Stores a map of the image data, where the key is the file name and the value
  82150. * is the image data
  82151. */
  82152. _imageData: {
  82153. [fileName: string]: {
  82154. data: Uint8Array;
  82155. mimeType: ImageMimeType;
  82156. };
  82157. };
  82158. /**
  82159. * Stores a map of the unique id of a node to its index in the node array
  82160. */
  82161. _nodeMap: {
  82162. [key: number]: number;
  82163. };
  82164. /**
  82165. * Specifies if the source Babylon scene was left handed, and needed conversion.
  82166. */
  82167. _convertToRightHandedSystem: boolean;
  82168. /**
  82169. * Specifies if a Babylon node should be converted to right-handed on export
  82170. */
  82171. _convertToRightHandedSystemMap: {
  82172. [nodeId: number]: boolean;
  82173. };
  82174. _includeCoordinateSystemConversionNodes: boolean;
  82175. /**
  82176. * Baked animation sample rate
  82177. */
  82178. private _animationSampleRate;
  82179. private _options;
  82180. private _localEngine;
  82181. _glTFMaterialExporter: _GLTFMaterialExporter;
  82182. private _extensions;
  82183. private static _ExtensionNames;
  82184. private static _ExtensionFactories;
  82185. private _applyExtension;
  82186. private _applyExtensions;
  82187. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  82188. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  82189. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  82190. [key: number]: number;
  82191. }): Promise<Nullable<INode>>;
  82192. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  82193. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  82194. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  82195. private _forEachExtensions;
  82196. private _extensionsOnExporting;
  82197. /**
  82198. * Load glTF serializer extensions
  82199. */
  82200. private _loadExtensions;
  82201. /**
  82202. * Creates a glTF Exporter instance, which can accept optional exporter options
  82203. * @param babylonScene Babylon scene object
  82204. * @param options Options to modify the behavior of the exporter
  82205. */
  82206. constructor(babylonScene: Scene, options?: IExportOptions);
  82207. dispose(): void;
  82208. /**
  82209. * Registers a glTF exporter extension
  82210. * @param name Name of the extension to export
  82211. * @param factory The factory function that creates the exporter extension
  82212. */
  82213. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  82214. /**
  82215. * Un-registers an exporter extension
  82216. * @param name The name fo the exporter extension
  82217. * @returns A boolean indicating whether the extension has been un-registered
  82218. */
  82219. static UnregisterExtension(name: string): boolean;
  82220. /**
  82221. * Lazy load a local engine
  82222. */
  82223. _getLocalEngine(): Engine;
  82224. private reorderIndicesBasedOnPrimitiveMode;
  82225. /**
  82226. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  82227. * clock-wise during export to glTF
  82228. * @param submesh BabylonJS submesh
  82229. * @param primitiveMode Primitive mode of the mesh
  82230. * @param sideOrientation the winding order of the submesh
  82231. * @param vertexBufferKind The type of vertex attribute
  82232. * @param meshAttributeArray The vertex attribute data
  82233. * @param byteOffset The offset to the binary data
  82234. * @param binaryWriter The binary data for the glTF file
  82235. * @param convertToRightHandedSystem Converts the values to right-handed
  82236. */
  82237. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  82238. /**
  82239. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  82240. * clock-wise during export to glTF
  82241. * @param submesh BabylonJS submesh
  82242. * @param primitiveMode Primitive mode of the mesh
  82243. * @param sideOrientation the winding order of the submesh
  82244. * @param vertexBufferKind The type of vertex attribute
  82245. * @param meshAttributeArray The vertex attribute data
  82246. * @param byteOffset The offset to the binary data
  82247. * @param binaryWriter The binary data for the glTF file
  82248. * @param convertToRightHandedSystem Converts the values to right-handed
  82249. */
  82250. private reorderTriangleFillMode;
  82251. /**
  82252. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  82253. * clock-wise during export to glTF
  82254. * @param submesh BabylonJS submesh
  82255. * @param primitiveMode Primitive mode of the mesh
  82256. * @param sideOrientation the winding order of the submesh
  82257. * @param vertexBufferKind The type of vertex attribute
  82258. * @param meshAttributeArray The vertex attribute data
  82259. * @param byteOffset The offset to the binary data
  82260. * @param binaryWriter The binary data for the glTF file
  82261. * @param convertToRightHandedSystem Converts the values to right-handed
  82262. */
  82263. private reorderTriangleStripDrawMode;
  82264. /**
  82265. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  82266. * clock-wise during export to glTF
  82267. * @param submesh BabylonJS submesh
  82268. * @param primitiveMode Primitive mode of the mesh
  82269. * @param sideOrientation the winding order of the submesh
  82270. * @param vertexBufferKind The type of vertex attribute
  82271. * @param meshAttributeArray The vertex attribute data
  82272. * @param byteOffset The offset to the binary data
  82273. * @param binaryWriter The binary data for the glTF file
  82274. * @param convertToRightHandedSystem Converts the values to right-handed
  82275. */
  82276. private reorderTriangleFanMode;
  82277. /**
  82278. * Writes the vertex attribute data to binary
  82279. * @param vertices The vertices to write to the binary writer
  82280. * @param byteOffset The offset into the binary writer to overwrite binary data
  82281. * @param vertexAttributeKind The vertex attribute type
  82282. * @param meshAttributeArray The vertex attribute data
  82283. * @param binaryWriter The writer containing the binary data
  82284. * @param convertToRightHandedSystem Converts the values to right-handed
  82285. */
  82286. private writeVertexAttributeData;
  82287. /**
  82288. * Writes mesh attribute data to a data buffer
  82289. * Returns the bytelength of the data
  82290. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  82291. * @param meshAttributeArray Array containing the attribute data
  82292. * @param byteStride Specifies the space between data
  82293. * @param binaryWriter The buffer to write the binary data to
  82294. * @param convertToRightHandedSystem Converts the values to right-handed
  82295. */
  82296. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  82297. /**
  82298. * Generates glTF json data
  82299. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  82300. * @param glTFPrefix Text to use when prefixing a glTF file
  82301. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  82302. * @returns json data as string
  82303. */
  82304. private generateJSON;
  82305. /**
  82306. * Generates data for .gltf and .bin files based on the glTF prefix string
  82307. * @param glTFPrefix Text to use when prefixing a glTF file
  82308. * @param dispose Dispose the exporter
  82309. * @returns GLTFData with glTF file data
  82310. */
  82311. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  82312. /**
  82313. * Creates a binary buffer for glTF
  82314. * @returns array buffer for binary data
  82315. */
  82316. private _generateBinaryAsync;
  82317. /**
  82318. * Pads the number to a multiple of 4
  82319. * @param num number to pad
  82320. * @returns padded number
  82321. */
  82322. private _getPadding;
  82323. /**
  82324. * @hidden
  82325. */
  82326. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  82327. /**
  82328. * Sets the TRS for each node
  82329. * @param node glTF Node for storing the transformation data
  82330. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  82331. * @param convertToRightHandedSystem Converts the values to right-handed
  82332. */
  82333. private setNodeTransformation;
  82334. private getVertexBufferFromMesh;
  82335. /**
  82336. * Creates a bufferview based on the vertices type for the Babylon mesh
  82337. * @param kind Indicates the type of vertices data
  82338. * @param componentType Indicates the numerical type used to store the data
  82339. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  82340. * @param binaryWriter The buffer to write the bufferview data to
  82341. * @param convertToRightHandedSystem Converts the values to right-handed
  82342. */
  82343. private createBufferViewKind;
  82344. /**
  82345. * The primitive mode of the Babylon mesh
  82346. * @param babylonMesh The BabylonJS mesh
  82347. */
  82348. private getMeshPrimitiveMode;
  82349. /**
  82350. * Sets the primitive mode of the glTF mesh primitive
  82351. * @param meshPrimitive glTF mesh primitive
  82352. * @param primitiveMode The primitive mode
  82353. */
  82354. private setPrimitiveMode;
  82355. /**
  82356. * Sets the vertex attribute accessor based of the glTF mesh primitive
  82357. * @param meshPrimitive glTF mesh primitive
  82358. * @param attributeKind vertex attribute
  82359. * @returns boolean specifying if uv coordinates are present
  82360. */
  82361. private setAttributeKind;
  82362. /**
  82363. * Sets data for the primitive attributes of each submesh
  82364. * @param mesh glTF Mesh object to store the primitive attribute information
  82365. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  82366. * @param binaryWriter Buffer to write the attribute data to
  82367. * @param convertToRightHandedSystem Converts the values to right-handed
  82368. */
  82369. private setPrimitiveAttributesAsync;
  82370. /**
  82371. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  82372. * @param node The node to check
  82373. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  82374. */
  82375. private isBabylonCoordinateSystemConvertingNode;
  82376. /**
  82377. * Creates a glTF scene based on the array of meshes
  82378. * Returns the the total byte offset
  82379. * @param babylonScene Babylon scene to get the mesh data from
  82380. * @param binaryWriter Buffer to write binary data to
  82381. */
  82382. private createSceneAsync;
  82383. /**
  82384. * Creates a mapping of Node unique id to node index and handles animations
  82385. * @param babylonScene Babylon Scene
  82386. * @param nodes Babylon transform nodes
  82387. * @param binaryWriter Buffer to write binary data to
  82388. * @returns Node mapping of unique id to index
  82389. */
  82390. private createNodeMapAndAnimationsAsync;
  82391. /**
  82392. * Creates a glTF node from a Babylon mesh
  82393. * @param babylonMesh Source Babylon mesh
  82394. * @param binaryWriter Buffer for storing geometry data
  82395. * @param convertToRightHandedSystem Converts the values to right-handed
  82396. * @param nodeMap Node mapping of unique id to glTF node index
  82397. * @returns glTF node
  82398. */
  82399. private createNodeAsync;
  82400. /**
  82401. * Creates a glTF skin from a Babylon skeleton
  82402. * @param babylonScene Babylon Scene
  82403. * @param nodes Babylon transform nodes
  82404. * @param binaryWriter Buffer to write binary data to
  82405. * @returns Node mapping of unique id to index
  82406. */
  82407. private createSkinsAsync;
  82408. }
  82409. /**
  82410. * @hidden
  82411. *
  82412. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  82413. */
  82414. export class _BinaryWriter {
  82415. /**
  82416. * Array buffer which stores all binary data
  82417. */
  82418. private _arrayBuffer;
  82419. /**
  82420. * View of the array buffer
  82421. */
  82422. private _dataView;
  82423. /**
  82424. * byte offset of data in array buffer
  82425. */
  82426. private _byteOffset;
  82427. /**
  82428. * Initialize binary writer with an initial byte length
  82429. * @param byteLength Initial byte length of the array buffer
  82430. */
  82431. constructor(byteLength: number);
  82432. /**
  82433. * Resize the array buffer to the specified byte length
  82434. * @param byteLength
  82435. */
  82436. private resizeBuffer;
  82437. /**
  82438. * Get an array buffer with the length of the byte offset
  82439. * @returns ArrayBuffer resized to the byte offset
  82440. */
  82441. getArrayBuffer(): ArrayBuffer;
  82442. /**
  82443. * Get the byte offset of the array buffer
  82444. * @returns byte offset
  82445. */
  82446. getByteOffset(): number;
  82447. /**
  82448. * Stores an UInt8 in the array buffer
  82449. * @param entry
  82450. * @param byteOffset If defined, specifies where to set the value as an offset.
  82451. */
  82452. setUInt8(entry: number, byteOffset?: number): void;
  82453. /**
  82454. * Stores an UInt16 in the array buffer
  82455. * @param entry
  82456. * @param byteOffset If defined, specifies where to set the value as an offset.
  82457. */
  82458. setUInt16(entry: number, byteOffset?: number): void;
  82459. /**
  82460. * Gets an UInt32 in the array buffer
  82461. * @param entry
  82462. * @param byteOffset If defined, specifies where to set the value as an offset.
  82463. */
  82464. getUInt32(byteOffset: number): number;
  82465. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  82466. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  82467. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  82468. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  82469. /**
  82470. * Stores a Float32 in the array buffer
  82471. * @param entry
  82472. */
  82473. setFloat32(entry: number, byteOffset?: number): void;
  82474. /**
  82475. * Stores an UInt32 in the array buffer
  82476. * @param entry
  82477. * @param byteOffset If defined, specifies where to set the value as an offset.
  82478. */
  82479. setUInt32(entry: number, byteOffset?: number): void;
  82480. }
  82481. }
  82482. declare module BABYLON.GLTF2.Exporter {
  82483. /**
  82484. * @hidden
  82485. * Interface to store animation data.
  82486. */
  82487. export interface _IAnimationData {
  82488. /**
  82489. * Keyframe data.
  82490. */
  82491. inputs: number[];
  82492. /**
  82493. * Value data.
  82494. */
  82495. outputs: number[][];
  82496. /**
  82497. * Animation interpolation data.
  82498. */
  82499. samplerInterpolation: AnimationSamplerInterpolation;
  82500. /**
  82501. * Minimum keyframe value.
  82502. */
  82503. inputsMin: number;
  82504. /**
  82505. * Maximum keyframe value.
  82506. */
  82507. inputsMax: number;
  82508. }
  82509. /**
  82510. * @hidden
  82511. */
  82512. export interface _IAnimationInfo {
  82513. /**
  82514. * The target channel for the animation
  82515. */
  82516. animationChannelTargetPath: AnimationChannelTargetPath;
  82517. /**
  82518. * The glTF accessor type for the data.
  82519. */
  82520. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  82521. /**
  82522. * Specifies if quaternions should be used.
  82523. */
  82524. useQuaternion: boolean;
  82525. }
  82526. /**
  82527. * @hidden
  82528. * Utility class for generating glTF animation data from BabylonJS.
  82529. */
  82530. export class _GLTFAnimation {
  82531. /**
  82532. * @ignore
  82533. *
  82534. * Creates glTF channel animation from BabylonJS animation.
  82535. * @param babylonTransformNode - BabylonJS mesh.
  82536. * @param animation - animation.
  82537. * @param animationChannelTargetPath - The target animation channel.
  82538. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  82539. * @param useQuaternion - Specifies if quaternions are used.
  82540. * @returns nullable IAnimationData
  82541. */
  82542. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  82543. private static _DeduceAnimationInfo;
  82544. /**
  82545. * @ignore
  82546. * Create node animations from the transform node animations
  82547. * @param babylonNode
  82548. * @param runtimeGLTFAnimation
  82549. * @param idleGLTFAnimations
  82550. * @param nodeMap
  82551. * @param nodes
  82552. * @param binaryWriter
  82553. * @param bufferViews
  82554. * @param accessors
  82555. * @param convertToRightHandedSystem
  82556. * @param animationSampleRate
  82557. */
  82558. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  82559. [key: number]: number;
  82560. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  82561. /**
  82562. * @ignore
  82563. * Create node animations from the animation groups
  82564. * @param babylonScene
  82565. * @param glTFAnimations
  82566. * @param nodeMap
  82567. * @param nodes
  82568. * @param binaryWriter
  82569. * @param bufferViews
  82570. * @param accessors
  82571. * @param convertToRightHandedSystemMap
  82572. * @param animationSampleRate
  82573. */
  82574. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  82575. [key: number]: number;
  82576. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  82577. [nodeId: number]: boolean;
  82578. }, animationSampleRate: number): void;
  82579. private static AddAnimation;
  82580. /**
  82581. * Create a baked animation
  82582. * @param babylonTransformNode BabylonJS mesh
  82583. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  82584. * @param animationChannelTargetPath animation target channel
  82585. * @param minFrame minimum animation frame
  82586. * @param maxFrame maximum animation frame
  82587. * @param fps frames per second of the animation
  82588. * @param inputs input key frames of the animation
  82589. * @param outputs output key frame data of the animation
  82590. * @param convertToRightHandedSystem converts the values to right-handed
  82591. * @param useQuaternion specifies if quaternions should be used
  82592. */
  82593. private static _CreateBakedAnimation;
  82594. private static _ConvertFactorToVector3OrQuaternion;
  82595. private static _SetInterpolatedValue;
  82596. /**
  82597. * Creates linear animation from the animation key frames
  82598. * @param babylonTransformNode BabylonJS mesh
  82599. * @param animation BabylonJS animation
  82600. * @param animationChannelTargetPath The target animation channel
  82601. * @param frameDelta The difference between the last and first frame of the animation
  82602. * @param inputs Array to store the key frame times
  82603. * @param outputs Array to store the key frame data
  82604. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  82605. * @param useQuaternion Specifies if quaternions are used in the animation
  82606. */
  82607. private static _CreateLinearOrStepAnimation;
  82608. /**
  82609. * Creates cubic spline animation from the animation key frames
  82610. * @param babylonTransformNode BabylonJS mesh
  82611. * @param animation BabylonJS animation
  82612. * @param animationChannelTargetPath The target animation channel
  82613. * @param frameDelta The difference between the last and first frame of the animation
  82614. * @param inputs Array to store the key frame times
  82615. * @param outputs Array to store the key frame data
  82616. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  82617. * @param useQuaternion Specifies if quaternions are used in the animation
  82618. */
  82619. private static _CreateCubicSplineAnimation;
  82620. private static _GetBasePositionRotationOrScale;
  82621. /**
  82622. * Adds a key frame value
  82623. * @param keyFrame
  82624. * @param animation
  82625. * @param outputs
  82626. * @param animationChannelTargetPath
  82627. * @param basePositionRotationOrScale
  82628. * @param convertToRightHandedSystem
  82629. * @param useQuaternion
  82630. */
  82631. private static _AddKeyframeValue;
  82632. /**
  82633. * Determine the interpolation based on the key frames
  82634. * @param keyFrames
  82635. * @param animationChannelTargetPath
  82636. * @param useQuaternion
  82637. */
  82638. private static _DeduceInterpolation;
  82639. /**
  82640. * Adds an input tangent or output tangent to the output data
  82641. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  82642. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  82643. * @param outputs The animation data by keyframe
  82644. * @param animationChannelTargetPath The target animation channel
  82645. * @param interpolation The interpolation type
  82646. * @param keyFrame The key frame with the animation data
  82647. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  82648. * @param useQuaternion Specifies if quaternions are used
  82649. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  82650. */
  82651. private static AddSplineTangent;
  82652. /**
  82653. * Get the minimum and maximum key frames' frame values
  82654. * @param keyFrames animation key frames
  82655. * @returns the minimum and maximum key frame value
  82656. */
  82657. private static calculateMinMaxKeyFrames;
  82658. }
  82659. }
  82660. declare module BABYLON.GLTF2.Exporter {
  82661. /** @hidden */
  82662. export var textureTransformPixelShader: {
  82663. name: string;
  82664. shader: string;
  82665. };
  82666. }
  82667. declare module BABYLON.GLTF2.Exporter.Extensions {
  82668. /**
  82669. * @hidden
  82670. */
  82671. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  82672. private _recordedTextures;
  82673. /** Name of this extension */
  82674. readonly name: string;
  82675. /** Defines whether this extension is enabled */
  82676. enabled: boolean;
  82677. /** Defines whether this extension is required */
  82678. required: boolean;
  82679. /** Reference to the glTF exporter */
  82680. private _wasUsed;
  82681. constructor(exporter: _Exporter);
  82682. dispose(): void;
  82683. /** @hidden */
  82684. get wasUsed(): boolean;
  82685. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  82686. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  82687. /**
  82688. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  82689. * @param babylonTexture
  82690. * @param offset
  82691. * @param rotation
  82692. * @param scale
  82693. * @param scene
  82694. */
  82695. private _textureTransformTextureAsync;
  82696. }
  82697. }
  82698. declare module BABYLON.GLTF2.Exporter.Extensions {
  82699. /**
  82700. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  82701. */
  82702. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  82703. /** The name of this extension. */
  82704. readonly name: string;
  82705. /** Defines whether this extension is enabled. */
  82706. enabled: boolean;
  82707. /** Defines whether this extension is required */
  82708. required: boolean;
  82709. /** Reference to the glTF exporter */
  82710. private _exporter;
  82711. private _lights;
  82712. /** @hidden */
  82713. constructor(exporter: _Exporter);
  82714. /** @hidden */
  82715. dispose(): void;
  82716. /** @hidden */
  82717. get wasUsed(): boolean;
  82718. /** @hidden */
  82719. onExporting(): void;
  82720. /**
  82721. * Define this method to modify the default behavior when exporting a node
  82722. * @param context The context when exporting the node
  82723. * @param node glTF node
  82724. * @param babylonNode BabylonJS node
  82725. * @param nodeMap Node mapping of unique id to glTF node index
  82726. * @returns nullable INode promise
  82727. */
  82728. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  82729. [key: number]: number;
  82730. }): Promise<Nullable<INode>>;
  82731. }
  82732. }
  82733. declare module BABYLON.GLTF2.Exporter.Extensions {
  82734. /**
  82735. * @hidden
  82736. */
  82737. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  82738. /** Name of this extension */
  82739. readonly name: string;
  82740. /** Defines whether this extension is enabled */
  82741. enabled: boolean;
  82742. /** Defines whether this extension is required */
  82743. required: boolean;
  82744. /** Reference to the glTF exporter */
  82745. private _textureInfos;
  82746. private _exportedTextures;
  82747. private _wasUsed;
  82748. constructor(exporter: _Exporter);
  82749. dispose(): void;
  82750. /** @hidden */
  82751. get wasUsed(): boolean;
  82752. private _getTextureIndex;
  82753. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  82754. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  82755. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  82756. }
  82757. }
  82758. declare module BABYLON.GLTF2.Exporter.Extensions {
  82759. /**
  82760. * @hidden
  82761. */
  82762. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  82763. /** Name of this extension */
  82764. readonly name: string;
  82765. /** Defines whether this extension is enabled */
  82766. enabled: boolean;
  82767. /** Defines whether this extension is required */
  82768. required: boolean;
  82769. private _wasUsed;
  82770. constructor(exporter: _Exporter);
  82771. /** @hidden */
  82772. get wasUsed(): boolean;
  82773. dispose(): void;
  82774. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  82775. }
  82776. }
  82777. declare module BABYLON {
  82778. /**
  82779. * Class for generating STL data from a Babylon scene.
  82780. */
  82781. export class STLExport {
  82782. /**
  82783. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  82784. * @param meshes list defines the mesh to serialize
  82785. * @param download triggers the automatic download of the file.
  82786. * @param fileName changes the downloads fileName.
  82787. * @param binary changes the STL to a binary type.
  82788. * @param isLittleEndian toggle for binary type exporter.
  82789. * @returns the STL as UTF8 string
  82790. */
  82791. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  82792. }
  82793. }
  82794. declare module "babylonjs-gltf2interface" {
  82795. export = BABYLON.GLTF2;
  82796. }
  82797. /**
  82798. * Module for glTF 2.0 Interface
  82799. */
  82800. declare module BABYLON.GLTF2 {
  82801. /**
  82802. * The datatype of the components in the attribute
  82803. */
  82804. const enum AccessorComponentType {
  82805. /**
  82806. * Byte
  82807. */
  82808. BYTE = 5120,
  82809. /**
  82810. * Unsigned Byte
  82811. */
  82812. UNSIGNED_BYTE = 5121,
  82813. /**
  82814. * Short
  82815. */
  82816. SHORT = 5122,
  82817. /**
  82818. * Unsigned Short
  82819. */
  82820. UNSIGNED_SHORT = 5123,
  82821. /**
  82822. * Unsigned Int
  82823. */
  82824. UNSIGNED_INT = 5125,
  82825. /**
  82826. * Float
  82827. */
  82828. FLOAT = 5126,
  82829. }
  82830. /**
  82831. * Specifies if the attirbute is a scalar, vector, or matrix
  82832. */
  82833. const enum AccessorType {
  82834. /**
  82835. * Scalar
  82836. */
  82837. SCALAR = "SCALAR",
  82838. /**
  82839. * Vector2
  82840. */
  82841. VEC2 = "VEC2",
  82842. /**
  82843. * Vector3
  82844. */
  82845. VEC3 = "VEC3",
  82846. /**
  82847. * Vector4
  82848. */
  82849. VEC4 = "VEC4",
  82850. /**
  82851. * Matrix2x2
  82852. */
  82853. MAT2 = "MAT2",
  82854. /**
  82855. * Matrix3x3
  82856. */
  82857. MAT3 = "MAT3",
  82858. /**
  82859. * Matrix4x4
  82860. */
  82861. MAT4 = "MAT4",
  82862. }
  82863. /**
  82864. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  82865. */
  82866. const enum AnimationChannelTargetPath {
  82867. /**
  82868. * Translation
  82869. */
  82870. TRANSLATION = "translation",
  82871. /**
  82872. * Rotation
  82873. */
  82874. ROTATION = "rotation",
  82875. /**
  82876. * Scale
  82877. */
  82878. SCALE = "scale",
  82879. /**
  82880. * Weights
  82881. */
  82882. WEIGHTS = "weights",
  82883. }
  82884. /**
  82885. * Interpolation algorithm
  82886. */
  82887. const enum AnimationSamplerInterpolation {
  82888. /**
  82889. * The animated values are linearly interpolated between keyframes
  82890. */
  82891. LINEAR = "LINEAR",
  82892. /**
  82893. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  82894. */
  82895. STEP = "STEP",
  82896. /**
  82897. * The animation's interpolation is computed using a cubic spline with specified tangents
  82898. */
  82899. CUBICSPLINE = "CUBICSPLINE",
  82900. }
  82901. /**
  82902. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  82903. */
  82904. const enum CameraType {
  82905. /**
  82906. * A perspective camera containing properties to create a perspective projection matrix
  82907. */
  82908. PERSPECTIVE = "perspective",
  82909. /**
  82910. * An orthographic camera containing properties to create an orthographic projection matrix
  82911. */
  82912. ORTHOGRAPHIC = "orthographic",
  82913. }
  82914. /**
  82915. * The mime-type of the image
  82916. */
  82917. const enum ImageMimeType {
  82918. /**
  82919. * JPEG Mime-type
  82920. */
  82921. JPEG = "image/jpeg",
  82922. /**
  82923. * PNG Mime-type
  82924. */
  82925. PNG = "image/png",
  82926. }
  82927. /**
  82928. * The alpha rendering mode of the material
  82929. */
  82930. const enum MaterialAlphaMode {
  82931. /**
  82932. * The alpha value is ignored and the rendered output is fully opaque
  82933. */
  82934. OPAQUE = "OPAQUE",
  82935. /**
  82936. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  82937. */
  82938. MASK = "MASK",
  82939. /**
  82940. * 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)
  82941. */
  82942. BLEND = "BLEND",
  82943. }
  82944. /**
  82945. * The type of the primitives to render
  82946. */
  82947. const enum MeshPrimitiveMode {
  82948. /**
  82949. * Points
  82950. */
  82951. POINTS = 0,
  82952. /**
  82953. * Lines
  82954. */
  82955. LINES = 1,
  82956. /**
  82957. * Line Loop
  82958. */
  82959. LINE_LOOP = 2,
  82960. /**
  82961. * Line Strip
  82962. */
  82963. LINE_STRIP = 3,
  82964. /**
  82965. * Triangles
  82966. */
  82967. TRIANGLES = 4,
  82968. /**
  82969. * Triangle Strip
  82970. */
  82971. TRIANGLE_STRIP = 5,
  82972. /**
  82973. * Triangle Fan
  82974. */
  82975. TRIANGLE_FAN = 6,
  82976. }
  82977. /**
  82978. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  82979. */
  82980. const enum TextureMagFilter {
  82981. /**
  82982. * Nearest
  82983. */
  82984. NEAREST = 9728,
  82985. /**
  82986. * Linear
  82987. */
  82988. LINEAR = 9729,
  82989. }
  82990. /**
  82991. * Minification filter. All valid values correspond to WebGL enums
  82992. */
  82993. const enum TextureMinFilter {
  82994. /**
  82995. * Nearest
  82996. */
  82997. NEAREST = 9728,
  82998. /**
  82999. * Linear
  83000. */
  83001. LINEAR = 9729,
  83002. /**
  83003. * Nearest Mip-Map Nearest
  83004. */
  83005. NEAREST_MIPMAP_NEAREST = 9984,
  83006. /**
  83007. * Linear Mipmap Nearest
  83008. */
  83009. LINEAR_MIPMAP_NEAREST = 9985,
  83010. /**
  83011. * Nearest Mipmap Linear
  83012. */
  83013. NEAREST_MIPMAP_LINEAR = 9986,
  83014. /**
  83015. * Linear Mipmap Linear
  83016. */
  83017. LINEAR_MIPMAP_LINEAR = 9987,
  83018. }
  83019. /**
  83020. * S (U) wrapping mode. All valid values correspond to WebGL enums
  83021. */
  83022. const enum TextureWrapMode {
  83023. /**
  83024. * Clamp to Edge
  83025. */
  83026. CLAMP_TO_EDGE = 33071,
  83027. /**
  83028. * Mirrored Repeat
  83029. */
  83030. MIRRORED_REPEAT = 33648,
  83031. /**
  83032. * Repeat
  83033. */
  83034. REPEAT = 10497,
  83035. }
  83036. /**
  83037. * glTF Property
  83038. */
  83039. interface IProperty {
  83040. /**
  83041. * Dictionary object with extension-specific objects
  83042. */
  83043. extensions?: {
  83044. [key: string]: any;
  83045. };
  83046. /**
  83047. * Application-Specific data
  83048. */
  83049. extras?: any;
  83050. }
  83051. /**
  83052. * glTF Child of Root Property
  83053. */
  83054. interface IChildRootProperty extends IProperty {
  83055. /**
  83056. * The user-defined name of this object
  83057. */
  83058. name?: string;
  83059. }
  83060. /**
  83061. * Indices of those attributes that deviate from their initialization value
  83062. */
  83063. interface IAccessorSparseIndices extends IProperty {
  83064. /**
  83065. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  83066. */
  83067. bufferView: number;
  83068. /**
  83069. * The offset relative to the start of the bufferView in bytes. Must be aligned
  83070. */
  83071. byteOffset?: number;
  83072. /**
  83073. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  83074. */
  83075. componentType: AccessorComponentType;
  83076. }
  83077. /**
  83078. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  83079. */
  83080. interface IAccessorSparseValues extends IProperty {
  83081. /**
  83082. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  83083. */
  83084. bufferView: number;
  83085. /**
  83086. * The offset relative to the start of the bufferView in bytes. Must be aligned
  83087. */
  83088. byteOffset?: number;
  83089. }
  83090. /**
  83091. * Sparse storage of attributes that deviate from their initialization value
  83092. */
  83093. interface IAccessorSparse extends IProperty {
  83094. /**
  83095. * The number of attributes encoded in this sparse accessor
  83096. */
  83097. count: number;
  83098. /**
  83099. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  83100. */
  83101. indices: IAccessorSparseIndices;
  83102. /**
  83103. * 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
  83104. */
  83105. values: IAccessorSparseValues;
  83106. }
  83107. /**
  83108. * 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
  83109. */
  83110. interface IAccessor extends IChildRootProperty {
  83111. /**
  83112. * The index of the bufferview
  83113. */
  83114. bufferView?: number;
  83115. /**
  83116. * The offset relative to the start of the bufferView in bytes
  83117. */
  83118. byteOffset?: number;
  83119. /**
  83120. * The datatype of components in the attribute
  83121. */
  83122. componentType: AccessorComponentType;
  83123. /**
  83124. * Specifies whether integer data values should be normalized
  83125. */
  83126. normalized?: boolean;
  83127. /**
  83128. * The number of attributes referenced by this accessor
  83129. */
  83130. count: number;
  83131. /**
  83132. * Specifies if the attribute is a scalar, vector, or matrix
  83133. */
  83134. type: AccessorType;
  83135. /**
  83136. * Maximum value of each component in this attribute
  83137. */
  83138. max?: number[];
  83139. /**
  83140. * Minimum value of each component in this attribute
  83141. */
  83142. min?: number[];
  83143. /**
  83144. * Sparse storage of attributes that deviate from their initialization value
  83145. */
  83146. sparse?: IAccessorSparse;
  83147. }
  83148. /**
  83149. * Targets an animation's sampler at a node's property
  83150. */
  83151. interface IAnimationChannel extends IProperty {
  83152. /**
  83153. * The index of a sampler in this animation used to compute the value for the target
  83154. */
  83155. sampler: number;
  83156. /**
  83157. * The index of the node and TRS property to target
  83158. */
  83159. target: IAnimationChannelTarget;
  83160. }
  83161. /**
  83162. * The index of the node and TRS property that an animation channel targets
  83163. */
  83164. interface IAnimationChannelTarget extends IProperty {
  83165. /**
  83166. * The index of the node to target
  83167. */
  83168. node: number;
  83169. /**
  83170. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  83171. */
  83172. path: AnimationChannelTargetPath;
  83173. }
  83174. /**
  83175. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  83176. */
  83177. interface IAnimationSampler extends IProperty {
  83178. /**
  83179. * The index of an accessor containing keyframe input values, e.g., time
  83180. */
  83181. input: number;
  83182. /**
  83183. * Interpolation algorithm
  83184. */
  83185. interpolation?: AnimationSamplerInterpolation;
  83186. /**
  83187. * The index of an accessor, containing keyframe output values
  83188. */
  83189. output: number;
  83190. }
  83191. /**
  83192. * A keyframe animation
  83193. */
  83194. interface IAnimation extends IChildRootProperty {
  83195. /**
  83196. * An array of channels, each of which targets an animation's sampler at a node's property
  83197. */
  83198. channels: IAnimationChannel[];
  83199. /**
  83200. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  83201. */
  83202. samplers: IAnimationSampler[];
  83203. }
  83204. /**
  83205. * Metadata about the glTF asset
  83206. */
  83207. interface IAsset extends IChildRootProperty {
  83208. /**
  83209. * A copyright message suitable for display to credit the content creator
  83210. */
  83211. copyright?: string;
  83212. /**
  83213. * Tool that generated this glTF model. Useful for debugging
  83214. */
  83215. generator?: string;
  83216. /**
  83217. * The glTF version that this asset targets
  83218. */
  83219. version: string;
  83220. /**
  83221. * The minimum glTF version that this asset targets
  83222. */
  83223. minVersion?: string;
  83224. }
  83225. /**
  83226. * A buffer points to binary geometry, animation, or skins
  83227. */
  83228. interface IBuffer extends IChildRootProperty {
  83229. /**
  83230. * 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
  83231. */
  83232. uri?: string;
  83233. /**
  83234. * The length of the buffer in bytes
  83235. */
  83236. byteLength: number;
  83237. }
  83238. /**
  83239. * A view into a buffer generally representing a subset of the buffer
  83240. */
  83241. interface IBufferView extends IChildRootProperty {
  83242. /**
  83243. * The index of the buffer
  83244. */
  83245. buffer: number;
  83246. /**
  83247. * The offset into the buffer in bytes
  83248. */
  83249. byteOffset?: number;
  83250. /**
  83251. * The lenth of the bufferView in bytes
  83252. */
  83253. byteLength: number;
  83254. /**
  83255. * The stride, in bytes
  83256. */
  83257. byteStride?: number;
  83258. }
  83259. /**
  83260. * An orthographic camera containing properties to create an orthographic projection matrix
  83261. */
  83262. interface ICameraOrthographic extends IProperty {
  83263. /**
  83264. * The floating-point horizontal magnification of the view. Must not be zero
  83265. */
  83266. xmag: number;
  83267. /**
  83268. * The floating-point vertical magnification of the view. Must not be zero
  83269. */
  83270. ymag: number;
  83271. /**
  83272. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  83273. */
  83274. zfar: number;
  83275. /**
  83276. * The floating-point distance to the near clipping plane
  83277. */
  83278. znear: number;
  83279. }
  83280. /**
  83281. * A perspective camera containing properties to create a perspective projection matrix
  83282. */
  83283. interface ICameraPerspective extends IProperty {
  83284. /**
  83285. * The floating-point aspect ratio of the field of view
  83286. */
  83287. aspectRatio?: number;
  83288. /**
  83289. * The floating-point vertical field of view in radians
  83290. */
  83291. yfov: number;
  83292. /**
  83293. * The floating-point distance to the far clipping plane
  83294. */
  83295. zfar?: number;
  83296. /**
  83297. * The floating-point distance to the near clipping plane
  83298. */
  83299. znear: number;
  83300. }
  83301. /**
  83302. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  83303. */
  83304. interface ICamera extends IChildRootProperty {
  83305. /**
  83306. * An orthographic camera containing properties to create an orthographic projection matrix
  83307. */
  83308. orthographic?: ICameraOrthographic;
  83309. /**
  83310. * A perspective camera containing properties to create a perspective projection matrix
  83311. */
  83312. perspective?: ICameraPerspective;
  83313. /**
  83314. * Specifies if the camera uses a perspective or orthographic projection
  83315. */
  83316. type: CameraType;
  83317. }
  83318. /**
  83319. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  83320. */
  83321. interface IImage extends IChildRootProperty {
  83322. /**
  83323. * 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
  83324. */
  83325. uri?: string;
  83326. /**
  83327. * The image's MIME type
  83328. */
  83329. mimeType?: ImageMimeType;
  83330. /**
  83331. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  83332. */
  83333. bufferView?: number;
  83334. }
  83335. /**
  83336. * Material Normal Texture Info
  83337. */
  83338. interface IMaterialNormalTextureInfo extends ITextureInfo {
  83339. /**
  83340. * The scalar multiplier applied to each normal vector of the normal texture
  83341. */
  83342. scale?: number;
  83343. }
  83344. /**
  83345. * Material Occlusion Texture Info
  83346. */
  83347. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  83348. /**
  83349. * A scalar multiplier controlling the amount of occlusion applied
  83350. */
  83351. strength?: number;
  83352. }
  83353. /**
  83354. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  83355. */
  83356. interface IMaterialPbrMetallicRoughness {
  83357. /**
  83358. * The material's base color factor
  83359. */
  83360. baseColorFactor?: number[];
  83361. /**
  83362. * The base color texture
  83363. */
  83364. baseColorTexture?: ITextureInfo;
  83365. /**
  83366. * The metalness of the material
  83367. */
  83368. metallicFactor?: number;
  83369. /**
  83370. * The roughness of the material
  83371. */
  83372. roughnessFactor?: number;
  83373. /**
  83374. * The metallic-roughness texture
  83375. */
  83376. metallicRoughnessTexture?: ITextureInfo;
  83377. }
  83378. /**
  83379. * The material appearance of a primitive
  83380. */
  83381. interface IMaterial extends IChildRootProperty {
  83382. /**
  83383. * 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
  83384. */
  83385. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  83386. /**
  83387. * The normal map texture
  83388. */
  83389. normalTexture?: IMaterialNormalTextureInfo;
  83390. /**
  83391. * The occlusion map texture
  83392. */
  83393. occlusionTexture?: IMaterialOcclusionTextureInfo;
  83394. /**
  83395. * The emissive map texture
  83396. */
  83397. emissiveTexture?: ITextureInfo;
  83398. /**
  83399. * 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
  83400. */
  83401. emissiveFactor?: number[];
  83402. /**
  83403. * The alpha rendering mode of the material
  83404. */
  83405. alphaMode?: MaterialAlphaMode;
  83406. /**
  83407. * The alpha cutoff value of the material
  83408. */
  83409. alphaCutoff?: number;
  83410. /**
  83411. * Specifies whether the material is double sided
  83412. */
  83413. doubleSided?: boolean;
  83414. }
  83415. /**
  83416. * Geometry to be rendered with the given material
  83417. */
  83418. interface IMeshPrimitive extends IProperty {
  83419. /**
  83420. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  83421. */
  83422. attributes: {
  83423. [name: string]: number;
  83424. };
  83425. /**
  83426. * The index of the accessor that contains the indices
  83427. */
  83428. indices?: number;
  83429. /**
  83430. * The index of the material to apply to this primitive when rendering
  83431. */
  83432. material?: number;
  83433. /**
  83434. * The type of primitives to render. All valid values correspond to WebGL enums
  83435. */
  83436. mode?: MeshPrimitiveMode;
  83437. /**
  83438. * 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
  83439. */
  83440. targets?: {
  83441. [name: string]: number;
  83442. }[];
  83443. }
  83444. /**
  83445. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  83446. */
  83447. interface IMesh extends IChildRootProperty {
  83448. /**
  83449. * An array of primitives, each defining geometry to be rendered with a material
  83450. */
  83451. primitives: IMeshPrimitive[];
  83452. /**
  83453. * Array of weights to be applied to the Morph Targets
  83454. */
  83455. weights?: number[];
  83456. }
  83457. /**
  83458. * A node in the node hierarchy
  83459. */
  83460. interface INode extends IChildRootProperty {
  83461. /**
  83462. * The index of the camera referenced by this node
  83463. */
  83464. camera?: number;
  83465. /**
  83466. * The indices of this node's children
  83467. */
  83468. children?: number[];
  83469. /**
  83470. * The index of the skin referenced by this node
  83471. */
  83472. skin?: number;
  83473. /**
  83474. * A floating-point 4x4 transformation matrix stored in column-major order
  83475. */
  83476. matrix?: number[];
  83477. /**
  83478. * The index of the mesh in this node
  83479. */
  83480. mesh?: number;
  83481. /**
  83482. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  83483. */
  83484. rotation?: number[];
  83485. /**
  83486. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  83487. */
  83488. scale?: number[];
  83489. /**
  83490. * The node's translation along the x, y, and z axes
  83491. */
  83492. translation?: number[];
  83493. /**
  83494. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  83495. */
  83496. weights?: number[];
  83497. }
  83498. /**
  83499. * Texture sampler properties for filtering and wrapping modes
  83500. */
  83501. interface ISampler extends IChildRootProperty {
  83502. /**
  83503. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  83504. */
  83505. magFilter?: TextureMagFilter;
  83506. /**
  83507. * Minification filter. All valid values correspond to WebGL enums
  83508. */
  83509. minFilter?: TextureMinFilter;
  83510. /**
  83511. * S (U) wrapping mode. All valid values correspond to WebGL enums
  83512. */
  83513. wrapS?: TextureWrapMode;
  83514. /**
  83515. * T (V) wrapping mode. All valid values correspond to WebGL enums
  83516. */
  83517. wrapT?: TextureWrapMode;
  83518. }
  83519. /**
  83520. * The root nodes of a scene
  83521. */
  83522. interface IScene extends IChildRootProperty {
  83523. /**
  83524. * The indices of each root node
  83525. */
  83526. nodes: number[];
  83527. }
  83528. /**
  83529. * Joints and matrices defining a skin
  83530. */
  83531. interface ISkin extends IChildRootProperty {
  83532. /**
  83533. * 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
  83534. */
  83535. inverseBindMatrices?: number;
  83536. /**
  83537. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  83538. */
  83539. skeleton?: number;
  83540. /**
  83541. * 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)
  83542. */
  83543. joints: number[];
  83544. }
  83545. /**
  83546. * A texture and its sampler
  83547. */
  83548. interface ITexture extends IChildRootProperty {
  83549. /**
  83550. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  83551. */
  83552. sampler?: number;
  83553. /**
  83554. * The index of the image used by this texture
  83555. */
  83556. source: number;
  83557. }
  83558. /**
  83559. * Reference to a texture
  83560. */
  83561. interface ITextureInfo extends IProperty {
  83562. /**
  83563. * The index of the texture
  83564. */
  83565. index: number;
  83566. /**
  83567. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  83568. */
  83569. texCoord?: number;
  83570. }
  83571. /**
  83572. * The root object for a glTF asset
  83573. */
  83574. interface IGLTF extends IProperty {
  83575. /**
  83576. * An array of accessors. An accessor is a typed view into a bufferView
  83577. */
  83578. accessors?: IAccessor[];
  83579. /**
  83580. * An array of keyframe animations
  83581. */
  83582. animations?: IAnimation[];
  83583. /**
  83584. * Metadata about the glTF asset
  83585. */
  83586. asset: IAsset;
  83587. /**
  83588. * An array of buffers. A buffer points to binary geometry, animation, or skins
  83589. */
  83590. buffers?: IBuffer[];
  83591. /**
  83592. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  83593. */
  83594. bufferViews?: IBufferView[];
  83595. /**
  83596. * An array of cameras
  83597. */
  83598. cameras?: ICamera[];
  83599. /**
  83600. * Names of glTF extensions used somewhere in this asset
  83601. */
  83602. extensionsUsed?: string[];
  83603. /**
  83604. * Names of glTF extensions required to properly load this asset
  83605. */
  83606. extensionsRequired?: string[];
  83607. /**
  83608. * An array of images. An image defines data used to create a texture
  83609. */
  83610. images?: IImage[];
  83611. /**
  83612. * An array of materials. A material defines the appearance of a primitive
  83613. */
  83614. materials?: IMaterial[];
  83615. /**
  83616. * An array of meshes. A mesh is a set of primitives to be rendered
  83617. */
  83618. meshes?: IMesh[];
  83619. /**
  83620. * An array of nodes
  83621. */
  83622. nodes?: INode[];
  83623. /**
  83624. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  83625. */
  83626. samplers?: ISampler[];
  83627. /**
  83628. * The index of the default scene
  83629. */
  83630. scene?: number;
  83631. /**
  83632. * An array of scenes
  83633. */
  83634. scenes?: IScene[];
  83635. /**
  83636. * An array of skins. A skin is defined by joints and matrices
  83637. */
  83638. skins?: ISkin[];
  83639. /**
  83640. * An array of textures
  83641. */
  83642. textures?: ITexture[];
  83643. }
  83644. /**
  83645. * The glTF validation results
  83646. * @ignore
  83647. */
  83648. interface IGLTFValidationResults {
  83649. info: {
  83650. generator: string;
  83651. hasAnimations: boolean;
  83652. hasDefaultScene: boolean;
  83653. hasMaterials: boolean;
  83654. hasMorphTargets: boolean;
  83655. hasSkins: boolean;
  83656. hasTextures: boolean;
  83657. maxAttributesUsed: number;
  83658. primitivesCount: number
  83659. };
  83660. issues: {
  83661. messages: Array<string>;
  83662. numErrors: number;
  83663. numHints: number;
  83664. numInfos: number;
  83665. numWarnings: number;
  83666. truncated: boolean
  83667. };
  83668. mimeType: string;
  83669. uri: string;
  83670. validatedAt: string;
  83671. validatorVersion: string;
  83672. }
  83673. /**
  83674. * The glTF validation options
  83675. */
  83676. interface IGLTFValidationOptions {
  83677. /** Uri to use */
  83678. uri?: string;
  83679. /** Function used to load external resources */
  83680. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  83681. /** Boolean indicating that we need to validate accessor data */
  83682. validateAccessorData?: boolean;
  83683. /** max number of issues allowed */
  83684. maxIssues?: number;
  83685. /** Ignored issues */
  83686. ignoredIssues?: Array<string>;
  83687. /** Value to override severy settings */
  83688. severityOverrides?: Object;
  83689. }
  83690. /**
  83691. * The glTF validator object
  83692. * @ignore
  83693. */
  83694. interface IGLTFValidator {
  83695. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  83696. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  83697. }
  83698. /**
  83699. * Interfaces from the EXT_lights_image_based extension
  83700. */
  83701. /** @hidden */
  83702. interface IEXTLightsImageBased_LightReferenceImageBased {
  83703. light: number;
  83704. }
  83705. /** @hidden */
  83706. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  83707. intensity: number;
  83708. rotation: number[];
  83709. specularImageSize: number;
  83710. specularImages: number[][];
  83711. irradianceCoefficients: number[][];
  83712. }
  83713. /** @hidden */
  83714. interface IEXTLightsImageBased {
  83715. lights: IEXTLightsImageBased_LightImageBased[];
  83716. }
  83717. /**
  83718. * Interfaces from the EXT_mesh_gpu_instancing extension
  83719. * !!! Experimental Extension Subject to Changes !!!
  83720. */
  83721. /** @hidden */
  83722. interface IEXTMeshGpuInstancing {
  83723. mesh?: number;
  83724. attributes: { [name: string]: number };
  83725. }
  83726. /**
  83727. * Interfaces from the KHR_draco_mesh_compression extension
  83728. */
  83729. /** @hidden */
  83730. interface IKHRDracoMeshCompression {
  83731. bufferView: number;
  83732. attributes: { [name: string]: number };
  83733. }
  83734. /**
  83735. * Interfaces from the KHR_lights_punctual extension
  83736. */
  83737. /** @hidden */
  83738. const enum IKHRLightsPunctual_LightType {
  83739. DIRECTIONAL = "directional",
  83740. POINT = "point",
  83741. SPOT = "spot"
  83742. }
  83743. /** @hidden */
  83744. interface IKHRLightsPunctual_LightReference {
  83745. light: number;
  83746. }
  83747. /** @hidden */
  83748. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  83749. type: IKHRLightsPunctual_LightType;
  83750. color?: number[];
  83751. intensity?: number;
  83752. range?: number;
  83753. spot?: {
  83754. innerConeAngle?: number;
  83755. outerConeAngle?: number;
  83756. };
  83757. }
  83758. /** @hidden */
  83759. interface IKHRLightsPunctual {
  83760. lights: IKHRLightsPunctual_Light[];
  83761. }
  83762. /**
  83763. * Interfaces from the KHR_materials_clearcoat extension
  83764. * !!! Experimental Extension Subject to Changes !!!
  83765. */
  83766. /** @hidden */
  83767. interface IKHRMaterialsClearcoat {
  83768. clearcoatFactor: number;
  83769. clearcoatTexture: ITextureInfo;
  83770. clearcoatRoughnessFactor: number;
  83771. clearcoatRoughnessTexture: ITextureInfo;
  83772. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  83773. }
  83774. /**
  83775. * Interfaces from the KHR_materials_ior extension
  83776. * !!! Experimental Extension Subject to Changes !!!
  83777. */
  83778. /** @hidden */
  83779. interface IKHRMaterialsIor {
  83780. ior: number;
  83781. }
  83782. /**
  83783. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  83784. */
  83785. /** @hidden */
  83786. interface IKHRMaterialsPbrSpecularGlossiness {
  83787. diffuseFactor: number[];
  83788. diffuseTexture: ITextureInfo;
  83789. specularFactor: number[];
  83790. glossinessFactor: number;
  83791. specularGlossinessTexture: ITextureInfo;
  83792. }
  83793. /**
  83794. * Interfaces from the KHR_materials_sheen extension
  83795. * !!! Experimental Extension Subject to Changes !!!
  83796. */
  83797. /** @hidden */
  83798. interface IKHRMaterialsSheen {
  83799. sheenColorFactor?: number[];
  83800. sheenTexture?: ITextureInfo;
  83801. sheenRoughnessFactor?: number;
  83802. }
  83803. /**
  83804. * Interfaces from the KHR_materials_specular extension
  83805. * !!! Experimental Extension Subject to Changes !!!
  83806. */
  83807. /** @hidden */
  83808. interface IKHRMaterialsSpecular {
  83809. specularFactor: number;
  83810. specularColorFactor: number[];
  83811. specularTexture: ITextureInfo;
  83812. }
  83813. /**
  83814. * Interfaces from the KHR_materials_transmission extension
  83815. * !!! Experimental Extension Subject to Changes !!!
  83816. */
  83817. /** @hidden */
  83818. interface IKHRMaterialsTransmission {
  83819. transmissionFactor?: number;
  83820. transmissionTexture?: ITextureInfo;
  83821. }
  83822. /**
  83823. * Interfaces from the KHR_materials_variants extension
  83824. * !!! Experimental Extension Subject to Changes !!!
  83825. */
  83826. /** @hidden */
  83827. interface IKHRMaterialVariants_Mapping {
  83828. tags: string[];
  83829. material: number;
  83830. }
  83831. /** @hidden */
  83832. interface IKHRMaterialVariants {
  83833. mapping: IKHRMaterialVariants_Mapping[];
  83834. }
  83835. /**
  83836. * Interfaces from the KHR_texture_basisu extension
  83837. * !!! Experimental Extension Subject to Changes !!!
  83838. */
  83839. /** @hidden */
  83840. interface IKHRTextureBasisU {
  83841. source: number;
  83842. }
  83843. /**
  83844. * Interfaces from the KHR_texture_transform extension
  83845. */
  83846. /** @hidden */
  83847. interface IKHRTextureTransform {
  83848. offset?: number[];
  83849. rotation?: number;
  83850. scale?: number[];
  83851. texCoord?: number;
  83852. }
  83853. /**
  83854. * Interfaces from the KHR_xmp extension
  83855. * !!! Experimental Extension Subject to Changes !!!
  83856. */
  83857. /** @hidden */
  83858. interface IKHRXmp_Data {
  83859. [key: string]: unknown;
  83860. }
  83861. /** @hidden */
  83862. interface IKHRXmp_Gltf {
  83863. packets: IKHRXmp_Data[];
  83864. }
  83865. /** @hidden */
  83866. interface IKHRXmp_Node {
  83867. packet: number;
  83868. }
  83869. /**
  83870. * Interfaces from the MSFT_audio_emitter extension
  83871. */
  83872. /** @hidden */
  83873. interface IMSFTAudioEmitter_ClipReference {
  83874. clip: number;
  83875. weight?: number;
  83876. }
  83877. /** @hidden */
  83878. interface IMSFTAudioEmitter_EmittersReference {
  83879. emitters: number[];
  83880. }
  83881. /** @hidden */
  83882. const enum IMSFTAudioEmitter_DistanceModel {
  83883. linear = "linear",
  83884. inverse = "inverse",
  83885. exponential = "exponential",
  83886. }
  83887. /** @hidden */
  83888. interface IMSFTAudioEmitter_Emitter {
  83889. name?: string;
  83890. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  83891. refDistance?: number;
  83892. maxDistance?: number;
  83893. rolloffFactor?: number;
  83894. innerAngle?: number;
  83895. outerAngle?: number;
  83896. loop?: boolean;
  83897. volume?: number;
  83898. clips: IMSFTAudioEmitter_ClipReference[];
  83899. }
  83900. /** @hidden */
  83901. const enum IMSFTAudioEmitter_AudioMimeType {
  83902. WAV = "audio/wav",
  83903. }
  83904. /** @hidden */
  83905. interface IMSFTAudioEmitter_Clip extends IProperty {
  83906. uri?: string;
  83907. bufferView?: number;
  83908. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  83909. }
  83910. /** @hidden */
  83911. const enum IMSFTAudioEmitter_AnimationEventAction {
  83912. play = "play",
  83913. pause = "pause",
  83914. stop = "stop",
  83915. }
  83916. /** @hidden */
  83917. interface IMSFTAudioEmitter_AnimationEvent {
  83918. action: IMSFTAudioEmitter_AnimationEventAction;
  83919. emitter: number;
  83920. time: number;
  83921. startOffset?: number;
  83922. }
  83923. /**
  83924. * Interfaces from the MSFT_lod extension
  83925. */
  83926. /** @hidden */
  83927. interface IMSFTLOD {
  83928. ids: number[];
  83929. }
  83930. }
  83931. declare module BABYLON {
  83932. /** @hidden */
  83933. export var cellPixelShader: {
  83934. name: string;
  83935. shader: string;
  83936. };
  83937. }
  83938. declare module BABYLON {
  83939. /** @hidden */
  83940. export var cellVertexShader: {
  83941. name: string;
  83942. shader: string;
  83943. };
  83944. }
  83945. declare module BABYLON {
  83946. export class CellMaterial extends BABYLON.PushMaterial {
  83947. private _diffuseTexture;
  83948. diffuseTexture: BABYLON.BaseTexture;
  83949. diffuseColor: BABYLON.Color3;
  83950. _computeHighLevel: boolean;
  83951. computeHighLevel: boolean;
  83952. private _disableLighting;
  83953. disableLighting: boolean;
  83954. private _maxSimultaneousLights;
  83955. maxSimultaneousLights: number;
  83956. constructor(name: string, scene: BABYLON.Scene);
  83957. needAlphaBlending(): boolean;
  83958. needAlphaTesting(): boolean;
  83959. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83960. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83961. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83962. getAnimatables(): BABYLON.IAnimatable[];
  83963. getActiveTextures(): BABYLON.BaseTexture[];
  83964. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83965. dispose(forceDisposeEffect?: boolean): void;
  83966. getClassName(): string;
  83967. clone(name: string): CellMaterial;
  83968. serialize(): any;
  83969. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  83970. }
  83971. }
  83972. declare module BABYLON {
  83973. export class CustomShaderStructure {
  83974. FragmentStore: string;
  83975. VertexStore: string;
  83976. constructor();
  83977. }
  83978. export class ShaderSpecialParts {
  83979. constructor();
  83980. Fragment_Begin: string;
  83981. Fragment_Definitions: string;
  83982. Fragment_MainBegin: string;
  83983. Fragment_Custom_Diffuse: string;
  83984. Fragment_Before_Lights: string;
  83985. Fragment_Before_Fog: string;
  83986. Fragment_Custom_Alpha: string;
  83987. Fragment_Before_FragColor: string;
  83988. Vertex_Begin: string;
  83989. Vertex_Definitions: string;
  83990. Vertex_MainBegin: string;
  83991. Vertex_Before_PositionUpdated: string;
  83992. Vertex_Before_NormalUpdated: string;
  83993. Vertex_After_WorldPosComputed: string;
  83994. Vertex_MainEnd: string;
  83995. }
  83996. export class CustomMaterial extends BABYLON.StandardMaterial {
  83997. static ShaderIndexer: number;
  83998. CustomParts: ShaderSpecialParts;
  83999. _isCreatedShader: boolean;
  84000. _createdShaderName: string;
  84001. _customUniform: string[];
  84002. _newUniforms: string[];
  84003. _newUniformInstances: {
  84004. [name: string]: any;
  84005. };
  84006. _newSamplerInstances: {
  84007. [name: string]: BABYLON.Texture;
  84008. };
  84009. _customAttributes: string[];
  84010. FragmentShader: string;
  84011. VertexShader: string;
  84012. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  84013. ReviewUniform(name: string, arr: string[]): string[];
  84014. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  84015. constructor(name: string, scene: BABYLON.Scene);
  84016. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  84017. AddAttribute(name: string): CustomMaterial;
  84018. Fragment_Begin(shaderPart: string): CustomMaterial;
  84019. Fragment_Definitions(shaderPart: string): CustomMaterial;
  84020. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  84021. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  84022. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  84023. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  84024. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  84025. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  84026. Vertex_Begin(shaderPart: string): CustomMaterial;
  84027. Vertex_Definitions(shaderPart: string): CustomMaterial;
  84028. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  84029. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  84030. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  84031. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  84032. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  84033. }
  84034. }
  84035. declare module BABYLON {
  84036. export class ShaderAlebdoParts {
  84037. constructor();
  84038. Fragment_Begin: string;
  84039. Fragment_Definitions: string;
  84040. Fragment_MainBegin: string;
  84041. Fragment_Custom_Albedo: string;
  84042. Fragment_Before_Lights: string;
  84043. Fragment_Custom_MetallicRoughness: string;
  84044. Fragment_Custom_MicroSurface: string;
  84045. Fragment_Before_Fog: string;
  84046. Fragment_Custom_Alpha: string;
  84047. Fragment_Before_FragColor: string;
  84048. Vertex_Begin: string;
  84049. Vertex_Definitions: string;
  84050. Vertex_MainBegin: string;
  84051. Vertex_Before_PositionUpdated: string;
  84052. Vertex_Before_NormalUpdated: string;
  84053. Vertex_After_WorldPosComputed: string;
  84054. Vertex_MainEnd: string;
  84055. }
  84056. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  84057. static ShaderIndexer: number;
  84058. CustomParts: ShaderAlebdoParts;
  84059. _isCreatedShader: boolean;
  84060. _createdShaderName: string;
  84061. _customUniform: string[];
  84062. _newUniforms: string[];
  84063. _newUniformInstances: {
  84064. [name: string]: any;
  84065. };
  84066. _newSamplerInstances: {
  84067. [name: string]: BABYLON.Texture;
  84068. };
  84069. _customAttributes: string[];
  84070. FragmentShader: string;
  84071. VertexShader: string;
  84072. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  84073. ReviewUniform(name: string, arr: string[]): string[];
  84074. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  84075. constructor(name: string, scene: BABYLON.Scene);
  84076. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  84077. AddAttribute(name: string): PBRCustomMaterial;
  84078. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  84079. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  84080. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  84081. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  84082. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  84083. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  84084. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  84085. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  84086. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  84087. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  84088. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  84089. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  84090. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  84091. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  84092. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  84093. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  84094. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  84095. }
  84096. }
  84097. declare module BABYLON {
  84098. /** @hidden */
  84099. export var firePixelShader: {
  84100. name: string;
  84101. shader: string;
  84102. };
  84103. }
  84104. declare module BABYLON {
  84105. /** @hidden */
  84106. export var fireVertexShader: {
  84107. name: string;
  84108. shader: string;
  84109. };
  84110. }
  84111. declare module BABYLON {
  84112. export class FireMaterial extends BABYLON.PushMaterial {
  84113. private _diffuseTexture;
  84114. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  84115. private _distortionTexture;
  84116. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  84117. private _opacityTexture;
  84118. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  84119. diffuseColor: BABYLON.Color3;
  84120. speed: number;
  84121. private _scaledDiffuse;
  84122. private _lastTime;
  84123. constructor(name: string, scene: BABYLON.Scene);
  84124. needAlphaBlending(): boolean;
  84125. needAlphaTesting(): boolean;
  84126. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84127. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84128. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84129. getAnimatables(): BABYLON.IAnimatable[];
  84130. getActiveTextures(): BABYLON.BaseTexture[];
  84131. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84132. getClassName(): string;
  84133. dispose(forceDisposeEffect?: boolean): void;
  84134. clone(name: string): FireMaterial;
  84135. serialize(): any;
  84136. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  84137. }
  84138. }
  84139. declare module BABYLON {
  84140. /** @hidden */
  84141. export var furPixelShader: {
  84142. name: string;
  84143. shader: string;
  84144. };
  84145. }
  84146. declare module BABYLON {
  84147. /** @hidden */
  84148. export var furVertexShader: {
  84149. name: string;
  84150. shader: string;
  84151. };
  84152. }
  84153. declare module BABYLON {
  84154. export class FurMaterial extends BABYLON.PushMaterial {
  84155. private _diffuseTexture;
  84156. diffuseTexture: BABYLON.BaseTexture;
  84157. private _heightTexture;
  84158. heightTexture: BABYLON.BaseTexture;
  84159. diffuseColor: BABYLON.Color3;
  84160. furLength: number;
  84161. furAngle: number;
  84162. furColor: BABYLON.Color3;
  84163. furOffset: number;
  84164. furSpacing: number;
  84165. furGravity: BABYLON.Vector3;
  84166. furSpeed: number;
  84167. furDensity: number;
  84168. furOcclusion: number;
  84169. furTexture: BABYLON.DynamicTexture;
  84170. private _disableLighting;
  84171. disableLighting: boolean;
  84172. private _maxSimultaneousLights;
  84173. maxSimultaneousLights: number;
  84174. highLevelFur: boolean;
  84175. _meshes: BABYLON.AbstractMesh[];
  84176. private _furTime;
  84177. constructor(name: string, scene: BABYLON.Scene);
  84178. get furTime(): number;
  84179. set furTime(furTime: number);
  84180. needAlphaBlending(): boolean;
  84181. needAlphaTesting(): boolean;
  84182. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84183. updateFur(): void;
  84184. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84185. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84186. getAnimatables(): BABYLON.IAnimatable[];
  84187. getActiveTextures(): BABYLON.BaseTexture[];
  84188. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84189. dispose(forceDisposeEffect?: boolean): void;
  84190. clone(name: string): FurMaterial;
  84191. serialize(): any;
  84192. getClassName(): string;
  84193. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  84194. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  84195. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  84196. }
  84197. }
  84198. declare module BABYLON {
  84199. /** @hidden */
  84200. export var gradientPixelShader: {
  84201. name: string;
  84202. shader: string;
  84203. };
  84204. }
  84205. declare module BABYLON {
  84206. /** @hidden */
  84207. export var gradientVertexShader: {
  84208. name: string;
  84209. shader: string;
  84210. };
  84211. }
  84212. declare module BABYLON {
  84213. export class GradientMaterial extends BABYLON.PushMaterial {
  84214. private _maxSimultaneousLights;
  84215. maxSimultaneousLights: number;
  84216. topColor: BABYLON.Color3;
  84217. topColorAlpha: number;
  84218. bottomColor: BABYLON.Color3;
  84219. bottomColorAlpha: number;
  84220. offset: number;
  84221. scale: number;
  84222. smoothness: number;
  84223. private _disableLighting;
  84224. disableLighting: boolean;
  84225. constructor(name: string, scene: BABYLON.Scene);
  84226. needAlphaBlending(): boolean;
  84227. needAlphaTesting(): boolean;
  84228. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84229. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84230. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84231. getAnimatables(): BABYLON.IAnimatable[];
  84232. dispose(forceDisposeEffect?: boolean): void;
  84233. clone(name: string): GradientMaterial;
  84234. serialize(): any;
  84235. getClassName(): string;
  84236. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  84237. }
  84238. }
  84239. declare module BABYLON {
  84240. /** @hidden */
  84241. export var gridPixelShader: {
  84242. name: string;
  84243. shader: string;
  84244. };
  84245. }
  84246. declare module BABYLON {
  84247. /** @hidden */
  84248. export var gridVertexShader: {
  84249. name: string;
  84250. shader: string;
  84251. };
  84252. }
  84253. declare module BABYLON {
  84254. /**
  84255. * The grid materials allows you to wrap any shape with a grid.
  84256. * Colors are customizable.
  84257. */
  84258. export class GridMaterial extends BABYLON.PushMaterial {
  84259. /**
  84260. * Main color of the grid (e.g. between lines)
  84261. */
  84262. mainColor: BABYLON.Color3;
  84263. /**
  84264. * Color of the grid lines.
  84265. */
  84266. lineColor: BABYLON.Color3;
  84267. /**
  84268. * The scale of the grid compared to unit.
  84269. */
  84270. gridRatio: number;
  84271. /**
  84272. * Allows setting an offset for the grid lines.
  84273. */
  84274. gridOffset: BABYLON.Vector3;
  84275. /**
  84276. * The frequency of thicker lines.
  84277. */
  84278. majorUnitFrequency: number;
  84279. /**
  84280. * The visibility of minor units in the grid.
  84281. */
  84282. minorUnitVisibility: number;
  84283. /**
  84284. * The grid opacity outside of the lines.
  84285. */
  84286. opacity: number;
  84287. /**
  84288. * Determine RBG output is premultiplied by alpha value.
  84289. */
  84290. preMultiplyAlpha: boolean;
  84291. private _opacityTexture;
  84292. opacityTexture: BABYLON.BaseTexture;
  84293. private _gridControl;
  84294. /**
  84295. * constructor
  84296. * @param name The name given to the material in order to identify it afterwards.
  84297. * @param scene The scene the material is used in.
  84298. */
  84299. constructor(name: string, scene: BABYLON.Scene);
  84300. /**
  84301. * Returns wehter or not the grid requires alpha blending.
  84302. */
  84303. needAlphaBlending(): boolean;
  84304. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  84305. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84306. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84307. /**
  84308. * Dispose the material and its associated resources.
  84309. * @param forceDisposeEffect will also dispose the used effect when true
  84310. */
  84311. dispose(forceDisposeEffect?: boolean): void;
  84312. clone(name: string): GridMaterial;
  84313. serialize(): any;
  84314. getClassName(): string;
  84315. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  84316. }
  84317. }
  84318. declare module BABYLON {
  84319. /** @hidden */
  84320. export var lavaPixelShader: {
  84321. name: string;
  84322. shader: string;
  84323. };
  84324. }
  84325. declare module BABYLON {
  84326. /** @hidden */
  84327. export var lavaVertexShader: {
  84328. name: string;
  84329. shader: string;
  84330. };
  84331. }
  84332. declare module BABYLON {
  84333. export class LavaMaterial extends BABYLON.PushMaterial {
  84334. private _diffuseTexture;
  84335. diffuseTexture: BABYLON.BaseTexture;
  84336. noiseTexture: BABYLON.BaseTexture;
  84337. fogColor: BABYLON.Color3;
  84338. speed: number;
  84339. movingSpeed: number;
  84340. lowFrequencySpeed: number;
  84341. fogDensity: number;
  84342. private _lastTime;
  84343. diffuseColor: BABYLON.Color3;
  84344. private _disableLighting;
  84345. disableLighting: boolean;
  84346. private _unlit;
  84347. unlit: boolean;
  84348. private _maxSimultaneousLights;
  84349. maxSimultaneousLights: number;
  84350. private _scaledDiffuse;
  84351. constructor(name: string, scene: BABYLON.Scene);
  84352. needAlphaBlending(): boolean;
  84353. needAlphaTesting(): boolean;
  84354. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84355. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84356. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84357. getAnimatables(): BABYLON.IAnimatable[];
  84358. getActiveTextures(): BABYLON.BaseTexture[];
  84359. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84360. dispose(forceDisposeEffect?: boolean): void;
  84361. clone(name: string): LavaMaterial;
  84362. serialize(): any;
  84363. getClassName(): string;
  84364. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  84365. }
  84366. }
  84367. declare module BABYLON {
  84368. /** @hidden */
  84369. export var mixPixelShader: {
  84370. name: string;
  84371. shader: string;
  84372. };
  84373. }
  84374. declare module BABYLON {
  84375. /** @hidden */
  84376. export var mixVertexShader: {
  84377. name: string;
  84378. shader: string;
  84379. };
  84380. }
  84381. declare module BABYLON {
  84382. export class MixMaterial extends BABYLON.PushMaterial {
  84383. /**
  84384. * Mix textures
  84385. */
  84386. private _mixTexture1;
  84387. mixTexture1: BABYLON.BaseTexture;
  84388. private _mixTexture2;
  84389. mixTexture2: BABYLON.BaseTexture;
  84390. /**
  84391. * Diffuse textures
  84392. */
  84393. private _diffuseTexture1;
  84394. diffuseTexture1: BABYLON.Texture;
  84395. private _diffuseTexture2;
  84396. diffuseTexture2: BABYLON.Texture;
  84397. private _diffuseTexture3;
  84398. diffuseTexture3: BABYLON.Texture;
  84399. private _diffuseTexture4;
  84400. diffuseTexture4: BABYLON.Texture;
  84401. private _diffuseTexture5;
  84402. diffuseTexture5: BABYLON.Texture;
  84403. private _diffuseTexture6;
  84404. diffuseTexture6: BABYLON.Texture;
  84405. private _diffuseTexture7;
  84406. diffuseTexture7: BABYLON.Texture;
  84407. private _diffuseTexture8;
  84408. diffuseTexture8: BABYLON.Texture;
  84409. /**
  84410. * Uniforms
  84411. */
  84412. diffuseColor: BABYLON.Color3;
  84413. specularColor: BABYLON.Color3;
  84414. specularPower: number;
  84415. private _disableLighting;
  84416. disableLighting: boolean;
  84417. private _maxSimultaneousLights;
  84418. maxSimultaneousLights: number;
  84419. constructor(name: string, scene: BABYLON.Scene);
  84420. needAlphaBlending(): boolean;
  84421. needAlphaTesting(): boolean;
  84422. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84423. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84424. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84425. getAnimatables(): BABYLON.IAnimatable[];
  84426. getActiveTextures(): BABYLON.BaseTexture[];
  84427. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84428. dispose(forceDisposeEffect?: boolean): void;
  84429. clone(name: string): MixMaterial;
  84430. serialize(): any;
  84431. getClassName(): string;
  84432. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  84433. }
  84434. }
  84435. declare module BABYLON {
  84436. /** @hidden */
  84437. export var normalPixelShader: {
  84438. name: string;
  84439. shader: string;
  84440. };
  84441. }
  84442. declare module BABYLON {
  84443. /** @hidden */
  84444. export var normalVertexShader: {
  84445. name: string;
  84446. shader: string;
  84447. };
  84448. }
  84449. declare module BABYLON {
  84450. export class NormalMaterial extends BABYLON.PushMaterial {
  84451. private _diffuseTexture;
  84452. diffuseTexture: BABYLON.BaseTexture;
  84453. diffuseColor: BABYLON.Color3;
  84454. private _disableLighting;
  84455. disableLighting: boolean;
  84456. private _maxSimultaneousLights;
  84457. maxSimultaneousLights: number;
  84458. constructor(name: string, scene: BABYLON.Scene);
  84459. needAlphaBlending(): boolean;
  84460. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  84461. needAlphaTesting(): boolean;
  84462. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84463. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84464. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84465. getAnimatables(): BABYLON.IAnimatable[];
  84466. getActiveTextures(): BABYLON.BaseTexture[];
  84467. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84468. dispose(forceDisposeEffect?: boolean): void;
  84469. clone(name: string): NormalMaterial;
  84470. serialize(): any;
  84471. getClassName(): string;
  84472. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  84473. }
  84474. }
  84475. declare module BABYLON {
  84476. /** @hidden */
  84477. export var shadowOnlyPixelShader: {
  84478. name: string;
  84479. shader: string;
  84480. };
  84481. }
  84482. declare module BABYLON {
  84483. /** @hidden */
  84484. export var shadowOnlyVertexShader: {
  84485. name: string;
  84486. shader: string;
  84487. };
  84488. }
  84489. declare module BABYLON {
  84490. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  84491. private _activeLight;
  84492. private _needAlphaBlending;
  84493. constructor(name: string, scene: BABYLON.Scene);
  84494. shadowColor: BABYLON.Color3;
  84495. needAlphaBlending(): boolean;
  84496. needAlphaTesting(): boolean;
  84497. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84498. get activeLight(): BABYLON.IShadowLight;
  84499. set activeLight(light: BABYLON.IShadowLight);
  84500. private _getFirstShadowLightForMesh;
  84501. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84502. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84503. clone(name: string): ShadowOnlyMaterial;
  84504. serialize(): any;
  84505. getClassName(): string;
  84506. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  84507. }
  84508. }
  84509. declare module BABYLON {
  84510. /** @hidden */
  84511. export var simplePixelShader: {
  84512. name: string;
  84513. shader: string;
  84514. };
  84515. }
  84516. declare module BABYLON {
  84517. /** @hidden */
  84518. export var simpleVertexShader: {
  84519. name: string;
  84520. shader: string;
  84521. };
  84522. }
  84523. declare module BABYLON {
  84524. export class SimpleMaterial extends BABYLON.PushMaterial {
  84525. private _diffuseTexture;
  84526. diffuseTexture: BABYLON.BaseTexture;
  84527. diffuseColor: BABYLON.Color3;
  84528. private _disableLighting;
  84529. disableLighting: boolean;
  84530. private _maxSimultaneousLights;
  84531. maxSimultaneousLights: number;
  84532. constructor(name: string, scene: BABYLON.Scene);
  84533. needAlphaBlending(): boolean;
  84534. needAlphaTesting(): boolean;
  84535. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84536. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84537. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84538. getAnimatables(): BABYLON.IAnimatable[];
  84539. getActiveTextures(): BABYLON.BaseTexture[];
  84540. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84541. dispose(forceDisposeEffect?: boolean): void;
  84542. clone(name: string): SimpleMaterial;
  84543. serialize(): any;
  84544. getClassName(): string;
  84545. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  84546. }
  84547. }
  84548. declare module BABYLON {
  84549. /** @hidden */
  84550. export var skyPixelShader: {
  84551. name: string;
  84552. shader: string;
  84553. };
  84554. }
  84555. declare module BABYLON {
  84556. /** @hidden */
  84557. export var skyVertexShader: {
  84558. name: string;
  84559. shader: string;
  84560. };
  84561. }
  84562. declare module BABYLON {
  84563. /**
  84564. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  84565. * @see https://doc.babylonjs.com/extensions/sky
  84566. */
  84567. export class SkyMaterial extends BABYLON.PushMaterial {
  84568. /**
  84569. * Defines the overall luminance of sky in interval ]0, 1[.
  84570. */
  84571. luminance: number;
  84572. /**
  84573. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  84574. */
  84575. turbidity: number;
  84576. /**
  84577. * Defines the sky appearance (light intensity).
  84578. */
  84579. rayleigh: number;
  84580. /**
  84581. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  84582. */
  84583. mieCoefficient: number;
  84584. /**
  84585. * Defines the amount of haze particles following the Mie scattering theory.
  84586. */
  84587. mieDirectionalG: number;
  84588. /**
  84589. * Defines the distance of the sun according to the active scene camera.
  84590. */
  84591. distance: number;
  84592. /**
  84593. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  84594. * "inclined".
  84595. */
  84596. inclination: number;
  84597. /**
  84598. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  84599. * an object direction and a reference direction.
  84600. */
  84601. azimuth: number;
  84602. /**
  84603. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  84604. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  84605. */
  84606. sunPosition: BABYLON.Vector3;
  84607. /**
  84608. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  84609. * .sunPosition property.
  84610. */
  84611. useSunPosition: boolean;
  84612. /**
  84613. * Defines an offset vector used to get a horizon offset.
  84614. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  84615. */
  84616. cameraOffset: BABYLON.Vector3;
  84617. private _cameraPosition;
  84618. /**
  84619. * Instantiates a new sky material.
  84620. * This material allows to create dynamic and texture free
  84621. * effects for skyboxes by taking care of the atmosphere state.
  84622. * @see https://doc.babylonjs.com/extensions/sky
  84623. * @param name Define the name of the material in the scene
  84624. * @param scene Define the scene the material belong to
  84625. */
  84626. constructor(name: string, scene: BABYLON.Scene);
  84627. /**
  84628. * Specifies if the material will require alpha blending
  84629. * @returns a boolean specifying if alpha blending is needed
  84630. */
  84631. needAlphaBlending(): boolean;
  84632. /**
  84633. * Specifies if this material should be rendered in alpha test mode
  84634. * @returns false as the sky material doesn't need alpha testing.
  84635. */
  84636. needAlphaTesting(): boolean;
  84637. /**
  84638. * Get the texture used for alpha test purpose.
  84639. * @returns null as the sky material has no texture.
  84640. */
  84641. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84642. /**
  84643. * Get if the submesh is ready to be used and all its information available.
  84644. * Child classes can use it to update shaders
  84645. * @param mesh defines the mesh to check
  84646. * @param subMesh defines which submesh to check
  84647. * @param useInstances specifies that instances should be used
  84648. * @returns a boolean indicating that the submesh is ready or not
  84649. */
  84650. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84651. /**
  84652. * Binds the submesh to this material by preparing the effect and shader to draw
  84653. * @param world defines the world transformation matrix
  84654. * @param mesh defines the mesh containing the submesh
  84655. * @param subMesh defines the submesh to bind the material to
  84656. */
  84657. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84658. /**
  84659. * Get the list of animatables in the material.
  84660. * @returns the list of animatables object used in the material
  84661. */
  84662. getAnimatables(): BABYLON.IAnimatable[];
  84663. /**
  84664. * Disposes the material
  84665. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  84666. */
  84667. dispose(forceDisposeEffect?: boolean): void;
  84668. /**
  84669. * Makes a duplicate of the material, and gives it a new name
  84670. * @param name defines the new name for the duplicated material
  84671. * @returns the cloned material
  84672. */
  84673. clone(name: string): SkyMaterial;
  84674. /**
  84675. * Serializes this material in a JSON representation
  84676. * @returns the serialized material object
  84677. */
  84678. serialize(): any;
  84679. /**
  84680. * Gets the current class name of the material e.g. "SkyMaterial"
  84681. * Mainly use in serialization.
  84682. * @returns the class name
  84683. */
  84684. getClassName(): string;
  84685. /**
  84686. * Creates a sky material from parsed material data
  84687. * @param source defines the JSON representation of the material
  84688. * @param scene defines the hosting scene
  84689. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  84690. * @returns a new sky material
  84691. */
  84692. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  84693. }
  84694. }
  84695. declare module BABYLON {
  84696. /** @hidden */
  84697. export var terrainPixelShader: {
  84698. name: string;
  84699. shader: string;
  84700. };
  84701. }
  84702. declare module BABYLON {
  84703. /** @hidden */
  84704. export var terrainVertexShader: {
  84705. name: string;
  84706. shader: string;
  84707. };
  84708. }
  84709. declare module BABYLON {
  84710. export class TerrainMaterial extends BABYLON.PushMaterial {
  84711. private _mixTexture;
  84712. mixTexture: BABYLON.BaseTexture;
  84713. private _diffuseTexture1;
  84714. diffuseTexture1: BABYLON.Texture;
  84715. private _diffuseTexture2;
  84716. diffuseTexture2: BABYLON.Texture;
  84717. private _diffuseTexture3;
  84718. diffuseTexture3: BABYLON.Texture;
  84719. private _bumpTexture1;
  84720. bumpTexture1: BABYLON.Texture;
  84721. private _bumpTexture2;
  84722. bumpTexture2: BABYLON.Texture;
  84723. private _bumpTexture3;
  84724. bumpTexture3: BABYLON.Texture;
  84725. diffuseColor: BABYLON.Color3;
  84726. specularColor: BABYLON.Color3;
  84727. specularPower: number;
  84728. private _disableLighting;
  84729. disableLighting: boolean;
  84730. private _maxSimultaneousLights;
  84731. maxSimultaneousLights: number;
  84732. constructor(name: string, scene: BABYLON.Scene);
  84733. needAlphaBlending(): boolean;
  84734. needAlphaTesting(): boolean;
  84735. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84736. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84737. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84738. getAnimatables(): BABYLON.IAnimatable[];
  84739. getActiveTextures(): BABYLON.BaseTexture[];
  84740. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84741. dispose(forceDisposeEffect?: boolean): void;
  84742. clone(name: string): TerrainMaterial;
  84743. serialize(): any;
  84744. getClassName(): string;
  84745. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  84746. }
  84747. }
  84748. declare module BABYLON {
  84749. /** @hidden */
  84750. export var triplanarPixelShader: {
  84751. name: string;
  84752. shader: string;
  84753. };
  84754. }
  84755. declare module BABYLON {
  84756. /** @hidden */
  84757. export var triplanarVertexShader: {
  84758. name: string;
  84759. shader: string;
  84760. };
  84761. }
  84762. declare module BABYLON {
  84763. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  84764. mixTexture: BABYLON.BaseTexture;
  84765. private _diffuseTextureX;
  84766. diffuseTextureX: BABYLON.BaseTexture;
  84767. private _diffuseTextureY;
  84768. diffuseTextureY: BABYLON.BaseTexture;
  84769. private _diffuseTextureZ;
  84770. diffuseTextureZ: BABYLON.BaseTexture;
  84771. private _normalTextureX;
  84772. normalTextureX: BABYLON.BaseTexture;
  84773. private _normalTextureY;
  84774. normalTextureY: BABYLON.BaseTexture;
  84775. private _normalTextureZ;
  84776. normalTextureZ: BABYLON.BaseTexture;
  84777. tileSize: number;
  84778. diffuseColor: BABYLON.Color3;
  84779. specularColor: BABYLON.Color3;
  84780. specularPower: number;
  84781. private _disableLighting;
  84782. disableLighting: boolean;
  84783. private _maxSimultaneousLights;
  84784. maxSimultaneousLights: number;
  84785. constructor(name: string, scene: BABYLON.Scene);
  84786. needAlphaBlending(): boolean;
  84787. needAlphaTesting(): boolean;
  84788. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84789. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84790. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84791. getAnimatables(): BABYLON.IAnimatable[];
  84792. getActiveTextures(): BABYLON.BaseTexture[];
  84793. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84794. dispose(forceDisposeEffect?: boolean): void;
  84795. clone(name: string): TriPlanarMaterial;
  84796. serialize(): any;
  84797. getClassName(): string;
  84798. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  84799. }
  84800. }
  84801. declare module BABYLON {
  84802. /** @hidden */
  84803. export var waterPixelShader: {
  84804. name: string;
  84805. shader: string;
  84806. };
  84807. }
  84808. declare module BABYLON {
  84809. /** @hidden */
  84810. export var waterVertexShader: {
  84811. name: string;
  84812. shader: string;
  84813. };
  84814. }
  84815. declare module BABYLON {
  84816. export class WaterMaterial extends BABYLON.PushMaterial {
  84817. renderTargetSize: BABYLON.Vector2;
  84818. private _bumpTexture;
  84819. bumpTexture: BABYLON.BaseTexture;
  84820. diffuseColor: BABYLON.Color3;
  84821. specularColor: BABYLON.Color3;
  84822. specularPower: number;
  84823. private _disableLighting;
  84824. disableLighting: boolean;
  84825. private _maxSimultaneousLights;
  84826. maxSimultaneousLights: number;
  84827. /**
  84828. * @param {number}: Represents the wind force
  84829. */
  84830. windForce: number;
  84831. /**
  84832. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  84833. */
  84834. windDirection: BABYLON.Vector2;
  84835. /**
  84836. * @param {number}: Wave height, represents the height of the waves
  84837. */
  84838. waveHeight: number;
  84839. /**
  84840. * @param {number}: Bump height, represents the bump height related to the bump map
  84841. */
  84842. bumpHeight: number;
  84843. /**
  84844. * @param {boolean}: Add a smaller moving bump to less steady waves.
  84845. */
  84846. private _bumpSuperimpose;
  84847. bumpSuperimpose: boolean;
  84848. /**
  84849. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  84850. */
  84851. private _fresnelSeparate;
  84852. fresnelSeparate: boolean;
  84853. /**
  84854. * @param {boolean}: bump Waves modify the reflection.
  84855. */
  84856. private _bumpAffectsReflection;
  84857. bumpAffectsReflection: boolean;
  84858. /**
  84859. * @param {number}: The water color blended with the refraction (near)
  84860. */
  84861. waterColor: BABYLON.Color3;
  84862. /**
  84863. * @param {number}: The blend factor related to the water color
  84864. */
  84865. colorBlendFactor: number;
  84866. /**
  84867. * @param {number}: The water color blended with the reflection (far)
  84868. */
  84869. waterColor2: BABYLON.Color3;
  84870. /**
  84871. * @param {number}: The blend factor related to the water color (reflection, far)
  84872. */
  84873. colorBlendFactor2: number;
  84874. /**
  84875. * @param {number}: Represents the maximum length of a wave
  84876. */
  84877. waveLength: number;
  84878. /**
  84879. * @param {number}: Defines the waves speed
  84880. */
  84881. waveSpeed: number;
  84882. /**
  84883. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  84884. * will avoid calculating useless pixels in the pixel shader of the water material.
  84885. */
  84886. disableClipPlane: boolean;
  84887. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  84888. private _mesh;
  84889. private _refractionRTT;
  84890. private _reflectionRTT;
  84891. private _reflectionTransform;
  84892. private _lastTime;
  84893. private _lastDeltaTime;
  84894. private _useLogarithmicDepth;
  84895. private _waitingRenderList;
  84896. private _imageProcessingConfiguration;
  84897. private _imageProcessingObserver;
  84898. /**
  84899. * Gets a boolean indicating that current material needs to register RTT
  84900. */
  84901. get hasRenderTargetTextures(): boolean;
  84902. /**
  84903. * Constructor
  84904. */
  84905. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  84906. get useLogarithmicDepth(): boolean;
  84907. set useLogarithmicDepth(value: boolean);
  84908. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  84909. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  84910. addToRenderList(node: any): void;
  84911. enableRenderTargets(enable: boolean): void;
  84912. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  84913. get renderTargetsEnabled(): boolean;
  84914. needAlphaBlending(): boolean;
  84915. needAlphaTesting(): boolean;
  84916. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84917. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84918. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84919. private _createRenderTargets;
  84920. getAnimatables(): BABYLON.IAnimatable[];
  84921. getActiveTextures(): BABYLON.BaseTexture[];
  84922. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84923. dispose(forceDisposeEffect?: boolean): void;
  84924. clone(name: string): WaterMaterial;
  84925. serialize(): any;
  84926. getClassName(): string;
  84927. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  84928. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  84929. }
  84930. }
  84931. declare module BABYLON {
  84932. /** @hidden */
  84933. export var asciiartPixelShader: {
  84934. name: string;
  84935. shader: string;
  84936. };
  84937. }
  84938. declare module BABYLON {
  84939. /**
  84940. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  84941. *
  84942. * It basically takes care rendering the font front the given font size to a texture.
  84943. * This is used later on in the postprocess.
  84944. */
  84945. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  84946. private _font;
  84947. private _text;
  84948. private _charSize;
  84949. /**
  84950. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  84951. */
  84952. get charSize(): number;
  84953. /**
  84954. * Create a new instance of the Ascii Art FontTexture class
  84955. * @param name the name of the texture
  84956. * @param font the font to use, use the W3C CSS notation
  84957. * @param text the caracter set to use in the rendering.
  84958. * @param scene the scene that owns the texture
  84959. */
  84960. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  84961. /**
  84962. * Gets the max char width of a font.
  84963. * @param font the font to use, use the W3C CSS notation
  84964. * @return the max char width
  84965. */
  84966. private getFontWidth;
  84967. /**
  84968. * Gets the max char height of a font.
  84969. * @param font the font to use, use the W3C CSS notation
  84970. * @return the max char height
  84971. */
  84972. private getFontHeight;
  84973. /**
  84974. * Clones the current AsciiArtTexture.
  84975. * @return the clone of the texture.
  84976. */
  84977. clone(): AsciiArtFontTexture;
  84978. /**
  84979. * Parses a json object representing the texture and returns an instance of it.
  84980. * @param source the source JSON representation
  84981. * @param scene the scene to create the texture for
  84982. * @return the parsed texture
  84983. */
  84984. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  84985. }
  84986. /**
  84987. * Option available in the Ascii Art Post Process.
  84988. */
  84989. export interface IAsciiArtPostProcessOptions {
  84990. /**
  84991. * The font to use following the w3c font definition.
  84992. */
  84993. font?: string;
  84994. /**
  84995. * The character set to use in the postprocess.
  84996. */
  84997. characterSet?: string;
  84998. /**
  84999. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  85000. * This number is defined between 0 and 1;
  85001. */
  85002. mixToTile?: number;
  85003. /**
  85004. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  85005. * This number is defined between 0 and 1;
  85006. */
  85007. mixToNormal?: number;
  85008. }
  85009. /**
  85010. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  85011. *
  85012. * Simmply add it to your scene and let the nerd that lives in you have fun.
  85013. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  85014. */
  85015. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  85016. /**
  85017. * The font texture used to render the char in the post process.
  85018. */
  85019. private _asciiArtFontTexture;
  85020. /**
  85021. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  85022. * This number is defined between 0 and 1;
  85023. */
  85024. mixToTile: number;
  85025. /**
  85026. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  85027. * This number is defined between 0 and 1;
  85028. */
  85029. mixToNormal: number;
  85030. /**
  85031. * Instantiates a new Ascii Art Post Process.
  85032. * @param name the name to give to the postprocess
  85033. * @camera the camera to apply the post process to.
  85034. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  85035. */
  85036. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  85037. }
  85038. }
  85039. declare module BABYLON {
  85040. /** @hidden */
  85041. export var digitalrainPixelShader: {
  85042. name: string;
  85043. shader: string;
  85044. };
  85045. }
  85046. declare module BABYLON {
  85047. /**
  85048. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  85049. *
  85050. * It basically takes care rendering the font front the given font size to a texture.
  85051. * This is used later on in the postprocess.
  85052. */
  85053. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  85054. private _font;
  85055. private _text;
  85056. private _charSize;
  85057. /**
  85058. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  85059. */
  85060. get charSize(): number;
  85061. /**
  85062. * Create a new instance of the Digital Rain FontTexture class
  85063. * @param name the name of the texture
  85064. * @param font the font to use, use the W3C CSS notation
  85065. * @param text the caracter set to use in the rendering.
  85066. * @param scene the scene that owns the texture
  85067. */
  85068. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  85069. /**
  85070. * Gets the max char width of a font.
  85071. * @param font the font to use, use the W3C CSS notation
  85072. * @return the max char width
  85073. */
  85074. private getFontWidth;
  85075. /**
  85076. * Gets the max char height of a font.
  85077. * @param font the font to use, use the W3C CSS notation
  85078. * @return the max char height
  85079. */
  85080. private getFontHeight;
  85081. /**
  85082. * Clones the current DigitalRainFontTexture.
  85083. * @return the clone of the texture.
  85084. */
  85085. clone(): DigitalRainFontTexture;
  85086. /**
  85087. * Parses a json object representing the texture and returns an instance of it.
  85088. * @param source the source JSON representation
  85089. * @param scene the scene to create the texture for
  85090. * @return the parsed texture
  85091. */
  85092. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  85093. }
  85094. /**
  85095. * Option available in the Digital Rain Post Process.
  85096. */
  85097. export interface IDigitalRainPostProcessOptions {
  85098. /**
  85099. * The font to use following the w3c font definition.
  85100. */
  85101. font?: string;
  85102. /**
  85103. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  85104. * This number is defined between 0 and 1;
  85105. */
  85106. mixToTile?: number;
  85107. /**
  85108. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  85109. * This number is defined between 0 and 1;
  85110. */
  85111. mixToNormal?: number;
  85112. }
  85113. /**
  85114. * DigitalRainPostProcess helps rendering everithing in digital rain.
  85115. *
  85116. * Simmply add it to your scene and let the nerd that lives in you have fun.
  85117. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  85118. */
  85119. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  85120. /**
  85121. * The font texture used to render the char in the post process.
  85122. */
  85123. private _digitalRainFontTexture;
  85124. /**
  85125. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  85126. * This number is defined between 0 and 1;
  85127. */
  85128. mixToTile: number;
  85129. /**
  85130. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  85131. * This number is defined between 0 and 1;
  85132. */
  85133. mixToNormal: number;
  85134. /**
  85135. * Instantiates a new Digital Rain Post Process.
  85136. * @param name the name to give to the postprocess
  85137. * @camera the camera to apply the post process to.
  85138. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  85139. */
  85140. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  85141. }
  85142. }
  85143. declare module BABYLON {
  85144. /** @hidden */
  85145. export var brickProceduralTexturePixelShader: {
  85146. name: string;
  85147. shader: string;
  85148. };
  85149. }
  85150. declare module BABYLON {
  85151. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  85152. private _numberOfBricksHeight;
  85153. private _numberOfBricksWidth;
  85154. private _jointColor;
  85155. private _brickColor;
  85156. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85157. updateShaderUniforms(): void;
  85158. get numberOfBricksHeight(): number;
  85159. set numberOfBricksHeight(value: number);
  85160. get numberOfBricksWidth(): number;
  85161. set numberOfBricksWidth(value: number);
  85162. get jointColor(): BABYLON.Color3;
  85163. set jointColor(value: BABYLON.Color3);
  85164. get brickColor(): BABYLON.Color3;
  85165. set brickColor(value: BABYLON.Color3);
  85166. /**
  85167. * Serializes this brick procedural texture
  85168. * @returns a serialized brick procedural texture object
  85169. */
  85170. serialize(): any;
  85171. /**
  85172. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  85173. * @param parsedTexture defines parsed texture data
  85174. * @param scene defines the current scene
  85175. * @param rootUrl defines the root URL containing brick procedural texture information
  85176. * @returns a parsed Brick Procedural BABYLON.Texture
  85177. */
  85178. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  85179. }
  85180. }
  85181. declare module BABYLON {
  85182. /** @hidden */
  85183. export var cloudProceduralTexturePixelShader: {
  85184. name: string;
  85185. shader: string;
  85186. };
  85187. }
  85188. declare module BABYLON {
  85189. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  85190. private _skyColor;
  85191. private _cloudColor;
  85192. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85193. updateShaderUniforms(): void;
  85194. get skyColor(): BABYLON.Color4;
  85195. set skyColor(value: BABYLON.Color4);
  85196. get cloudColor(): BABYLON.Color4;
  85197. set cloudColor(value: BABYLON.Color4);
  85198. /**
  85199. * Serializes this cloud procedural texture
  85200. * @returns a serialized cloud procedural texture object
  85201. */
  85202. serialize(): any;
  85203. /**
  85204. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  85205. * @param parsedTexture defines parsed texture data
  85206. * @param scene defines the current scene
  85207. * @param rootUrl defines the root URL containing cloud procedural texture information
  85208. * @returns a parsed Cloud Procedural BABYLON.Texture
  85209. */
  85210. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  85211. }
  85212. }
  85213. declare module BABYLON {
  85214. /** @hidden */
  85215. export var fireProceduralTexturePixelShader: {
  85216. name: string;
  85217. shader: string;
  85218. };
  85219. }
  85220. declare module BABYLON {
  85221. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  85222. private _time;
  85223. private _speed;
  85224. private _autoGenerateTime;
  85225. private _fireColors;
  85226. private _alphaThreshold;
  85227. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85228. updateShaderUniforms(): void;
  85229. render(useCameraPostProcess?: boolean): void;
  85230. static get PurpleFireColors(): BABYLON.Color3[];
  85231. static get GreenFireColors(): BABYLON.Color3[];
  85232. static get RedFireColors(): BABYLON.Color3[];
  85233. static get BlueFireColors(): BABYLON.Color3[];
  85234. get autoGenerateTime(): boolean;
  85235. set autoGenerateTime(value: boolean);
  85236. get fireColors(): BABYLON.Color3[];
  85237. set fireColors(value: BABYLON.Color3[]);
  85238. get time(): number;
  85239. set time(value: number);
  85240. get speed(): BABYLON.Vector2;
  85241. set speed(value: BABYLON.Vector2);
  85242. get alphaThreshold(): number;
  85243. set alphaThreshold(value: number);
  85244. /**
  85245. * Serializes this fire procedural texture
  85246. * @returns a serialized fire procedural texture object
  85247. */
  85248. serialize(): any;
  85249. /**
  85250. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  85251. * @param parsedTexture defines parsed texture data
  85252. * @param scene defines the current scene
  85253. * @param rootUrl defines the root URL containing fire procedural texture information
  85254. * @returns a parsed Fire Procedural BABYLON.Texture
  85255. */
  85256. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  85257. }
  85258. }
  85259. declare module BABYLON {
  85260. /** @hidden */
  85261. export var grassProceduralTexturePixelShader: {
  85262. name: string;
  85263. shader: string;
  85264. };
  85265. }
  85266. declare module BABYLON {
  85267. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  85268. private _grassColors;
  85269. private _groundColor;
  85270. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85271. updateShaderUniforms(): void;
  85272. get grassColors(): BABYLON.Color3[];
  85273. set grassColors(value: BABYLON.Color3[]);
  85274. get groundColor(): BABYLON.Color3;
  85275. set groundColor(value: BABYLON.Color3);
  85276. /**
  85277. * Serializes this grass procedural texture
  85278. * @returns a serialized grass procedural texture object
  85279. */
  85280. serialize(): any;
  85281. /**
  85282. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  85283. * @param parsedTexture defines parsed texture data
  85284. * @param scene defines the current scene
  85285. * @param rootUrl defines the root URL containing grass procedural texture information
  85286. * @returns a parsed Grass Procedural BABYLON.Texture
  85287. */
  85288. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  85289. }
  85290. }
  85291. declare module BABYLON {
  85292. /** @hidden */
  85293. export var marbleProceduralTexturePixelShader: {
  85294. name: string;
  85295. shader: string;
  85296. };
  85297. }
  85298. declare module BABYLON {
  85299. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  85300. private _numberOfTilesHeight;
  85301. private _numberOfTilesWidth;
  85302. private _amplitude;
  85303. private _jointColor;
  85304. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85305. updateShaderUniforms(): void;
  85306. get numberOfTilesHeight(): number;
  85307. set numberOfTilesHeight(value: number);
  85308. get amplitude(): number;
  85309. set amplitude(value: number);
  85310. get numberOfTilesWidth(): number;
  85311. set numberOfTilesWidth(value: number);
  85312. get jointColor(): BABYLON.Color3;
  85313. set jointColor(value: BABYLON.Color3);
  85314. /**
  85315. * Serializes this marble procedural texture
  85316. * @returns a serialized marble procedural texture object
  85317. */
  85318. serialize(): any;
  85319. /**
  85320. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  85321. * @param parsedTexture defines parsed texture data
  85322. * @param scene defines the current scene
  85323. * @param rootUrl defines the root URL containing marble procedural texture information
  85324. * @returns a parsed Marble Procedural BABYLON.Texture
  85325. */
  85326. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  85327. }
  85328. }
  85329. declare module BABYLON {
  85330. /** @hidden */
  85331. export var normalMapProceduralTexturePixelShader: {
  85332. name: string;
  85333. shader: string;
  85334. };
  85335. }
  85336. declare module BABYLON {
  85337. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  85338. private _baseTexture;
  85339. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85340. updateShaderUniforms(): void;
  85341. render(useCameraPostProcess?: boolean): void;
  85342. resize(size: any, generateMipMaps: any): void;
  85343. get baseTexture(): BABYLON.Texture;
  85344. set baseTexture(texture: BABYLON.Texture);
  85345. /**
  85346. * Serializes this normal map procedural texture
  85347. * @returns a serialized normal map procedural texture object
  85348. */
  85349. serialize(): any;
  85350. /**
  85351. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  85352. * @param parsedTexture defines parsed texture data
  85353. * @param scene defines the current scene
  85354. * @param rootUrl defines the root URL containing normal map procedural texture information
  85355. * @returns a parsed Normal Map Procedural BABYLON.Texture
  85356. */
  85357. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  85358. }
  85359. }
  85360. declare module BABYLON {
  85361. /** @hidden */
  85362. export var perlinNoiseProceduralTexturePixelShader: {
  85363. name: string;
  85364. shader: string;
  85365. };
  85366. }
  85367. declare module BABYLON {
  85368. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  85369. time: number;
  85370. timeScale: number;
  85371. translationSpeed: number;
  85372. private _currentTranslation;
  85373. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85374. updateShaderUniforms(): void;
  85375. render(useCameraPostProcess?: boolean): void;
  85376. resize(size: any, generateMipMaps: any): void;
  85377. /**
  85378. * Serializes this perlin noise procedural texture
  85379. * @returns a serialized perlin noise procedural texture object
  85380. */
  85381. serialize(): any;
  85382. /**
  85383. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  85384. * @param parsedTexture defines parsed texture data
  85385. * @param scene defines the current scene
  85386. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  85387. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  85388. */
  85389. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  85390. }
  85391. }
  85392. declare module BABYLON {
  85393. /** @hidden */
  85394. export var roadProceduralTexturePixelShader: {
  85395. name: string;
  85396. shader: string;
  85397. };
  85398. }
  85399. declare module BABYLON {
  85400. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  85401. private _roadColor;
  85402. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85403. updateShaderUniforms(): void;
  85404. get roadColor(): BABYLON.Color3;
  85405. set roadColor(value: BABYLON.Color3);
  85406. /**
  85407. * Serializes this road procedural texture
  85408. * @returns a serialized road procedural texture object
  85409. */
  85410. serialize(): any;
  85411. /**
  85412. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  85413. * @param parsedTexture defines parsed texture data
  85414. * @param scene defines the current scene
  85415. * @param rootUrl defines the root URL containing road procedural texture information
  85416. * @returns a parsed Road Procedural BABYLON.Texture
  85417. */
  85418. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  85419. }
  85420. }
  85421. declare module BABYLON {
  85422. /** @hidden */
  85423. export var starfieldProceduralTexturePixelShader: {
  85424. name: string;
  85425. shader: string;
  85426. };
  85427. }
  85428. declare module BABYLON {
  85429. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  85430. private _time;
  85431. private _alpha;
  85432. private _beta;
  85433. private _zoom;
  85434. private _formuparam;
  85435. private _stepsize;
  85436. private _tile;
  85437. private _brightness;
  85438. private _darkmatter;
  85439. private _distfading;
  85440. private _saturation;
  85441. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85442. updateShaderUniforms(): void;
  85443. get time(): number;
  85444. set time(value: number);
  85445. get alpha(): number;
  85446. set alpha(value: number);
  85447. get beta(): number;
  85448. set beta(value: number);
  85449. get formuparam(): number;
  85450. set formuparam(value: number);
  85451. get stepsize(): number;
  85452. set stepsize(value: number);
  85453. get zoom(): number;
  85454. set zoom(value: number);
  85455. get tile(): number;
  85456. set tile(value: number);
  85457. get brightness(): number;
  85458. set brightness(value: number);
  85459. get darkmatter(): number;
  85460. set darkmatter(value: number);
  85461. get distfading(): number;
  85462. set distfading(value: number);
  85463. get saturation(): number;
  85464. set saturation(value: number);
  85465. /**
  85466. * Serializes this starfield procedural texture
  85467. * @returns a serialized starfield procedural texture object
  85468. */
  85469. serialize(): any;
  85470. /**
  85471. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  85472. * @param parsedTexture defines parsed texture data
  85473. * @param scene defines the current scene
  85474. * @param rootUrl defines the root URL containing startfield procedural texture information
  85475. * @returns a parsed Starfield Procedural BABYLON.Texture
  85476. */
  85477. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  85478. }
  85479. }
  85480. declare module BABYLON {
  85481. /** @hidden */
  85482. export var woodProceduralTexturePixelShader: {
  85483. name: string;
  85484. shader: string;
  85485. };
  85486. }
  85487. declare module BABYLON {
  85488. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  85489. private _ampScale;
  85490. private _woodColor;
  85491. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85492. updateShaderUniforms(): void;
  85493. get ampScale(): number;
  85494. set ampScale(value: number);
  85495. get woodColor(): BABYLON.Color3;
  85496. set woodColor(value: BABYLON.Color3);
  85497. /**
  85498. * Serializes this wood procedural texture
  85499. * @returns a serialized wood procedural texture object
  85500. */
  85501. serialize(): any;
  85502. /**
  85503. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  85504. * @param parsedTexture defines parsed texture data
  85505. * @param scene defines the current scene
  85506. * @param rootUrl defines the root URL containing wood procedural texture information
  85507. * @returns a parsed Wood Procedural BABYLON.Texture
  85508. */
  85509. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  85510. }
  85511. }