documentation.d.ts 3.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677
  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 (can be set to _BLANK to create a default one)
  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. get computeBonesUsingShaders(): boolean;
  27974. set computeBonesUsingShaders(value: boolean);
  27975. /**
  27976. * An event triggered before rendering the mesh
  27977. */
  27978. get onBeforeRenderObservable(): Observable<Mesh>;
  27979. /**
  27980. * An event triggered before binding the mesh
  27981. */
  27982. get onBeforeBindObservable(): Observable<Mesh>;
  27983. /**
  27984. * An event triggered after rendering the mesh
  27985. */
  27986. get onAfterRenderObservable(): Observable<Mesh>;
  27987. /**
  27988. * An event triggered before drawing the mesh
  27989. */
  27990. get onBeforeDrawObservable(): Observable<Mesh>;
  27991. private _onBeforeDrawObserver;
  27992. /**
  27993. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  27994. */
  27995. set onBeforeDraw(callback: () => void);
  27996. get hasInstances(): boolean;
  27997. get hasThinInstances(): boolean;
  27998. /**
  27999. * Gets the delay loading state of the mesh (when delay loading is turned on)
  28000. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  28001. */
  28002. delayLoadState: number;
  28003. /**
  28004. * Gets the list of instances created from this mesh
  28005. * it is not supposed to be modified manually.
  28006. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  28007. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28008. */
  28009. instances: InstancedMesh[];
  28010. /**
  28011. * Gets the file containing delay loading data for this mesh
  28012. */
  28013. delayLoadingFile: string;
  28014. /** @hidden */
  28015. _binaryInfo: any;
  28016. /**
  28017. * User defined function used to change how LOD level selection is done
  28018. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28019. */
  28020. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  28021. /**
  28022. * Gets or sets the morph target manager
  28023. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28024. */
  28025. get morphTargetManager(): Nullable<MorphTargetManager>;
  28026. set morphTargetManager(value: Nullable<MorphTargetManager>);
  28027. /** @hidden */
  28028. _creationDataStorage: Nullable<_CreationDataStorage>;
  28029. /** @hidden */
  28030. _geometry: Nullable<Geometry>;
  28031. /** @hidden */
  28032. _delayInfo: Array<string>;
  28033. /** @hidden */
  28034. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  28035. /** @hidden */
  28036. _instanceDataStorage: _InstanceDataStorage;
  28037. /** @hidden */
  28038. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  28039. private _effectiveMaterial;
  28040. /** @hidden */
  28041. _shouldGenerateFlatShading: boolean;
  28042. /** @hidden */
  28043. _originalBuilderSideOrientation: number;
  28044. /**
  28045. * Use this property to change the original side orientation defined at construction time
  28046. */
  28047. overrideMaterialSideOrientation: Nullable<number>;
  28048. /**
  28049. * Gets the source mesh (the one used to clone this one from)
  28050. */
  28051. get source(): Nullable<Mesh>;
  28052. /**
  28053. * Gets or sets a boolean indicating that this mesh does not use index buffer
  28054. */
  28055. get isUnIndexed(): boolean;
  28056. set isUnIndexed(value: boolean);
  28057. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  28058. get worldMatrixInstancedBuffer(): Float32Array;
  28059. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  28060. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  28061. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  28062. /**
  28063. * @constructor
  28064. * @param name The value used by scene.getMeshByName() to do a lookup.
  28065. * @param scene The scene to add this mesh to.
  28066. * @param parent The parent of this mesh, if it has one
  28067. * @param source An optional Mesh from which geometry is shared, cloned.
  28068. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28069. * When false, achieved by calling a clone(), also passing False.
  28070. * This will make creation of children, recursive.
  28071. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  28072. */
  28073. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  28074. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28075. doNotInstantiate: boolean;
  28076. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28077. /**
  28078. * Gets the class name
  28079. * @returns the string "Mesh".
  28080. */
  28081. getClassName(): string;
  28082. /** @hidden */
  28083. get _isMesh(): boolean;
  28084. /**
  28085. * Returns a description of this mesh
  28086. * @param fullDetails define if full details about this mesh must be used
  28087. * @returns a descriptive string representing this mesh
  28088. */
  28089. toString(fullDetails?: boolean): string;
  28090. /** @hidden */
  28091. _unBindEffect(): void;
  28092. /**
  28093. * Gets a boolean indicating if this mesh has LOD
  28094. */
  28095. get hasLODLevels(): boolean;
  28096. /**
  28097. * Gets the list of MeshLODLevel associated with the current mesh
  28098. * @returns an array of MeshLODLevel
  28099. */
  28100. getLODLevels(): MeshLODLevel[];
  28101. private _sortLODLevels;
  28102. /**
  28103. * Add a mesh as LOD level triggered at the given distance.
  28104. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28105. * @param distance The distance from the center of the object to show this level
  28106. * @param mesh The mesh to be added as LOD level (can be null)
  28107. * @return This mesh (for chaining)
  28108. */
  28109. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  28110. /**
  28111. * Returns the LOD level mesh at the passed distance or null if not found.
  28112. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28113. * @param distance The distance from the center of the object to show this level
  28114. * @returns a Mesh or `null`
  28115. */
  28116. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  28117. /**
  28118. * Remove a mesh from the LOD array
  28119. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28120. * @param mesh defines the mesh to be removed
  28121. * @return This mesh (for chaining)
  28122. */
  28123. removeLODLevel(mesh: Mesh): Mesh;
  28124. /**
  28125. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  28126. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28127. * @param camera defines the camera to use to compute distance
  28128. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  28129. * @return This mesh (for chaining)
  28130. */
  28131. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  28132. /**
  28133. * Gets the mesh internal Geometry object
  28134. */
  28135. get geometry(): Nullable<Geometry>;
  28136. /**
  28137. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  28138. * @returns the total number of vertices
  28139. */
  28140. getTotalVertices(): number;
  28141. /**
  28142. * Returns the content of an associated vertex buffer
  28143. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28144. * - VertexBuffer.PositionKind
  28145. * - VertexBuffer.UVKind
  28146. * - VertexBuffer.UV2Kind
  28147. * - VertexBuffer.UV3Kind
  28148. * - VertexBuffer.UV4Kind
  28149. * - VertexBuffer.UV5Kind
  28150. * - VertexBuffer.UV6Kind
  28151. * - VertexBuffer.ColorKind
  28152. * - VertexBuffer.MatricesIndicesKind
  28153. * - VertexBuffer.MatricesIndicesExtraKind
  28154. * - VertexBuffer.MatricesWeightsKind
  28155. * - VertexBuffer.MatricesWeightsExtraKind
  28156. * @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
  28157. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  28158. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  28159. */
  28160. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28161. /**
  28162. * Returns the mesh VertexBuffer object from the requested `kind`
  28163. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28164. * - VertexBuffer.PositionKind
  28165. * - VertexBuffer.NormalKind
  28166. * - VertexBuffer.UVKind
  28167. * - VertexBuffer.UV2Kind
  28168. * - VertexBuffer.UV3Kind
  28169. * - VertexBuffer.UV4Kind
  28170. * - VertexBuffer.UV5Kind
  28171. * - VertexBuffer.UV6Kind
  28172. * - VertexBuffer.ColorKind
  28173. * - VertexBuffer.MatricesIndicesKind
  28174. * - VertexBuffer.MatricesIndicesExtraKind
  28175. * - VertexBuffer.MatricesWeightsKind
  28176. * - VertexBuffer.MatricesWeightsExtraKind
  28177. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  28178. */
  28179. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  28180. /**
  28181. * Tests if a specific vertex buffer is associated with this mesh
  28182. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28183. * - VertexBuffer.PositionKind
  28184. * - VertexBuffer.NormalKind
  28185. * - VertexBuffer.UVKind
  28186. * - VertexBuffer.UV2Kind
  28187. * - VertexBuffer.UV3Kind
  28188. * - VertexBuffer.UV4Kind
  28189. * - VertexBuffer.UV5Kind
  28190. * - VertexBuffer.UV6Kind
  28191. * - VertexBuffer.ColorKind
  28192. * - VertexBuffer.MatricesIndicesKind
  28193. * - VertexBuffer.MatricesIndicesExtraKind
  28194. * - VertexBuffer.MatricesWeightsKind
  28195. * - VertexBuffer.MatricesWeightsExtraKind
  28196. * @returns a boolean
  28197. */
  28198. isVerticesDataPresent(kind: string): boolean;
  28199. /**
  28200. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  28201. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28202. * - VertexBuffer.PositionKind
  28203. * - VertexBuffer.UVKind
  28204. * - VertexBuffer.UV2Kind
  28205. * - VertexBuffer.UV3Kind
  28206. * - VertexBuffer.UV4Kind
  28207. * - VertexBuffer.UV5Kind
  28208. * - VertexBuffer.UV6Kind
  28209. * - VertexBuffer.ColorKind
  28210. * - VertexBuffer.MatricesIndicesKind
  28211. * - VertexBuffer.MatricesIndicesExtraKind
  28212. * - VertexBuffer.MatricesWeightsKind
  28213. * - VertexBuffer.MatricesWeightsExtraKind
  28214. * @returns a boolean
  28215. */
  28216. isVertexBufferUpdatable(kind: string): boolean;
  28217. /**
  28218. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  28219. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28220. * - VertexBuffer.PositionKind
  28221. * - VertexBuffer.NormalKind
  28222. * - VertexBuffer.UVKind
  28223. * - VertexBuffer.UV2Kind
  28224. * - VertexBuffer.UV3Kind
  28225. * - VertexBuffer.UV4Kind
  28226. * - VertexBuffer.UV5Kind
  28227. * - VertexBuffer.UV6Kind
  28228. * - VertexBuffer.ColorKind
  28229. * - VertexBuffer.MatricesIndicesKind
  28230. * - VertexBuffer.MatricesIndicesExtraKind
  28231. * - VertexBuffer.MatricesWeightsKind
  28232. * - VertexBuffer.MatricesWeightsExtraKind
  28233. * @returns an array of strings
  28234. */
  28235. getVerticesDataKinds(): string[];
  28236. /**
  28237. * Returns a positive integer : the total number of indices in this mesh geometry.
  28238. * @returns the numner of indices or zero if the mesh has no geometry.
  28239. */
  28240. getTotalIndices(): number;
  28241. /**
  28242. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28243. * @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.
  28244. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  28245. * @returns the indices array or an empty array if the mesh has no geometry
  28246. */
  28247. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  28248. get isBlocked(): boolean;
  28249. /**
  28250. * Determine if the current mesh is ready to be rendered
  28251. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28252. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  28253. * @returns true if all associated assets are ready (material, textures, shaders)
  28254. */
  28255. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  28256. /**
  28257. * 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.
  28258. */
  28259. get areNormalsFrozen(): boolean;
  28260. /**
  28261. * 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.
  28262. * @returns the current mesh
  28263. */
  28264. freezeNormals(): Mesh;
  28265. /**
  28266. * 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
  28267. * @returns the current mesh
  28268. */
  28269. unfreezeNormals(): Mesh;
  28270. /**
  28271. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  28272. */
  28273. set overridenInstanceCount(count: number);
  28274. /** @hidden */
  28275. _preActivate(): Mesh;
  28276. /** @hidden */
  28277. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28278. /** @hidden */
  28279. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  28280. protected _afterComputeWorldMatrix(): void;
  28281. /** @hidden */
  28282. _postActivate(): void;
  28283. /**
  28284. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28285. * This means the mesh underlying bounding box and sphere are recomputed.
  28286. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28287. * @returns the current mesh
  28288. */
  28289. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  28290. /** @hidden */
  28291. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  28292. /**
  28293. * This function will subdivide the mesh into multiple submeshes
  28294. * @param count defines the expected number of submeshes
  28295. */
  28296. subdivide(count: number): void;
  28297. /**
  28298. * Copy a FloatArray into a specific associated vertex buffer
  28299. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28300. * - VertexBuffer.PositionKind
  28301. * - VertexBuffer.UVKind
  28302. * - VertexBuffer.UV2Kind
  28303. * - VertexBuffer.UV3Kind
  28304. * - VertexBuffer.UV4Kind
  28305. * - VertexBuffer.UV5Kind
  28306. * - VertexBuffer.UV6Kind
  28307. * - VertexBuffer.ColorKind
  28308. * - VertexBuffer.MatricesIndicesKind
  28309. * - VertexBuffer.MatricesIndicesExtraKind
  28310. * - VertexBuffer.MatricesWeightsKind
  28311. * - VertexBuffer.MatricesWeightsExtraKind
  28312. * @param data defines the data source
  28313. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28314. * @param stride defines the data stride size (can be null)
  28315. * @returns the current mesh
  28316. */
  28317. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28318. /**
  28319. * Delete a vertex buffer associated with this mesh
  28320. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  28321. * - VertexBuffer.PositionKind
  28322. * - VertexBuffer.UVKind
  28323. * - VertexBuffer.UV2Kind
  28324. * - VertexBuffer.UV3Kind
  28325. * - VertexBuffer.UV4Kind
  28326. * - VertexBuffer.UV5Kind
  28327. * - VertexBuffer.UV6Kind
  28328. * - VertexBuffer.ColorKind
  28329. * - VertexBuffer.MatricesIndicesKind
  28330. * - VertexBuffer.MatricesIndicesExtraKind
  28331. * - VertexBuffer.MatricesWeightsKind
  28332. * - VertexBuffer.MatricesWeightsExtraKind
  28333. */
  28334. removeVerticesData(kind: string): void;
  28335. /**
  28336. * Flags an associated vertex buffer as updatable
  28337. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  28338. * - VertexBuffer.PositionKind
  28339. * - VertexBuffer.UVKind
  28340. * - VertexBuffer.UV2Kind
  28341. * - VertexBuffer.UV3Kind
  28342. * - VertexBuffer.UV4Kind
  28343. * - VertexBuffer.UV5Kind
  28344. * - VertexBuffer.UV6Kind
  28345. * - VertexBuffer.ColorKind
  28346. * - VertexBuffer.MatricesIndicesKind
  28347. * - VertexBuffer.MatricesIndicesExtraKind
  28348. * - VertexBuffer.MatricesWeightsKind
  28349. * - VertexBuffer.MatricesWeightsExtraKind
  28350. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28351. */
  28352. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  28353. /**
  28354. * Sets the mesh global Vertex Buffer
  28355. * @param buffer defines the buffer to use
  28356. * @returns the current mesh
  28357. */
  28358. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  28359. /**
  28360. * Update a specific associated vertex buffer
  28361. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28362. * - VertexBuffer.PositionKind
  28363. * - VertexBuffer.UVKind
  28364. * - VertexBuffer.UV2Kind
  28365. * - VertexBuffer.UV3Kind
  28366. * - VertexBuffer.UV4Kind
  28367. * - VertexBuffer.UV5Kind
  28368. * - VertexBuffer.UV6Kind
  28369. * - VertexBuffer.ColorKind
  28370. * - VertexBuffer.MatricesIndicesKind
  28371. * - VertexBuffer.MatricesIndicesExtraKind
  28372. * - VertexBuffer.MatricesWeightsKind
  28373. * - VertexBuffer.MatricesWeightsExtraKind
  28374. * @param data defines the data source
  28375. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  28376. * @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)
  28377. * @returns the current mesh
  28378. */
  28379. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28380. /**
  28381. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  28382. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  28383. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  28384. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  28385. * @returns the current mesh
  28386. */
  28387. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  28388. /**
  28389. * Creates a un-shared specific occurence of the geometry for the mesh.
  28390. * @returns the current mesh
  28391. */
  28392. makeGeometryUnique(): Mesh;
  28393. /**
  28394. * Set the index buffer of this mesh
  28395. * @param indices defines the source data
  28396. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  28397. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  28398. * @returns the current mesh
  28399. */
  28400. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  28401. /**
  28402. * Update the current index buffer
  28403. * @param indices defines the source data
  28404. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28405. * @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)
  28406. * @returns the current mesh
  28407. */
  28408. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28409. /**
  28410. * Invert the geometry to move from a right handed system to a left handed one.
  28411. * @returns the current mesh
  28412. */
  28413. toLeftHanded(): Mesh;
  28414. /** @hidden */
  28415. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28416. /** @hidden */
  28417. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28418. /**
  28419. * Registers for this mesh a javascript function called just before the rendering process
  28420. * @param func defines the function to call before rendering this mesh
  28421. * @returns the current mesh
  28422. */
  28423. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28424. /**
  28425. * Disposes a previously registered javascript function called before the rendering
  28426. * @param func defines the function to remove
  28427. * @returns the current mesh
  28428. */
  28429. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28430. /**
  28431. * Registers for this mesh a javascript function called just after the rendering is complete
  28432. * @param func defines the function to call after rendering this mesh
  28433. * @returns the current mesh
  28434. */
  28435. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28436. /**
  28437. * Disposes a previously registered javascript function called after the rendering.
  28438. * @param func defines the function to remove
  28439. * @returns the current mesh
  28440. */
  28441. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28442. /** @hidden */
  28443. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  28444. /** @hidden */
  28445. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  28446. /** @hidden */
  28447. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  28448. /** @hidden */
  28449. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  28450. /** @hidden */
  28451. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  28452. /** @hidden */
  28453. _rebuild(): void;
  28454. /** @hidden */
  28455. _freeze(): void;
  28456. /** @hidden */
  28457. _unFreeze(): void;
  28458. /**
  28459. * 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
  28460. * @param subMesh defines the subMesh to render
  28461. * @param enableAlphaMode defines if alpha mode can be changed
  28462. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  28463. * @returns the current mesh
  28464. */
  28465. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  28466. private _onBeforeDraw;
  28467. /**
  28468. * Renormalize the mesh and patch it up if there are no weights
  28469. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  28470. * However in the case of zero weights then we set just a single influence to 1.
  28471. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  28472. */
  28473. cleanMatrixWeights(): void;
  28474. private normalizeSkinFourWeights;
  28475. private normalizeSkinWeightsAndExtra;
  28476. /**
  28477. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  28478. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  28479. * the user know there was an issue with importing the mesh
  28480. * @returns a validation object with skinned, valid and report string
  28481. */
  28482. validateSkinning(): {
  28483. skinned: boolean;
  28484. valid: boolean;
  28485. report: string;
  28486. };
  28487. /** @hidden */
  28488. _checkDelayState(): Mesh;
  28489. private _queueLoad;
  28490. /**
  28491. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28492. * A mesh is in the frustum if its bounding box intersects the frustum
  28493. * @param frustumPlanes defines the frustum to test
  28494. * @returns true if the mesh is in the frustum planes
  28495. */
  28496. isInFrustum(frustumPlanes: Plane[]): boolean;
  28497. /**
  28498. * Sets the mesh material by the material or multiMaterial `id` property
  28499. * @param id is a string identifying the material or the multiMaterial
  28500. * @returns the current mesh
  28501. */
  28502. setMaterialByID(id: string): Mesh;
  28503. /**
  28504. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  28505. * @returns an array of IAnimatable
  28506. */
  28507. getAnimatables(): IAnimatable[];
  28508. /**
  28509. * Modifies the mesh geometry according to the passed transformation matrix.
  28510. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  28511. * The mesh normals are modified using the same transformation.
  28512. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28513. * @param transform defines the transform matrix to use
  28514. * @see https://doc.babylonjs.com/resources/baking_transformations
  28515. * @returns the current mesh
  28516. */
  28517. bakeTransformIntoVertices(transform: Matrix): Mesh;
  28518. /**
  28519. * Modifies the mesh geometry according to its own current World Matrix.
  28520. * The mesh World Matrix is then reset.
  28521. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  28522. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28523. * @see https://doc.babylonjs.com/resources/baking_transformations
  28524. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  28525. * @returns the current mesh
  28526. */
  28527. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  28528. /** @hidden */
  28529. get _positions(): Nullable<Vector3[]>;
  28530. /** @hidden */
  28531. _resetPointsArrayCache(): Mesh;
  28532. /** @hidden */
  28533. _generatePointsArray(): boolean;
  28534. /**
  28535. * Returns a new Mesh object generated from the current mesh properties.
  28536. * This method must not get confused with createInstance()
  28537. * @param name is a string, the name given to the new mesh
  28538. * @param newParent can be any Node object (default `null`)
  28539. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  28540. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  28541. * @returns a new mesh
  28542. */
  28543. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  28544. /**
  28545. * Releases resources associated with this mesh.
  28546. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28547. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28548. */
  28549. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28550. /** @hidden */
  28551. _disposeInstanceSpecificData(): void;
  28552. /** @hidden */
  28553. _disposeThinInstanceSpecificData(): void;
  28554. /**
  28555. * Modifies the mesh geometry according to a displacement map.
  28556. * 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.
  28557. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28558. * @param url is a string, the URL from the image file is to be downloaded.
  28559. * @param minHeight is the lower limit of the displacement.
  28560. * @param maxHeight is the upper limit of the displacement.
  28561. * @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.
  28562. * @param uvOffset is an optional vector2 used to offset UV.
  28563. * @param uvScale is an optional vector2 used to scale UV.
  28564. * @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.
  28565. * @returns the Mesh.
  28566. */
  28567. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28568. /**
  28569. * Modifies the mesh geometry according to a displacementMap buffer.
  28570. * 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.
  28571. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28572. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  28573. * @param heightMapWidth is the width of the buffer image.
  28574. * @param heightMapHeight is the height of the buffer image.
  28575. * @param minHeight is the lower limit of the displacement.
  28576. * @param maxHeight is the upper limit of the displacement.
  28577. * @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.
  28578. * @param uvOffset is an optional vector2 used to offset UV.
  28579. * @param uvScale is an optional vector2 used to scale UV.
  28580. * @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.
  28581. * @returns the Mesh.
  28582. */
  28583. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28584. /**
  28585. * Modify the mesh to get a flat shading rendering.
  28586. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  28587. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  28588. * @returns current mesh
  28589. */
  28590. convertToFlatShadedMesh(): Mesh;
  28591. /**
  28592. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  28593. * In other words, more vertices, no more indices and a single bigger VBO.
  28594. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  28595. * @returns current mesh
  28596. */
  28597. convertToUnIndexedMesh(): Mesh;
  28598. /**
  28599. * Inverses facet orientations.
  28600. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28601. * @param flipNormals will also inverts the normals
  28602. * @returns current mesh
  28603. */
  28604. flipFaces(flipNormals?: boolean): Mesh;
  28605. /**
  28606. * Increase the number of facets and hence vertices in a mesh
  28607. * Vertex normals are interpolated from existing vertex normals
  28608. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28609. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  28610. */
  28611. increaseVertices(numberPerEdge: number): void;
  28612. /**
  28613. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  28614. * This will undo any application of covertToFlatShadedMesh
  28615. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28616. */
  28617. forceSharedVertices(): void;
  28618. /** @hidden */
  28619. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  28620. /** @hidden */
  28621. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  28622. /**
  28623. * Creates a new InstancedMesh object from the mesh model.
  28624. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28625. * @param name defines the name of the new instance
  28626. * @returns a new InstancedMesh
  28627. */
  28628. createInstance(name: string): InstancedMesh;
  28629. /**
  28630. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  28631. * After this call, all the mesh instances have the same submeshes than the current mesh.
  28632. * @returns the current mesh
  28633. */
  28634. synchronizeInstances(): Mesh;
  28635. /**
  28636. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28637. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28638. * This should be used together with the simplification to avoid disappearing triangles.
  28639. * @param successCallback an optional success callback to be called after the optimization finished.
  28640. * @returns the current mesh
  28641. */
  28642. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28643. /**
  28644. * Serialize current mesh
  28645. * @param serializationObject defines the object which will receive the serialization data
  28646. */
  28647. serialize(serializationObject: any): void;
  28648. /** @hidden */
  28649. _syncGeometryWithMorphTargetManager(): void;
  28650. /** @hidden */
  28651. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28652. /**
  28653. * Returns a new Mesh object parsed from the source provided.
  28654. * @param parsedMesh is the source
  28655. * @param scene defines the hosting scene
  28656. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28657. * @returns a new Mesh
  28658. */
  28659. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28660. /**
  28661. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28662. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28663. * @param name defines the name of the mesh to create
  28664. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28665. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28666. * @param closePath creates a seam between the first and the last points of each path of the path array
  28667. * @param offset is taken in account only if the `pathArray` is containing a single path
  28668. * @param scene defines the hosting scene
  28669. * @param updatable defines if the mesh must be flagged as updatable
  28670. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28671. * @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)
  28672. * @returns a new Mesh
  28673. */
  28674. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28675. /**
  28676. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28677. * @param name defines the name of the mesh to create
  28678. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28679. * @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
  28680. * @param scene defines the hosting scene
  28681. * @param updatable defines if the mesh must be flagged as updatable
  28682. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28683. * @returns a new Mesh
  28684. */
  28685. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28686. /**
  28687. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  28688. * @param name defines the name of the mesh to create
  28689. * @param size sets the size (float) of each box side (default 1)
  28690. * @param scene defines the hosting scene
  28691. * @param updatable defines if the mesh must be flagged as updatable
  28692. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28693. * @returns a new Mesh
  28694. */
  28695. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28696. /**
  28697. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  28698. * @param name defines the name of the mesh to create
  28699. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28700. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28701. * @param scene defines the hosting scene
  28702. * @param updatable defines if the mesh must be flagged as updatable
  28703. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28704. * @returns a new Mesh
  28705. */
  28706. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28707. /**
  28708. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  28709. * @param name defines the name of the mesh to create
  28710. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28711. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28712. * @param scene defines the hosting scene
  28713. * @returns a new Mesh
  28714. */
  28715. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  28716. /**
  28717. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  28718. * @param name defines the name of the mesh to create
  28719. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  28720. * @param diameterTop set the top cap diameter (floats, default 1)
  28721. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  28722. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  28723. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  28724. * @param scene defines the hosting scene
  28725. * @param updatable defines if the mesh must be flagged as updatable
  28726. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28727. * @returns a new Mesh
  28728. */
  28729. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28730. /**
  28731. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28732. * @param name defines the name of the mesh to create
  28733. * @param diameter sets the diameter size (float) of the torus (default 1)
  28734. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28735. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28736. * @param scene defines the hosting scene
  28737. * @param updatable defines if the mesh must be flagged as updatable
  28738. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28739. * @returns a new Mesh
  28740. */
  28741. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28742. /**
  28743. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28744. * @param name defines the name of the mesh to create
  28745. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28746. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28747. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28748. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28749. * @param p the number of windings on X axis (positive integers, default 2)
  28750. * @param q the number of windings on Y axis (positive integers, default 3)
  28751. * @param scene defines the hosting scene
  28752. * @param updatable defines if the mesh must be flagged as updatable
  28753. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28754. * @returns a new Mesh
  28755. */
  28756. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28757. /**
  28758. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  28759. * @param name defines the name of the mesh to create
  28760. * @param points is an array successive Vector3
  28761. * @param scene defines the hosting scene
  28762. * @param updatable defines if the mesh must be flagged as updatable
  28763. * @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).
  28764. * @returns a new Mesh
  28765. */
  28766. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  28767. /**
  28768. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  28769. * @param name defines the name of the mesh to create
  28770. * @param points is an array successive Vector3
  28771. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  28772. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28773. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  28774. * @param scene defines the hosting scene
  28775. * @param updatable defines if the mesh must be flagged as updatable
  28776. * @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)
  28777. * @returns a new Mesh
  28778. */
  28779. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  28780. /**
  28781. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  28782. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  28783. * 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.
  28784. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28785. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28786. * Remember you can only change the shape positions, not their number when updating a polygon.
  28787. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28788. * @param name defines the name of the mesh to create
  28789. * @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
  28790. * @param scene defines the hosting scene
  28791. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28792. * @param updatable defines if the mesh must be flagged as updatable
  28793. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28794. * @param earcutInjection can be used to inject your own earcut reference
  28795. * @returns a new Mesh
  28796. */
  28797. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28798. /**
  28799. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  28800. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  28801. * @param name defines the name of the mesh to create
  28802. * @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
  28803. * @param depth defines the height of extrusion
  28804. * @param scene defines the hosting scene
  28805. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28806. * @param updatable defines if the mesh must be flagged as updatable
  28807. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28808. * @param earcutInjection can be used to inject your own earcut reference
  28809. * @returns a new Mesh
  28810. */
  28811. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28812. /**
  28813. * Creates an extruded shape mesh.
  28814. * 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
  28815. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28816. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28817. * @param name defines the name of the mesh to create
  28818. * @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
  28819. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28820. * @param scale is the value to scale the shape
  28821. * @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
  28822. * @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
  28823. * @param scene defines the hosting scene
  28824. * @param updatable defines if the mesh must be flagged as updatable
  28825. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28826. * @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)
  28827. * @returns a new Mesh
  28828. */
  28829. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28830. /**
  28831. * Creates an custom extruded shape mesh.
  28832. * The custom extrusion is a parametric shape.
  28833. * It has no predefined shape. Its final shape will depend on the input parameters.
  28834. * Please consider using the same method from the MeshBuilder class instead
  28835. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28836. * @param name defines the name of the mesh to create
  28837. * @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
  28838. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28839. * @param scaleFunction is a custom Javascript function called on each path point
  28840. * @param rotationFunction is a custom Javascript function called on each path point
  28841. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28842. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  28843. * @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
  28844. * @param scene defines the hosting scene
  28845. * @param updatable defines if the mesh must be flagged as updatable
  28846. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28847. * @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)
  28848. * @returns a new Mesh
  28849. */
  28850. 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;
  28851. /**
  28852. * Creates lathe mesh.
  28853. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  28854. * Please consider using the same method from the MeshBuilder class instead
  28855. * @param name defines the name of the mesh to create
  28856. * @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
  28857. * @param radius is the radius value of the lathe
  28858. * @param tessellation is the side number of the lathe.
  28859. * @param scene defines the hosting scene
  28860. * @param updatable defines if the mesh must be flagged as updatable
  28861. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28862. * @returns a new Mesh
  28863. */
  28864. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28865. /**
  28866. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  28867. * @param name defines the name of the mesh to create
  28868. * @param size sets the size (float) of both sides of the plane at once (default 1)
  28869. * @param scene defines the hosting scene
  28870. * @param updatable defines if the mesh must be flagged as updatable
  28871. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28872. * @returns a new Mesh
  28873. */
  28874. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28875. /**
  28876. * Creates a ground mesh.
  28877. * Please consider using the same method from the MeshBuilder class instead
  28878. * @param name defines the name of the mesh to create
  28879. * @param width set the width of the ground
  28880. * @param height set the height of the ground
  28881. * @param subdivisions sets the number of subdivisions per side
  28882. * @param scene defines the hosting scene
  28883. * @param updatable defines if the mesh must be flagged as updatable
  28884. * @returns a new Mesh
  28885. */
  28886. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  28887. /**
  28888. * Creates a tiled ground mesh.
  28889. * Please consider using the same method from the MeshBuilder class instead
  28890. * @param name defines the name of the mesh to create
  28891. * @param xmin set the ground minimum X coordinate
  28892. * @param zmin set the ground minimum Y coordinate
  28893. * @param xmax set the ground maximum X coordinate
  28894. * @param zmax set the ground maximum Z coordinate
  28895. * @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
  28896. * @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
  28897. * @param scene defines the hosting scene
  28898. * @param updatable defines if the mesh must be flagged as updatable
  28899. * @returns a new Mesh
  28900. */
  28901. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  28902. w: number;
  28903. h: number;
  28904. }, precision: {
  28905. w: number;
  28906. h: number;
  28907. }, scene: Scene, updatable?: boolean): Mesh;
  28908. /**
  28909. * Creates a ground mesh from a height map.
  28910. * Please consider using the same method from the MeshBuilder class instead
  28911. * @see https://doc.babylonjs.com/babylon101/height_map
  28912. * @param name defines the name of the mesh to create
  28913. * @param url sets the URL of the height map image resource
  28914. * @param width set the ground width size
  28915. * @param height set the ground height size
  28916. * @param subdivisions sets the number of subdivision per side
  28917. * @param minHeight is the minimum altitude on the ground
  28918. * @param maxHeight is the maximum altitude on the ground
  28919. * @param scene defines the hosting scene
  28920. * @param updatable defines if the mesh must be flagged as updatable
  28921. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  28922. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28923. * @returns a new Mesh
  28924. */
  28925. 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;
  28926. /**
  28927. * Creates a tube mesh.
  28928. * The tube is a parametric shape.
  28929. * It has no predefined shape. Its final shape will depend on the input parameters.
  28930. * Please consider using the same method from the MeshBuilder class instead
  28931. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28932. * @param name defines the name of the mesh to create
  28933. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  28934. * @param radius sets the tube radius size
  28935. * @param tessellation is the number of sides on the tubular surface
  28936. * @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
  28937. * @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
  28938. * @param scene defines the hosting scene
  28939. * @param updatable defines if the mesh must be flagged as updatable
  28940. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28941. * @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)
  28942. * @returns a new Mesh
  28943. */
  28944. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  28945. (i: number, distance: number): number;
  28946. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28947. /**
  28948. * Creates a polyhedron mesh.
  28949. * Please consider using the same method from the MeshBuilder class instead.
  28950. * * 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
  28951. * * The parameter `size` (positive float, default 1) sets the polygon size
  28952. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28953. * * 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`
  28954. * * 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
  28955. * * 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)`)
  28956. * * 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
  28957. * * 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
  28958. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28959. * * 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
  28960. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28961. * @param name defines the name of the mesh to create
  28962. * @param options defines the options used to create the mesh
  28963. * @param scene defines the hosting scene
  28964. * @returns a new Mesh
  28965. */
  28966. static CreatePolyhedron(name: string, options: {
  28967. type?: number;
  28968. size?: number;
  28969. sizeX?: number;
  28970. sizeY?: number;
  28971. sizeZ?: number;
  28972. custom?: any;
  28973. faceUV?: Vector4[];
  28974. faceColors?: Color4[];
  28975. updatable?: boolean;
  28976. sideOrientation?: number;
  28977. }, scene: Scene): Mesh;
  28978. /**
  28979. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28980. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28981. * * 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`)
  28982. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28983. * * 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
  28984. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28985. * * 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
  28986. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28987. * @param name defines the name of the mesh
  28988. * @param options defines the options used to create the mesh
  28989. * @param scene defines the hosting scene
  28990. * @returns a new Mesh
  28991. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28992. */
  28993. static CreateIcoSphere(name: string, options: {
  28994. radius?: number;
  28995. flat?: boolean;
  28996. subdivisions?: number;
  28997. sideOrientation?: number;
  28998. updatable?: boolean;
  28999. }, scene: Scene): Mesh;
  29000. /**
  29001. * Creates a decal mesh.
  29002. * Please consider using the same method from the MeshBuilder class instead.
  29003. * A decal is a mesh usually applied as a model onto the surface of another mesh
  29004. * @param name defines the name of the mesh
  29005. * @param sourceMesh defines the mesh receiving the decal
  29006. * @param position sets the position of the decal in world coordinates
  29007. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  29008. * @param size sets the decal scaling
  29009. * @param angle sets the angle to rotate the decal
  29010. * @returns a new Mesh
  29011. */
  29012. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  29013. /**
  29014. * Prepare internal position array for software CPU skinning
  29015. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  29016. */
  29017. setPositionsForCPUSkinning(): Float32Array;
  29018. /**
  29019. * Prepare internal normal array for software CPU skinning
  29020. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  29021. */
  29022. setNormalsForCPUSkinning(): Float32Array;
  29023. /**
  29024. * Updates the vertex buffer by applying transformation from the bones
  29025. * @param skeleton defines the skeleton to apply to current mesh
  29026. * @returns the current mesh
  29027. */
  29028. applySkeleton(skeleton: Skeleton): Mesh;
  29029. /**
  29030. * 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
  29031. * @param meshes defines the list of meshes to scan
  29032. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  29033. */
  29034. static MinMax(meshes: AbstractMesh[]): {
  29035. min: Vector3;
  29036. max: Vector3;
  29037. };
  29038. /**
  29039. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  29040. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  29041. * @returns a vector3
  29042. */
  29043. static Center(meshesOrMinMaxVector: {
  29044. min: Vector3;
  29045. max: Vector3;
  29046. } | AbstractMesh[]): Vector3;
  29047. /**
  29048. * Merge the array of meshes into a single mesh for performance reasons.
  29049. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  29050. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  29051. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  29052. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  29053. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  29054. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  29055. * @returns a new mesh
  29056. */
  29057. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  29058. /** @hidden */
  29059. addInstance(instance: InstancedMesh): void;
  29060. /** @hidden */
  29061. removeInstance(instance: InstancedMesh): void;
  29062. }
  29063. }
  29064. declare module BABYLON {
  29065. /**
  29066. * This is the base class of all the camera used in the application.
  29067. * @see https://doc.babylonjs.com/features/cameras
  29068. */
  29069. export class Camera extends Node {
  29070. /** @hidden */
  29071. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29072. /**
  29073. * This is the default projection mode used by the cameras.
  29074. * It helps recreating a feeling of perspective and better appreciate depth.
  29075. * This is the best way to simulate real life cameras.
  29076. */
  29077. static readonly PERSPECTIVE_CAMERA: number;
  29078. /**
  29079. * This helps creating camera with an orthographic mode.
  29080. * 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.
  29081. */
  29082. static readonly ORTHOGRAPHIC_CAMERA: number;
  29083. /**
  29084. * This is the default FOV mode for perspective cameras.
  29085. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29086. */
  29087. static readonly FOVMODE_VERTICAL_FIXED: number;
  29088. /**
  29089. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29090. */
  29091. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29092. /**
  29093. * This specifies ther is no need for a camera rig.
  29094. * Basically only one eye is rendered corresponding to the camera.
  29095. */
  29096. static readonly RIG_MODE_NONE: number;
  29097. /**
  29098. * Simulates a camera Rig with one blue eye and one red eye.
  29099. * This can be use with 3d blue and red glasses.
  29100. */
  29101. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29102. /**
  29103. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29104. */
  29105. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29106. /**
  29107. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29108. */
  29109. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29110. /**
  29111. * Defines that both eyes of the camera will be rendered over under each other.
  29112. */
  29113. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29114. /**
  29115. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  29116. */
  29117. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  29118. /**
  29119. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29120. */
  29121. static readonly RIG_MODE_VR: number;
  29122. /**
  29123. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29124. */
  29125. static readonly RIG_MODE_WEBVR: number;
  29126. /**
  29127. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29128. */
  29129. static readonly RIG_MODE_CUSTOM: number;
  29130. /**
  29131. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29132. */
  29133. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29134. /**
  29135. * Define the input manager associated with the camera.
  29136. */
  29137. inputs: CameraInputsManager<Camera>;
  29138. /** @hidden */
  29139. _position: Vector3;
  29140. /**
  29141. * Define the current local position of the camera in the scene
  29142. */
  29143. get position(): Vector3;
  29144. set position(newPosition: Vector3);
  29145. /**
  29146. * The vector the camera should consider as up.
  29147. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29148. */
  29149. upVector: Vector3;
  29150. /**
  29151. * Define the current limit on the left side for an orthographic camera
  29152. * In scene unit
  29153. */
  29154. orthoLeft: Nullable<number>;
  29155. /**
  29156. * Define the current limit on the right side for an orthographic camera
  29157. * In scene unit
  29158. */
  29159. orthoRight: Nullable<number>;
  29160. /**
  29161. * Define the current limit on the bottom side for an orthographic camera
  29162. * In scene unit
  29163. */
  29164. orthoBottom: Nullable<number>;
  29165. /**
  29166. * Define the current limit on the top side for an orthographic camera
  29167. * In scene unit
  29168. */
  29169. orthoTop: Nullable<number>;
  29170. /**
  29171. * Field Of View is set in Radians. (default is 0.8)
  29172. */
  29173. fov: number;
  29174. /**
  29175. * Define the minimum distance the camera can see from.
  29176. * This is important to note that the depth buffer are not infinite and the closer it starts
  29177. * the more your scene might encounter depth fighting issue.
  29178. */
  29179. minZ: number;
  29180. /**
  29181. * Define the maximum distance the camera can see to.
  29182. * This is important to note that the depth buffer are not infinite and the further it end
  29183. * the more your scene might encounter depth fighting issue.
  29184. */
  29185. maxZ: number;
  29186. /**
  29187. * Define the default inertia of the camera.
  29188. * This helps giving a smooth feeling to the camera movement.
  29189. */
  29190. inertia: number;
  29191. /**
  29192. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  29193. */
  29194. mode: number;
  29195. /**
  29196. * Define whether the camera is intermediate.
  29197. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29198. */
  29199. isIntermediate: boolean;
  29200. /**
  29201. * Define the viewport of the camera.
  29202. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29203. */
  29204. viewport: Viewport;
  29205. /**
  29206. * Restricts the camera to viewing objects with the same layerMask.
  29207. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29208. */
  29209. layerMask: number;
  29210. /**
  29211. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29212. */
  29213. fovMode: number;
  29214. /**
  29215. * Rig mode of the camera.
  29216. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29217. * This is normally controlled byt the camera themselves as internal use.
  29218. */
  29219. cameraRigMode: number;
  29220. /**
  29221. * Defines the distance between both "eyes" in case of a RIG
  29222. */
  29223. interaxialDistance: number;
  29224. /**
  29225. * Defines if stereoscopic rendering is done side by side or over under.
  29226. */
  29227. isStereoscopicSideBySide: boolean;
  29228. /**
  29229. * 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
  29230. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29231. * else in the scene. (Eg. security camera)
  29232. *
  29233. * 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)
  29234. */
  29235. customRenderTargets: RenderTargetTexture[];
  29236. /**
  29237. * When set, the camera will render to this render target instead of the default canvas
  29238. *
  29239. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  29240. */
  29241. outputRenderTarget: Nullable<RenderTargetTexture>;
  29242. /**
  29243. * Observable triggered when the camera view matrix has changed.
  29244. */
  29245. onViewMatrixChangedObservable: Observable<Camera>;
  29246. /**
  29247. * Observable triggered when the camera Projection matrix has changed.
  29248. */
  29249. onProjectionMatrixChangedObservable: Observable<Camera>;
  29250. /**
  29251. * Observable triggered when the inputs have been processed.
  29252. */
  29253. onAfterCheckInputsObservable: Observable<Camera>;
  29254. /**
  29255. * Observable triggered when reset has been called and applied to the camera.
  29256. */
  29257. onRestoreStateObservable: Observable<Camera>;
  29258. /**
  29259. * Is this camera a part of a rig system?
  29260. */
  29261. isRigCamera: boolean;
  29262. /**
  29263. * If isRigCamera set to true this will be set with the parent camera.
  29264. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  29265. */
  29266. rigParent?: Camera;
  29267. /** @hidden */
  29268. _cameraRigParams: any;
  29269. /** @hidden */
  29270. _rigCameras: Camera[];
  29271. /** @hidden */
  29272. _rigPostProcess: Nullable<PostProcess>;
  29273. protected _webvrViewMatrix: Matrix;
  29274. /** @hidden */
  29275. _skipRendering: boolean;
  29276. /** @hidden */
  29277. _projectionMatrix: Matrix;
  29278. /** @hidden */
  29279. _postProcesses: Nullable<PostProcess>[];
  29280. /** @hidden */
  29281. _activeMeshes: SmartArray<AbstractMesh>;
  29282. protected _globalPosition: Vector3;
  29283. /** @hidden */
  29284. _computedViewMatrix: Matrix;
  29285. private _doNotComputeProjectionMatrix;
  29286. private _transformMatrix;
  29287. private _frustumPlanes;
  29288. private _refreshFrustumPlanes;
  29289. private _storedFov;
  29290. private _stateStored;
  29291. /**
  29292. * Instantiates a new camera object.
  29293. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29294. * @see https://doc.babylonjs.com/features/cameras
  29295. * @param name Defines the name of the camera in the scene
  29296. * @param position Defines the position of the camera
  29297. * @param scene Defines the scene the camera belongs too
  29298. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29299. */
  29300. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29301. /**
  29302. * Store current camera state (fov, position, etc..)
  29303. * @returns the camera
  29304. */
  29305. storeState(): Camera;
  29306. /**
  29307. * Restores the camera state values if it has been stored. You must call storeState() first
  29308. */
  29309. protected _restoreStateValues(): boolean;
  29310. /**
  29311. * Restored camera state. You must call storeState() first.
  29312. * @returns true if restored and false otherwise
  29313. */
  29314. restoreState(): boolean;
  29315. /**
  29316. * Gets the class name of the camera.
  29317. * @returns the class name
  29318. */
  29319. getClassName(): string;
  29320. /** @hidden */
  29321. readonly _isCamera: boolean;
  29322. /**
  29323. * Gets a string representation of the camera useful for debug purpose.
  29324. * @param fullDetails Defines that a more verboe level of logging is required
  29325. * @returns the string representation
  29326. */
  29327. toString(fullDetails?: boolean): string;
  29328. /**
  29329. * Gets the current world space position of the camera.
  29330. */
  29331. get globalPosition(): Vector3;
  29332. /**
  29333. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29334. * @returns the active meshe list
  29335. */
  29336. getActiveMeshes(): SmartArray<AbstractMesh>;
  29337. /**
  29338. * Check whether a mesh is part of the current active mesh list of the camera
  29339. * @param mesh Defines the mesh to check
  29340. * @returns true if active, false otherwise
  29341. */
  29342. isActiveMesh(mesh: Mesh): boolean;
  29343. /**
  29344. * Is this camera ready to be used/rendered
  29345. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29346. * @return true if the camera is ready
  29347. */
  29348. isReady(completeCheck?: boolean): boolean;
  29349. /** @hidden */
  29350. _initCache(): void;
  29351. /** @hidden */
  29352. _updateCache(ignoreParentClass?: boolean): void;
  29353. /** @hidden */
  29354. _isSynchronized(): boolean;
  29355. /** @hidden */
  29356. _isSynchronizedViewMatrix(): boolean;
  29357. /** @hidden */
  29358. _isSynchronizedProjectionMatrix(): boolean;
  29359. /**
  29360. * Attach the input controls to a specific dom element to get the input from.
  29361. * @param element Defines the element the controls should be listened from
  29362. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29363. */
  29364. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29365. /**
  29366. * Detach the current controls from the specified dom element.
  29367. * @param element Defines the element to stop listening the inputs from
  29368. */
  29369. detachControl(element: HTMLElement): void;
  29370. /**
  29371. * Update the camera state according to the different inputs gathered during the frame.
  29372. */
  29373. update(): void;
  29374. /** @hidden */
  29375. _checkInputs(): void;
  29376. /** @hidden */
  29377. get rigCameras(): Camera[];
  29378. /**
  29379. * Gets the post process used by the rig cameras
  29380. */
  29381. get rigPostProcess(): Nullable<PostProcess>;
  29382. /**
  29383. * Internal, gets the first post proces.
  29384. * @returns the first post process to be run on this camera.
  29385. */
  29386. _getFirstPostProcess(): Nullable<PostProcess>;
  29387. private _cascadePostProcessesToRigCams;
  29388. /**
  29389. * Attach a post process to the camera.
  29390. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29391. * @param postProcess The post process to attach to the camera
  29392. * @param insertAt The position of the post process in case several of them are in use in the scene
  29393. * @returns the position the post process has been inserted at
  29394. */
  29395. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29396. /**
  29397. * Detach a post process to the camera.
  29398. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29399. * @param postProcess The post process to detach from the camera
  29400. */
  29401. detachPostProcess(postProcess: PostProcess): void;
  29402. /**
  29403. * Gets the current world matrix of the camera
  29404. */
  29405. getWorldMatrix(): Matrix;
  29406. /** @hidden */
  29407. _getViewMatrix(): Matrix;
  29408. /**
  29409. * Gets the current view matrix of the camera.
  29410. * @param force forces the camera to recompute the matrix without looking at the cached state
  29411. * @returns the view matrix
  29412. */
  29413. getViewMatrix(force?: boolean): Matrix;
  29414. /**
  29415. * Freeze the projection matrix.
  29416. * It will prevent the cache check of the camera projection compute and can speed up perf
  29417. * if no parameter of the camera are meant to change
  29418. * @param projection Defines manually a projection if necessary
  29419. */
  29420. freezeProjectionMatrix(projection?: Matrix): void;
  29421. /**
  29422. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29423. */
  29424. unfreezeProjectionMatrix(): void;
  29425. /**
  29426. * Gets the current projection matrix of the camera.
  29427. * @param force forces the camera to recompute the matrix without looking at the cached state
  29428. * @returns the projection matrix
  29429. */
  29430. getProjectionMatrix(force?: boolean): Matrix;
  29431. /**
  29432. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29433. * @returns a Matrix
  29434. */
  29435. getTransformationMatrix(): Matrix;
  29436. private _updateFrustumPlanes;
  29437. /**
  29438. * Checks if a cullable object (mesh...) is in the camera frustum
  29439. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29440. * @param target The object to check
  29441. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29442. * @returns true if the object is in frustum otherwise false
  29443. */
  29444. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29445. /**
  29446. * Checks if a cullable object (mesh...) is in the camera frustum
  29447. * Unlike isInFrustum this cheks the full bounding box
  29448. * @param target The object to check
  29449. * @returns true if the object is in frustum otherwise false
  29450. */
  29451. isCompletelyInFrustum(target: ICullable): boolean;
  29452. /**
  29453. * Gets a ray in the forward direction from the camera.
  29454. * @param length Defines the length of the ray to create
  29455. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29456. * @param origin Defines the start point of the ray which defaults to the camera position
  29457. * @returns the forward ray
  29458. */
  29459. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29460. /**
  29461. * Releases resources associated with this node.
  29462. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29463. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29464. */
  29465. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29466. /** @hidden */
  29467. _isLeftCamera: boolean;
  29468. /**
  29469. * Gets the left camera of a rig setup in case of Rigged Camera
  29470. */
  29471. get isLeftCamera(): boolean;
  29472. /** @hidden */
  29473. _isRightCamera: boolean;
  29474. /**
  29475. * Gets the right camera of a rig setup in case of Rigged Camera
  29476. */
  29477. get isRightCamera(): boolean;
  29478. /**
  29479. * Gets the left camera of a rig setup in case of Rigged Camera
  29480. */
  29481. get leftCamera(): Nullable<FreeCamera>;
  29482. /**
  29483. * Gets the right camera of a rig setup in case of Rigged Camera
  29484. */
  29485. get rightCamera(): Nullable<FreeCamera>;
  29486. /**
  29487. * Gets the left camera target of a rig setup in case of Rigged Camera
  29488. * @returns the target position
  29489. */
  29490. getLeftTarget(): Nullable<Vector3>;
  29491. /**
  29492. * Gets the right camera target of a rig setup in case of Rigged Camera
  29493. * @returns the target position
  29494. */
  29495. getRightTarget(): Nullable<Vector3>;
  29496. /**
  29497. * @hidden
  29498. */
  29499. setCameraRigMode(mode: number, rigParams: any): void;
  29500. /** @hidden */
  29501. static _setStereoscopicRigMode(camera: Camera): void;
  29502. /** @hidden */
  29503. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29504. /** @hidden */
  29505. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29506. /** @hidden */
  29507. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29508. /** @hidden */
  29509. _getVRProjectionMatrix(): Matrix;
  29510. protected _updateCameraRotationMatrix(): void;
  29511. protected _updateWebVRCameraRotationMatrix(): void;
  29512. /**
  29513. * This function MUST be overwritten by the different WebVR cameras available.
  29514. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29515. * @hidden
  29516. */
  29517. _getWebVRProjectionMatrix(): Matrix;
  29518. /**
  29519. * This function MUST be overwritten by the different WebVR cameras available.
  29520. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29521. * @hidden
  29522. */
  29523. _getWebVRViewMatrix(): Matrix;
  29524. /** @hidden */
  29525. setCameraRigParameter(name: string, value: any): void;
  29526. /**
  29527. * needs to be overridden by children so sub has required properties to be copied
  29528. * @hidden
  29529. */
  29530. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29531. /**
  29532. * May need to be overridden by children
  29533. * @hidden
  29534. */
  29535. _updateRigCameras(): void;
  29536. /** @hidden */
  29537. _setupInputs(): void;
  29538. /**
  29539. * Serialiaze the camera setup to a json represention
  29540. * @returns the JSON representation
  29541. */
  29542. serialize(): any;
  29543. /**
  29544. * Clones the current camera.
  29545. * @param name The cloned camera name
  29546. * @returns the cloned camera
  29547. */
  29548. clone(name: string): Camera;
  29549. /**
  29550. * Gets the direction of the camera relative to a given local axis.
  29551. * @param localAxis Defines the reference axis to provide a relative direction.
  29552. * @return the direction
  29553. */
  29554. getDirection(localAxis: Vector3): Vector3;
  29555. /**
  29556. * Returns the current camera absolute rotation
  29557. */
  29558. get absoluteRotation(): Quaternion;
  29559. /**
  29560. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29561. * @param localAxis Defines the reference axis to provide a relative direction.
  29562. * @param result Defines the vector to store the result in
  29563. */
  29564. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29565. /**
  29566. * Gets a camera constructor for a given camera type
  29567. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29568. * @param name The name of the camera the result will be able to instantiate
  29569. * @param scene The scene the result will construct the camera in
  29570. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29571. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29572. * @returns a factory method to construc the camera
  29573. */
  29574. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29575. /**
  29576. * Compute the world matrix of the camera.
  29577. * @returns the camera world matrix
  29578. */
  29579. computeWorldMatrix(): Matrix;
  29580. /**
  29581. * Parse a JSON and creates the camera from the parsed information
  29582. * @param parsedCamera The JSON to parse
  29583. * @param scene The scene to instantiate the camera in
  29584. * @returns the newly constructed camera
  29585. */
  29586. static Parse(parsedCamera: any, scene: Scene): Camera;
  29587. }
  29588. }
  29589. declare module BABYLON {
  29590. /**
  29591. * Class containing static functions to help procedurally build meshes
  29592. */
  29593. export class DiscBuilder {
  29594. /**
  29595. * Creates a plane polygonal mesh. By default, this is a disc
  29596. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  29597. * * 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
  29598. * * 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
  29599. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29600. * * 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
  29601. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29602. * @param name defines the name of the mesh
  29603. * @param options defines the options used to create the mesh
  29604. * @param scene defines the hosting scene
  29605. * @returns the plane polygonal mesh
  29606. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  29607. */
  29608. static CreateDisc(name: string, options: {
  29609. radius?: number;
  29610. tessellation?: number;
  29611. arc?: number;
  29612. updatable?: boolean;
  29613. sideOrientation?: number;
  29614. frontUVs?: Vector4;
  29615. backUVs?: Vector4;
  29616. }, scene?: Nullable<Scene>): Mesh;
  29617. }
  29618. }
  29619. declare module BABYLON {
  29620. /**
  29621. * Options to be used when creating a FresnelParameters.
  29622. */
  29623. export type IFresnelParametersCreationOptions = {
  29624. /**
  29625. * Define the color used on edges (grazing angle)
  29626. */
  29627. leftColor?: Color3;
  29628. /**
  29629. * Define the color used on center
  29630. */
  29631. rightColor?: Color3;
  29632. /**
  29633. * Define bias applied to computed fresnel term
  29634. */
  29635. bias?: number;
  29636. /**
  29637. * Defined the power exponent applied to fresnel term
  29638. */
  29639. power?: number;
  29640. /**
  29641. * Define if the fresnel effect is enable or not.
  29642. */
  29643. isEnabled?: boolean;
  29644. };
  29645. /**
  29646. * Serialized format for FresnelParameters.
  29647. */
  29648. export type IFresnelParametersSerialized = {
  29649. /**
  29650. * Define the color used on edges (grazing angle) [as an array]
  29651. */
  29652. leftColor: number[];
  29653. /**
  29654. * Define the color used on center [as an array]
  29655. */
  29656. rightColor: number[];
  29657. /**
  29658. * Define bias applied to computed fresnel term
  29659. */
  29660. bias: number;
  29661. /**
  29662. * Defined the power exponent applied to fresnel term
  29663. */
  29664. power?: number;
  29665. /**
  29666. * Define if the fresnel effect is enable or not.
  29667. */
  29668. isEnabled: boolean;
  29669. };
  29670. /**
  29671. * This represents all the required information to add a fresnel effect on a material:
  29672. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29673. */
  29674. export class FresnelParameters {
  29675. private _isEnabled;
  29676. /**
  29677. * Define if the fresnel effect is enable or not.
  29678. */
  29679. get isEnabled(): boolean;
  29680. set isEnabled(value: boolean);
  29681. /**
  29682. * Define the color used on edges (grazing angle)
  29683. */
  29684. leftColor: Color3;
  29685. /**
  29686. * Define the color used on center
  29687. */
  29688. rightColor: Color3;
  29689. /**
  29690. * Define bias applied to computed fresnel term
  29691. */
  29692. bias: number;
  29693. /**
  29694. * Defined the power exponent applied to fresnel term
  29695. */
  29696. power: number;
  29697. /**
  29698. * Creates a new FresnelParameters object.
  29699. *
  29700. * @param options provide your own settings to optionally to override defaults
  29701. */
  29702. constructor(options?: IFresnelParametersCreationOptions);
  29703. /**
  29704. * Clones the current fresnel and its valuues
  29705. * @returns a clone fresnel configuration
  29706. */
  29707. clone(): FresnelParameters;
  29708. /**
  29709. * Determines equality between FresnelParameters objects
  29710. * @param otherFresnelParameters defines the second operand
  29711. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  29712. */
  29713. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  29714. /**
  29715. * Serializes the current fresnel parameters to a JSON representation.
  29716. * @return the JSON serialization
  29717. */
  29718. serialize(): IFresnelParametersSerialized;
  29719. /**
  29720. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29721. * @param parsedFresnelParameters Define the JSON representation
  29722. * @returns the parsed parameters
  29723. */
  29724. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  29725. }
  29726. }
  29727. declare module BABYLON {
  29728. /**
  29729. * This groups all the flags used to control the materials channel.
  29730. */
  29731. export class MaterialFlags {
  29732. private static _DiffuseTextureEnabled;
  29733. /**
  29734. * Are diffuse textures enabled in the application.
  29735. */
  29736. static get DiffuseTextureEnabled(): boolean;
  29737. static set DiffuseTextureEnabled(value: boolean);
  29738. private static _DetailTextureEnabled;
  29739. /**
  29740. * Are detail textures enabled in the application.
  29741. */
  29742. static get DetailTextureEnabled(): boolean;
  29743. static set DetailTextureEnabled(value: boolean);
  29744. private static _AmbientTextureEnabled;
  29745. /**
  29746. * Are ambient textures enabled in the application.
  29747. */
  29748. static get AmbientTextureEnabled(): boolean;
  29749. static set AmbientTextureEnabled(value: boolean);
  29750. private static _OpacityTextureEnabled;
  29751. /**
  29752. * Are opacity textures enabled in the application.
  29753. */
  29754. static get OpacityTextureEnabled(): boolean;
  29755. static set OpacityTextureEnabled(value: boolean);
  29756. private static _ReflectionTextureEnabled;
  29757. /**
  29758. * Are reflection textures enabled in the application.
  29759. */
  29760. static get ReflectionTextureEnabled(): boolean;
  29761. static set ReflectionTextureEnabled(value: boolean);
  29762. private static _EmissiveTextureEnabled;
  29763. /**
  29764. * Are emissive textures enabled in the application.
  29765. */
  29766. static get EmissiveTextureEnabled(): boolean;
  29767. static set EmissiveTextureEnabled(value: boolean);
  29768. private static _SpecularTextureEnabled;
  29769. /**
  29770. * Are specular textures enabled in the application.
  29771. */
  29772. static get SpecularTextureEnabled(): boolean;
  29773. static set SpecularTextureEnabled(value: boolean);
  29774. private static _BumpTextureEnabled;
  29775. /**
  29776. * Are bump textures enabled in the application.
  29777. */
  29778. static get BumpTextureEnabled(): boolean;
  29779. static set BumpTextureEnabled(value: boolean);
  29780. private static _LightmapTextureEnabled;
  29781. /**
  29782. * Are lightmap textures enabled in the application.
  29783. */
  29784. static get LightmapTextureEnabled(): boolean;
  29785. static set LightmapTextureEnabled(value: boolean);
  29786. private static _RefractionTextureEnabled;
  29787. /**
  29788. * Are refraction textures enabled in the application.
  29789. */
  29790. static get RefractionTextureEnabled(): boolean;
  29791. static set RefractionTextureEnabled(value: boolean);
  29792. private static _ColorGradingTextureEnabled;
  29793. /**
  29794. * Are color grading textures enabled in the application.
  29795. */
  29796. static get ColorGradingTextureEnabled(): boolean;
  29797. static set ColorGradingTextureEnabled(value: boolean);
  29798. private static _FresnelEnabled;
  29799. /**
  29800. * Are fresnels enabled in the application.
  29801. */
  29802. static get FresnelEnabled(): boolean;
  29803. static set FresnelEnabled(value: boolean);
  29804. private static _ClearCoatTextureEnabled;
  29805. /**
  29806. * Are clear coat textures enabled in the application.
  29807. */
  29808. static get ClearCoatTextureEnabled(): boolean;
  29809. static set ClearCoatTextureEnabled(value: boolean);
  29810. private static _ClearCoatBumpTextureEnabled;
  29811. /**
  29812. * Are clear coat bump textures enabled in the application.
  29813. */
  29814. static get ClearCoatBumpTextureEnabled(): boolean;
  29815. static set ClearCoatBumpTextureEnabled(value: boolean);
  29816. private static _ClearCoatTintTextureEnabled;
  29817. /**
  29818. * Are clear coat tint textures enabled in the application.
  29819. */
  29820. static get ClearCoatTintTextureEnabled(): boolean;
  29821. static set ClearCoatTintTextureEnabled(value: boolean);
  29822. private static _SheenTextureEnabled;
  29823. /**
  29824. * Are sheen textures enabled in the application.
  29825. */
  29826. static get SheenTextureEnabled(): boolean;
  29827. static set SheenTextureEnabled(value: boolean);
  29828. private static _AnisotropicTextureEnabled;
  29829. /**
  29830. * Are anisotropic textures enabled in the application.
  29831. */
  29832. static get AnisotropicTextureEnabled(): boolean;
  29833. static set AnisotropicTextureEnabled(value: boolean);
  29834. private static _ThicknessTextureEnabled;
  29835. /**
  29836. * Are thickness textures enabled in the application.
  29837. */
  29838. static get ThicknessTextureEnabled(): boolean;
  29839. static set ThicknessTextureEnabled(value: boolean);
  29840. }
  29841. }
  29842. declare module BABYLON {
  29843. /** @hidden */
  29844. export var defaultFragmentDeclaration: {
  29845. name: string;
  29846. shader: string;
  29847. };
  29848. }
  29849. declare module BABYLON {
  29850. /** @hidden */
  29851. export var defaultUboDeclaration: {
  29852. name: string;
  29853. shader: string;
  29854. };
  29855. }
  29856. declare module BABYLON {
  29857. /** @hidden */
  29858. export var prePassDeclaration: {
  29859. name: string;
  29860. shader: string;
  29861. };
  29862. }
  29863. declare module BABYLON {
  29864. /** @hidden */
  29865. export var lightFragmentDeclaration: {
  29866. name: string;
  29867. shader: string;
  29868. };
  29869. }
  29870. declare module BABYLON {
  29871. /** @hidden */
  29872. export var lightUboDeclaration: {
  29873. name: string;
  29874. shader: string;
  29875. };
  29876. }
  29877. declare module BABYLON {
  29878. /** @hidden */
  29879. export var lightsFragmentFunctions: {
  29880. name: string;
  29881. shader: string;
  29882. };
  29883. }
  29884. declare module BABYLON {
  29885. /** @hidden */
  29886. export var shadowsFragmentFunctions: {
  29887. name: string;
  29888. shader: string;
  29889. };
  29890. }
  29891. declare module BABYLON {
  29892. /** @hidden */
  29893. export var fresnelFunction: {
  29894. name: string;
  29895. shader: string;
  29896. };
  29897. }
  29898. declare module BABYLON {
  29899. /** @hidden */
  29900. export var bumpFragmentMainFunctions: {
  29901. name: string;
  29902. shader: string;
  29903. };
  29904. }
  29905. declare module BABYLON {
  29906. /** @hidden */
  29907. export var bumpFragmentFunctions: {
  29908. name: string;
  29909. shader: string;
  29910. };
  29911. }
  29912. declare module BABYLON {
  29913. /** @hidden */
  29914. export var logDepthDeclaration: {
  29915. name: string;
  29916. shader: string;
  29917. };
  29918. }
  29919. declare module BABYLON {
  29920. /** @hidden */
  29921. export var bumpFragment: {
  29922. name: string;
  29923. shader: string;
  29924. };
  29925. }
  29926. declare module BABYLON {
  29927. /** @hidden */
  29928. export var depthPrePass: {
  29929. name: string;
  29930. shader: string;
  29931. };
  29932. }
  29933. declare module BABYLON {
  29934. /** @hidden */
  29935. export var lightFragment: {
  29936. name: string;
  29937. shader: string;
  29938. };
  29939. }
  29940. declare module BABYLON {
  29941. /** @hidden */
  29942. export var logDepthFragment: {
  29943. name: string;
  29944. shader: string;
  29945. };
  29946. }
  29947. declare module BABYLON {
  29948. /** @hidden */
  29949. export var defaultPixelShader: {
  29950. name: string;
  29951. shader: string;
  29952. };
  29953. }
  29954. declare module BABYLON {
  29955. /** @hidden */
  29956. export var defaultVertexDeclaration: {
  29957. name: string;
  29958. shader: string;
  29959. };
  29960. }
  29961. declare module BABYLON {
  29962. /** @hidden */
  29963. export var bumpVertexDeclaration: {
  29964. name: string;
  29965. shader: string;
  29966. };
  29967. }
  29968. declare module BABYLON {
  29969. /** @hidden */
  29970. export var bumpVertex: {
  29971. name: string;
  29972. shader: string;
  29973. };
  29974. }
  29975. declare module BABYLON {
  29976. /** @hidden */
  29977. export var fogVertex: {
  29978. name: string;
  29979. shader: string;
  29980. };
  29981. }
  29982. declare module BABYLON {
  29983. /** @hidden */
  29984. export var shadowsVertex: {
  29985. name: string;
  29986. shader: string;
  29987. };
  29988. }
  29989. declare module BABYLON {
  29990. /** @hidden */
  29991. export var pointCloudVertex: {
  29992. name: string;
  29993. shader: string;
  29994. };
  29995. }
  29996. declare module BABYLON {
  29997. /** @hidden */
  29998. export var logDepthVertex: {
  29999. name: string;
  30000. shader: string;
  30001. };
  30002. }
  30003. declare module BABYLON {
  30004. /** @hidden */
  30005. export var defaultVertexShader: {
  30006. name: string;
  30007. shader: string;
  30008. };
  30009. }
  30010. declare module BABYLON {
  30011. /**
  30012. * @hidden
  30013. */
  30014. export interface IMaterialDetailMapDefines {
  30015. DETAIL: boolean;
  30016. DETAILDIRECTUV: number;
  30017. DETAIL_NORMALBLENDMETHOD: number;
  30018. /** @hidden */
  30019. _areTexturesDirty: boolean;
  30020. }
  30021. /**
  30022. * Define the code related to the detail map parameters of a material
  30023. *
  30024. * Inspired from:
  30025. * 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
  30026. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  30027. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  30028. */
  30029. export class DetailMapConfiguration {
  30030. private _texture;
  30031. /**
  30032. * The detail texture of the material.
  30033. */
  30034. texture: Nullable<BaseTexture>;
  30035. /**
  30036. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  30037. * Bigger values mean stronger blending
  30038. */
  30039. diffuseBlendLevel: number;
  30040. /**
  30041. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  30042. * Bigger values mean stronger blending. Only used with PBR materials
  30043. */
  30044. roughnessBlendLevel: number;
  30045. /**
  30046. * Defines how strong the bump effect from the detail map is
  30047. * Bigger values mean stronger effect
  30048. */
  30049. bumpLevel: number;
  30050. private _normalBlendMethod;
  30051. /**
  30052. * The method used to blend the bump and detail normals together
  30053. */
  30054. normalBlendMethod: number;
  30055. private _isEnabled;
  30056. /**
  30057. * Enable or disable the detail map on this material
  30058. */
  30059. isEnabled: boolean;
  30060. /** @hidden */
  30061. private _internalMarkAllSubMeshesAsTexturesDirty;
  30062. /** @hidden */
  30063. _markAllSubMeshesAsTexturesDirty(): void;
  30064. /**
  30065. * Instantiate a new detail map
  30066. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  30067. */
  30068. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  30069. /**
  30070. * Gets whether the submesh is ready to be used or not.
  30071. * @param defines the list of "defines" to update.
  30072. * @param scene defines the scene the material belongs to.
  30073. * @returns - boolean indicating that the submesh is ready or not.
  30074. */
  30075. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  30076. /**
  30077. * Update the defines for detail map usage
  30078. * @param defines the list of "defines" to update.
  30079. * @param scene defines the scene the material belongs to.
  30080. */
  30081. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  30082. /**
  30083. * Binds the material data.
  30084. * @param uniformBuffer defines the Uniform buffer to fill in.
  30085. * @param scene defines the scene the material belongs to.
  30086. * @param isFrozen defines whether the material is frozen or not.
  30087. */
  30088. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  30089. /**
  30090. * Checks to see if a texture is used in the material.
  30091. * @param texture - Base texture to use.
  30092. * @returns - Boolean specifying if a texture is used in the material.
  30093. */
  30094. hasTexture(texture: BaseTexture): boolean;
  30095. /**
  30096. * Returns an array of the actively used textures.
  30097. * @param activeTextures Array of BaseTextures
  30098. */
  30099. getActiveTextures(activeTextures: BaseTexture[]): void;
  30100. /**
  30101. * Returns the animatable textures.
  30102. * @param animatables Array of animatable textures.
  30103. */
  30104. getAnimatables(animatables: IAnimatable[]): void;
  30105. /**
  30106. * Disposes the resources of the material.
  30107. * @param forceDisposeTextures - Forces the disposal of all textures.
  30108. */
  30109. dispose(forceDisposeTextures?: boolean): void;
  30110. /**
  30111. * Get the current class name useful for serialization or dynamic coding.
  30112. * @returns "DetailMap"
  30113. */
  30114. getClassName(): string;
  30115. /**
  30116. * Add the required uniforms to the current list.
  30117. * @param uniforms defines the current uniform list.
  30118. */
  30119. static AddUniforms(uniforms: string[]): void;
  30120. /**
  30121. * Add the required samplers to the current list.
  30122. * @param samplers defines the current sampler list.
  30123. */
  30124. static AddSamplers(samplers: string[]): void;
  30125. /**
  30126. * Add the required uniforms to the current buffer.
  30127. * @param uniformBuffer defines the current uniform buffer.
  30128. */
  30129. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  30130. /**
  30131. * Makes a duplicate of the current instance into another one.
  30132. * @param detailMap define the instance where to copy the info
  30133. */
  30134. copyTo(detailMap: DetailMapConfiguration): void;
  30135. /**
  30136. * Serializes this detail map instance
  30137. * @returns - An object with the serialized instance.
  30138. */
  30139. serialize(): any;
  30140. /**
  30141. * Parses a detail map setting from a serialized object.
  30142. * @param source - Serialized object.
  30143. * @param scene Defines the scene we are parsing for
  30144. * @param rootUrl Defines the rootUrl to load from
  30145. */
  30146. parse(source: any, scene: Scene, rootUrl: string): void;
  30147. }
  30148. }
  30149. declare module BABYLON {
  30150. /** @hidden */
  30151. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  30152. MAINUV1: boolean;
  30153. MAINUV2: boolean;
  30154. DIFFUSE: boolean;
  30155. DIFFUSEDIRECTUV: number;
  30156. DETAIL: boolean;
  30157. DETAILDIRECTUV: number;
  30158. DETAIL_NORMALBLENDMETHOD: number;
  30159. AMBIENT: boolean;
  30160. AMBIENTDIRECTUV: number;
  30161. OPACITY: boolean;
  30162. OPACITYDIRECTUV: number;
  30163. OPACITYRGB: boolean;
  30164. REFLECTION: boolean;
  30165. EMISSIVE: boolean;
  30166. EMISSIVEDIRECTUV: number;
  30167. SPECULAR: boolean;
  30168. SPECULARDIRECTUV: number;
  30169. BUMP: boolean;
  30170. BUMPDIRECTUV: number;
  30171. PARALLAX: boolean;
  30172. PARALLAXOCCLUSION: boolean;
  30173. SPECULAROVERALPHA: boolean;
  30174. CLIPPLANE: boolean;
  30175. CLIPPLANE2: boolean;
  30176. CLIPPLANE3: boolean;
  30177. CLIPPLANE4: boolean;
  30178. CLIPPLANE5: boolean;
  30179. CLIPPLANE6: boolean;
  30180. ALPHATEST: boolean;
  30181. DEPTHPREPASS: boolean;
  30182. ALPHAFROMDIFFUSE: boolean;
  30183. POINTSIZE: boolean;
  30184. FOG: boolean;
  30185. SPECULARTERM: boolean;
  30186. DIFFUSEFRESNEL: boolean;
  30187. OPACITYFRESNEL: boolean;
  30188. REFLECTIONFRESNEL: boolean;
  30189. REFRACTIONFRESNEL: boolean;
  30190. EMISSIVEFRESNEL: boolean;
  30191. FRESNEL: boolean;
  30192. NORMAL: boolean;
  30193. UV1: boolean;
  30194. UV2: boolean;
  30195. VERTEXCOLOR: boolean;
  30196. VERTEXALPHA: boolean;
  30197. NUM_BONE_INFLUENCERS: number;
  30198. BonesPerMesh: number;
  30199. BONETEXTURE: boolean;
  30200. INSTANCES: boolean;
  30201. THIN_INSTANCES: boolean;
  30202. GLOSSINESS: boolean;
  30203. ROUGHNESS: boolean;
  30204. EMISSIVEASILLUMINATION: boolean;
  30205. LINKEMISSIVEWITHDIFFUSE: boolean;
  30206. REFLECTIONFRESNELFROMSPECULAR: boolean;
  30207. LIGHTMAP: boolean;
  30208. LIGHTMAPDIRECTUV: number;
  30209. OBJECTSPACE_NORMALMAP: boolean;
  30210. USELIGHTMAPASSHADOWMAP: boolean;
  30211. REFLECTIONMAP_3D: boolean;
  30212. REFLECTIONMAP_SPHERICAL: boolean;
  30213. REFLECTIONMAP_PLANAR: boolean;
  30214. REFLECTIONMAP_CUBIC: boolean;
  30215. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  30216. REFLECTIONMAP_PROJECTION: boolean;
  30217. REFLECTIONMAP_SKYBOX: boolean;
  30218. REFLECTIONMAP_EXPLICIT: boolean;
  30219. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  30220. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  30221. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  30222. INVERTCUBICMAP: boolean;
  30223. LOGARITHMICDEPTH: boolean;
  30224. REFRACTION: boolean;
  30225. REFRACTIONMAP_3D: boolean;
  30226. REFLECTIONOVERALPHA: boolean;
  30227. TWOSIDEDLIGHTING: boolean;
  30228. SHADOWFLOAT: boolean;
  30229. MORPHTARGETS: boolean;
  30230. MORPHTARGETS_NORMAL: boolean;
  30231. MORPHTARGETS_TANGENT: boolean;
  30232. MORPHTARGETS_UV: boolean;
  30233. NUM_MORPH_INFLUENCERS: number;
  30234. NONUNIFORMSCALING: boolean;
  30235. PREMULTIPLYALPHA: boolean;
  30236. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  30237. ALPHABLEND: boolean;
  30238. PREPASS: boolean;
  30239. SCENE_MRT_COUNT: number;
  30240. RGBDLIGHTMAP: boolean;
  30241. RGBDREFLECTION: boolean;
  30242. RGBDREFRACTION: boolean;
  30243. IMAGEPROCESSING: boolean;
  30244. VIGNETTE: boolean;
  30245. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30246. VIGNETTEBLENDMODEOPAQUE: boolean;
  30247. TONEMAPPING: boolean;
  30248. TONEMAPPING_ACES: boolean;
  30249. CONTRAST: boolean;
  30250. COLORCURVES: boolean;
  30251. COLORGRADING: boolean;
  30252. COLORGRADING3D: boolean;
  30253. SAMPLER3DGREENDEPTH: boolean;
  30254. SAMPLER3DBGRMAP: boolean;
  30255. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30256. MULTIVIEW: boolean;
  30257. /**
  30258. * If the reflection texture on this material is in linear color space
  30259. * @hidden
  30260. */
  30261. IS_REFLECTION_LINEAR: boolean;
  30262. /**
  30263. * If the refraction texture on this material is in linear color space
  30264. * @hidden
  30265. */
  30266. IS_REFRACTION_LINEAR: boolean;
  30267. EXPOSURE: boolean;
  30268. constructor();
  30269. setReflectionMode(modeToEnable: string): void;
  30270. }
  30271. /**
  30272. * This is the default material used in Babylon. It is the best trade off between quality
  30273. * and performances.
  30274. * @see https://doc.babylonjs.com/babylon101/materials
  30275. */
  30276. export class StandardMaterial extends PushMaterial {
  30277. private _diffuseTexture;
  30278. /**
  30279. * The basic texture of the material as viewed under a light.
  30280. */
  30281. diffuseTexture: Nullable<BaseTexture>;
  30282. private _ambientTexture;
  30283. /**
  30284. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  30285. */
  30286. ambientTexture: Nullable<BaseTexture>;
  30287. private _opacityTexture;
  30288. /**
  30289. * Define the transparency of the material from a texture.
  30290. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  30291. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  30292. */
  30293. opacityTexture: Nullable<BaseTexture>;
  30294. private _reflectionTexture;
  30295. /**
  30296. * Define the texture used to display the reflection.
  30297. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30298. */
  30299. reflectionTexture: Nullable<BaseTexture>;
  30300. private _emissiveTexture;
  30301. /**
  30302. * Define texture of the material as if self lit.
  30303. * This will be mixed in the final result even in the absence of light.
  30304. */
  30305. emissiveTexture: Nullable<BaseTexture>;
  30306. private _specularTexture;
  30307. /**
  30308. * Define how the color and intensity of the highlight given by the light in the material.
  30309. */
  30310. specularTexture: Nullable<BaseTexture>;
  30311. private _bumpTexture;
  30312. /**
  30313. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  30314. * 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.
  30315. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  30316. */
  30317. bumpTexture: Nullable<BaseTexture>;
  30318. private _lightmapTexture;
  30319. /**
  30320. * Complex lighting can be computationally expensive to compute at runtime.
  30321. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  30322. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  30323. */
  30324. lightmapTexture: Nullable<BaseTexture>;
  30325. private _refractionTexture;
  30326. /**
  30327. * Define the texture used to display the refraction.
  30328. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30329. */
  30330. refractionTexture: Nullable<BaseTexture>;
  30331. /**
  30332. * The color of the material lit by the environmental background lighting.
  30333. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  30334. */
  30335. ambientColor: Color3;
  30336. /**
  30337. * The basic color of the material as viewed under a light.
  30338. */
  30339. diffuseColor: Color3;
  30340. /**
  30341. * Define how the color and intensity of the highlight given by the light in the material.
  30342. */
  30343. specularColor: Color3;
  30344. /**
  30345. * Define the color of the material as if self lit.
  30346. * This will be mixed in the final result even in the absence of light.
  30347. */
  30348. emissiveColor: Color3;
  30349. /**
  30350. * Defines how sharp are the highlights in the material.
  30351. * The bigger the value the sharper giving a more glossy feeling to the result.
  30352. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  30353. */
  30354. specularPower: number;
  30355. private _useAlphaFromDiffuseTexture;
  30356. /**
  30357. * Does the transparency come from the diffuse texture alpha channel.
  30358. */
  30359. useAlphaFromDiffuseTexture: boolean;
  30360. private _useEmissiveAsIllumination;
  30361. /**
  30362. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  30363. */
  30364. useEmissiveAsIllumination: boolean;
  30365. private _linkEmissiveWithDiffuse;
  30366. /**
  30367. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  30368. * the emissive level when the final color is close to one.
  30369. */
  30370. linkEmissiveWithDiffuse: boolean;
  30371. private _useSpecularOverAlpha;
  30372. /**
  30373. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  30374. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30375. */
  30376. useSpecularOverAlpha: boolean;
  30377. private _useReflectionOverAlpha;
  30378. /**
  30379. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30380. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30381. */
  30382. useReflectionOverAlpha: boolean;
  30383. private _disableLighting;
  30384. /**
  30385. * Does lights from the scene impacts this material.
  30386. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  30387. */
  30388. disableLighting: boolean;
  30389. private _useObjectSpaceNormalMap;
  30390. /**
  30391. * Allows using an object space normal map (instead of tangent space).
  30392. */
  30393. useObjectSpaceNormalMap: boolean;
  30394. private _useParallax;
  30395. /**
  30396. * Is parallax enabled or not.
  30397. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30398. */
  30399. useParallax: boolean;
  30400. private _useParallaxOcclusion;
  30401. /**
  30402. * Is parallax occlusion enabled or not.
  30403. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  30404. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30405. */
  30406. useParallaxOcclusion: boolean;
  30407. /**
  30408. * 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.
  30409. */
  30410. parallaxScaleBias: number;
  30411. private _roughness;
  30412. /**
  30413. * Helps to define how blurry the reflections should appears in the material.
  30414. */
  30415. roughness: number;
  30416. /**
  30417. * In case of refraction, define the value of the index of refraction.
  30418. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30419. */
  30420. indexOfRefraction: number;
  30421. /**
  30422. * Invert the refraction texture alongside the y axis.
  30423. * It can be useful with procedural textures or probe for instance.
  30424. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30425. */
  30426. invertRefractionY: boolean;
  30427. /**
  30428. * Defines the alpha limits in alpha test mode.
  30429. */
  30430. alphaCutOff: number;
  30431. private _useLightmapAsShadowmap;
  30432. /**
  30433. * In case of light mapping, define whether the map contains light or shadow informations.
  30434. */
  30435. useLightmapAsShadowmap: boolean;
  30436. private _diffuseFresnelParameters;
  30437. /**
  30438. * Define the diffuse fresnel parameters of the material.
  30439. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30440. */
  30441. diffuseFresnelParameters: FresnelParameters;
  30442. private _opacityFresnelParameters;
  30443. /**
  30444. * Define the opacity fresnel parameters of the material.
  30445. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30446. */
  30447. opacityFresnelParameters: FresnelParameters;
  30448. private _reflectionFresnelParameters;
  30449. /**
  30450. * Define the reflection fresnel parameters of the material.
  30451. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30452. */
  30453. reflectionFresnelParameters: FresnelParameters;
  30454. private _refractionFresnelParameters;
  30455. /**
  30456. * Define the refraction fresnel parameters of the material.
  30457. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30458. */
  30459. refractionFresnelParameters: FresnelParameters;
  30460. private _emissiveFresnelParameters;
  30461. /**
  30462. * Define the emissive fresnel parameters of the material.
  30463. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30464. */
  30465. emissiveFresnelParameters: FresnelParameters;
  30466. private _useReflectionFresnelFromSpecular;
  30467. /**
  30468. * If true automatically deducts the fresnels values from the material specularity.
  30469. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30470. */
  30471. useReflectionFresnelFromSpecular: boolean;
  30472. private _useGlossinessFromSpecularMapAlpha;
  30473. /**
  30474. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  30475. */
  30476. useGlossinessFromSpecularMapAlpha: boolean;
  30477. private _maxSimultaneousLights;
  30478. /**
  30479. * Defines the maximum number of lights that can be used in the material
  30480. */
  30481. maxSimultaneousLights: number;
  30482. private _invertNormalMapX;
  30483. /**
  30484. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30485. */
  30486. invertNormalMapX: boolean;
  30487. private _invertNormalMapY;
  30488. /**
  30489. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30490. */
  30491. invertNormalMapY: boolean;
  30492. private _twoSidedLighting;
  30493. /**
  30494. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30495. */
  30496. twoSidedLighting: boolean;
  30497. /**
  30498. * Default configuration related to image processing available in the standard Material.
  30499. */
  30500. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30501. /**
  30502. * Gets the image processing configuration used either in this material.
  30503. */
  30504. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  30505. /**
  30506. * Sets the Default image processing configuration used either in the this material.
  30507. *
  30508. * If sets to null, the scene one is in use.
  30509. */
  30510. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  30511. /**
  30512. * Keep track of the image processing observer to allow dispose and replace.
  30513. */
  30514. private _imageProcessingObserver;
  30515. /**
  30516. * Attaches a new image processing configuration to the Standard Material.
  30517. * @param configuration
  30518. */
  30519. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30520. /**
  30521. * Gets wether the color curves effect is enabled.
  30522. */
  30523. get cameraColorCurvesEnabled(): boolean;
  30524. /**
  30525. * Sets wether the color curves effect is enabled.
  30526. */
  30527. set cameraColorCurvesEnabled(value: boolean);
  30528. /**
  30529. * Gets wether the color grading effect is enabled.
  30530. */
  30531. get cameraColorGradingEnabled(): boolean;
  30532. /**
  30533. * Gets wether the color grading effect is enabled.
  30534. */
  30535. set cameraColorGradingEnabled(value: boolean);
  30536. /**
  30537. * Gets wether tonemapping is enabled or not.
  30538. */
  30539. get cameraToneMappingEnabled(): boolean;
  30540. /**
  30541. * Sets wether tonemapping is enabled or not
  30542. */
  30543. set cameraToneMappingEnabled(value: boolean);
  30544. /**
  30545. * The camera exposure used on this material.
  30546. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30547. * This corresponds to a photographic exposure.
  30548. */
  30549. get cameraExposure(): number;
  30550. /**
  30551. * The camera exposure used on this material.
  30552. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30553. * This corresponds to a photographic exposure.
  30554. */
  30555. set cameraExposure(value: number);
  30556. /**
  30557. * Gets The camera contrast used on this material.
  30558. */
  30559. get cameraContrast(): number;
  30560. /**
  30561. * Sets The camera contrast used on this material.
  30562. */
  30563. set cameraContrast(value: number);
  30564. /**
  30565. * Gets the Color Grading 2D Lookup Texture.
  30566. */
  30567. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  30568. /**
  30569. * Sets the Color Grading 2D Lookup Texture.
  30570. */
  30571. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  30572. /**
  30573. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30574. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30575. * 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;
  30576. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30577. */
  30578. get cameraColorCurves(): Nullable<ColorCurves>;
  30579. /**
  30580. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30581. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30582. * 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;
  30583. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30584. */
  30585. set cameraColorCurves(value: Nullable<ColorCurves>);
  30586. /**
  30587. * Can this material render to several textures at once
  30588. */
  30589. get canRenderToMRT(): boolean;
  30590. /**
  30591. * Defines the detail map parameters for the material.
  30592. */
  30593. readonly detailMap: DetailMapConfiguration;
  30594. protected _renderTargets: SmartArray<RenderTargetTexture>;
  30595. protected _worldViewProjectionMatrix: Matrix;
  30596. protected _globalAmbientColor: Color3;
  30597. protected _useLogarithmicDepth: boolean;
  30598. protected _rebuildInParallel: boolean;
  30599. /**
  30600. * Instantiates a new standard material.
  30601. * This is the default material used in Babylon. It is the best trade off between quality
  30602. * and performances.
  30603. * @see https://doc.babylonjs.com/babylon101/materials
  30604. * @param name Define the name of the material in the scene
  30605. * @param scene Define the scene the material belong to
  30606. */
  30607. constructor(name: string, scene: Scene);
  30608. /**
  30609. * Gets a boolean indicating that current material needs to register RTT
  30610. */
  30611. get hasRenderTargetTextures(): boolean;
  30612. /**
  30613. * Gets the current class name of the material e.g. "StandardMaterial"
  30614. * Mainly use in serialization.
  30615. * @returns the class name
  30616. */
  30617. getClassName(): string;
  30618. /**
  30619. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  30620. * You can try switching to logarithmic depth.
  30621. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  30622. */
  30623. get useLogarithmicDepth(): boolean;
  30624. set useLogarithmicDepth(value: boolean);
  30625. /**
  30626. * Specifies if the material will require alpha blending
  30627. * @returns a boolean specifying if alpha blending is needed
  30628. */
  30629. needAlphaBlending(): boolean;
  30630. /**
  30631. * Specifies if this material should be rendered in alpha test mode
  30632. * @returns a boolean specifying if an alpha test is needed.
  30633. */
  30634. needAlphaTesting(): boolean;
  30635. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  30636. /**
  30637. * Get the texture used for alpha test purpose.
  30638. * @returns the diffuse texture in case of the standard material.
  30639. */
  30640. getAlphaTestTexture(): Nullable<BaseTexture>;
  30641. /**
  30642. * Get if the submesh is ready to be used and all its information available.
  30643. * Child classes can use it to update shaders
  30644. * @param mesh defines the mesh to check
  30645. * @param subMesh defines which submesh to check
  30646. * @param useInstances specifies that instances should be used
  30647. * @returns a boolean indicating that the submesh is ready or not
  30648. */
  30649. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30650. /**
  30651. * Builds the material UBO layouts.
  30652. * Used internally during the effect preparation.
  30653. */
  30654. buildUniformLayout(): void;
  30655. /**
  30656. * Unbinds the material from the mesh
  30657. */
  30658. unbind(): void;
  30659. /**
  30660. * Binds the submesh to this material by preparing the effect and shader to draw
  30661. * @param world defines the world transformation matrix
  30662. * @param mesh defines the mesh containing the submesh
  30663. * @param subMesh defines the submesh to bind the material to
  30664. */
  30665. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30666. /**
  30667. * Get the list of animatables in the material.
  30668. * @returns the list of animatables object used in the material
  30669. */
  30670. getAnimatables(): IAnimatable[];
  30671. /**
  30672. * Gets the active textures from the material
  30673. * @returns an array of textures
  30674. */
  30675. getActiveTextures(): BaseTexture[];
  30676. /**
  30677. * Specifies if the material uses a texture
  30678. * @param texture defines the texture to check against the material
  30679. * @returns a boolean specifying if the material uses the texture
  30680. */
  30681. hasTexture(texture: BaseTexture): boolean;
  30682. /**
  30683. * Disposes the material
  30684. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30685. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30686. */
  30687. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  30688. /**
  30689. * Makes a duplicate of the material, and gives it a new name
  30690. * @param name defines the new name for the duplicated material
  30691. * @returns the cloned material
  30692. */
  30693. clone(name: string): StandardMaterial;
  30694. /**
  30695. * Serializes this material in a JSON representation
  30696. * @returns the serialized material object
  30697. */
  30698. serialize(): any;
  30699. /**
  30700. * Creates a standard material from parsed material data
  30701. * @param source defines the JSON representation of the material
  30702. * @param scene defines the hosting scene
  30703. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  30704. * @returns a new standard material
  30705. */
  30706. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  30707. /**
  30708. * Are diffuse textures enabled in the application.
  30709. */
  30710. static get DiffuseTextureEnabled(): boolean;
  30711. static set DiffuseTextureEnabled(value: boolean);
  30712. /**
  30713. * Are detail textures enabled in the application.
  30714. */
  30715. static get DetailTextureEnabled(): boolean;
  30716. static set DetailTextureEnabled(value: boolean);
  30717. /**
  30718. * Are ambient textures enabled in the application.
  30719. */
  30720. static get AmbientTextureEnabled(): boolean;
  30721. static set AmbientTextureEnabled(value: boolean);
  30722. /**
  30723. * Are opacity textures enabled in the application.
  30724. */
  30725. static get OpacityTextureEnabled(): boolean;
  30726. static set OpacityTextureEnabled(value: boolean);
  30727. /**
  30728. * Are reflection textures enabled in the application.
  30729. */
  30730. static get ReflectionTextureEnabled(): boolean;
  30731. static set ReflectionTextureEnabled(value: boolean);
  30732. /**
  30733. * Are emissive textures enabled in the application.
  30734. */
  30735. static get EmissiveTextureEnabled(): boolean;
  30736. static set EmissiveTextureEnabled(value: boolean);
  30737. /**
  30738. * Are specular textures enabled in the application.
  30739. */
  30740. static get SpecularTextureEnabled(): boolean;
  30741. static set SpecularTextureEnabled(value: boolean);
  30742. /**
  30743. * Are bump textures enabled in the application.
  30744. */
  30745. static get BumpTextureEnabled(): boolean;
  30746. static set BumpTextureEnabled(value: boolean);
  30747. /**
  30748. * Are lightmap textures enabled in the application.
  30749. */
  30750. static get LightmapTextureEnabled(): boolean;
  30751. static set LightmapTextureEnabled(value: boolean);
  30752. /**
  30753. * Are refraction textures enabled in the application.
  30754. */
  30755. static get RefractionTextureEnabled(): boolean;
  30756. static set RefractionTextureEnabled(value: boolean);
  30757. /**
  30758. * Are color grading textures enabled in the application.
  30759. */
  30760. static get ColorGradingTextureEnabled(): boolean;
  30761. static set ColorGradingTextureEnabled(value: boolean);
  30762. /**
  30763. * Are fresnels enabled in the application.
  30764. */
  30765. static get FresnelEnabled(): boolean;
  30766. static set FresnelEnabled(value: boolean);
  30767. }
  30768. }
  30769. declare module BABYLON {
  30770. /**
  30771. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  30772. *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.
  30773. * The SPS is also a particle system. It provides some methods to manage the particles.
  30774. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  30775. *
  30776. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  30777. */
  30778. export class SolidParticleSystem implements IDisposable {
  30779. /**
  30780. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  30781. * Example : var p = SPS.particles[i];
  30782. */
  30783. particles: SolidParticle[];
  30784. /**
  30785. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  30786. */
  30787. nbParticles: number;
  30788. /**
  30789. * If the particles must ever face the camera (default false). Useful for planar particles.
  30790. */
  30791. billboard: boolean;
  30792. /**
  30793. * Recompute normals when adding a shape
  30794. */
  30795. recomputeNormals: boolean;
  30796. /**
  30797. * This a counter ofr your own usage. It's not set by any SPS functions.
  30798. */
  30799. counter: number;
  30800. /**
  30801. * The SPS name. This name is also given to the underlying mesh.
  30802. */
  30803. name: string;
  30804. /**
  30805. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  30806. */
  30807. mesh: Mesh;
  30808. /**
  30809. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  30810. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  30811. */
  30812. vars: any;
  30813. /**
  30814. * This array is populated when the SPS is set as 'pickable'.
  30815. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  30816. * Each element of this array is an object `{idx: int, faceId: int}`.
  30817. * `idx` is the picked particle index in the `SPS.particles` array
  30818. * `faceId` is the picked face index counted within this particle.
  30819. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  30820. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  30821. * Use the method SPS.pickedParticle(pickingInfo) instead.
  30822. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30823. */
  30824. pickedParticles: {
  30825. idx: number;
  30826. faceId: number;
  30827. }[];
  30828. /**
  30829. * This array is populated when the SPS is set as 'pickable'
  30830. * Each key of this array is a submesh index.
  30831. * Each element of this array is a second array defined like this :
  30832. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  30833. * Each element of this second array is an object `{idx: int, faceId: int}`.
  30834. * `idx` is the picked particle index in the `SPS.particles` array
  30835. * `faceId` is the picked face index counted within this particle.
  30836. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  30837. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30838. */
  30839. pickedBySubMesh: {
  30840. idx: number;
  30841. faceId: number;
  30842. }[][];
  30843. /**
  30844. * This array is populated when `enableDepthSort` is set to true.
  30845. * Each element of this array is an instance of the class DepthSortedParticle.
  30846. */
  30847. depthSortedParticles: DepthSortedParticle[];
  30848. /**
  30849. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  30850. * @hidden
  30851. */
  30852. _bSphereOnly: boolean;
  30853. /**
  30854. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  30855. * @hidden
  30856. */
  30857. _bSphereRadiusFactor: number;
  30858. private _scene;
  30859. private _positions;
  30860. private _indices;
  30861. private _normals;
  30862. private _colors;
  30863. private _uvs;
  30864. private _indices32;
  30865. private _positions32;
  30866. private _normals32;
  30867. private _fixedNormal32;
  30868. private _colors32;
  30869. private _uvs32;
  30870. private _index;
  30871. private _updatable;
  30872. private _pickable;
  30873. private _isVisibilityBoxLocked;
  30874. private _alwaysVisible;
  30875. private _depthSort;
  30876. private _expandable;
  30877. private _shapeCounter;
  30878. private _copy;
  30879. private _color;
  30880. private _computeParticleColor;
  30881. private _computeParticleTexture;
  30882. private _computeParticleRotation;
  30883. private _computeParticleVertex;
  30884. private _computeBoundingBox;
  30885. private _depthSortParticles;
  30886. private _camera;
  30887. private _mustUnrotateFixedNormals;
  30888. private _particlesIntersect;
  30889. private _needs32Bits;
  30890. private _isNotBuilt;
  30891. private _lastParticleId;
  30892. private _idxOfId;
  30893. private _multimaterialEnabled;
  30894. private _useModelMaterial;
  30895. private _indicesByMaterial;
  30896. private _materialIndexes;
  30897. private _depthSortFunction;
  30898. private _materialSortFunction;
  30899. private _materials;
  30900. private _multimaterial;
  30901. private _materialIndexesById;
  30902. private _defaultMaterial;
  30903. private _autoUpdateSubMeshes;
  30904. private _tmpVertex;
  30905. /**
  30906. * Creates a SPS (Solid Particle System) object.
  30907. * @param name (String) is the SPS name, this will be the underlying mesh name.
  30908. * @param scene (Scene) is the scene in which the SPS is added.
  30909. * @param options defines the options of the sps e.g.
  30910. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  30911. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  30912. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  30913. * * 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.
  30914. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  30915. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  30916. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  30917. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  30918. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  30919. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  30920. */
  30921. constructor(name: string, scene: Scene, options?: {
  30922. updatable?: boolean;
  30923. isPickable?: boolean;
  30924. enableDepthSort?: boolean;
  30925. particleIntersection?: boolean;
  30926. boundingSphereOnly?: boolean;
  30927. bSphereRadiusFactor?: number;
  30928. expandable?: boolean;
  30929. useModelMaterial?: boolean;
  30930. enableMultiMaterial?: boolean;
  30931. });
  30932. /**
  30933. * Builds the SPS underlying mesh. Returns a standard Mesh.
  30934. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  30935. * @returns the created mesh
  30936. */
  30937. buildMesh(): Mesh;
  30938. /**
  30939. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  30940. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  30941. * Thus the particles generated from `digest()` have their property `position` set yet.
  30942. * @param mesh ( Mesh ) is the mesh to be digested
  30943. * @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
  30944. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  30945. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  30946. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30947. * @returns the current SPS
  30948. */
  30949. digest(mesh: Mesh, options?: {
  30950. facetNb?: number;
  30951. number?: number;
  30952. delta?: number;
  30953. storage?: [];
  30954. }): SolidParticleSystem;
  30955. /**
  30956. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  30957. * @hidden
  30958. */
  30959. private _unrotateFixedNormals;
  30960. /**
  30961. * Resets the temporary working copy particle
  30962. * @hidden
  30963. */
  30964. private _resetCopy;
  30965. /**
  30966. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  30967. * @param p the current index in the positions array to be updated
  30968. * @param ind the current index in the indices array
  30969. * @param shape a Vector3 array, the shape geometry
  30970. * @param positions the positions array to be updated
  30971. * @param meshInd the shape indices array
  30972. * @param indices the indices array to be updated
  30973. * @param meshUV the shape uv array
  30974. * @param uvs the uv array to be updated
  30975. * @param meshCol the shape color array
  30976. * @param colors the color array to be updated
  30977. * @param meshNor the shape normals array
  30978. * @param normals the normals array to be updated
  30979. * @param idx the particle index
  30980. * @param idxInShape the particle index in its shape
  30981. * @param options the addShape() method passed options
  30982. * @model the particle model
  30983. * @hidden
  30984. */
  30985. private _meshBuilder;
  30986. /**
  30987. * Returns a shape Vector3 array from positions float array
  30988. * @param positions float array
  30989. * @returns a vector3 array
  30990. * @hidden
  30991. */
  30992. private _posToShape;
  30993. /**
  30994. * Returns a shapeUV array from a float uvs (array deep copy)
  30995. * @param uvs as a float array
  30996. * @returns a shapeUV array
  30997. * @hidden
  30998. */
  30999. private _uvsToShapeUV;
  31000. /**
  31001. * Adds a new particle object in the particles array
  31002. * @param idx particle index in particles array
  31003. * @param id particle id
  31004. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  31005. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  31006. * @param model particle ModelShape object
  31007. * @param shapeId model shape identifier
  31008. * @param idxInShape index of the particle in the current model
  31009. * @param bInfo model bounding info object
  31010. * @param storage target storage array, if any
  31011. * @hidden
  31012. */
  31013. private _addParticle;
  31014. /**
  31015. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31016. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  31017. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31018. * @param nb (positive integer) the number of particles to be created from this model
  31019. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31020. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31021. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31022. * @returns the number of shapes in the system
  31023. */
  31024. addShape(mesh: Mesh, nb: number, options?: {
  31025. positionFunction?: any;
  31026. vertexFunction?: any;
  31027. storage?: [];
  31028. }): number;
  31029. /**
  31030. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  31031. * @hidden
  31032. */
  31033. private _rebuildParticle;
  31034. /**
  31035. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31036. * @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.
  31037. * @returns the SPS.
  31038. */
  31039. rebuildMesh(reset?: boolean): SolidParticleSystem;
  31040. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  31041. * Returns an array with the removed particles.
  31042. * 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.
  31043. * The SPS can't be empty so at least one particle needs to remain in place.
  31044. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  31045. * @param start index of the first particle to remove
  31046. * @param end index of the last particle to remove (included)
  31047. * @returns an array populated with the removed particles
  31048. */
  31049. removeParticles(start: number, end: number): SolidParticle[];
  31050. /**
  31051. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  31052. * @param solidParticleArray an array populated with Solid Particles objects
  31053. * @returns the SPS
  31054. */
  31055. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  31056. /**
  31057. * Creates a new particle and modifies the SPS mesh geometry :
  31058. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  31059. * - calls _addParticle() to populate the particle array
  31060. * factorized code from addShape() and insertParticlesFromArray()
  31061. * @param idx particle index in the particles array
  31062. * @param i particle index in its shape
  31063. * @param modelShape particle ModelShape object
  31064. * @param shape shape vertex array
  31065. * @param meshInd shape indices array
  31066. * @param meshUV shape uv array
  31067. * @param meshCol shape color array
  31068. * @param meshNor shape normals array
  31069. * @param bbInfo shape bounding info
  31070. * @param storage target particle storage
  31071. * @options addShape() passed options
  31072. * @hidden
  31073. */
  31074. private _insertNewParticle;
  31075. /**
  31076. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31077. * This method calls `updateParticle()` for each particle of the SPS.
  31078. * For an animated SPS, it is usually called within the render loop.
  31079. * 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.
  31080. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31081. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31082. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31083. * @returns the SPS.
  31084. */
  31085. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31086. /**
  31087. * Disposes the SPS.
  31088. */
  31089. dispose(): void;
  31090. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  31091. * idx is the particle index in the SPS
  31092. * faceId is the picked face index counted within this particle.
  31093. * Returns null if the pickInfo can't identify a picked particle.
  31094. * @param pickingInfo (PickingInfo object)
  31095. * @returns {idx: number, faceId: number} or null
  31096. */
  31097. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  31098. idx: number;
  31099. faceId: number;
  31100. }>;
  31101. /**
  31102. * Returns a SolidParticle object from its identifier : particle.id
  31103. * @param id (integer) the particle Id
  31104. * @returns the searched particle or null if not found in the SPS.
  31105. */
  31106. getParticleById(id: number): Nullable<SolidParticle>;
  31107. /**
  31108. * Returns a new array populated with the particles having the passed shapeId.
  31109. * @param shapeId (integer) the shape identifier
  31110. * @returns a new solid particle array
  31111. */
  31112. getParticlesByShapeId(shapeId: number): SolidParticle[];
  31113. /**
  31114. * Populates the passed array "ref" with the particles having the passed shapeId.
  31115. * @param shapeId the shape identifier
  31116. * @returns the SPS
  31117. * @param ref
  31118. */
  31119. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  31120. /**
  31121. * Computes the required SubMeshes according the materials assigned to the particles.
  31122. * @returns the solid particle system.
  31123. * Does nothing if called before the SPS mesh is built.
  31124. */
  31125. computeSubMeshes(): SolidParticleSystem;
  31126. /**
  31127. * Sorts the solid particles by material when MultiMaterial is enabled.
  31128. * Updates the indices32 array.
  31129. * Updates the indicesByMaterial array.
  31130. * Updates the mesh indices array.
  31131. * @returns the SPS
  31132. * @hidden
  31133. */
  31134. private _sortParticlesByMaterial;
  31135. /**
  31136. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  31137. * @hidden
  31138. */
  31139. private _setMaterialIndexesById;
  31140. /**
  31141. * Returns an array with unique values of Materials from the passed array
  31142. * @param array the material array to be checked and filtered
  31143. * @hidden
  31144. */
  31145. private _filterUniqueMaterialId;
  31146. /**
  31147. * Sets a new Standard Material as _defaultMaterial if not already set.
  31148. * @hidden
  31149. */
  31150. private _setDefaultMaterial;
  31151. /**
  31152. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31153. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31154. * @returns the SPS.
  31155. */
  31156. refreshVisibleSize(): SolidParticleSystem;
  31157. /**
  31158. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31159. * @param size the size (float) of the visibility box
  31160. * note : this doesn't lock the SPS mesh bounding box.
  31161. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31162. */
  31163. setVisibilityBox(size: number): void;
  31164. /**
  31165. * Gets whether the SPS as always visible or not
  31166. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31167. */
  31168. get isAlwaysVisible(): boolean;
  31169. /**
  31170. * Sets the SPS as always visible or not
  31171. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31172. */
  31173. set isAlwaysVisible(val: boolean);
  31174. /**
  31175. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31176. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31177. */
  31178. set isVisibilityBoxLocked(val: boolean);
  31179. /**
  31180. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31181. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31182. */
  31183. get isVisibilityBoxLocked(): boolean;
  31184. /**
  31185. * Tells to `setParticles()` to compute the particle rotations or not.
  31186. * Default value : true. The SPS is faster when it's set to false.
  31187. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31188. */
  31189. set computeParticleRotation(val: boolean);
  31190. /**
  31191. * Tells to `setParticles()` to compute the particle colors or not.
  31192. * Default value : true. The SPS is faster when it's set to false.
  31193. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31194. */
  31195. set computeParticleColor(val: boolean);
  31196. set computeParticleTexture(val: boolean);
  31197. /**
  31198. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31199. * Default value : false. The SPS is faster when it's set to false.
  31200. * Note : the particle custom vertex positions aren't stored values.
  31201. */
  31202. set computeParticleVertex(val: boolean);
  31203. /**
  31204. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31205. */
  31206. set computeBoundingBox(val: boolean);
  31207. /**
  31208. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31209. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31210. * Default : `true`
  31211. */
  31212. set depthSortParticles(val: boolean);
  31213. /**
  31214. * Gets if `setParticles()` computes the particle rotations or not.
  31215. * Default value : true. The SPS is faster when it's set to false.
  31216. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31217. */
  31218. get computeParticleRotation(): boolean;
  31219. /**
  31220. * Gets if `setParticles()` computes the particle colors or not.
  31221. * Default value : true. The SPS is faster when it's set to false.
  31222. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31223. */
  31224. get computeParticleColor(): boolean;
  31225. /**
  31226. * Gets if `setParticles()` computes the particle textures or not.
  31227. * Default value : true. The SPS is faster when it's set to false.
  31228. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31229. */
  31230. get computeParticleTexture(): boolean;
  31231. /**
  31232. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31233. * Default value : false. The SPS is faster when it's set to false.
  31234. * Note : the particle custom vertex positions aren't stored values.
  31235. */
  31236. get computeParticleVertex(): boolean;
  31237. /**
  31238. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31239. */
  31240. get computeBoundingBox(): boolean;
  31241. /**
  31242. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31243. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31244. * Default : `true`
  31245. */
  31246. get depthSortParticles(): boolean;
  31247. /**
  31248. * Gets if the SPS is created as expandable at construction time.
  31249. * Default : `false`
  31250. */
  31251. get expandable(): boolean;
  31252. /**
  31253. * Gets if the SPS supports the Multi Materials
  31254. */
  31255. get multimaterialEnabled(): boolean;
  31256. /**
  31257. * Gets if the SPS uses the model materials for its own multimaterial.
  31258. */
  31259. get useModelMaterial(): boolean;
  31260. /**
  31261. * The SPS used material array.
  31262. */
  31263. get materials(): Material[];
  31264. /**
  31265. * Sets the SPS MultiMaterial from the passed materials.
  31266. * Note : the passed array is internally copied and not used then by reference.
  31267. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  31268. */
  31269. setMultiMaterial(materials: Material[]): void;
  31270. /**
  31271. * The SPS computed multimaterial object
  31272. */
  31273. get multimaterial(): MultiMaterial;
  31274. set multimaterial(mm: MultiMaterial);
  31275. /**
  31276. * If the subMeshes must be updated on the next call to setParticles()
  31277. */
  31278. get autoUpdateSubMeshes(): boolean;
  31279. set autoUpdateSubMeshes(val: boolean);
  31280. /**
  31281. * This function does nothing. It may be overwritten to set all the particle first values.
  31282. * The SPS doesn't call this function, you may have to call it by your own.
  31283. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31284. */
  31285. initParticles(): void;
  31286. /**
  31287. * This function does nothing. It may be overwritten to recycle a particle.
  31288. * The SPS doesn't call this function, you may have to call it by your own.
  31289. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31290. * @param particle The particle to recycle
  31291. * @returns the recycled particle
  31292. */
  31293. recycleParticle(particle: SolidParticle): SolidParticle;
  31294. /**
  31295. * Updates a particle : this function should be overwritten by the user.
  31296. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31297. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31298. * @example : just set a particle position or velocity and recycle conditions
  31299. * @param particle The particle to update
  31300. * @returns the updated particle
  31301. */
  31302. updateParticle(particle: SolidParticle): SolidParticle;
  31303. /**
  31304. * Updates a vertex of a particle : it can be overwritten by the user.
  31305. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31306. * @param particle the current particle
  31307. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  31308. * @param pt the index of the current vertex in the particle shape
  31309. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  31310. * @example : just set a vertex particle position or color
  31311. * @returns the sps
  31312. */
  31313. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  31314. /**
  31315. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31316. * This does nothing and may be overwritten by the user.
  31317. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31318. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31319. * @param update the boolean update value actually passed to setParticles()
  31320. */
  31321. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31322. /**
  31323. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31324. * This will be passed three parameters.
  31325. * This does nothing and may be overwritten by the user.
  31326. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31327. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31328. * @param update the boolean update value actually passed to setParticles()
  31329. */
  31330. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31331. }
  31332. }
  31333. declare module BABYLON {
  31334. /**
  31335. * Represents one particle of a solid particle system.
  31336. */
  31337. export class SolidParticle {
  31338. /**
  31339. * particle global index
  31340. */
  31341. idx: number;
  31342. /**
  31343. * particle identifier
  31344. */
  31345. id: number;
  31346. /**
  31347. * The color of the particle
  31348. */
  31349. color: Nullable<Color4>;
  31350. /**
  31351. * The world space position of the particle.
  31352. */
  31353. position: Vector3;
  31354. /**
  31355. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31356. */
  31357. rotation: Vector3;
  31358. /**
  31359. * The world space rotation quaternion of the particle.
  31360. */
  31361. rotationQuaternion: Nullable<Quaternion>;
  31362. /**
  31363. * The scaling of the particle.
  31364. */
  31365. scaling: Vector3;
  31366. /**
  31367. * The uvs of the particle.
  31368. */
  31369. uvs: Vector4;
  31370. /**
  31371. * The current speed of the particle.
  31372. */
  31373. velocity: Vector3;
  31374. /**
  31375. * The pivot point in the particle local space.
  31376. */
  31377. pivot: Vector3;
  31378. /**
  31379. * Must the particle be translated from its pivot point in its local space ?
  31380. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31381. * Default : false
  31382. */
  31383. translateFromPivot: boolean;
  31384. /**
  31385. * Is the particle active or not ?
  31386. */
  31387. alive: boolean;
  31388. /**
  31389. * Is the particle visible or not ?
  31390. */
  31391. isVisible: boolean;
  31392. /**
  31393. * Index of this particle in the global "positions" array (Internal use)
  31394. * @hidden
  31395. */
  31396. _pos: number;
  31397. /**
  31398. * @hidden Index of this particle in the global "indices" array (Internal use)
  31399. */
  31400. _ind: number;
  31401. /**
  31402. * @hidden ModelShape of this particle (Internal use)
  31403. */
  31404. _model: ModelShape;
  31405. /**
  31406. * ModelShape id of this particle
  31407. */
  31408. shapeId: number;
  31409. /**
  31410. * Index of the particle in its shape id
  31411. */
  31412. idxInShape: number;
  31413. /**
  31414. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31415. */
  31416. _modelBoundingInfo: BoundingInfo;
  31417. /**
  31418. * @hidden Particle BoundingInfo object (Internal use)
  31419. */
  31420. _boundingInfo: BoundingInfo;
  31421. /**
  31422. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31423. */
  31424. _sps: SolidParticleSystem;
  31425. /**
  31426. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31427. */
  31428. _stillInvisible: boolean;
  31429. /**
  31430. * @hidden Last computed particle rotation matrix
  31431. */
  31432. _rotationMatrix: number[];
  31433. /**
  31434. * Parent particle Id, if any.
  31435. * Default null.
  31436. */
  31437. parentId: Nullable<number>;
  31438. /**
  31439. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  31440. */
  31441. materialIndex: Nullable<number>;
  31442. /**
  31443. * Custom object or properties.
  31444. */
  31445. props: Nullable<any>;
  31446. /**
  31447. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  31448. * The possible values are :
  31449. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31450. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31451. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31452. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31453. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31454. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  31455. * */
  31456. cullingStrategy: number;
  31457. /**
  31458. * @hidden Internal global position in the SPS.
  31459. */
  31460. _globalPosition: Vector3;
  31461. /**
  31462. * Creates a Solid Particle object.
  31463. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31464. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  31465. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  31466. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31467. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31468. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31469. * @param shapeId (integer) is the model shape identifier in the SPS.
  31470. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31471. * @param sps defines the sps it is associated to
  31472. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31473. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  31474. */
  31475. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  31476. /**
  31477. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  31478. * @param target the particle target
  31479. * @returns the current particle
  31480. */
  31481. copyToRef(target: SolidParticle): SolidParticle;
  31482. /**
  31483. * Legacy support, changed scale to scaling
  31484. */
  31485. get scale(): Vector3;
  31486. /**
  31487. * Legacy support, changed scale to scaling
  31488. */
  31489. set scale(scale: Vector3);
  31490. /**
  31491. * Legacy support, changed quaternion to rotationQuaternion
  31492. */
  31493. get quaternion(): Nullable<Quaternion>;
  31494. /**
  31495. * Legacy support, changed quaternion to rotationQuaternion
  31496. */
  31497. set quaternion(q: Nullable<Quaternion>);
  31498. /**
  31499. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31500. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31501. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31502. * @returns true if it intersects
  31503. */
  31504. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31505. /**
  31506. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  31507. * A particle is in the frustum if its bounding box intersects the frustum
  31508. * @param frustumPlanes defines the frustum to test
  31509. * @returns true if the particle is in the frustum planes
  31510. */
  31511. isInFrustum(frustumPlanes: Plane[]): boolean;
  31512. /**
  31513. * get the rotation matrix of the particle
  31514. * @hidden
  31515. */
  31516. getRotationMatrix(m: Matrix): void;
  31517. }
  31518. /**
  31519. * Represents the shape of the model used by one particle of a solid particle system.
  31520. * SPS internal tool, don't use it manually.
  31521. */
  31522. export class ModelShape {
  31523. /**
  31524. * The shape id
  31525. * @hidden
  31526. */
  31527. shapeID: number;
  31528. /**
  31529. * flat array of model positions (internal use)
  31530. * @hidden
  31531. */
  31532. _shape: Vector3[];
  31533. /**
  31534. * flat array of model UVs (internal use)
  31535. * @hidden
  31536. */
  31537. _shapeUV: number[];
  31538. /**
  31539. * color array of the model
  31540. * @hidden
  31541. */
  31542. _shapeColors: number[];
  31543. /**
  31544. * indices array of the model
  31545. * @hidden
  31546. */
  31547. _indices: number[];
  31548. /**
  31549. * normals array of the model
  31550. * @hidden
  31551. */
  31552. _normals: number[];
  31553. /**
  31554. * length of the shape in the model indices array (internal use)
  31555. * @hidden
  31556. */
  31557. _indicesLength: number;
  31558. /**
  31559. * Custom position function (internal use)
  31560. * @hidden
  31561. */
  31562. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31563. /**
  31564. * Custom vertex function (internal use)
  31565. * @hidden
  31566. */
  31567. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31568. /**
  31569. * Model material (internal use)
  31570. * @hidden
  31571. */
  31572. _material: Nullable<Material>;
  31573. /**
  31574. * 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.
  31575. * SPS internal tool, don't use it manually.
  31576. * @hidden
  31577. */
  31578. 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>);
  31579. }
  31580. /**
  31581. * Represents a Depth Sorted Particle in the solid particle system.
  31582. * @hidden
  31583. */
  31584. export class DepthSortedParticle {
  31585. /**
  31586. * Particle index
  31587. */
  31588. idx: number;
  31589. /**
  31590. * Index of the particle in the "indices" array
  31591. */
  31592. ind: number;
  31593. /**
  31594. * Length of the particle shape in the "indices" array
  31595. */
  31596. indicesLength: number;
  31597. /**
  31598. * Squared distance from the particle to the camera
  31599. */
  31600. sqDistance: number;
  31601. /**
  31602. * Material index when used with MultiMaterials
  31603. */
  31604. materialIndex: number;
  31605. /**
  31606. * Creates a new sorted particle
  31607. * @param materialIndex
  31608. */
  31609. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  31610. }
  31611. /**
  31612. * Represents a solid particle vertex
  31613. */
  31614. export class SolidParticleVertex {
  31615. /**
  31616. * Vertex position
  31617. */
  31618. position: Vector3;
  31619. /**
  31620. * Vertex color
  31621. */
  31622. color: Color4;
  31623. /**
  31624. * Vertex UV
  31625. */
  31626. uv: Vector2;
  31627. /**
  31628. * Creates a new solid particle vertex
  31629. */
  31630. constructor();
  31631. /** Vertex x coordinate */
  31632. get x(): number;
  31633. set x(val: number);
  31634. /** Vertex y coordinate */
  31635. get y(): number;
  31636. set y(val: number);
  31637. /** Vertex z coordinate */
  31638. get z(): number;
  31639. set z(val: number);
  31640. }
  31641. }
  31642. declare module BABYLON {
  31643. /**
  31644. * @hidden
  31645. */
  31646. export class _MeshCollisionData {
  31647. _checkCollisions: boolean;
  31648. _collisionMask: number;
  31649. _collisionGroup: number;
  31650. _surroundingMeshes: Nullable<AbstractMesh[]>;
  31651. _collider: Nullable<Collider>;
  31652. _oldPositionForCollisions: Vector3;
  31653. _diffPositionForCollisions: Vector3;
  31654. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  31655. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  31656. }
  31657. }
  31658. declare module BABYLON {
  31659. /** @hidden */
  31660. class _FacetDataStorage {
  31661. facetPositions: Vector3[];
  31662. facetNormals: Vector3[];
  31663. facetPartitioning: number[][];
  31664. facetNb: number;
  31665. partitioningSubdivisions: number;
  31666. partitioningBBoxRatio: number;
  31667. facetDataEnabled: boolean;
  31668. facetParameters: any;
  31669. bbSize: Vector3;
  31670. subDiv: {
  31671. max: number;
  31672. X: number;
  31673. Y: number;
  31674. Z: number;
  31675. };
  31676. facetDepthSort: boolean;
  31677. facetDepthSortEnabled: boolean;
  31678. depthSortedIndices: IndicesArray;
  31679. depthSortedFacets: {
  31680. ind: number;
  31681. sqDistance: number;
  31682. }[];
  31683. facetDepthSortFunction: (f1: {
  31684. ind: number;
  31685. sqDistance: number;
  31686. }, f2: {
  31687. ind: number;
  31688. sqDistance: number;
  31689. }) => number;
  31690. facetDepthSortFrom: Vector3;
  31691. facetDepthSortOrigin: Vector3;
  31692. invertedMatrix: Matrix;
  31693. }
  31694. /**
  31695. * @hidden
  31696. **/
  31697. class _InternalAbstractMeshDataInfo {
  31698. _hasVertexAlpha: boolean;
  31699. _useVertexColors: boolean;
  31700. _numBoneInfluencers: number;
  31701. _applyFog: boolean;
  31702. _receiveShadows: boolean;
  31703. _facetData: _FacetDataStorage;
  31704. _visibility: number;
  31705. _skeleton: Nullable<Skeleton>;
  31706. _layerMask: number;
  31707. _computeBonesUsingShaders: boolean;
  31708. _isActive: boolean;
  31709. _onlyForInstances: boolean;
  31710. _isActiveIntermediate: boolean;
  31711. _onlyForInstancesIntermediate: boolean;
  31712. _actAsRegularMesh: boolean;
  31713. }
  31714. /**
  31715. * Class used to store all common mesh properties
  31716. */
  31717. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  31718. /** No occlusion */
  31719. static OCCLUSION_TYPE_NONE: number;
  31720. /** Occlusion set to optimisitic */
  31721. static OCCLUSION_TYPE_OPTIMISTIC: number;
  31722. /** Occlusion set to strict */
  31723. static OCCLUSION_TYPE_STRICT: number;
  31724. /** Use an accurante occlusion algorithm */
  31725. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  31726. /** Use a conservative occlusion algorithm */
  31727. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  31728. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  31729. * Test order :
  31730. * Is the bounding sphere outside the frustum ?
  31731. * If not, are the bounding box vertices outside the frustum ?
  31732. * It not, then the cullable object is in the frustum.
  31733. */
  31734. static readonly CULLINGSTRATEGY_STANDARD: number;
  31735. /** Culling strategy : Bounding Sphere Only.
  31736. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  31737. * It's also less accurate than the standard because some not visible objects can still be selected.
  31738. * Test : is the bounding sphere outside the frustum ?
  31739. * If not, then the cullable object is in the frustum.
  31740. */
  31741. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  31742. /** Culling strategy : Optimistic Inclusion.
  31743. * This in an inclusion test first, then the standard exclusion test.
  31744. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  31745. * 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.
  31746. * Anyway, it's as accurate as the standard strategy.
  31747. * Test :
  31748. * Is the cullable object bounding sphere center in the frustum ?
  31749. * If not, apply the default culling strategy.
  31750. */
  31751. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  31752. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  31753. * This in an inclusion test first, then the bounding sphere only exclusion test.
  31754. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  31755. * 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.
  31756. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  31757. * Test :
  31758. * Is the cullable object bounding sphere center in the frustum ?
  31759. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  31760. */
  31761. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  31762. /**
  31763. * No billboard
  31764. */
  31765. static get BILLBOARDMODE_NONE(): number;
  31766. /** Billboard on X axis */
  31767. static get BILLBOARDMODE_X(): number;
  31768. /** Billboard on Y axis */
  31769. static get BILLBOARDMODE_Y(): number;
  31770. /** Billboard on Z axis */
  31771. static get BILLBOARDMODE_Z(): number;
  31772. /** Billboard on all axes */
  31773. static get BILLBOARDMODE_ALL(): number;
  31774. /** Billboard on using position instead of orientation */
  31775. static get BILLBOARDMODE_USE_POSITION(): number;
  31776. /** @hidden */
  31777. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  31778. /**
  31779. * The culling strategy to use to check whether the mesh must be rendered or not.
  31780. * This value can be changed at any time and will be used on the next render mesh selection.
  31781. * The possible values are :
  31782. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31783. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31784. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31785. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31786. * Please read each static variable documentation to get details about the culling process.
  31787. * */
  31788. cullingStrategy: number;
  31789. /**
  31790. * Gets the number of facets in the mesh
  31791. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31792. */
  31793. get facetNb(): number;
  31794. /**
  31795. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  31796. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  31797. */
  31798. get partitioningSubdivisions(): number;
  31799. set partitioningSubdivisions(nb: number);
  31800. /**
  31801. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  31802. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  31803. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  31804. */
  31805. get partitioningBBoxRatio(): number;
  31806. set partitioningBBoxRatio(ratio: number);
  31807. /**
  31808. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  31809. * Works only for updatable meshes.
  31810. * Doesn't work with multi-materials
  31811. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  31812. */
  31813. get mustDepthSortFacets(): boolean;
  31814. set mustDepthSortFacets(sort: boolean);
  31815. /**
  31816. * The location (Vector3) where the facet depth sort must be computed from.
  31817. * By default, the active camera position.
  31818. * Used only when facet depth sort is enabled
  31819. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  31820. */
  31821. get facetDepthSortFrom(): Vector3;
  31822. set facetDepthSortFrom(location: Vector3);
  31823. /**
  31824. * gets a boolean indicating if facetData is enabled
  31825. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31826. */
  31827. get isFacetDataEnabled(): boolean;
  31828. /** @hidden */
  31829. _updateNonUniformScalingState(value: boolean): boolean;
  31830. /**
  31831. * An event triggered when this mesh collides with another one
  31832. */
  31833. onCollideObservable: Observable<AbstractMesh>;
  31834. /** Set a function to call when this mesh collides with another one */
  31835. set onCollide(callback: () => void);
  31836. /**
  31837. * An event triggered when the collision's position changes
  31838. */
  31839. onCollisionPositionChangeObservable: Observable<Vector3>;
  31840. /** Set a function to call when the collision's position changes */
  31841. set onCollisionPositionChange(callback: () => void);
  31842. /**
  31843. * An event triggered when material is changed
  31844. */
  31845. onMaterialChangedObservable: Observable<AbstractMesh>;
  31846. /**
  31847. * Gets or sets the orientation for POV movement & rotation
  31848. */
  31849. definedFacingForward: boolean;
  31850. /** @hidden */
  31851. _occlusionQuery: Nullable<WebGLQuery>;
  31852. /** @hidden */
  31853. _renderingGroup: Nullable<RenderingGroup>;
  31854. /**
  31855. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  31856. */
  31857. get visibility(): number;
  31858. /**
  31859. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  31860. */
  31861. set visibility(value: number);
  31862. /** Gets or sets the alpha index used to sort transparent meshes
  31863. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  31864. */
  31865. alphaIndex: number;
  31866. /**
  31867. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  31868. */
  31869. isVisible: boolean;
  31870. /**
  31871. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  31872. */
  31873. isPickable: boolean;
  31874. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  31875. showSubMeshesBoundingBox: boolean;
  31876. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  31877. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  31878. */
  31879. isBlocker: boolean;
  31880. /**
  31881. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  31882. */
  31883. enablePointerMoveEvents: boolean;
  31884. /**
  31885. * Specifies the rendering group id for this mesh (0 by default)
  31886. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  31887. */
  31888. renderingGroupId: number;
  31889. private _material;
  31890. /** Gets or sets current material */
  31891. get material(): Nullable<Material>;
  31892. set material(value: Nullable<Material>);
  31893. /**
  31894. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  31895. * @see https://doc.babylonjs.com/babylon101/shadows
  31896. */
  31897. get receiveShadows(): boolean;
  31898. set receiveShadows(value: boolean);
  31899. /** Defines color to use when rendering outline */
  31900. outlineColor: Color3;
  31901. /** Define width to use when rendering outline */
  31902. outlineWidth: number;
  31903. /** Defines color to use when rendering overlay */
  31904. overlayColor: Color3;
  31905. /** Defines alpha to use when rendering overlay */
  31906. overlayAlpha: number;
  31907. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  31908. get hasVertexAlpha(): boolean;
  31909. set hasVertexAlpha(value: boolean);
  31910. /** 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) */
  31911. get useVertexColors(): boolean;
  31912. set useVertexColors(value: boolean);
  31913. /**
  31914. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  31915. */
  31916. get computeBonesUsingShaders(): boolean;
  31917. set computeBonesUsingShaders(value: boolean);
  31918. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  31919. get numBoneInfluencers(): number;
  31920. set numBoneInfluencers(value: number);
  31921. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  31922. get applyFog(): boolean;
  31923. set applyFog(value: boolean);
  31924. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  31925. useOctreeForRenderingSelection: boolean;
  31926. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  31927. useOctreeForPicking: boolean;
  31928. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  31929. useOctreeForCollisions: boolean;
  31930. /**
  31931. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  31932. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  31933. */
  31934. get layerMask(): number;
  31935. set layerMask(value: number);
  31936. /**
  31937. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  31938. */
  31939. alwaysSelectAsActiveMesh: boolean;
  31940. /**
  31941. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  31942. */
  31943. doNotSyncBoundingInfo: boolean;
  31944. /**
  31945. * Gets or sets the current action manager
  31946. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  31947. */
  31948. actionManager: Nullable<AbstractActionManager>;
  31949. private _meshCollisionData;
  31950. /**
  31951. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  31952. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31953. */
  31954. ellipsoid: Vector3;
  31955. /**
  31956. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  31957. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31958. */
  31959. ellipsoidOffset: Vector3;
  31960. /**
  31961. * Gets or sets a collision mask used to mask collisions (default is -1).
  31962. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31963. */
  31964. get collisionMask(): number;
  31965. set collisionMask(mask: number);
  31966. /**
  31967. * Gets or sets the current collision group mask (-1 by default).
  31968. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31969. */
  31970. get collisionGroup(): number;
  31971. set collisionGroup(mask: number);
  31972. /**
  31973. * Gets or sets current surrounding meshes (null by default).
  31974. *
  31975. * By default collision detection is tested against every mesh in the scene.
  31976. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  31977. * meshes will be tested for the collision.
  31978. *
  31979. * Note: if set to an empty array no collision will happen when this mesh is moved.
  31980. */
  31981. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  31982. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  31983. /**
  31984. * Defines edge width used when edgesRenderer is enabled
  31985. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31986. */
  31987. edgesWidth: number;
  31988. /**
  31989. * Defines edge color used when edgesRenderer is enabled
  31990. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31991. */
  31992. edgesColor: Color4;
  31993. /** @hidden */
  31994. _edgesRenderer: Nullable<IEdgesRenderer>;
  31995. /** @hidden */
  31996. _masterMesh: Nullable<AbstractMesh>;
  31997. /** @hidden */
  31998. _boundingInfo: Nullable<BoundingInfo>;
  31999. /** @hidden */
  32000. _renderId: number;
  32001. /**
  32002. * Gets or sets the list of subMeshes
  32003. * @see https://doc.babylonjs.com/how_to/multi_materials
  32004. */
  32005. subMeshes: SubMesh[];
  32006. /** @hidden */
  32007. _intersectionsInProgress: AbstractMesh[];
  32008. /** @hidden */
  32009. _unIndexed: boolean;
  32010. /** @hidden */
  32011. _lightSources: Light[];
  32012. /** Gets the list of lights affecting that mesh */
  32013. get lightSources(): Light[];
  32014. /** @hidden */
  32015. get _positions(): Nullable<Vector3[]>;
  32016. /** @hidden */
  32017. _waitingData: {
  32018. lods: Nullable<any>;
  32019. actions: Nullable<any>;
  32020. freezeWorldMatrix: Nullable<boolean>;
  32021. };
  32022. /** @hidden */
  32023. _bonesTransformMatrices: Nullable<Float32Array>;
  32024. /** @hidden */
  32025. _transformMatrixTexture: Nullable<RawTexture>;
  32026. /**
  32027. * Gets or sets a skeleton to apply skining transformations
  32028. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32029. */
  32030. set skeleton(value: Nullable<Skeleton>);
  32031. get skeleton(): Nullable<Skeleton>;
  32032. /**
  32033. * An event triggered when the mesh is rebuilt.
  32034. */
  32035. onRebuildObservable: Observable<AbstractMesh>;
  32036. /**
  32037. * Creates a new AbstractMesh
  32038. * @param name defines the name of the mesh
  32039. * @param scene defines the hosting scene
  32040. */
  32041. constructor(name: string, scene?: Nullable<Scene>);
  32042. /**
  32043. * Returns the string "AbstractMesh"
  32044. * @returns "AbstractMesh"
  32045. */
  32046. getClassName(): string;
  32047. /**
  32048. * Gets a string representation of the current mesh
  32049. * @param fullDetails defines a boolean indicating if full details must be included
  32050. * @returns a string representation of the current mesh
  32051. */
  32052. toString(fullDetails?: boolean): string;
  32053. /**
  32054. * @hidden
  32055. */
  32056. protected _getEffectiveParent(): Nullable<Node>;
  32057. /** @hidden */
  32058. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32059. /** @hidden */
  32060. _rebuild(): void;
  32061. /** @hidden */
  32062. _resyncLightSources(): void;
  32063. /** @hidden */
  32064. _resyncLightSource(light: Light): void;
  32065. /** @hidden */
  32066. _unBindEffect(): void;
  32067. /** @hidden */
  32068. _removeLightSource(light: Light, dispose: boolean): void;
  32069. private _markSubMeshesAsDirty;
  32070. /** @hidden */
  32071. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  32072. /** @hidden */
  32073. _markSubMeshesAsAttributesDirty(): void;
  32074. /** @hidden */
  32075. _markSubMeshesAsMiscDirty(): void;
  32076. /**
  32077. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  32078. */
  32079. get scaling(): Vector3;
  32080. set scaling(newScaling: Vector3);
  32081. /**
  32082. * Returns true if the mesh is blocked. Implemented by child classes
  32083. */
  32084. get isBlocked(): boolean;
  32085. /**
  32086. * Returns the mesh itself by default. Implemented by child classes
  32087. * @param camera defines the camera to use to pick the right LOD level
  32088. * @returns the currentAbstractMesh
  32089. */
  32090. getLOD(camera: Camera): Nullable<AbstractMesh>;
  32091. /**
  32092. * Returns 0 by default. Implemented by child classes
  32093. * @returns an integer
  32094. */
  32095. getTotalVertices(): number;
  32096. /**
  32097. * Returns a positive integer : the total number of indices in this mesh geometry.
  32098. * @returns the numner of indices or zero if the mesh has no geometry.
  32099. */
  32100. getTotalIndices(): number;
  32101. /**
  32102. * Returns null by default. Implemented by child classes
  32103. * @returns null
  32104. */
  32105. getIndices(): Nullable<IndicesArray>;
  32106. /**
  32107. * Returns the array of the requested vertex data kind. Implemented by child classes
  32108. * @param kind defines the vertex data kind to use
  32109. * @returns null
  32110. */
  32111. getVerticesData(kind: string): Nullable<FloatArray>;
  32112. /**
  32113. * Sets the vertex data of the mesh geometry for the requested `kind`.
  32114. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  32115. * Note that a new underlying VertexBuffer object is created each call.
  32116. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  32117. * @param kind defines vertex data kind:
  32118. * * VertexBuffer.PositionKind
  32119. * * VertexBuffer.UVKind
  32120. * * VertexBuffer.UV2Kind
  32121. * * VertexBuffer.UV3Kind
  32122. * * VertexBuffer.UV4Kind
  32123. * * VertexBuffer.UV5Kind
  32124. * * VertexBuffer.UV6Kind
  32125. * * VertexBuffer.ColorKind
  32126. * * VertexBuffer.MatricesIndicesKind
  32127. * * VertexBuffer.MatricesIndicesExtraKind
  32128. * * VertexBuffer.MatricesWeightsKind
  32129. * * VertexBuffer.MatricesWeightsExtraKind
  32130. * @param data defines the data source
  32131. * @param updatable defines if the data must be flagged as updatable (or static)
  32132. * @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
  32133. * @returns the current mesh
  32134. */
  32135. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32136. /**
  32137. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  32138. * If the mesh has no geometry, it is simply returned as it is.
  32139. * @param kind defines vertex data kind:
  32140. * * VertexBuffer.PositionKind
  32141. * * VertexBuffer.UVKind
  32142. * * VertexBuffer.UV2Kind
  32143. * * VertexBuffer.UV3Kind
  32144. * * VertexBuffer.UV4Kind
  32145. * * VertexBuffer.UV5Kind
  32146. * * VertexBuffer.UV6Kind
  32147. * * VertexBuffer.ColorKind
  32148. * * VertexBuffer.MatricesIndicesKind
  32149. * * VertexBuffer.MatricesIndicesExtraKind
  32150. * * VertexBuffer.MatricesWeightsKind
  32151. * * VertexBuffer.MatricesWeightsExtraKind
  32152. * @param data defines the data source
  32153. * @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
  32154. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  32155. * @returns the current mesh
  32156. */
  32157. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32158. /**
  32159. * Sets the mesh indices,
  32160. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  32161. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  32162. * @param totalVertices Defines the total number of vertices
  32163. * @returns the current mesh
  32164. */
  32165. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  32166. /**
  32167. * Gets a boolean indicating if specific vertex data is present
  32168. * @param kind defines the vertex data kind to use
  32169. * @returns true is data kind is present
  32170. */
  32171. isVerticesDataPresent(kind: string): boolean;
  32172. /**
  32173. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  32174. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  32175. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  32176. * @returns a BoundingInfo
  32177. */
  32178. getBoundingInfo(): BoundingInfo;
  32179. /**
  32180. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  32181. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  32182. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  32183. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  32184. * @returns the current mesh
  32185. */
  32186. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  32187. /**
  32188. * Overwrite the current bounding info
  32189. * @param boundingInfo defines the new bounding info
  32190. * @returns the current mesh
  32191. */
  32192. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  32193. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  32194. get useBones(): boolean;
  32195. /** @hidden */
  32196. _preActivate(): void;
  32197. /** @hidden */
  32198. _preActivateForIntermediateRendering(renderId: number): void;
  32199. /** @hidden */
  32200. _activate(renderId: number, intermediateRendering: boolean): boolean;
  32201. /** @hidden */
  32202. _postActivate(): void;
  32203. /** @hidden */
  32204. _freeze(): void;
  32205. /** @hidden */
  32206. _unFreeze(): void;
  32207. /**
  32208. * Gets the current world matrix
  32209. * @returns a Matrix
  32210. */
  32211. getWorldMatrix(): Matrix;
  32212. /** @hidden */
  32213. _getWorldMatrixDeterminant(): number;
  32214. /**
  32215. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  32216. */
  32217. get isAnInstance(): boolean;
  32218. /**
  32219. * Gets a boolean indicating if this mesh has instances
  32220. */
  32221. get hasInstances(): boolean;
  32222. /**
  32223. * Gets a boolean indicating if this mesh has thin instances
  32224. */
  32225. get hasThinInstances(): boolean;
  32226. /**
  32227. * Perform relative position change from the point of view of behind the front of the mesh.
  32228. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32229. * Supports definition of mesh facing forward or backward
  32230. * @param amountRight defines the distance on the right axis
  32231. * @param amountUp defines the distance on the up axis
  32232. * @param amountForward defines the distance on the forward axis
  32233. * @returns the current mesh
  32234. */
  32235. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  32236. /**
  32237. * Calculate relative position change from the point of view of behind the front of the mesh.
  32238. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32239. * Supports definition of mesh facing forward or backward
  32240. * @param amountRight defines the distance on the right axis
  32241. * @param amountUp defines the distance on the up axis
  32242. * @param amountForward defines the distance on the forward axis
  32243. * @returns the new displacement vector
  32244. */
  32245. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  32246. /**
  32247. * Perform relative rotation change from the point of view of behind the front of the mesh.
  32248. * Supports definition of mesh facing forward or backward
  32249. * @param flipBack defines the flip
  32250. * @param twirlClockwise defines the twirl
  32251. * @param tiltRight defines the tilt
  32252. * @returns the current mesh
  32253. */
  32254. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  32255. /**
  32256. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  32257. * Supports definition of mesh facing forward or backward.
  32258. * @param flipBack defines the flip
  32259. * @param twirlClockwise defines the twirl
  32260. * @param tiltRight defines the tilt
  32261. * @returns the new rotation vector
  32262. */
  32263. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  32264. /**
  32265. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32266. * This means the mesh underlying bounding box and sphere are recomputed.
  32267. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32268. * @returns the current mesh
  32269. */
  32270. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  32271. /** @hidden */
  32272. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  32273. /** @hidden */
  32274. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  32275. /** @hidden */
  32276. _updateBoundingInfo(): AbstractMesh;
  32277. /** @hidden */
  32278. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  32279. /** @hidden */
  32280. protected _afterComputeWorldMatrix(): void;
  32281. /** @hidden */
  32282. get _effectiveMesh(): AbstractMesh;
  32283. /**
  32284. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32285. * A mesh is in the frustum if its bounding box intersects the frustum
  32286. * @param frustumPlanes defines the frustum to test
  32287. * @returns true if the mesh is in the frustum planes
  32288. */
  32289. isInFrustum(frustumPlanes: Plane[]): boolean;
  32290. /**
  32291. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  32292. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  32293. * @param frustumPlanes defines the frustum to test
  32294. * @returns true if the mesh is completely in the frustum planes
  32295. */
  32296. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32297. /**
  32298. * True if the mesh intersects another mesh or a SolidParticle object
  32299. * @param mesh defines a target mesh or SolidParticle to test
  32300. * @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)
  32301. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  32302. * @returns true if there is an intersection
  32303. */
  32304. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  32305. /**
  32306. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  32307. * @param point defines the point to test
  32308. * @returns true if there is an intersection
  32309. */
  32310. intersectsPoint(point: Vector3): boolean;
  32311. /**
  32312. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  32313. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32314. */
  32315. get checkCollisions(): boolean;
  32316. set checkCollisions(collisionEnabled: boolean);
  32317. /**
  32318. * Gets Collider object used to compute collisions (not physics)
  32319. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32320. */
  32321. get collider(): Nullable<Collider>;
  32322. /**
  32323. * Move the mesh using collision engine
  32324. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32325. * @param displacement defines the requested displacement vector
  32326. * @returns the current mesh
  32327. */
  32328. moveWithCollisions(displacement: Vector3): AbstractMesh;
  32329. private _onCollisionPositionChange;
  32330. /** @hidden */
  32331. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  32332. /** @hidden */
  32333. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  32334. /** @hidden */
  32335. _checkCollision(collider: Collider): AbstractMesh;
  32336. /** @hidden */
  32337. _generatePointsArray(): boolean;
  32338. /**
  32339. * Checks if the passed Ray intersects with the mesh
  32340. * @param ray defines the ray to use
  32341. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  32342. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32343. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  32344. * @returns the picking info
  32345. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  32346. */
  32347. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  32348. /**
  32349. * Clones the current mesh
  32350. * @param name defines the mesh name
  32351. * @param newParent defines the new mesh parent
  32352. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  32353. * @returns the new mesh
  32354. */
  32355. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  32356. /**
  32357. * Disposes all the submeshes of the current meshnp
  32358. * @returns the current mesh
  32359. */
  32360. releaseSubMeshes(): AbstractMesh;
  32361. /**
  32362. * Releases resources associated with this abstract mesh.
  32363. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32364. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32365. */
  32366. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32367. /**
  32368. * Adds the passed mesh as a child to the current mesh
  32369. * @param mesh defines the child mesh
  32370. * @returns the current mesh
  32371. */
  32372. addChild(mesh: AbstractMesh): AbstractMesh;
  32373. /**
  32374. * Removes the passed mesh from the current mesh children list
  32375. * @param mesh defines the child mesh
  32376. * @returns the current mesh
  32377. */
  32378. removeChild(mesh: AbstractMesh): AbstractMesh;
  32379. /** @hidden */
  32380. private _initFacetData;
  32381. /**
  32382. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  32383. * This method can be called within the render loop.
  32384. * 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
  32385. * @returns the current mesh
  32386. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32387. */
  32388. updateFacetData(): AbstractMesh;
  32389. /**
  32390. * Returns the facetLocalNormals array.
  32391. * The normals are expressed in the mesh local spac
  32392. * @returns an array of Vector3
  32393. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32394. */
  32395. getFacetLocalNormals(): Vector3[];
  32396. /**
  32397. * Returns the facetLocalPositions array.
  32398. * The facet positions are expressed in the mesh local space
  32399. * @returns an array of Vector3
  32400. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32401. */
  32402. getFacetLocalPositions(): Vector3[];
  32403. /**
  32404. * Returns the facetLocalPartioning array
  32405. * @returns an array of array of numbers
  32406. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32407. */
  32408. getFacetLocalPartitioning(): number[][];
  32409. /**
  32410. * Returns the i-th facet position in the world system.
  32411. * This method allocates a new Vector3 per call
  32412. * @param i defines the facet index
  32413. * @returns a new Vector3
  32414. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32415. */
  32416. getFacetPosition(i: number): Vector3;
  32417. /**
  32418. * Sets the reference Vector3 with the i-th facet position in the world system
  32419. * @param i defines the facet index
  32420. * @param ref defines the target vector
  32421. * @returns the current mesh
  32422. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32423. */
  32424. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  32425. /**
  32426. * Returns the i-th facet normal in the world system.
  32427. * This method allocates a new Vector3 per call
  32428. * @param i defines the facet index
  32429. * @returns a new Vector3
  32430. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32431. */
  32432. getFacetNormal(i: number): Vector3;
  32433. /**
  32434. * Sets the reference Vector3 with the i-th facet normal in the world system
  32435. * @param i defines the facet index
  32436. * @param ref defines the target vector
  32437. * @returns the current mesh
  32438. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32439. */
  32440. getFacetNormalToRef(i: number, ref: Vector3): this;
  32441. /**
  32442. * 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)
  32443. * @param x defines x coordinate
  32444. * @param y defines y coordinate
  32445. * @param z defines z coordinate
  32446. * @returns the array of facet indexes
  32447. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32448. */
  32449. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  32450. /**
  32451. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  32452. * @param projected sets as the (x,y,z) world projection on the facet
  32453. * @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
  32454. * @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
  32455. * @param x defines x coordinate
  32456. * @param y defines y coordinate
  32457. * @param z defines z coordinate
  32458. * @returns the face index if found (or null instead)
  32459. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32460. */
  32461. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32462. /**
  32463. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  32464. * @param projected sets as the (x,y,z) local projection on the facet
  32465. * @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
  32466. * @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
  32467. * @param x defines x coordinate
  32468. * @param y defines y coordinate
  32469. * @param z defines z coordinate
  32470. * @returns the face index if found (or null instead)
  32471. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32472. */
  32473. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32474. /**
  32475. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  32476. * @returns the parameters
  32477. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32478. */
  32479. getFacetDataParameters(): any;
  32480. /**
  32481. * Disables the feature FacetData and frees the related memory
  32482. * @returns the current mesh
  32483. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32484. */
  32485. disableFacetData(): AbstractMesh;
  32486. /**
  32487. * Updates the AbstractMesh indices array
  32488. * @param indices defines the data source
  32489. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32490. * @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)
  32491. * @returns the current mesh
  32492. */
  32493. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32494. /**
  32495. * Creates new normals data for the mesh
  32496. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  32497. * @returns the current mesh
  32498. */
  32499. createNormals(updatable: boolean): AbstractMesh;
  32500. /**
  32501. * Align the mesh with a normal
  32502. * @param normal defines the normal to use
  32503. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  32504. * @returns the current mesh
  32505. */
  32506. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  32507. /** @hidden */
  32508. _checkOcclusionQuery(): boolean;
  32509. /**
  32510. * Disables the mesh edge rendering mode
  32511. * @returns the currentAbstractMesh
  32512. */
  32513. disableEdgesRendering(): AbstractMesh;
  32514. /**
  32515. * Enables the edge rendering mode on the mesh.
  32516. * This mode makes the mesh edges visible
  32517. * @param epsilon defines the maximal distance between two angles to detect a face
  32518. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32519. * @returns the currentAbstractMesh
  32520. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32521. */
  32522. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32523. /**
  32524. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  32525. * @returns an array of particle systems in the scene that use the mesh as an emitter
  32526. */
  32527. getConnectedParticleSystems(): IParticleSystem[];
  32528. }
  32529. }
  32530. declare module BABYLON {
  32531. /**
  32532. * Interface used to define ActionEvent
  32533. */
  32534. export interface IActionEvent {
  32535. /** The mesh or sprite that triggered the action */
  32536. source: any;
  32537. /** The X mouse cursor position at the time of the event */
  32538. pointerX: number;
  32539. /** The Y mouse cursor position at the time of the event */
  32540. pointerY: number;
  32541. /** The mesh that is currently pointed at (can be null) */
  32542. meshUnderPointer: Nullable<AbstractMesh>;
  32543. /** the original (browser) event that triggered the ActionEvent */
  32544. sourceEvent?: any;
  32545. /** additional data for the event */
  32546. additionalData?: any;
  32547. }
  32548. /**
  32549. * ActionEvent is the event being sent when an action is triggered.
  32550. */
  32551. export class ActionEvent implements IActionEvent {
  32552. /** The mesh or sprite that triggered the action */
  32553. source: any;
  32554. /** The X mouse cursor position at the time of the event */
  32555. pointerX: number;
  32556. /** The Y mouse cursor position at the time of the event */
  32557. pointerY: number;
  32558. /** The mesh that is currently pointed at (can be null) */
  32559. meshUnderPointer: Nullable<AbstractMesh>;
  32560. /** the original (browser) event that triggered the ActionEvent */
  32561. sourceEvent?: any;
  32562. /** additional data for the event */
  32563. additionalData?: any;
  32564. /**
  32565. * Creates a new ActionEvent
  32566. * @param source The mesh or sprite that triggered the action
  32567. * @param pointerX The X mouse cursor position at the time of the event
  32568. * @param pointerY The Y mouse cursor position at the time of the event
  32569. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  32570. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  32571. * @param additionalData additional data for the event
  32572. */
  32573. constructor(
  32574. /** The mesh or sprite that triggered the action */
  32575. source: any,
  32576. /** The X mouse cursor position at the time of the event */
  32577. pointerX: number,
  32578. /** The Y mouse cursor position at the time of the event */
  32579. pointerY: number,
  32580. /** The mesh that is currently pointed at (can be null) */
  32581. meshUnderPointer: Nullable<AbstractMesh>,
  32582. /** the original (browser) event that triggered the ActionEvent */
  32583. sourceEvent?: any,
  32584. /** additional data for the event */
  32585. additionalData?: any);
  32586. /**
  32587. * Helper function to auto-create an ActionEvent from a source mesh.
  32588. * @param source The source mesh that triggered the event
  32589. * @param evt The original (browser) event
  32590. * @param additionalData additional data for the event
  32591. * @returns the new ActionEvent
  32592. */
  32593. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  32594. /**
  32595. * Helper function to auto-create an ActionEvent from a source sprite
  32596. * @param source The source sprite that triggered the event
  32597. * @param scene Scene associated with the sprite
  32598. * @param evt The original (browser) event
  32599. * @param additionalData additional data for the event
  32600. * @returns the new ActionEvent
  32601. */
  32602. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  32603. /**
  32604. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  32605. * @param scene the scene where the event occurred
  32606. * @param evt The original (browser) event
  32607. * @returns the new ActionEvent
  32608. */
  32609. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  32610. /**
  32611. * Helper function to auto-create an ActionEvent from a primitive
  32612. * @param prim defines the target primitive
  32613. * @param pointerPos defines the pointer position
  32614. * @param evt The original (browser) event
  32615. * @param additionalData additional data for the event
  32616. * @returns the new ActionEvent
  32617. */
  32618. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  32619. }
  32620. }
  32621. declare module BABYLON {
  32622. /**
  32623. * Abstract class used to decouple action Manager from scene and meshes.
  32624. * Do not instantiate.
  32625. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32626. */
  32627. export abstract class AbstractActionManager implements IDisposable {
  32628. /** Gets the list of active triggers */
  32629. static Triggers: {
  32630. [key: string]: number;
  32631. };
  32632. /** Gets the cursor to use when hovering items */
  32633. hoverCursor: string;
  32634. /** Gets the list of actions */
  32635. actions: IAction[];
  32636. /**
  32637. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  32638. */
  32639. isRecursive: boolean;
  32640. /**
  32641. * Releases all associated resources
  32642. */
  32643. abstract dispose(): void;
  32644. /**
  32645. * Does this action manager has pointer triggers
  32646. */
  32647. abstract get hasPointerTriggers(): boolean;
  32648. /**
  32649. * Does this action manager has pick triggers
  32650. */
  32651. abstract get hasPickTriggers(): boolean;
  32652. /**
  32653. * Process a specific trigger
  32654. * @param trigger defines the trigger to process
  32655. * @param evt defines the event details to be processed
  32656. */
  32657. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  32658. /**
  32659. * Does this action manager handles actions of any of the given triggers
  32660. * @param triggers defines the triggers to be tested
  32661. * @return a boolean indicating whether one (or more) of the triggers is handled
  32662. */
  32663. abstract hasSpecificTriggers(triggers: number[]): boolean;
  32664. /**
  32665. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  32666. * speed.
  32667. * @param triggerA defines the trigger to be tested
  32668. * @param triggerB defines the trigger to be tested
  32669. * @return a boolean indicating whether one (or more) of the triggers is handled
  32670. */
  32671. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  32672. /**
  32673. * Does this action manager handles actions of a given trigger
  32674. * @param trigger defines the trigger to be tested
  32675. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  32676. * @return whether the trigger is handled
  32677. */
  32678. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  32679. /**
  32680. * Serialize this manager to a JSON object
  32681. * @param name defines the property name to store this manager
  32682. * @returns a JSON representation of this manager
  32683. */
  32684. abstract serialize(name: string): any;
  32685. /**
  32686. * Registers an action to this action manager
  32687. * @param action defines the action to be registered
  32688. * @return the action amended (prepared) after registration
  32689. */
  32690. abstract registerAction(action: IAction): Nullable<IAction>;
  32691. /**
  32692. * Unregisters an action to this action manager
  32693. * @param action defines the action to be unregistered
  32694. * @return a boolean indicating whether the action has been unregistered
  32695. */
  32696. abstract unregisterAction(action: IAction): Boolean;
  32697. /**
  32698. * Does exist one action manager with at least one trigger
  32699. **/
  32700. static get HasTriggers(): boolean;
  32701. /**
  32702. * Does exist one action manager with at least one pick trigger
  32703. **/
  32704. static get HasPickTriggers(): boolean;
  32705. /**
  32706. * Does exist one action manager that handles actions of a given trigger
  32707. * @param trigger defines the trigger to be tested
  32708. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  32709. **/
  32710. static HasSpecificTrigger(trigger: number): boolean;
  32711. }
  32712. }
  32713. declare module BABYLON {
  32714. /**
  32715. * Defines how a node can be built from a string name.
  32716. */
  32717. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  32718. /**
  32719. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  32720. */
  32721. export class Node implements IBehaviorAware<Node> {
  32722. /** @hidden */
  32723. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  32724. private static _NodeConstructors;
  32725. /**
  32726. * Add a new node constructor
  32727. * @param type defines the type name of the node to construct
  32728. * @param constructorFunc defines the constructor function
  32729. */
  32730. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  32731. /**
  32732. * Returns a node constructor based on type name
  32733. * @param type defines the type name
  32734. * @param name defines the new node name
  32735. * @param scene defines the hosting scene
  32736. * @param options defines optional options to transmit to constructors
  32737. * @returns the new constructor or null
  32738. */
  32739. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  32740. /**
  32741. * Gets or sets the name of the node
  32742. */
  32743. name: string;
  32744. /**
  32745. * Gets or sets the id of the node
  32746. */
  32747. id: string;
  32748. /**
  32749. * Gets or sets the unique id of the node
  32750. */
  32751. uniqueId: number;
  32752. /**
  32753. * Gets or sets a string used to store user defined state for the node
  32754. */
  32755. state: string;
  32756. /**
  32757. * Gets or sets an object used to store user defined information for the node
  32758. */
  32759. metadata: any;
  32760. /**
  32761. * For internal use only. Please do not use.
  32762. */
  32763. reservedDataStore: any;
  32764. /**
  32765. * List of inspectable custom properties (used by the Inspector)
  32766. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  32767. */
  32768. inspectableCustomProperties: IInspectable[];
  32769. private _doNotSerialize;
  32770. /**
  32771. * Gets or sets a boolean used to define if the node must be serialized
  32772. */
  32773. get doNotSerialize(): boolean;
  32774. set doNotSerialize(value: boolean);
  32775. /** @hidden */
  32776. _isDisposed: boolean;
  32777. /**
  32778. * Gets a list of Animations associated with the node
  32779. */
  32780. animations: Animation[];
  32781. protected _ranges: {
  32782. [name: string]: Nullable<AnimationRange>;
  32783. };
  32784. /**
  32785. * Callback raised when the node is ready to be used
  32786. */
  32787. onReady: Nullable<(node: Node) => void>;
  32788. private _isEnabled;
  32789. private _isParentEnabled;
  32790. private _isReady;
  32791. /** @hidden */
  32792. _currentRenderId: number;
  32793. private _parentUpdateId;
  32794. /** @hidden */
  32795. _childUpdateId: number;
  32796. /** @hidden */
  32797. _waitingParentId: Nullable<string>;
  32798. /** @hidden */
  32799. _scene: Scene;
  32800. /** @hidden */
  32801. _cache: any;
  32802. private _parentNode;
  32803. private _children;
  32804. /** @hidden */
  32805. _worldMatrix: Matrix;
  32806. /** @hidden */
  32807. _worldMatrixDeterminant: number;
  32808. /** @hidden */
  32809. _worldMatrixDeterminantIsDirty: boolean;
  32810. /** @hidden */
  32811. private _sceneRootNodesIndex;
  32812. /**
  32813. * Gets a boolean indicating if the node has been disposed
  32814. * @returns true if the node was disposed
  32815. */
  32816. isDisposed(): boolean;
  32817. /**
  32818. * Gets or sets the parent of the node (without keeping the current position in the scene)
  32819. * @see https://doc.babylonjs.com/how_to/parenting
  32820. */
  32821. set parent(parent: Nullable<Node>);
  32822. get parent(): Nullable<Node>;
  32823. /** @hidden */
  32824. _addToSceneRootNodes(): void;
  32825. /** @hidden */
  32826. _removeFromSceneRootNodes(): void;
  32827. private _animationPropertiesOverride;
  32828. /**
  32829. * Gets or sets the animation properties override
  32830. */
  32831. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  32832. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  32833. /**
  32834. * Gets a string idenfifying the name of the class
  32835. * @returns "Node" string
  32836. */
  32837. getClassName(): string;
  32838. /** @hidden */
  32839. readonly _isNode: boolean;
  32840. /**
  32841. * An event triggered when the mesh is disposed
  32842. */
  32843. onDisposeObservable: Observable<Node>;
  32844. private _onDisposeObserver;
  32845. /**
  32846. * Sets a callback that will be raised when the node will be disposed
  32847. */
  32848. set onDispose(callback: () => void);
  32849. /**
  32850. * Creates a new Node
  32851. * @param name the name and id to be given to this node
  32852. * @param scene the scene this node will be added to
  32853. */
  32854. constructor(name: string, scene?: Nullable<Scene>);
  32855. /**
  32856. * Gets the scene of the node
  32857. * @returns a scene
  32858. */
  32859. getScene(): Scene;
  32860. /**
  32861. * Gets the engine of the node
  32862. * @returns a Engine
  32863. */
  32864. getEngine(): Engine;
  32865. private _behaviors;
  32866. /**
  32867. * Attach a behavior to the node
  32868. * @see https://doc.babylonjs.com/features/behaviour
  32869. * @param behavior defines the behavior to attach
  32870. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  32871. * @returns the current Node
  32872. */
  32873. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  32874. /**
  32875. * Remove an attached behavior
  32876. * @see https://doc.babylonjs.com/features/behaviour
  32877. * @param behavior defines the behavior to attach
  32878. * @returns the current Node
  32879. */
  32880. removeBehavior(behavior: Behavior<Node>): Node;
  32881. /**
  32882. * Gets the list of attached behaviors
  32883. * @see https://doc.babylonjs.com/features/behaviour
  32884. */
  32885. get behaviors(): Behavior<Node>[];
  32886. /**
  32887. * Gets an attached behavior by name
  32888. * @param name defines the name of the behavior to look for
  32889. * @see https://doc.babylonjs.com/features/behaviour
  32890. * @returns null if behavior was not found else the requested behavior
  32891. */
  32892. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  32893. /**
  32894. * Returns the latest update of the World matrix
  32895. * @returns a Matrix
  32896. */
  32897. getWorldMatrix(): Matrix;
  32898. /** @hidden */
  32899. _getWorldMatrixDeterminant(): number;
  32900. /**
  32901. * Returns directly the latest state of the mesh World matrix.
  32902. * A Matrix is returned.
  32903. */
  32904. get worldMatrixFromCache(): Matrix;
  32905. /** @hidden */
  32906. _initCache(): void;
  32907. /** @hidden */
  32908. updateCache(force?: boolean): void;
  32909. /** @hidden */
  32910. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32911. /** @hidden */
  32912. _updateCache(ignoreParentClass?: boolean): void;
  32913. /** @hidden */
  32914. _isSynchronized(): boolean;
  32915. /** @hidden */
  32916. _markSyncedWithParent(): void;
  32917. /** @hidden */
  32918. isSynchronizedWithParent(): boolean;
  32919. /** @hidden */
  32920. isSynchronized(): boolean;
  32921. /**
  32922. * Is this node ready to be used/rendered
  32923. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32924. * @return true if the node is ready
  32925. */
  32926. isReady(completeCheck?: boolean): boolean;
  32927. /**
  32928. * Is this node enabled?
  32929. * 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
  32930. * @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
  32931. * @return whether this node (and its parent) is enabled
  32932. */
  32933. isEnabled(checkAncestors?: boolean): boolean;
  32934. /** @hidden */
  32935. protected _syncParentEnabledState(): void;
  32936. /**
  32937. * Set the enabled state of this node
  32938. * @param value defines the new enabled state
  32939. */
  32940. setEnabled(value: boolean): void;
  32941. /**
  32942. * Is this node a descendant of the given node?
  32943. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  32944. * @param ancestor defines the parent node to inspect
  32945. * @returns a boolean indicating if this node is a descendant of the given node
  32946. */
  32947. isDescendantOf(ancestor: Node): boolean;
  32948. /** @hidden */
  32949. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  32950. /**
  32951. * Will return all nodes that have this node as ascendant
  32952. * @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
  32953. * @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
  32954. * @return all children nodes of all types
  32955. */
  32956. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  32957. /**
  32958. * Get all child-meshes of this node
  32959. * @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)
  32960. * @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
  32961. * @returns an array of AbstractMesh
  32962. */
  32963. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  32964. /**
  32965. * Get all direct children of this node
  32966. * @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
  32967. * @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)
  32968. * @returns an array of Node
  32969. */
  32970. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  32971. /** @hidden */
  32972. _setReady(state: boolean): void;
  32973. /**
  32974. * Get an animation by name
  32975. * @param name defines the name of the animation to look for
  32976. * @returns null if not found else the requested animation
  32977. */
  32978. getAnimationByName(name: string): Nullable<Animation>;
  32979. /**
  32980. * Creates an animation range for this node
  32981. * @param name defines the name of the range
  32982. * @param from defines the starting key
  32983. * @param to defines the end key
  32984. */
  32985. createAnimationRange(name: string, from: number, to: number): void;
  32986. /**
  32987. * Delete a specific animation range
  32988. * @param name defines the name of the range to delete
  32989. * @param deleteFrames defines if animation frames from the range must be deleted as well
  32990. */
  32991. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  32992. /**
  32993. * Get an animation range by name
  32994. * @param name defines the name of the animation range to look for
  32995. * @returns null if not found else the requested animation range
  32996. */
  32997. getAnimationRange(name: string): Nullable<AnimationRange>;
  32998. /**
  32999. * Gets the list of all animation ranges defined on this node
  33000. * @returns an array
  33001. */
  33002. getAnimationRanges(): Nullable<AnimationRange>[];
  33003. /**
  33004. * Will start the animation sequence
  33005. * @param name defines the range frames for animation sequence
  33006. * @param loop defines if the animation should loop (false by default)
  33007. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  33008. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  33009. * @returns the object created for this animation. If range does not exist, it will return null
  33010. */
  33011. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  33012. /**
  33013. * Serialize animation ranges into a JSON compatible object
  33014. * @returns serialization object
  33015. */
  33016. serializeAnimationRanges(): any;
  33017. /**
  33018. * Computes the world matrix of the node
  33019. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  33020. * @returns the world matrix
  33021. */
  33022. computeWorldMatrix(force?: boolean): Matrix;
  33023. /**
  33024. * Releases resources associated with this node.
  33025. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33026. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33027. */
  33028. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33029. /**
  33030. * Parse animation range data from a serialization object and store them into a given node
  33031. * @param node defines where to store the animation ranges
  33032. * @param parsedNode defines the serialization object to read data from
  33033. * @param scene defines the hosting scene
  33034. */
  33035. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  33036. /**
  33037. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  33038. * @param includeDescendants Include bounding info from descendants as well (true by default)
  33039. * @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
  33040. * @returns the new bounding vectors
  33041. */
  33042. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  33043. min: Vector3;
  33044. max: Vector3;
  33045. };
  33046. }
  33047. }
  33048. declare module BABYLON {
  33049. /**
  33050. * @hidden
  33051. */
  33052. export class _IAnimationState {
  33053. key: number;
  33054. repeatCount: number;
  33055. workValue?: any;
  33056. loopMode?: number;
  33057. offsetValue?: any;
  33058. highLimitValue?: any;
  33059. }
  33060. /**
  33061. * Class used to store any kind of animation
  33062. */
  33063. export class Animation {
  33064. /**Name of the animation */
  33065. name: string;
  33066. /**Property to animate */
  33067. targetProperty: string;
  33068. /**The frames per second of the animation */
  33069. framePerSecond: number;
  33070. /**The data type of the animation */
  33071. dataType: number;
  33072. /**The loop mode of the animation */
  33073. loopMode?: number | undefined;
  33074. /**Specifies if blending should be enabled */
  33075. enableBlending?: boolean | undefined;
  33076. /**
  33077. * Use matrix interpolation instead of using direct key value when animating matrices
  33078. */
  33079. static AllowMatricesInterpolation: boolean;
  33080. /**
  33081. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  33082. */
  33083. static AllowMatrixDecomposeForInterpolation: boolean;
  33084. /** Define the Url to load snippets */
  33085. static SnippetUrl: string;
  33086. /** Snippet ID if the animation was created from the snippet server */
  33087. snippetId: string;
  33088. /**
  33089. * Stores the key frames of the animation
  33090. */
  33091. private _keys;
  33092. /**
  33093. * Stores the easing function of the animation
  33094. */
  33095. private _easingFunction;
  33096. /**
  33097. * @hidden Internal use only
  33098. */
  33099. _runtimeAnimations: RuntimeAnimation[];
  33100. /**
  33101. * The set of event that will be linked to this animation
  33102. */
  33103. private _events;
  33104. /**
  33105. * Stores an array of target property paths
  33106. */
  33107. targetPropertyPath: string[];
  33108. /**
  33109. * Stores the blending speed of the animation
  33110. */
  33111. blendingSpeed: number;
  33112. /**
  33113. * Stores the animation ranges for the animation
  33114. */
  33115. private _ranges;
  33116. /**
  33117. * @hidden Internal use
  33118. */
  33119. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  33120. /**
  33121. * Sets up an animation
  33122. * @param property The property to animate
  33123. * @param animationType The animation type to apply
  33124. * @param framePerSecond The frames per second of the animation
  33125. * @param easingFunction The easing function used in the animation
  33126. * @returns The created animation
  33127. */
  33128. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  33129. /**
  33130. * Create and start an animation on a node
  33131. * @param name defines the name of the global animation that will be run on all nodes
  33132. * @param node defines the root node where the animation will take place
  33133. * @param targetProperty defines property to animate
  33134. * @param framePerSecond defines the number of frame per second yo use
  33135. * @param totalFrame defines the number of frames in total
  33136. * @param from defines the initial value
  33137. * @param to defines the final value
  33138. * @param loopMode defines which loop mode you want to use (off by default)
  33139. * @param easingFunction defines the easing function to use (linear by default)
  33140. * @param onAnimationEnd defines the callback to call when animation end
  33141. * @returns the animatable created for this animation
  33142. */
  33143. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33144. /**
  33145. * Create and start an animation on a node and its descendants
  33146. * @param name defines the name of the global animation that will be run on all nodes
  33147. * @param node defines the root node where the animation will take place
  33148. * @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
  33149. * @param targetProperty defines property to animate
  33150. * @param framePerSecond defines the number of frame per second to use
  33151. * @param totalFrame defines the number of frames in total
  33152. * @param from defines the initial value
  33153. * @param to defines the final value
  33154. * @param loopMode defines which loop mode you want to use (off by default)
  33155. * @param easingFunction defines the easing function to use (linear by default)
  33156. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33157. * @returns the list of animatables created for all nodes
  33158. * @example https://www.babylonjs-playground.com/#MH0VLI
  33159. */
  33160. 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[]>;
  33161. /**
  33162. * Creates a new animation, merges it with the existing animations and starts it
  33163. * @param name Name of the animation
  33164. * @param node Node which contains the scene that begins the animations
  33165. * @param targetProperty Specifies which property to animate
  33166. * @param framePerSecond The frames per second of the animation
  33167. * @param totalFrame The total number of frames
  33168. * @param from The frame at the beginning of the animation
  33169. * @param to The frame at the end of the animation
  33170. * @param loopMode Specifies the loop mode of the animation
  33171. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  33172. * @param onAnimationEnd Callback to run once the animation is complete
  33173. * @returns Nullable animation
  33174. */
  33175. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33176. /**
  33177. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  33178. * @param sourceAnimation defines the Animation containing keyframes to convert
  33179. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  33180. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  33181. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  33182. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  33183. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  33184. */
  33185. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  33186. /**
  33187. * Transition property of an host to the target Value
  33188. * @param property The property to transition
  33189. * @param targetValue The target Value of the property
  33190. * @param host The object where the property to animate belongs
  33191. * @param scene Scene used to run the animation
  33192. * @param frameRate Framerate (in frame/s) to use
  33193. * @param transition The transition type we want to use
  33194. * @param duration The duration of the animation, in milliseconds
  33195. * @param onAnimationEnd Callback trigger at the end of the animation
  33196. * @returns Nullable animation
  33197. */
  33198. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  33199. /**
  33200. * Return the array of runtime animations currently using this animation
  33201. */
  33202. get runtimeAnimations(): RuntimeAnimation[];
  33203. /**
  33204. * Specifies if any of the runtime animations are currently running
  33205. */
  33206. get hasRunningRuntimeAnimations(): boolean;
  33207. /**
  33208. * Initializes the animation
  33209. * @param name Name of the animation
  33210. * @param targetProperty Property to animate
  33211. * @param framePerSecond The frames per second of the animation
  33212. * @param dataType The data type of the animation
  33213. * @param loopMode The loop mode of the animation
  33214. * @param enableBlending Specifies if blending should be enabled
  33215. */
  33216. constructor(
  33217. /**Name of the animation */
  33218. name: string,
  33219. /**Property to animate */
  33220. targetProperty: string,
  33221. /**The frames per second of the animation */
  33222. framePerSecond: number,
  33223. /**The data type of the animation */
  33224. dataType: number,
  33225. /**The loop mode of the animation */
  33226. loopMode?: number | undefined,
  33227. /**Specifies if blending should be enabled */
  33228. enableBlending?: boolean | undefined);
  33229. /**
  33230. * Converts the animation to a string
  33231. * @param fullDetails support for multiple levels of logging within scene loading
  33232. * @returns String form of the animation
  33233. */
  33234. toString(fullDetails?: boolean): string;
  33235. /**
  33236. * Add an event to this animation
  33237. * @param event Event to add
  33238. */
  33239. addEvent(event: AnimationEvent): void;
  33240. /**
  33241. * Remove all events found at the given frame
  33242. * @param frame The frame to remove events from
  33243. */
  33244. removeEvents(frame: number): void;
  33245. /**
  33246. * Retrieves all the events from the animation
  33247. * @returns Events from the animation
  33248. */
  33249. getEvents(): AnimationEvent[];
  33250. /**
  33251. * Creates an animation range
  33252. * @param name Name of the animation range
  33253. * @param from Starting frame of the animation range
  33254. * @param to Ending frame of the animation
  33255. */
  33256. createRange(name: string, from: number, to: number): void;
  33257. /**
  33258. * Deletes an animation range by name
  33259. * @param name Name of the animation range to delete
  33260. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  33261. */
  33262. deleteRange(name: string, deleteFrames?: boolean): void;
  33263. /**
  33264. * Gets the animation range by name, or null if not defined
  33265. * @param name Name of the animation range
  33266. * @returns Nullable animation range
  33267. */
  33268. getRange(name: string): Nullable<AnimationRange>;
  33269. /**
  33270. * Gets the key frames from the animation
  33271. * @returns The key frames of the animation
  33272. */
  33273. getKeys(): Array<IAnimationKey>;
  33274. /**
  33275. * Gets the highest frame rate of the animation
  33276. * @returns Highest frame rate of the animation
  33277. */
  33278. getHighestFrame(): number;
  33279. /**
  33280. * Gets the easing function of the animation
  33281. * @returns Easing function of the animation
  33282. */
  33283. getEasingFunction(): IEasingFunction;
  33284. /**
  33285. * Sets the easing function of the animation
  33286. * @param easingFunction A custom mathematical formula for animation
  33287. */
  33288. setEasingFunction(easingFunction: EasingFunction): void;
  33289. /**
  33290. * Interpolates a scalar linearly
  33291. * @param startValue Start value of the animation curve
  33292. * @param endValue End value of the animation curve
  33293. * @param gradient Scalar amount to interpolate
  33294. * @returns Interpolated scalar value
  33295. */
  33296. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  33297. /**
  33298. * Interpolates a scalar cubically
  33299. * @param startValue Start value of the animation curve
  33300. * @param outTangent End tangent of the animation
  33301. * @param endValue End value of the animation curve
  33302. * @param inTangent Start tangent of the animation curve
  33303. * @param gradient Scalar amount to interpolate
  33304. * @returns Interpolated scalar value
  33305. */
  33306. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  33307. /**
  33308. * Interpolates a quaternion using a spherical linear interpolation
  33309. * @param startValue Start value of the animation curve
  33310. * @param endValue End value of the animation curve
  33311. * @param gradient Scalar amount to interpolate
  33312. * @returns Interpolated quaternion value
  33313. */
  33314. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  33315. /**
  33316. * Interpolates a quaternion cubically
  33317. * @param startValue Start value of the animation curve
  33318. * @param outTangent End tangent of the animation curve
  33319. * @param endValue End value of the animation curve
  33320. * @param inTangent Start tangent of the animation curve
  33321. * @param gradient Scalar amount to interpolate
  33322. * @returns Interpolated quaternion value
  33323. */
  33324. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  33325. /**
  33326. * Interpolates a Vector3 linearl
  33327. * @param startValue Start value of the animation curve
  33328. * @param endValue End value of the animation curve
  33329. * @param gradient Scalar amount to interpolate
  33330. * @returns Interpolated scalar value
  33331. */
  33332. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  33333. /**
  33334. * Interpolates a Vector3 cubically
  33335. * @param startValue Start value of the animation curve
  33336. * @param outTangent End tangent of the animation
  33337. * @param endValue End value of the animation curve
  33338. * @param inTangent Start tangent of the animation curve
  33339. * @param gradient Scalar amount to interpolate
  33340. * @returns InterpolatedVector3 value
  33341. */
  33342. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  33343. /**
  33344. * Interpolates a Vector2 linearly
  33345. * @param startValue Start value of the animation curve
  33346. * @param endValue End value of the animation curve
  33347. * @param gradient Scalar amount to interpolate
  33348. * @returns Interpolated Vector2 value
  33349. */
  33350. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  33351. /**
  33352. * Interpolates a Vector2 cubically
  33353. * @param startValue Start value of the animation curve
  33354. * @param outTangent End tangent of the animation
  33355. * @param endValue End value of the animation curve
  33356. * @param inTangent Start tangent of the animation curve
  33357. * @param gradient Scalar amount to interpolate
  33358. * @returns Interpolated Vector2 value
  33359. */
  33360. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  33361. /**
  33362. * Interpolates a size linearly
  33363. * @param startValue Start value of the animation curve
  33364. * @param endValue End value of the animation curve
  33365. * @param gradient Scalar amount to interpolate
  33366. * @returns Interpolated Size value
  33367. */
  33368. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  33369. /**
  33370. * Interpolates a Color3 linearly
  33371. * @param startValue Start value of the animation curve
  33372. * @param endValue End value of the animation curve
  33373. * @param gradient Scalar amount to interpolate
  33374. * @returns Interpolated Color3 value
  33375. */
  33376. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  33377. /**
  33378. * Interpolates a Color4 linearly
  33379. * @param startValue Start value of the animation curve
  33380. * @param endValue End value of the animation curve
  33381. * @param gradient Scalar amount to interpolate
  33382. * @returns Interpolated Color3 value
  33383. */
  33384. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  33385. /**
  33386. * @hidden Internal use only
  33387. */
  33388. _getKeyValue(value: any): any;
  33389. /**
  33390. * @hidden Internal use only
  33391. */
  33392. _interpolate(currentFrame: number, state: _IAnimationState): any;
  33393. /**
  33394. * Defines the function to use to interpolate matrices
  33395. * @param startValue defines the start matrix
  33396. * @param endValue defines the end matrix
  33397. * @param gradient defines the gradient between both matrices
  33398. * @param result defines an optional target matrix where to store the interpolation
  33399. * @returns the interpolated matrix
  33400. */
  33401. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  33402. /**
  33403. * Makes a copy of the animation
  33404. * @returns Cloned animation
  33405. */
  33406. clone(): Animation;
  33407. /**
  33408. * Sets the key frames of the animation
  33409. * @param values The animation key frames to set
  33410. */
  33411. setKeys(values: Array<IAnimationKey>): void;
  33412. /**
  33413. * Serializes the animation to an object
  33414. * @returns Serialized object
  33415. */
  33416. serialize(): any;
  33417. /**
  33418. * Float animation type
  33419. */
  33420. static readonly ANIMATIONTYPE_FLOAT: number;
  33421. /**
  33422. * Vector3 animation type
  33423. */
  33424. static readonly ANIMATIONTYPE_VECTOR3: number;
  33425. /**
  33426. * Quaternion animation type
  33427. */
  33428. static readonly ANIMATIONTYPE_QUATERNION: number;
  33429. /**
  33430. * Matrix animation type
  33431. */
  33432. static readonly ANIMATIONTYPE_MATRIX: number;
  33433. /**
  33434. * Color3 animation type
  33435. */
  33436. static readonly ANIMATIONTYPE_COLOR3: number;
  33437. /**
  33438. * Color3 animation type
  33439. */
  33440. static readonly ANIMATIONTYPE_COLOR4: number;
  33441. /**
  33442. * Vector2 animation type
  33443. */
  33444. static readonly ANIMATIONTYPE_VECTOR2: number;
  33445. /**
  33446. * Size animation type
  33447. */
  33448. static readonly ANIMATIONTYPE_SIZE: number;
  33449. /**
  33450. * Relative Loop Mode
  33451. */
  33452. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  33453. /**
  33454. * Cycle Loop Mode
  33455. */
  33456. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  33457. /**
  33458. * Constant Loop Mode
  33459. */
  33460. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  33461. /** @hidden */
  33462. static _UniversalLerp(left: any, right: any, amount: number): any;
  33463. /**
  33464. * Parses an animation object and creates an animation
  33465. * @param parsedAnimation Parsed animation object
  33466. * @returns Animation object
  33467. */
  33468. static Parse(parsedAnimation: any): Animation;
  33469. /**
  33470. * Appends the serialized animations from the source animations
  33471. * @param source Source containing the animations
  33472. * @param destination Target to store the animations
  33473. */
  33474. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33475. /**
  33476. * Creates a new animation or an array of animations from a snippet saved in a remote file
  33477. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  33478. * @param url defines the url to load from
  33479. * @returns a promise that will resolve to the new animation or an array of animations
  33480. */
  33481. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  33482. /**
  33483. * Creates an animation or an array of animations from a snippet saved by the Inspector
  33484. * @param snippetId defines the snippet to load
  33485. * @returns a promise that will resolve to the new animation or a new array of animations
  33486. */
  33487. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  33488. }
  33489. }
  33490. declare module BABYLON {
  33491. /**
  33492. * Interface containing an array of animations
  33493. */
  33494. export interface IAnimatable {
  33495. /**
  33496. * Array of animations
  33497. */
  33498. animations: Nullable<Array<Animation>>;
  33499. }
  33500. }
  33501. declare module BABYLON {
  33502. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  33503. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33504. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33505. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33506. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33507. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33508. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33509. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33510. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33511. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33512. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33513. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33514. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33515. /**
  33516. * Decorator used to define property that can be serialized as reference to a camera
  33517. * @param sourceName defines the name of the property to decorate
  33518. */
  33519. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33520. /**
  33521. * Class used to help serialization objects
  33522. */
  33523. export class SerializationHelper {
  33524. /** @hidden */
  33525. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  33526. /** @hidden */
  33527. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  33528. /** @hidden */
  33529. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  33530. /** @hidden */
  33531. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  33532. /**
  33533. * Appends the serialized animations from the source animations
  33534. * @param source Source containing the animations
  33535. * @param destination Target to store the animations
  33536. */
  33537. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33538. /**
  33539. * Static function used to serialized a specific entity
  33540. * @param entity defines the entity to serialize
  33541. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  33542. * @returns a JSON compatible object representing the serialization of the entity
  33543. */
  33544. static Serialize<T>(entity: T, serializationObject?: any): any;
  33545. /**
  33546. * Creates a new entity from a serialization data object
  33547. * @param creationFunction defines a function used to instanciated the new entity
  33548. * @param source defines the source serialization data
  33549. * @param scene defines the hosting scene
  33550. * @param rootUrl defines the root url for resources
  33551. * @returns a new entity
  33552. */
  33553. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  33554. /**
  33555. * Clones an object
  33556. * @param creationFunction defines the function used to instanciate the new object
  33557. * @param source defines the source object
  33558. * @returns the cloned object
  33559. */
  33560. static Clone<T>(creationFunction: () => T, source: T): T;
  33561. /**
  33562. * Instanciates a new object based on a source one (some data will be shared between both object)
  33563. * @param creationFunction defines the function used to instanciate the new object
  33564. * @param source defines the source object
  33565. * @returns the new object
  33566. */
  33567. static Instanciate<T>(creationFunction: () => T, source: T): T;
  33568. }
  33569. }
  33570. declare module BABYLON {
  33571. /**
  33572. * Base class of all the textures in babylon.
  33573. * It groups all the common properties the materials, post process, lights... might need
  33574. * in order to make a correct use of the texture.
  33575. */
  33576. export class BaseTexture implements IAnimatable {
  33577. /**
  33578. * Default anisotropic filtering level for the application.
  33579. * It is set to 4 as a good tradeoff between perf and quality.
  33580. */
  33581. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  33582. /**
  33583. * Gets or sets the unique id of the texture
  33584. */
  33585. uniqueId: number;
  33586. /**
  33587. * Define the name of the texture.
  33588. */
  33589. name: string;
  33590. /**
  33591. * Gets or sets an object used to store user defined information.
  33592. */
  33593. metadata: any;
  33594. /**
  33595. * For internal use only. Please do not use.
  33596. */
  33597. reservedDataStore: any;
  33598. private _hasAlpha;
  33599. /**
  33600. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  33601. */
  33602. set hasAlpha(value: boolean);
  33603. get hasAlpha(): boolean;
  33604. /**
  33605. * Defines if the alpha value should be determined via the rgb values.
  33606. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  33607. */
  33608. getAlphaFromRGB: boolean;
  33609. /**
  33610. * Intensity or strength of the texture.
  33611. * It is commonly used by materials to fine tune the intensity of the texture
  33612. */
  33613. level: number;
  33614. /**
  33615. * Define the UV chanel to use starting from 0 and defaulting to 0.
  33616. * This is part of the texture as textures usually maps to one uv set.
  33617. */
  33618. coordinatesIndex: number;
  33619. private _coordinatesMode;
  33620. /**
  33621. * How a texture is mapped.
  33622. *
  33623. * | Value | Type | Description |
  33624. * | ----- | ----------------------------------- | ----------- |
  33625. * | 0 | EXPLICIT_MODE | |
  33626. * | 1 | SPHERICAL_MODE | |
  33627. * | 2 | PLANAR_MODE | |
  33628. * | 3 | CUBIC_MODE | |
  33629. * | 4 | PROJECTION_MODE | |
  33630. * | 5 | SKYBOX_MODE | |
  33631. * | 6 | INVCUBIC_MODE | |
  33632. * | 7 | EQUIRECTANGULAR_MODE | |
  33633. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  33634. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  33635. */
  33636. set coordinatesMode(value: number);
  33637. get coordinatesMode(): number;
  33638. /**
  33639. * | Value | Type | Description |
  33640. * | ----- | ------------------ | ----------- |
  33641. * | 0 | CLAMP_ADDRESSMODE | |
  33642. * | 1 | WRAP_ADDRESSMODE | |
  33643. * | 2 | MIRROR_ADDRESSMODE | |
  33644. */
  33645. wrapU: number;
  33646. /**
  33647. * | Value | Type | Description |
  33648. * | ----- | ------------------ | ----------- |
  33649. * | 0 | CLAMP_ADDRESSMODE | |
  33650. * | 1 | WRAP_ADDRESSMODE | |
  33651. * | 2 | MIRROR_ADDRESSMODE | |
  33652. */
  33653. wrapV: number;
  33654. /**
  33655. * | Value | Type | Description |
  33656. * | ----- | ------------------ | ----------- |
  33657. * | 0 | CLAMP_ADDRESSMODE | |
  33658. * | 1 | WRAP_ADDRESSMODE | |
  33659. * | 2 | MIRROR_ADDRESSMODE | |
  33660. */
  33661. wrapR: number;
  33662. /**
  33663. * With compliant hardware and browser (supporting anisotropic filtering)
  33664. * this defines the level of anisotropic filtering in the texture.
  33665. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  33666. */
  33667. anisotropicFilteringLevel: number;
  33668. /**
  33669. * Define if the texture is a cube texture or if false a 2d texture.
  33670. */
  33671. get isCube(): boolean;
  33672. set isCube(value: boolean);
  33673. /**
  33674. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  33675. */
  33676. get is3D(): boolean;
  33677. set is3D(value: boolean);
  33678. /**
  33679. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  33680. */
  33681. get is2DArray(): boolean;
  33682. set is2DArray(value: boolean);
  33683. /**
  33684. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  33685. * HDR texture are usually stored in linear space.
  33686. * This only impacts the PBR and Background materials
  33687. */
  33688. gammaSpace: boolean;
  33689. /**
  33690. * Gets or sets whether or not the texture contains RGBD data.
  33691. */
  33692. get isRGBD(): boolean;
  33693. set isRGBD(value: boolean);
  33694. /**
  33695. * Is Z inverted in the texture (useful in a cube texture).
  33696. */
  33697. invertZ: boolean;
  33698. /**
  33699. * Are mip maps generated for this texture or not.
  33700. */
  33701. get noMipmap(): boolean;
  33702. /**
  33703. * @hidden
  33704. */
  33705. lodLevelInAlpha: boolean;
  33706. /**
  33707. * With prefiltered texture, defined the offset used during the prefiltering steps.
  33708. */
  33709. get lodGenerationOffset(): number;
  33710. set lodGenerationOffset(value: number);
  33711. /**
  33712. * With prefiltered texture, defined the scale used during the prefiltering steps.
  33713. */
  33714. get lodGenerationScale(): number;
  33715. set lodGenerationScale(value: number);
  33716. /**
  33717. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  33718. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  33719. * average roughness values.
  33720. */
  33721. get linearSpecularLOD(): boolean;
  33722. set linearSpecularLOD(value: boolean);
  33723. /**
  33724. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  33725. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  33726. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  33727. */
  33728. get irradianceTexture(): Nullable<BaseTexture>;
  33729. set irradianceTexture(value: Nullable<BaseTexture>);
  33730. /**
  33731. * Define if the texture is a render target.
  33732. */
  33733. isRenderTarget: boolean;
  33734. /**
  33735. * Define the unique id of the texture in the scene.
  33736. */
  33737. get uid(): string;
  33738. /** @hidden */
  33739. _prefiltered: boolean;
  33740. /**
  33741. * Return a string representation of the texture.
  33742. * @returns the texture as a string
  33743. */
  33744. toString(): string;
  33745. /**
  33746. * Get the class name of the texture.
  33747. * @returns "BaseTexture"
  33748. */
  33749. getClassName(): string;
  33750. /**
  33751. * Define the list of animation attached to the texture.
  33752. */
  33753. animations: Animation[];
  33754. /**
  33755. * An event triggered when the texture is disposed.
  33756. */
  33757. onDisposeObservable: Observable<BaseTexture>;
  33758. private _onDisposeObserver;
  33759. /**
  33760. * Callback triggered when the texture has been disposed.
  33761. * Kept for back compatibility, you can use the onDisposeObservable instead.
  33762. */
  33763. set onDispose(callback: () => void);
  33764. /**
  33765. * Define the current state of the loading sequence when in delayed load mode.
  33766. */
  33767. delayLoadState: number;
  33768. private _scene;
  33769. private _engine;
  33770. /** @hidden */
  33771. _texture: Nullable<InternalTexture>;
  33772. private _uid;
  33773. /**
  33774. * Define if the texture is preventinga material to render or not.
  33775. * If not and the texture is not ready, the engine will use a default black texture instead.
  33776. */
  33777. get isBlocking(): boolean;
  33778. /**
  33779. * Instantiates a new BaseTexture.
  33780. * Base class of all the textures in babylon.
  33781. * It groups all the common properties the materials, post process, lights... might need
  33782. * in order to make a correct use of the texture.
  33783. * @param sceneOrEngine Define the scene or engine the texture blongs to
  33784. */
  33785. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  33786. /**
  33787. * Get the scene the texture belongs to.
  33788. * @returns the scene or null if undefined
  33789. */
  33790. getScene(): Nullable<Scene>;
  33791. /** @hidden */
  33792. protected _getEngine(): Nullable<ThinEngine>;
  33793. /**
  33794. * Get the texture transform matrix used to offset tile the texture for istance.
  33795. * @returns the transformation matrix
  33796. */
  33797. getTextureMatrix(): Matrix;
  33798. /**
  33799. * Get the texture reflection matrix used to rotate/transform the reflection.
  33800. * @returns the reflection matrix
  33801. */
  33802. getReflectionTextureMatrix(): Matrix;
  33803. /**
  33804. * Get the underlying lower level texture from Babylon.
  33805. * @returns the insternal texture
  33806. */
  33807. getInternalTexture(): Nullable<InternalTexture>;
  33808. /**
  33809. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  33810. * @returns true if ready or not blocking
  33811. */
  33812. isReadyOrNotBlocking(): boolean;
  33813. /**
  33814. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  33815. * @returns true if fully ready
  33816. */
  33817. isReady(): boolean;
  33818. private _cachedSize;
  33819. /**
  33820. * Get the size of the texture.
  33821. * @returns the texture size.
  33822. */
  33823. getSize(): ISize;
  33824. /**
  33825. * Get the base size of the texture.
  33826. * It can be different from the size if the texture has been resized for POT for instance
  33827. * @returns the base size
  33828. */
  33829. getBaseSize(): ISize;
  33830. /**
  33831. * Update the sampling mode of the texture.
  33832. * Default is Trilinear mode.
  33833. *
  33834. * | Value | Type | Description |
  33835. * | ----- | ------------------ | ----------- |
  33836. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  33837. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  33838. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  33839. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  33840. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  33841. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  33842. * | 7 | NEAREST_LINEAR | |
  33843. * | 8 | NEAREST_NEAREST | |
  33844. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  33845. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  33846. * | 11 | LINEAR_LINEAR | |
  33847. * | 12 | LINEAR_NEAREST | |
  33848. *
  33849. * > _mag_: magnification filter (close to the viewer)
  33850. * > _min_: minification filter (far from the viewer)
  33851. * > _mip_: filter used between mip map levels
  33852. *@param samplingMode Define the new sampling mode of the texture
  33853. */
  33854. updateSamplingMode(samplingMode: number): void;
  33855. /**
  33856. * Scales the texture if is `canRescale()`
  33857. * @param ratio the resize factor we want to use to rescale
  33858. */
  33859. scale(ratio: number): void;
  33860. /**
  33861. * Get if the texture can rescale.
  33862. */
  33863. get canRescale(): boolean;
  33864. /** @hidden */
  33865. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  33866. /** @hidden */
  33867. _rebuild(): void;
  33868. /**
  33869. * Triggers the load sequence in delayed load mode.
  33870. */
  33871. delayLoad(): void;
  33872. /**
  33873. * Clones the texture.
  33874. * @returns the cloned texture
  33875. */
  33876. clone(): Nullable<BaseTexture>;
  33877. /**
  33878. * Get the texture underlying type (INT, FLOAT...)
  33879. */
  33880. get textureType(): number;
  33881. /**
  33882. * Get the texture underlying format (RGB, RGBA...)
  33883. */
  33884. get textureFormat(): number;
  33885. /**
  33886. * Indicates that textures need to be re-calculated for all materials
  33887. */
  33888. protected _markAllSubMeshesAsTexturesDirty(): void;
  33889. /**
  33890. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  33891. * This will returns an RGBA array buffer containing either in values (0-255) or
  33892. * float values (0-1) depending of the underlying buffer type.
  33893. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  33894. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  33895. * @param buffer defines a user defined buffer to fill with data (can be null)
  33896. * @returns The Array buffer containing the pixels data.
  33897. */
  33898. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  33899. /**
  33900. * Release and destroy the underlying lower level texture aka internalTexture.
  33901. */
  33902. releaseInternalTexture(): void;
  33903. /** @hidden */
  33904. get _lodTextureHigh(): Nullable<BaseTexture>;
  33905. /** @hidden */
  33906. get _lodTextureMid(): Nullable<BaseTexture>;
  33907. /** @hidden */
  33908. get _lodTextureLow(): Nullable<BaseTexture>;
  33909. /**
  33910. * Dispose the texture and release its associated resources.
  33911. */
  33912. dispose(): void;
  33913. /**
  33914. * Serialize the texture into a JSON representation that can be parsed later on.
  33915. * @returns the JSON representation of the texture
  33916. */
  33917. serialize(): any;
  33918. /**
  33919. * Helper function to be called back once a list of texture contains only ready textures.
  33920. * @param textures Define the list of textures to wait for
  33921. * @param callback Define the callback triggered once the entire list will be ready
  33922. */
  33923. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  33924. private static _isScene;
  33925. }
  33926. }
  33927. declare module BABYLON {
  33928. /**
  33929. * Options to be used when creating an effect.
  33930. */
  33931. export interface IEffectCreationOptions {
  33932. /**
  33933. * Atrributes that will be used in the shader.
  33934. */
  33935. attributes: string[];
  33936. /**
  33937. * Uniform varible names that will be set in the shader.
  33938. */
  33939. uniformsNames: string[];
  33940. /**
  33941. * Uniform buffer variable names that will be set in the shader.
  33942. */
  33943. uniformBuffersNames: string[];
  33944. /**
  33945. * Sampler texture variable names that will be set in the shader.
  33946. */
  33947. samplers: string[];
  33948. /**
  33949. * Define statements that will be set in the shader.
  33950. */
  33951. defines: any;
  33952. /**
  33953. * Possible fallbacks for this effect to improve performance when needed.
  33954. */
  33955. fallbacks: Nullable<IEffectFallbacks>;
  33956. /**
  33957. * Callback that will be called when the shader is compiled.
  33958. */
  33959. onCompiled: Nullable<(effect: Effect) => void>;
  33960. /**
  33961. * Callback that will be called if an error occurs during shader compilation.
  33962. */
  33963. onError: Nullable<(effect: Effect, errors: string) => void>;
  33964. /**
  33965. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33966. */
  33967. indexParameters?: any;
  33968. /**
  33969. * Max number of lights that can be used in the shader.
  33970. */
  33971. maxSimultaneousLights?: number;
  33972. /**
  33973. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  33974. */
  33975. transformFeedbackVaryings?: Nullable<string[]>;
  33976. /**
  33977. * 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
  33978. */
  33979. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  33980. /**
  33981. * Is this effect rendering to several color attachments ?
  33982. */
  33983. multiTarget?: boolean;
  33984. }
  33985. /**
  33986. * Effect containing vertex and fragment shader that can be executed on an object.
  33987. */
  33988. export class Effect implements IDisposable {
  33989. /**
  33990. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  33991. */
  33992. static ShadersRepository: string;
  33993. /**
  33994. * Enable logging of the shader code when a compilation error occurs
  33995. */
  33996. static LogShaderCodeOnCompilationError: boolean;
  33997. /**
  33998. * Name of the effect.
  33999. */
  34000. name: any;
  34001. /**
  34002. * String container all the define statements that should be set on the shader.
  34003. */
  34004. defines: string;
  34005. /**
  34006. * Callback that will be called when the shader is compiled.
  34007. */
  34008. onCompiled: Nullable<(effect: Effect) => void>;
  34009. /**
  34010. * Callback that will be called if an error occurs during shader compilation.
  34011. */
  34012. onError: Nullable<(effect: Effect, errors: string) => void>;
  34013. /**
  34014. * Callback that will be called when effect is bound.
  34015. */
  34016. onBind: Nullable<(effect: Effect) => void>;
  34017. /**
  34018. * Unique ID of the effect.
  34019. */
  34020. uniqueId: number;
  34021. /**
  34022. * Observable that will be called when the shader is compiled.
  34023. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  34024. */
  34025. onCompileObservable: Observable<Effect>;
  34026. /**
  34027. * Observable that will be called if an error occurs during shader compilation.
  34028. */
  34029. onErrorObservable: Observable<Effect>;
  34030. /** @hidden */
  34031. _onBindObservable: Nullable<Observable<Effect>>;
  34032. /**
  34033. * @hidden
  34034. * Specifies if the effect was previously ready
  34035. */
  34036. _wasPreviouslyReady: boolean;
  34037. /**
  34038. * Observable that will be called when effect is bound.
  34039. */
  34040. get onBindObservable(): Observable<Effect>;
  34041. /** @hidden */
  34042. _bonesComputationForcedToCPU: boolean;
  34043. /** @hidden */
  34044. _multiTarget: boolean;
  34045. private static _uniqueIdSeed;
  34046. private _engine;
  34047. private _uniformBuffersNames;
  34048. private _uniformBuffersNamesList;
  34049. private _uniformsNames;
  34050. private _samplerList;
  34051. private _samplers;
  34052. private _isReady;
  34053. private _compilationError;
  34054. private _allFallbacksProcessed;
  34055. private _attributesNames;
  34056. private _attributes;
  34057. private _attributeLocationByName;
  34058. private _uniforms;
  34059. /**
  34060. * Key for the effect.
  34061. * @hidden
  34062. */
  34063. _key: string;
  34064. private _indexParameters;
  34065. private _fallbacks;
  34066. private _vertexSourceCode;
  34067. private _fragmentSourceCode;
  34068. private _vertexSourceCodeOverride;
  34069. private _fragmentSourceCodeOverride;
  34070. private _transformFeedbackVaryings;
  34071. /**
  34072. * Compiled shader to webGL program.
  34073. * @hidden
  34074. */
  34075. _pipelineContext: Nullable<IPipelineContext>;
  34076. private _valueCache;
  34077. private static _baseCache;
  34078. /**
  34079. * Instantiates an effect.
  34080. * An effect can be used to create/manage/execute vertex and fragment shaders.
  34081. * @param baseName Name of the effect.
  34082. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  34083. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  34084. * @param samplers List of sampler variables that will be passed to the shader.
  34085. * @param engine Engine to be used to render the effect
  34086. * @param defines Define statements to be added to the shader.
  34087. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  34088. * @param onCompiled Callback that will be called when the shader is compiled.
  34089. * @param onError Callback that will be called if an error occurs during shader compilation.
  34090. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34091. */
  34092. 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);
  34093. private _useFinalCode;
  34094. /**
  34095. * Unique key for this effect
  34096. */
  34097. get key(): string;
  34098. /**
  34099. * If the effect has been compiled and prepared.
  34100. * @returns if the effect is compiled and prepared.
  34101. */
  34102. isReady(): boolean;
  34103. private _isReadyInternal;
  34104. /**
  34105. * The engine the effect was initialized with.
  34106. * @returns the engine.
  34107. */
  34108. getEngine(): Engine;
  34109. /**
  34110. * The pipeline context for this effect
  34111. * @returns the associated pipeline context
  34112. */
  34113. getPipelineContext(): Nullable<IPipelineContext>;
  34114. /**
  34115. * The set of names of attribute variables for the shader.
  34116. * @returns An array of attribute names.
  34117. */
  34118. getAttributesNames(): string[];
  34119. /**
  34120. * Returns the attribute at the given index.
  34121. * @param index The index of the attribute.
  34122. * @returns The location of the attribute.
  34123. */
  34124. getAttributeLocation(index: number): number;
  34125. /**
  34126. * Returns the attribute based on the name of the variable.
  34127. * @param name of the attribute to look up.
  34128. * @returns the attribute location.
  34129. */
  34130. getAttributeLocationByName(name: string): number;
  34131. /**
  34132. * The number of attributes.
  34133. * @returns the numnber of attributes.
  34134. */
  34135. getAttributesCount(): number;
  34136. /**
  34137. * Gets the index of a uniform variable.
  34138. * @param uniformName of the uniform to look up.
  34139. * @returns the index.
  34140. */
  34141. getUniformIndex(uniformName: string): number;
  34142. /**
  34143. * Returns the attribute based on the name of the variable.
  34144. * @param uniformName of the uniform to look up.
  34145. * @returns the location of the uniform.
  34146. */
  34147. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  34148. /**
  34149. * Returns an array of sampler variable names
  34150. * @returns The array of sampler variable names.
  34151. */
  34152. getSamplers(): string[];
  34153. /**
  34154. * Returns an array of uniform variable names
  34155. * @returns The array of uniform variable names.
  34156. */
  34157. getUniformNames(): string[];
  34158. /**
  34159. * Returns an array of uniform buffer variable names
  34160. * @returns The array of uniform buffer variable names.
  34161. */
  34162. getUniformBuffersNames(): string[];
  34163. /**
  34164. * Returns the index parameters used to create the effect
  34165. * @returns The index parameters object
  34166. */
  34167. getIndexParameters(): any;
  34168. /**
  34169. * The error from the last compilation.
  34170. * @returns the error string.
  34171. */
  34172. getCompilationError(): string;
  34173. /**
  34174. * Gets a boolean indicating that all fallbacks were used during compilation
  34175. * @returns true if all fallbacks were used
  34176. */
  34177. allFallbacksProcessed(): boolean;
  34178. /**
  34179. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  34180. * @param func The callback to be used.
  34181. */
  34182. executeWhenCompiled(func: (effect: Effect) => void): void;
  34183. private _checkIsReady;
  34184. private _loadShader;
  34185. /**
  34186. * Gets the vertex shader source code of this effect
  34187. */
  34188. get vertexSourceCode(): string;
  34189. /**
  34190. * Gets the fragment shader source code of this effect
  34191. */
  34192. get fragmentSourceCode(): string;
  34193. /**
  34194. * Recompiles the webGL program
  34195. * @param vertexSourceCode The source code for the vertex shader.
  34196. * @param fragmentSourceCode The source code for the fragment shader.
  34197. * @param onCompiled Callback called when completed.
  34198. * @param onError Callback called on error.
  34199. * @hidden
  34200. */
  34201. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  34202. /**
  34203. * Prepares the effect
  34204. * @hidden
  34205. */
  34206. _prepareEffect(): void;
  34207. private _getShaderCodeAndErrorLine;
  34208. private _processCompilationErrors;
  34209. /**
  34210. * Checks if the effect is supported. (Must be called after compilation)
  34211. */
  34212. get isSupported(): boolean;
  34213. /**
  34214. * Binds a texture to the engine to be used as output of the shader.
  34215. * @param channel Name of the output variable.
  34216. * @param texture Texture to bind.
  34217. * @hidden
  34218. */
  34219. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  34220. /**
  34221. * Sets a texture on the engine to be used in the shader.
  34222. * @param channel Name of the sampler variable.
  34223. * @param texture Texture to set.
  34224. */
  34225. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  34226. /**
  34227. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  34228. * @param channel Name of the sampler variable.
  34229. * @param texture Texture to set.
  34230. */
  34231. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  34232. /**
  34233. * Sets an array of textures on the engine to be used in the shader.
  34234. * @param channel Name of the variable.
  34235. * @param textures Textures to set.
  34236. */
  34237. setTextureArray(channel: string, textures: BaseTexture[]): void;
  34238. /**
  34239. * 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)
  34240. * @param channel Name of the sampler variable.
  34241. * @param postProcess Post process to get the input texture from.
  34242. */
  34243. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  34244. /**
  34245. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  34246. * 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)
  34247. * @param channel Name of the sampler variable.
  34248. * @param postProcess Post process to get the output texture from.
  34249. */
  34250. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  34251. /** @hidden */
  34252. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  34253. /** @hidden */
  34254. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  34255. /** @hidden */
  34256. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  34257. /** @hidden */
  34258. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  34259. /**
  34260. * Binds a buffer to a uniform.
  34261. * @param buffer Buffer to bind.
  34262. * @param name Name of the uniform variable to bind to.
  34263. */
  34264. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  34265. /**
  34266. * Binds block to a uniform.
  34267. * @param blockName Name of the block to bind.
  34268. * @param index Index to bind.
  34269. */
  34270. bindUniformBlock(blockName: string, index: number): void;
  34271. /**
  34272. * Sets an interger value on a uniform variable.
  34273. * @param uniformName Name of the variable.
  34274. * @param value Value to be set.
  34275. * @returns this effect.
  34276. */
  34277. setInt(uniformName: string, value: number): Effect;
  34278. /**
  34279. * Sets an int array on a uniform variable.
  34280. * @param uniformName Name of the variable.
  34281. * @param array array to be set.
  34282. * @returns this effect.
  34283. */
  34284. setIntArray(uniformName: string, array: Int32Array): Effect;
  34285. /**
  34286. * 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)
  34287. * @param uniformName Name of the variable.
  34288. * @param array array to be set.
  34289. * @returns this effect.
  34290. */
  34291. setIntArray2(uniformName: string, array: Int32Array): Effect;
  34292. /**
  34293. * 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)
  34294. * @param uniformName Name of the variable.
  34295. * @param array array to be set.
  34296. * @returns this effect.
  34297. */
  34298. setIntArray3(uniformName: string, array: Int32Array): Effect;
  34299. /**
  34300. * 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)
  34301. * @param uniformName Name of the variable.
  34302. * @param array array to be set.
  34303. * @returns this effect.
  34304. */
  34305. setIntArray4(uniformName: string, array: Int32Array): Effect;
  34306. /**
  34307. * Sets an float array on a uniform variable.
  34308. * @param uniformName Name of the variable.
  34309. * @param array array to be set.
  34310. * @returns this effect.
  34311. */
  34312. setFloatArray(uniformName: string, array: Float32Array): Effect;
  34313. /**
  34314. * 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)
  34315. * @param uniformName Name of the variable.
  34316. * @param array array to be set.
  34317. * @returns this effect.
  34318. */
  34319. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  34320. /**
  34321. * 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)
  34322. * @param uniformName Name of the variable.
  34323. * @param array array to be set.
  34324. * @returns this effect.
  34325. */
  34326. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  34327. /**
  34328. * 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)
  34329. * @param uniformName Name of the variable.
  34330. * @param array array to be set.
  34331. * @returns this effect.
  34332. */
  34333. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  34334. /**
  34335. * Sets an array on a uniform variable.
  34336. * @param uniformName Name of the variable.
  34337. * @param array array to be set.
  34338. * @returns this effect.
  34339. */
  34340. setArray(uniformName: string, array: number[]): Effect;
  34341. /**
  34342. * 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)
  34343. * @param uniformName Name of the variable.
  34344. * @param array array to be set.
  34345. * @returns this effect.
  34346. */
  34347. setArray2(uniformName: string, array: number[]): Effect;
  34348. /**
  34349. * 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)
  34350. * @param uniformName Name of the variable.
  34351. * @param array array to be set.
  34352. * @returns this effect.
  34353. */
  34354. setArray3(uniformName: string, array: number[]): Effect;
  34355. /**
  34356. * 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)
  34357. * @param uniformName Name of the variable.
  34358. * @param array array to be set.
  34359. * @returns this effect.
  34360. */
  34361. setArray4(uniformName: string, array: number[]): Effect;
  34362. /**
  34363. * Sets matrices on a uniform variable.
  34364. * @param uniformName Name of the variable.
  34365. * @param matrices matrices to be set.
  34366. * @returns this effect.
  34367. */
  34368. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  34369. /**
  34370. * Sets matrix on a uniform variable.
  34371. * @param uniformName Name of the variable.
  34372. * @param matrix matrix to be set.
  34373. * @returns this effect.
  34374. */
  34375. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  34376. /**
  34377. * 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)
  34378. * @param uniformName Name of the variable.
  34379. * @param matrix matrix to be set.
  34380. * @returns this effect.
  34381. */
  34382. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34383. /**
  34384. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  34385. * @param uniformName Name of the variable.
  34386. * @param matrix matrix to be set.
  34387. * @returns this effect.
  34388. */
  34389. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34390. /**
  34391. * Sets a float on a uniform variable.
  34392. * @param uniformName Name of the variable.
  34393. * @param value value to be set.
  34394. * @returns this effect.
  34395. */
  34396. setFloat(uniformName: string, value: number): Effect;
  34397. /**
  34398. * Sets a boolean on a uniform variable.
  34399. * @param uniformName Name of the variable.
  34400. * @param bool value to be set.
  34401. * @returns this effect.
  34402. */
  34403. setBool(uniformName: string, bool: boolean): Effect;
  34404. /**
  34405. * Sets a Vector2 on a uniform variable.
  34406. * @param uniformName Name of the variable.
  34407. * @param vector2 vector2 to be set.
  34408. * @returns this effect.
  34409. */
  34410. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  34411. /**
  34412. * Sets a float2 on a uniform variable.
  34413. * @param uniformName Name of the variable.
  34414. * @param x First float in float2.
  34415. * @param y Second float in float2.
  34416. * @returns this effect.
  34417. */
  34418. setFloat2(uniformName: string, x: number, y: number): Effect;
  34419. /**
  34420. * Sets a Vector3 on a uniform variable.
  34421. * @param uniformName Name of the variable.
  34422. * @param vector3 Value to be set.
  34423. * @returns this effect.
  34424. */
  34425. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  34426. /**
  34427. * Sets a float3 on a uniform variable.
  34428. * @param uniformName Name of the variable.
  34429. * @param x First float in float3.
  34430. * @param y Second float in float3.
  34431. * @param z Third float in float3.
  34432. * @returns this effect.
  34433. */
  34434. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  34435. /**
  34436. * Sets a Vector4 on a uniform variable.
  34437. * @param uniformName Name of the variable.
  34438. * @param vector4 Value to be set.
  34439. * @returns this effect.
  34440. */
  34441. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  34442. /**
  34443. * Sets a float4 on a uniform variable.
  34444. * @param uniformName Name of the variable.
  34445. * @param x First float in float4.
  34446. * @param y Second float in float4.
  34447. * @param z Third float in float4.
  34448. * @param w Fourth float in float4.
  34449. * @returns this effect.
  34450. */
  34451. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  34452. /**
  34453. * Sets a Color3 on a uniform variable.
  34454. * @param uniformName Name of the variable.
  34455. * @param color3 Value to be set.
  34456. * @returns this effect.
  34457. */
  34458. setColor3(uniformName: string, color3: IColor3Like): Effect;
  34459. /**
  34460. * Sets a Color4 on a uniform variable.
  34461. * @param uniformName Name of the variable.
  34462. * @param color3 Value to be set.
  34463. * @param alpha Alpha value to be set.
  34464. * @returns this effect.
  34465. */
  34466. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  34467. /**
  34468. * Sets a Color4 on a uniform variable
  34469. * @param uniformName defines the name of the variable
  34470. * @param color4 defines the value to be set
  34471. * @returns this effect.
  34472. */
  34473. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  34474. /** Release all associated resources */
  34475. dispose(): void;
  34476. /**
  34477. * This function will add a new shader to the shader store
  34478. * @param name the name of the shader
  34479. * @param pixelShader optional pixel shader content
  34480. * @param vertexShader optional vertex shader content
  34481. */
  34482. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  34483. /**
  34484. * Store of each shader (The can be looked up using effect.key)
  34485. */
  34486. static ShadersStore: {
  34487. [key: string]: string;
  34488. };
  34489. /**
  34490. * Store of each included file for a shader (The can be looked up using effect.key)
  34491. */
  34492. static IncludesShadersStore: {
  34493. [key: string]: string;
  34494. };
  34495. /**
  34496. * Resets the cache of effects.
  34497. */
  34498. static ResetCache(): void;
  34499. }
  34500. }
  34501. declare module BABYLON {
  34502. /**
  34503. * Interface used to describe the capabilities of the engine relatively to the current browser
  34504. */
  34505. export interface EngineCapabilities {
  34506. /** Maximum textures units per fragment shader */
  34507. maxTexturesImageUnits: number;
  34508. /** Maximum texture units per vertex shader */
  34509. maxVertexTextureImageUnits: number;
  34510. /** Maximum textures units in the entire pipeline */
  34511. maxCombinedTexturesImageUnits: number;
  34512. /** Maximum texture size */
  34513. maxTextureSize: number;
  34514. /** Maximum texture samples */
  34515. maxSamples?: number;
  34516. /** Maximum cube texture size */
  34517. maxCubemapTextureSize: number;
  34518. /** Maximum render texture size */
  34519. maxRenderTextureSize: number;
  34520. /** Maximum number of vertex attributes */
  34521. maxVertexAttribs: number;
  34522. /** Maximum number of varyings */
  34523. maxVaryingVectors: number;
  34524. /** Maximum number of uniforms per vertex shader */
  34525. maxVertexUniformVectors: number;
  34526. /** Maximum number of uniforms per fragment shader */
  34527. maxFragmentUniformVectors: number;
  34528. /** Defines if standard derivates (dx/dy) are supported */
  34529. standardDerivatives: boolean;
  34530. /** Defines if s3tc texture compression is supported */
  34531. s3tc?: WEBGL_compressed_texture_s3tc;
  34532. /** Defines if pvrtc texture compression is supported */
  34533. pvrtc: any;
  34534. /** Defines if etc1 texture compression is supported */
  34535. etc1: any;
  34536. /** Defines if etc2 texture compression is supported */
  34537. etc2: any;
  34538. /** Defines if astc texture compression is supported */
  34539. astc: any;
  34540. /** Defines if float textures are supported */
  34541. textureFloat: boolean;
  34542. /** Defines if vertex array objects are supported */
  34543. vertexArrayObject: boolean;
  34544. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  34545. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  34546. /** Gets the maximum level of anisotropy supported */
  34547. maxAnisotropy: number;
  34548. /** Defines if instancing is supported */
  34549. instancedArrays: boolean;
  34550. /** Defines if 32 bits indices are supported */
  34551. uintIndices: boolean;
  34552. /** Defines if high precision shaders are supported */
  34553. highPrecisionShaderSupported: boolean;
  34554. /** Defines if depth reading in the fragment shader is supported */
  34555. fragmentDepthSupported: boolean;
  34556. /** Defines if float texture linear filtering is supported*/
  34557. textureFloatLinearFiltering: boolean;
  34558. /** Defines if rendering to float textures is supported */
  34559. textureFloatRender: boolean;
  34560. /** Defines if half float textures are supported*/
  34561. textureHalfFloat: boolean;
  34562. /** Defines if half float texture linear filtering is supported*/
  34563. textureHalfFloatLinearFiltering: boolean;
  34564. /** Defines if rendering to half float textures is supported */
  34565. textureHalfFloatRender: boolean;
  34566. /** Defines if textureLOD shader command is supported */
  34567. textureLOD: boolean;
  34568. /** Defines if draw buffers extension is supported */
  34569. drawBuffersExtension: boolean;
  34570. /** Defines if depth textures are supported */
  34571. depthTextureExtension: boolean;
  34572. /** Defines if float color buffer are supported */
  34573. colorBufferFloat: boolean;
  34574. /** Gets disjoint timer query extension (null if not supported) */
  34575. timerQuery?: EXT_disjoint_timer_query;
  34576. /** Defines if timestamp can be used with timer query */
  34577. canUseTimestampForTimerQuery: boolean;
  34578. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  34579. multiview?: any;
  34580. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  34581. oculusMultiview?: any;
  34582. /** Function used to let the system compiles shaders in background */
  34583. parallelShaderCompile?: {
  34584. COMPLETION_STATUS_KHR: number;
  34585. };
  34586. /** Max number of texture samples for MSAA */
  34587. maxMSAASamples: number;
  34588. /** Defines if the blend min max extension is supported */
  34589. blendMinMax: boolean;
  34590. }
  34591. }
  34592. declare module BABYLON {
  34593. /**
  34594. * @hidden
  34595. **/
  34596. export class DepthCullingState {
  34597. private _isDepthTestDirty;
  34598. private _isDepthMaskDirty;
  34599. private _isDepthFuncDirty;
  34600. private _isCullFaceDirty;
  34601. private _isCullDirty;
  34602. private _isZOffsetDirty;
  34603. private _isFrontFaceDirty;
  34604. private _depthTest;
  34605. private _depthMask;
  34606. private _depthFunc;
  34607. private _cull;
  34608. private _cullFace;
  34609. private _zOffset;
  34610. private _frontFace;
  34611. /**
  34612. * Initializes the state.
  34613. */
  34614. constructor();
  34615. get isDirty(): boolean;
  34616. get zOffset(): number;
  34617. set zOffset(value: number);
  34618. get cullFace(): Nullable<number>;
  34619. set cullFace(value: Nullable<number>);
  34620. get cull(): Nullable<boolean>;
  34621. set cull(value: Nullable<boolean>);
  34622. get depthFunc(): Nullable<number>;
  34623. set depthFunc(value: Nullable<number>);
  34624. get depthMask(): boolean;
  34625. set depthMask(value: boolean);
  34626. get depthTest(): boolean;
  34627. set depthTest(value: boolean);
  34628. get frontFace(): Nullable<number>;
  34629. set frontFace(value: Nullable<number>);
  34630. reset(): void;
  34631. apply(gl: WebGLRenderingContext): void;
  34632. }
  34633. }
  34634. declare module BABYLON {
  34635. /**
  34636. * @hidden
  34637. **/
  34638. export class StencilState {
  34639. /** 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 */
  34640. static readonly ALWAYS: number;
  34641. /** Passed to stencilOperation to specify that stencil value must be kept */
  34642. static readonly KEEP: number;
  34643. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34644. static readonly REPLACE: number;
  34645. private _isStencilTestDirty;
  34646. private _isStencilMaskDirty;
  34647. private _isStencilFuncDirty;
  34648. private _isStencilOpDirty;
  34649. private _stencilTest;
  34650. private _stencilMask;
  34651. private _stencilFunc;
  34652. private _stencilFuncRef;
  34653. private _stencilFuncMask;
  34654. private _stencilOpStencilFail;
  34655. private _stencilOpDepthFail;
  34656. private _stencilOpStencilDepthPass;
  34657. get isDirty(): boolean;
  34658. get stencilFunc(): number;
  34659. set stencilFunc(value: number);
  34660. get stencilFuncRef(): number;
  34661. set stencilFuncRef(value: number);
  34662. get stencilFuncMask(): number;
  34663. set stencilFuncMask(value: number);
  34664. get stencilOpStencilFail(): number;
  34665. set stencilOpStencilFail(value: number);
  34666. get stencilOpDepthFail(): number;
  34667. set stencilOpDepthFail(value: number);
  34668. get stencilOpStencilDepthPass(): number;
  34669. set stencilOpStencilDepthPass(value: number);
  34670. get stencilMask(): number;
  34671. set stencilMask(value: number);
  34672. get stencilTest(): boolean;
  34673. set stencilTest(value: boolean);
  34674. constructor();
  34675. reset(): void;
  34676. apply(gl: WebGLRenderingContext): void;
  34677. }
  34678. }
  34679. declare module BABYLON {
  34680. /**
  34681. * @hidden
  34682. **/
  34683. export class AlphaState {
  34684. private _isAlphaBlendDirty;
  34685. private _isBlendFunctionParametersDirty;
  34686. private _isBlendEquationParametersDirty;
  34687. private _isBlendConstantsDirty;
  34688. private _alphaBlend;
  34689. private _blendFunctionParameters;
  34690. private _blendEquationParameters;
  34691. private _blendConstants;
  34692. /**
  34693. * Initializes the state.
  34694. */
  34695. constructor();
  34696. get isDirty(): boolean;
  34697. get alphaBlend(): boolean;
  34698. set alphaBlend(value: boolean);
  34699. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  34700. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  34701. setAlphaEquationParameters(rgb: number, alpha: number): void;
  34702. reset(): void;
  34703. apply(gl: WebGLRenderingContext): void;
  34704. }
  34705. }
  34706. declare module BABYLON {
  34707. /** @hidden */
  34708. export class WebGL2ShaderProcessor implements IShaderProcessor {
  34709. attributeProcessor(attribute: string): string;
  34710. varyingProcessor(varying: string, isFragment: boolean): string;
  34711. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  34712. }
  34713. }
  34714. declare module BABYLON {
  34715. /**
  34716. * Interface for attribute information associated with buffer instanciation
  34717. */
  34718. export interface InstancingAttributeInfo {
  34719. /**
  34720. * Name of the GLSL attribute
  34721. * if attribute index is not specified, this is used to retrieve the index from the effect
  34722. */
  34723. attributeName: string;
  34724. /**
  34725. * Index/offset of the attribute in the vertex shader
  34726. * if not specified, this will be computes from the name.
  34727. */
  34728. index?: number;
  34729. /**
  34730. * size of the attribute, 1, 2, 3 or 4
  34731. */
  34732. attributeSize: number;
  34733. /**
  34734. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  34735. */
  34736. offset: number;
  34737. /**
  34738. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  34739. * default to 1
  34740. */
  34741. divisor?: number;
  34742. /**
  34743. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  34744. * default is FLOAT
  34745. */
  34746. attributeType?: number;
  34747. /**
  34748. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  34749. */
  34750. normalized?: boolean;
  34751. }
  34752. }
  34753. declare module BABYLON {
  34754. interface ThinEngine {
  34755. /**
  34756. * Update a video texture
  34757. * @param texture defines the texture to update
  34758. * @param video defines the video element to use
  34759. * @param invertY defines if data must be stored with Y axis inverted
  34760. */
  34761. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  34762. }
  34763. }
  34764. declare module BABYLON {
  34765. interface ThinEngine {
  34766. /**
  34767. * Creates a dynamic texture
  34768. * @param width defines the width of the texture
  34769. * @param height defines the height of the texture
  34770. * @param generateMipMaps defines if the engine should generate the mip levels
  34771. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  34772. * @returns the dynamic texture inside an InternalTexture
  34773. */
  34774. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  34775. /**
  34776. * Update the content of a dynamic texture
  34777. * @param texture defines the texture to update
  34778. * @param canvas defines the canvas containing the source
  34779. * @param invertY defines if data must be stored with Y axis inverted
  34780. * @param premulAlpha defines if alpha is stored as premultiplied
  34781. * @param format defines the format of the data
  34782. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  34783. */
  34784. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  34785. }
  34786. }
  34787. declare module BABYLON {
  34788. /**
  34789. * Settings for finer control over video usage
  34790. */
  34791. export interface VideoTextureSettings {
  34792. /**
  34793. * Applies `autoplay` to video, if specified
  34794. */
  34795. autoPlay?: boolean;
  34796. /**
  34797. * Applies `loop` to video, if specified
  34798. */
  34799. loop?: boolean;
  34800. /**
  34801. * Automatically updates internal texture from video at every frame in the render loop
  34802. */
  34803. autoUpdateTexture: boolean;
  34804. /**
  34805. * Image src displayed during the video loading or until the user interacts with the video.
  34806. */
  34807. poster?: string;
  34808. }
  34809. /**
  34810. * If you want to display a video in your scene, this is the special texture for that.
  34811. * This special texture works similar to other textures, with the exception of a few parameters.
  34812. * @see https://doc.babylonjs.com/how_to/video_texture
  34813. */
  34814. export class VideoTexture extends Texture {
  34815. /**
  34816. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  34817. */
  34818. readonly autoUpdateTexture: boolean;
  34819. /**
  34820. * The video instance used by the texture internally
  34821. */
  34822. readonly video: HTMLVideoElement;
  34823. private _onUserActionRequestedObservable;
  34824. /**
  34825. * Event triggerd when a dom action is required by the user to play the video.
  34826. * This happens due to recent changes in browser policies preventing video to auto start.
  34827. */
  34828. get onUserActionRequestedObservable(): Observable<Texture>;
  34829. private _generateMipMaps;
  34830. private _stillImageCaptured;
  34831. private _displayingPosterTexture;
  34832. private _settings;
  34833. private _createInternalTextureOnEvent;
  34834. private _frameId;
  34835. private _currentSrc;
  34836. /**
  34837. * Creates a video texture.
  34838. * If you want to display a video in your scene, this is the special texture for that.
  34839. * This special texture works similar to other textures, with the exception of a few parameters.
  34840. * @see https://doc.babylonjs.com/how_to/video_texture
  34841. * @param name optional name, will detect from video source, if not defined
  34842. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  34843. * @param scene is obviously the current scene.
  34844. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  34845. * @param invertY is false by default but can be used to invert video on Y axis
  34846. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  34847. * @param settings allows finer control over video usage
  34848. */
  34849. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  34850. private _getName;
  34851. private _getVideo;
  34852. private _createInternalTexture;
  34853. private reset;
  34854. /**
  34855. * @hidden Internal method to initiate `update`.
  34856. */
  34857. _rebuild(): void;
  34858. /**
  34859. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  34860. */
  34861. update(): void;
  34862. /**
  34863. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  34864. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  34865. */
  34866. updateTexture(isVisible: boolean): void;
  34867. protected _updateInternalTexture: () => void;
  34868. /**
  34869. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  34870. * @param url New url.
  34871. */
  34872. updateURL(url: string): void;
  34873. /**
  34874. * Clones the texture.
  34875. * @returns the cloned texture
  34876. */
  34877. clone(): VideoTexture;
  34878. /**
  34879. * Dispose the texture and release its associated resources.
  34880. */
  34881. dispose(): void;
  34882. /**
  34883. * Creates a video texture straight from a stream.
  34884. * @param scene Define the scene the texture should be created in
  34885. * @param stream Define the stream the texture should be created from
  34886. * @returns The created video texture as a promise
  34887. */
  34888. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  34889. /**
  34890. * Creates a video texture straight from your WebCam video feed.
  34891. * @param scene Define the scene the texture should be created in
  34892. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  34893. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  34894. * @returns The created video texture as a promise
  34895. */
  34896. static CreateFromWebCamAsync(scene: Scene, constraints: {
  34897. minWidth: number;
  34898. maxWidth: number;
  34899. minHeight: number;
  34900. maxHeight: number;
  34901. deviceId: string;
  34902. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  34903. /**
  34904. * Creates a video texture straight from your WebCam video feed.
  34905. * @param scene Define the scene the texture should be created in
  34906. * @param onReady Define a callback to triggered once the texture will be ready
  34907. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  34908. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  34909. */
  34910. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  34911. minWidth: number;
  34912. maxWidth: number;
  34913. minHeight: number;
  34914. maxHeight: number;
  34915. deviceId: string;
  34916. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  34917. }
  34918. }
  34919. declare module BABYLON {
  34920. /**
  34921. * Defines the interface used by objects working like Scene
  34922. * @hidden
  34923. */
  34924. export interface ISceneLike {
  34925. _addPendingData(data: any): void;
  34926. _removePendingData(data: any): void;
  34927. offlineProvider: IOfflineProvider;
  34928. }
  34929. /** Interface defining initialization parameters for Engine class */
  34930. export interface EngineOptions extends WebGLContextAttributes {
  34931. /**
  34932. * Defines if the engine should no exceed a specified device ratio
  34933. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  34934. */
  34935. limitDeviceRatio?: number;
  34936. /**
  34937. * Defines if webvr should be enabled automatically
  34938. * @see https://doc.babylonjs.com/how_to/webvr_camera
  34939. */
  34940. autoEnableWebVR?: boolean;
  34941. /**
  34942. * Defines if webgl2 should be turned off even if supported
  34943. * @see https://doc.babylonjs.com/features/webgl2
  34944. */
  34945. disableWebGL2Support?: boolean;
  34946. /**
  34947. * Defines if webaudio should be initialized as well
  34948. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  34949. */
  34950. audioEngine?: boolean;
  34951. /**
  34952. * Defines if animations should run using a deterministic lock step
  34953. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34954. */
  34955. deterministicLockstep?: boolean;
  34956. /** Defines the maximum steps to use with deterministic lock step mode */
  34957. lockstepMaxSteps?: number;
  34958. /** Defines the seconds between each deterministic lock step */
  34959. timeStep?: number;
  34960. /**
  34961. * Defines that engine should ignore context lost events
  34962. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  34963. */
  34964. doNotHandleContextLost?: boolean;
  34965. /**
  34966. * Defines that engine should ignore modifying touch action attribute and style
  34967. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  34968. */
  34969. doNotHandleTouchAction?: boolean;
  34970. /**
  34971. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  34972. */
  34973. useHighPrecisionFloats?: boolean;
  34974. /**
  34975. * Make the canvas XR Compatible for XR sessions
  34976. */
  34977. xrCompatible?: boolean;
  34978. /**
  34979. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  34980. */
  34981. useHighPrecisionMatrix?: boolean;
  34982. }
  34983. /**
  34984. * The base engine class (root of all engines)
  34985. */
  34986. export class ThinEngine {
  34987. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  34988. static ExceptionList: ({
  34989. key: string;
  34990. capture: string;
  34991. captureConstraint: number;
  34992. targets: string[];
  34993. } | {
  34994. key: string;
  34995. capture: null;
  34996. captureConstraint: null;
  34997. targets: string[];
  34998. })[];
  34999. /** @hidden */
  35000. static _TextureLoaders: IInternalTextureLoader[];
  35001. /**
  35002. * Returns the current npm package of the sdk
  35003. */
  35004. static get NpmPackage(): string;
  35005. /**
  35006. * Returns the current version of the framework
  35007. */
  35008. static get Version(): string;
  35009. /**
  35010. * Returns a string describing the current engine
  35011. */
  35012. get description(): string;
  35013. /**
  35014. * Gets or sets the epsilon value used by collision engine
  35015. */
  35016. static CollisionsEpsilon: number;
  35017. /**
  35018. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35019. */
  35020. static get ShadersRepository(): string;
  35021. static set ShadersRepository(value: string);
  35022. /** @hidden */
  35023. _shaderProcessor: IShaderProcessor;
  35024. /**
  35025. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35026. */
  35027. forcePOTTextures: boolean;
  35028. /**
  35029. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35030. */
  35031. isFullscreen: boolean;
  35032. /**
  35033. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35034. */
  35035. cullBackFaces: boolean;
  35036. /**
  35037. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35038. */
  35039. renderEvenInBackground: boolean;
  35040. /**
  35041. * Gets or sets a boolean indicating that cache can be kept between frames
  35042. */
  35043. preventCacheWipeBetweenFrames: boolean;
  35044. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35045. validateShaderPrograms: boolean;
  35046. /**
  35047. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35048. * This can provide greater z depth for distant objects.
  35049. */
  35050. useReverseDepthBuffer: boolean;
  35051. /**
  35052. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35053. */
  35054. disableUniformBuffers: boolean;
  35055. /** @hidden */
  35056. _uniformBuffers: UniformBuffer[];
  35057. /**
  35058. * Gets a boolean indicating that the engine supports uniform buffers
  35059. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35060. */
  35061. get supportsUniformBuffers(): boolean;
  35062. /** @hidden */
  35063. _gl: WebGLRenderingContext;
  35064. /** @hidden */
  35065. _webGLVersion: number;
  35066. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35067. protected _windowIsBackground: boolean;
  35068. protected _creationOptions: EngineOptions;
  35069. protected _highPrecisionShadersAllowed: boolean;
  35070. /** @hidden */
  35071. get _shouldUseHighPrecisionShader(): boolean;
  35072. /**
  35073. * Gets a boolean indicating that only power of 2 textures are supported
  35074. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35075. */
  35076. get needPOTTextures(): boolean;
  35077. /** @hidden */
  35078. _badOS: boolean;
  35079. /** @hidden */
  35080. _badDesktopOS: boolean;
  35081. private _hardwareScalingLevel;
  35082. /** @hidden */
  35083. _caps: EngineCapabilities;
  35084. private _isStencilEnable;
  35085. private _glVersion;
  35086. private _glRenderer;
  35087. private _glVendor;
  35088. /** @hidden */
  35089. _videoTextureSupported: boolean;
  35090. protected _renderingQueueLaunched: boolean;
  35091. protected _activeRenderLoops: (() => void)[];
  35092. /**
  35093. * Observable signaled when a context lost event is raised
  35094. */
  35095. onContextLostObservable: Observable<ThinEngine>;
  35096. /**
  35097. * Observable signaled when a context restored event is raised
  35098. */
  35099. onContextRestoredObservable: Observable<ThinEngine>;
  35100. private _onContextLost;
  35101. private _onContextRestored;
  35102. protected _contextWasLost: boolean;
  35103. /** @hidden */
  35104. _doNotHandleContextLost: boolean;
  35105. /**
  35106. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35107. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35108. */
  35109. get doNotHandleContextLost(): boolean;
  35110. set doNotHandleContextLost(value: boolean);
  35111. /**
  35112. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35113. */
  35114. disableVertexArrayObjects: boolean;
  35115. /** @hidden */
  35116. protected _colorWrite: boolean;
  35117. /** @hidden */
  35118. protected _colorWriteChanged: boolean;
  35119. /** @hidden */
  35120. protected _depthCullingState: DepthCullingState;
  35121. /** @hidden */
  35122. protected _stencilState: StencilState;
  35123. /** @hidden */
  35124. _alphaState: AlphaState;
  35125. /** @hidden */
  35126. _alphaMode: number;
  35127. /** @hidden */
  35128. _alphaEquation: number;
  35129. /** @hidden */
  35130. _internalTexturesCache: InternalTexture[];
  35131. /** @hidden */
  35132. protected _activeChannel: number;
  35133. private _currentTextureChannel;
  35134. /** @hidden */
  35135. protected _boundTexturesCache: {
  35136. [key: string]: Nullable<InternalTexture>;
  35137. };
  35138. /** @hidden */
  35139. protected _currentEffect: Nullable<Effect>;
  35140. /** @hidden */
  35141. protected _currentProgram: Nullable<WebGLProgram>;
  35142. private _compiledEffects;
  35143. private _vertexAttribArraysEnabled;
  35144. /** @hidden */
  35145. protected _cachedViewport: Nullable<IViewportLike>;
  35146. private _cachedVertexArrayObject;
  35147. /** @hidden */
  35148. protected _cachedVertexBuffers: any;
  35149. /** @hidden */
  35150. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35151. /** @hidden */
  35152. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35153. /** @hidden */
  35154. _currentRenderTarget: Nullable<InternalTexture>;
  35155. private _uintIndicesCurrentlySet;
  35156. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35157. /** @hidden */
  35158. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35159. /** @hidden */
  35160. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35161. private _currentBufferPointers;
  35162. private _currentInstanceLocations;
  35163. private _currentInstanceBuffers;
  35164. private _textureUnits;
  35165. /** @hidden */
  35166. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35167. /** @hidden */
  35168. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35169. /** @hidden */
  35170. _boundRenderFunction: any;
  35171. private _vaoRecordInProgress;
  35172. private _mustWipeVertexAttributes;
  35173. private _emptyTexture;
  35174. private _emptyCubeTexture;
  35175. private _emptyTexture3D;
  35176. private _emptyTexture2DArray;
  35177. /** @hidden */
  35178. _frameHandler: number;
  35179. private _nextFreeTextureSlots;
  35180. private _maxSimultaneousTextures;
  35181. private _activeRequests;
  35182. /** @hidden */
  35183. _transformTextureUrl: Nullable<(url: string) => string>;
  35184. protected get _supportsHardwareTextureRescaling(): boolean;
  35185. private _framebufferDimensionsObject;
  35186. /**
  35187. * sets the object from which width and height will be taken from when getting render width and height
  35188. * Will fallback to the gl object
  35189. * @param dimensions the framebuffer width and height that will be used.
  35190. */
  35191. set framebufferDimensionsObject(dimensions: Nullable<{
  35192. framebufferWidth: number;
  35193. framebufferHeight: number;
  35194. }>);
  35195. /**
  35196. * Gets the current viewport
  35197. */
  35198. get currentViewport(): Nullable<IViewportLike>;
  35199. /**
  35200. * Gets the default empty texture
  35201. */
  35202. get emptyTexture(): InternalTexture;
  35203. /**
  35204. * Gets the default empty 3D texture
  35205. */
  35206. get emptyTexture3D(): InternalTexture;
  35207. /**
  35208. * Gets the default empty 2D array texture
  35209. */
  35210. get emptyTexture2DArray(): InternalTexture;
  35211. /**
  35212. * Gets the default empty cube texture
  35213. */
  35214. get emptyCubeTexture(): InternalTexture;
  35215. /**
  35216. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35217. */
  35218. readonly premultipliedAlpha: boolean;
  35219. /**
  35220. * Observable event triggered before each texture is initialized
  35221. */
  35222. onBeforeTextureInitObservable: Observable<Texture>;
  35223. /**
  35224. * Creates a new engine
  35225. * @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
  35226. * @param antialias defines enable antialiasing (default: false)
  35227. * @param options defines further options to be sent to the getContext() function
  35228. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35229. */
  35230. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35231. private _rebuildInternalTextures;
  35232. private _rebuildEffects;
  35233. /**
  35234. * Gets a boolean indicating if all created effects are ready
  35235. * @returns true if all effects are ready
  35236. */
  35237. areAllEffectsReady(): boolean;
  35238. protected _rebuildBuffers(): void;
  35239. protected _initGLContext(): void;
  35240. /**
  35241. * Gets version of the current webGL context
  35242. */
  35243. get webGLVersion(): number;
  35244. /**
  35245. * Gets a string idenfifying the name of the class
  35246. * @returns "Engine" string
  35247. */
  35248. getClassName(): string;
  35249. /**
  35250. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35251. */
  35252. get isStencilEnable(): boolean;
  35253. /** @hidden */
  35254. _prepareWorkingCanvas(): void;
  35255. /**
  35256. * Reset the texture cache to empty state
  35257. */
  35258. resetTextureCache(): void;
  35259. /**
  35260. * Gets an object containing information about the current webGL context
  35261. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35262. */
  35263. getGlInfo(): {
  35264. vendor: string;
  35265. renderer: string;
  35266. version: string;
  35267. };
  35268. /**
  35269. * Defines the hardware scaling level.
  35270. * By default the hardware scaling level is computed from the window device ratio.
  35271. * 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.
  35272. * @param level defines the level to use
  35273. */
  35274. setHardwareScalingLevel(level: number): void;
  35275. /**
  35276. * Gets the current hardware scaling level.
  35277. * By default the hardware scaling level is computed from the window device ratio.
  35278. * 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.
  35279. * @returns a number indicating the current hardware scaling level
  35280. */
  35281. getHardwareScalingLevel(): number;
  35282. /**
  35283. * Gets the list of loaded textures
  35284. * @returns an array containing all loaded textures
  35285. */
  35286. getLoadedTexturesCache(): InternalTexture[];
  35287. /**
  35288. * Gets the object containing all engine capabilities
  35289. * @returns the EngineCapabilities object
  35290. */
  35291. getCaps(): EngineCapabilities;
  35292. /**
  35293. * stop executing a render loop function and remove it from the execution array
  35294. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35295. */
  35296. stopRenderLoop(renderFunction?: () => void): void;
  35297. /** @hidden */
  35298. _renderLoop(): void;
  35299. /**
  35300. * Gets the HTML canvas attached with the current webGL context
  35301. * @returns a HTML canvas
  35302. */
  35303. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35304. /**
  35305. * Gets host window
  35306. * @returns the host window object
  35307. */
  35308. getHostWindow(): Nullable<Window>;
  35309. /**
  35310. * Gets the current render width
  35311. * @param useScreen defines if screen size must be used (or the current render target if any)
  35312. * @returns a number defining the current render width
  35313. */
  35314. getRenderWidth(useScreen?: boolean): number;
  35315. /**
  35316. * Gets the current render height
  35317. * @param useScreen defines if screen size must be used (or the current render target if any)
  35318. * @returns a number defining the current render height
  35319. */
  35320. getRenderHeight(useScreen?: boolean): number;
  35321. /**
  35322. * Can be used to override the current requestAnimationFrame requester.
  35323. * @hidden
  35324. */
  35325. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35326. /**
  35327. * Register and execute a render loop. The engine can have more than one render function
  35328. * @param renderFunction defines the function to continuously execute
  35329. */
  35330. runRenderLoop(renderFunction: () => void): void;
  35331. /**
  35332. * Clear the current render buffer or the current render target (if any is set up)
  35333. * @param color defines the color to use
  35334. * @param backBuffer defines if the back buffer must be cleared
  35335. * @param depth defines if the depth buffer must be cleared
  35336. * @param stencil defines if the stencil buffer must be cleared
  35337. */
  35338. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35339. private _viewportCached;
  35340. /** @hidden */
  35341. _viewport(x: number, y: number, width: number, height: number): void;
  35342. /**
  35343. * Set the WebGL's viewport
  35344. * @param viewport defines the viewport element to be used
  35345. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35346. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35347. */
  35348. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35349. /**
  35350. * Begin a new frame
  35351. */
  35352. beginFrame(): void;
  35353. /**
  35354. * Enf the current frame
  35355. */
  35356. endFrame(): void;
  35357. /**
  35358. * Resize the view according to the canvas' size
  35359. */
  35360. resize(): void;
  35361. /**
  35362. * Force a specific size of the canvas
  35363. * @param width defines the new canvas' width
  35364. * @param height defines the new canvas' height
  35365. * @returns true if the size was changed
  35366. */
  35367. setSize(width: number, height: number): boolean;
  35368. /**
  35369. * Binds the frame buffer to the specified texture.
  35370. * @param texture The texture to render to or null for the default canvas
  35371. * @param faceIndex The face of the texture to render to in case of cube texture
  35372. * @param requiredWidth The width of the target to render to
  35373. * @param requiredHeight The height of the target to render to
  35374. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35375. * @param lodLevel defines the lod level to bind to the frame buffer
  35376. * @param layer defines the 2d array index to bind to frame buffer to
  35377. */
  35378. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35379. /** @hidden */
  35380. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35381. /**
  35382. * Unbind the current render target texture from the webGL context
  35383. * @param texture defines the render target texture to unbind
  35384. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35385. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35386. */
  35387. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35388. /**
  35389. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35390. */
  35391. flushFramebuffer(): void;
  35392. /**
  35393. * Unbind the current render target and bind the default framebuffer
  35394. */
  35395. restoreDefaultFramebuffer(): void;
  35396. /** @hidden */
  35397. protected _resetVertexBufferBinding(): void;
  35398. /**
  35399. * Creates a vertex buffer
  35400. * @param data the data for the vertex buffer
  35401. * @returns the new WebGL static buffer
  35402. */
  35403. createVertexBuffer(data: DataArray): DataBuffer;
  35404. private _createVertexBuffer;
  35405. /**
  35406. * Creates a dynamic vertex buffer
  35407. * @param data the data for the dynamic vertex buffer
  35408. * @returns the new WebGL dynamic buffer
  35409. */
  35410. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35411. protected _resetIndexBufferBinding(): void;
  35412. /**
  35413. * Creates a new index buffer
  35414. * @param indices defines the content of the index buffer
  35415. * @param updatable defines if the index buffer must be updatable
  35416. * @returns a new webGL buffer
  35417. */
  35418. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  35419. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  35420. /**
  35421. * Bind a webGL buffer to the webGL context
  35422. * @param buffer defines the buffer to bind
  35423. */
  35424. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  35425. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  35426. private bindBuffer;
  35427. /**
  35428. * update the bound buffer with the given data
  35429. * @param data defines the data to update
  35430. */
  35431. updateArrayBuffer(data: Float32Array): void;
  35432. private _vertexAttribPointer;
  35433. /** @hidden */
  35434. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  35435. private _bindVertexBuffersAttributes;
  35436. /**
  35437. * Records a vertex array object
  35438. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35439. * @param vertexBuffers defines the list of vertex buffers to store
  35440. * @param indexBuffer defines the index buffer to store
  35441. * @param effect defines the effect to store
  35442. * @returns the new vertex array object
  35443. */
  35444. recordVertexArrayObject(vertexBuffers: {
  35445. [key: string]: VertexBuffer;
  35446. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  35447. /**
  35448. * Bind a specific vertex array object
  35449. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35450. * @param vertexArrayObject defines the vertex array object to bind
  35451. * @param indexBuffer defines the index buffer to bind
  35452. */
  35453. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  35454. /**
  35455. * Bind webGl buffers directly to the webGL context
  35456. * @param vertexBuffer defines the vertex buffer to bind
  35457. * @param indexBuffer defines the index buffer to bind
  35458. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  35459. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  35460. * @param effect defines the effect associated with the vertex buffer
  35461. */
  35462. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  35463. private _unbindVertexArrayObject;
  35464. /**
  35465. * Bind a list of vertex buffers to the webGL context
  35466. * @param vertexBuffers defines the list of vertex buffers to bind
  35467. * @param indexBuffer defines the index buffer to bind
  35468. * @param effect defines the effect associated with the vertex buffers
  35469. */
  35470. bindBuffers(vertexBuffers: {
  35471. [key: string]: Nullable<VertexBuffer>;
  35472. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  35473. /**
  35474. * Unbind all instance attributes
  35475. */
  35476. unbindInstanceAttributes(): void;
  35477. /**
  35478. * Release and free the memory of a vertex array object
  35479. * @param vao defines the vertex array object to delete
  35480. */
  35481. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  35482. /** @hidden */
  35483. _releaseBuffer(buffer: DataBuffer): boolean;
  35484. protected _deleteBuffer(buffer: DataBuffer): void;
  35485. /**
  35486. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  35487. * @param instancesBuffer defines the webGL buffer to update and bind
  35488. * @param data defines the data to store in the buffer
  35489. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  35490. */
  35491. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  35492. /**
  35493. * Bind the content of a webGL buffer used with instantiation
  35494. * @param instancesBuffer defines the webGL buffer to bind
  35495. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  35496. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  35497. */
  35498. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  35499. /**
  35500. * Disable the instance attribute corresponding to the name in parameter
  35501. * @param name defines the name of the attribute to disable
  35502. */
  35503. disableInstanceAttributeByName(name: string): void;
  35504. /**
  35505. * Disable the instance attribute corresponding to the location in parameter
  35506. * @param attributeLocation defines the attribute location of the attribute to disable
  35507. */
  35508. disableInstanceAttribute(attributeLocation: number): void;
  35509. /**
  35510. * Disable the attribute corresponding to the location in parameter
  35511. * @param attributeLocation defines the attribute location of the attribute to disable
  35512. */
  35513. disableAttributeByIndex(attributeLocation: number): void;
  35514. /**
  35515. * Send a draw order
  35516. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35517. * @param indexStart defines the starting index
  35518. * @param indexCount defines the number of index to draw
  35519. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35520. */
  35521. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  35522. /**
  35523. * Draw a list of points
  35524. * @param verticesStart defines the index of first vertex to draw
  35525. * @param verticesCount defines the count of vertices to draw
  35526. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35527. */
  35528. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35529. /**
  35530. * Draw a list of unindexed primitives
  35531. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35532. * @param verticesStart defines the index of first vertex to draw
  35533. * @param verticesCount defines the count of vertices to draw
  35534. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35535. */
  35536. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35537. /**
  35538. * Draw a list of indexed primitives
  35539. * @param fillMode defines the primitive to use
  35540. * @param indexStart defines the starting index
  35541. * @param indexCount defines the number of index to draw
  35542. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35543. */
  35544. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  35545. /**
  35546. * Draw a list of unindexed primitives
  35547. * @param fillMode defines the primitive to use
  35548. * @param verticesStart defines the index of first vertex to draw
  35549. * @param verticesCount defines the count of vertices to draw
  35550. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35551. */
  35552. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35553. private _drawMode;
  35554. /** @hidden */
  35555. protected _reportDrawCall(): void;
  35556. /** @hidden */
  35557. _releaseEffect(effect: Effect): void;
  35558. /** @hidden */
  35559. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35560. /**
  35561. * Create a new effect (used to store vertex/fragment shaders)
  35562. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  35563. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  35564. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  35565. * @param samplers defines an array of string used to represent textures
  35566. * @param defines defines the string containing the defines to use to compile the shaders
  35567. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  35568. * @param onCompiled defines a function to call when the effect creation is successful
  35569. * @param onError defines a function to call when the effect creation has failed
  35570. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  35571. * @returns the new Effect
  35572. */
  35573. 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;
  35574. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  35575. private _compileShader;
  35576. private _compileRawShader;
  35577. /** @hidden */
  35578. _getShaderSource(shader: WebGLShader): Nullable<string>;
  35579. /**
  35580. * Directly creates a webGL program
  35581. * @param pipelineContext defines the pipeline context to attach to
  35582. * @param vertexCode defines the vertex shader code to use
  35583. * @param fragmentCode defines the fragment shader code to use
  35584. * @param context defines the webGL context to use (if not set, the current one will be used)
  35585. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35586. * @returns the new webGL program
  35587. */
  35588. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35589. /**
  35590. * Creates a webGL program
  35591. * @param pipelineContext defines the pipeline context to attach to
  35592. * @param vertexCode defines the vertex shader code to use
  35593. * @param fragmentCode defines the fragment shader code to use
  35594. * @param defines defines the string containing the defines to use to compile the shaders
  35595. * @param context defines the webGL context to use (if not set, the current one will be used)
  35596. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35597. * @returns the new webGL program
  35598. */
  35599. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35600. /**
  35601. * Creates a new pipeline context
  35602. * @returns the new pipeline
  35603. */
  35604. createPipelineContext(): IPipelineContext;
  35605. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35606. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  35607. /** @hidden */
  35608. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  35609. /** @hidden */
  35610. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  35611. /** @hidden */
  35612. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  35613. /**
  35614. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  35615. * @param pipelineContext defines the pipeline context to use
  35616. * @param uniformsNames defines the list of uniform names
  35617. * @returns an array of webGL uniform locations
  35618. */
  35619. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  35620. /**
  35621. * Gets the lsit of active attributes for a given webGL program
  35622. * @param pipelineContext defines the pipeline context to use
  35623. * @param attributesNames defines the list of attribute names to get
  35624. * @returns an array of indices indicating the offset of each attribute
  35625. */
  35626. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  35627. /**
  35628. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  35629. * @param effect defines the effect to activate
  35630. */
  35631. enableEffect(effect: Nullable<Effect>): void;
  35632. /**
  35633. * Set the value of an uniform to a number (int)
  35634. * @param uniform defines the webGL uniform location where to store the value
  35635. * @param value defines the int number to store
  35636. */
  35637. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35638. /**
  35639. * Set the value of an uniform to an array of int32
  35640. * @param uniform defines the webGL uniform location where to store the value
  35641. * @param array defines the array of int32 to store
  35642. */
  35643. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35644. /**
  35645. * Set the value of an uniform to an array of int32 (stored as vec2)
  35646. * @param uniform defines the webGL uniform location where to store the value
  35647. * @param array defines the array of int32 to store
  35648. */
  35649. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35650. /**
  35651. * Set the value of an uniform to an array of int32 (stored as vec3)
  35652. * @param uniform defines the webGL uniform location where to store the value
  35653. * @param array defines the array of int32 to store
  35654. */
  35655. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35656. /**
  35657. * Set the value of an uniform to an array of int32 (stored as vec4)
  35658. * @param uniform defines the webGL uniform location where to store the value
  35659. * @param array defines the array of int32 to store
  35660. */
  35661. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35662. /**
  35663. * Set the value of an uniform to an array of number
  35664. * @param uniform defines the webGL uniform location where to store the value
  35665. * @param array defines the array of number to store
  35666. */
  35667. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35668. /**
  35669. * Set the value of an uniform to an array of number (stored as vec2)
  35670. * @param uniform defines the webGL uniform location where to store the value
  35671. * @param array defines the array of number to store
  35672. */
  35673. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35674. /**
  35675. * Set the value of an uniform to an array of number (stored as vec3)
  35676. * @param uniform defines the webGL uniform location where to store the value
  35677. * @param array defines the array of number to store
  35678. */
  35679. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35680. /**
  35681. * Set the value of an uniform to an array of number (stored as vec4)
  35682. * @param uniform defines the webGL uniform location where to store the value
  35683. * @param array defines the array of number to store
  35684. */
  35685. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35686. /**
  35687. * Set the value of an uniform to an array of float32 (stored as matrices)
  35688. * @param uniform defines the webGL uniform location where to store the value
  35689. * @param matrices defines the array of float32 to store
  35690. */
  35691. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  35692. /**
  35693. * Set the value of an uniform to a matrix (3x3)
  35694. * @param uniform defines the webGL uniform location where to store the value
  35695. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  35696. */
  35697. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35698. /**
  35699. * Set the value of an uniform to a matrix (2x2)
  35700. * @param uniform defines the webGL uniform location where to store the value
  35701. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  35702. */
  35703. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35704. /**
  35705. * Set the value of an uniform to a number (float)
  35706. * @param uniform defines the webGL uniform location where to store the value
  35707. * @param value defines the float number to store
  35708. */
  35709. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35710. /**
  35711. * Set the value of an uniform to a vec2
  35712. * @param uniform defines the webGL uniform location where to store the value
  35713. * @param x defines the 1st component of the value
  35714. * @param y defines the 2nd component of the value
  35715. */
  35716. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  35717. /**
  35718. * Set the value of an uniform to a vec3
  35719. * @param uniform defines the webGL uniform location where to store the value
  35720. * @param x defines the 1st component of the value
  35721. * @param y defines the 2nd component of the value
  35722. * @param z defines the 3rd component of the value
  35723. */
  35724. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  35725. /**
  35726. * Set the value of an uniform to a vec4
  35727. * @param uniform defines the webGL uniform location where to store the value
  35728. * @param x defines the 1st component of the value
  35729. * @param y defines the 2nd component of the value
  35730. * @param z defines the 3rd component of the value
  35731. * @param w defines the 4th component of the value
  35732. */
  35733. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  35734. /**
  35735. * Apply all cached states (depth, culling, stencil and alpha)
  35736. */
  35737. applyStates(): void;
  35738. /**
  35739. * Enable or disable color writing
  35740. * @param enable defines the state to set
  35741. */
  35742. setColorWrite(enable: boolean): void;
  35743. /**
  35744. * Gets a boolean indicating if color writing is enabled
  35745. * @returns the current color writing state
  35746. */
  35747. getColorWrite(): boolean;
  35748. /**
  35749. * Gets the depth culling state manager
  35750. */
  35751. get depthCullingState(): DepthCullingState;
  35752. /**
  35753. * Gets the alpha state manager
  35754. */
  35755. get alphaState(): AlphaState;
  35756. /**
  35757. * Gets the stencil state manager
  35758. */
  35759. get stencilState(): StencilState;
  35760. /**
  35761. * Clears the list of texture accessible through engine.
  35762. * This can help preventing texture load conflict due to name collision.
  35763. */
  35764. clearInternalTexturesCache(): void;
  35765. /**
  35766. * Force the entire cache to be cleared
  35767. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  35768. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  35769. */
  35770. wipeCaches(bruteForce?: boolean): void;
  35771. /** @hidden */
  35772. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  35773. min: number;
  35774. mag: number;
  35775. };
  35776. /** @hidden */
  35777. _createTexture(): WebGLTexture;
  35778. /**
  35779. * Usually called from Texture.ts.
  35780. * Passed information to create a WebGLTexture
  35781. * @param url defines a value which contains one of the following:
  35782. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  35783. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  35784. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  35785. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  35786. * @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)
  35787. * @param scene needed for loading to the correct scene
  35788. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  35789. * @param onLoad optional callback to be called upon successful completion
  35790. * @param onError optional callback to be called upon failure
  35791. * @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
  35792. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  35793. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  35794. * @param forcedExtension defines the extension to use to pick the right loader
  35795. * @param mimeType defines an optional mime type
  35796. * @returns a InternalTexture for assignment back into BABYLON.Texture
  35797. */
  35798. 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;
  35799. /**
  35800. * Loads an image as an HTMLImageElement.
  35801. * @param input url string, ArrayBuffer, or Blob to load
  35802. * @param onLoad callback called when the image successfully loads
  35803. * @param onError callback called when the image fails to load
  35804. * @param offlineProvider offline provider for caching
  35805. * @param mimeType optional mime type
  35806. * @returns the HTMLImageElement of the loaded image
  35807. * @hidden
  35808. */
  35809. 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>;
  35810. /**
  35811. * @hidden
  35812. */
  35813. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  35814. private _unpackFlipYCached;
  35815. /**
  35816. * In case you are sharing the context with other applications, it might
  35817. * be interested to not cache the unpack flip y state to ensure a consistent
  35818. * value would be set.
  35819. */
  35820. enableUnpackFlipYCached: boolean;
  35821. /** @hidden */
  35822. _unpackFlipY(value: boolean): void;
  35823. /** @hidden */
  35824. _getUnpackAlignement(): number;
  35825. private _getTextureTarget;
  35826. /**
  35827. * Update the sampling mode of a given texture
  35828. * @param samplingMode defines the required sampling mode
  35829. * @param texture defines the texture to update
  35830. * @param generateMipMaps defines whether to generate mipmaps for the texture
  35831. */
  35832. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  35833. /**
  35834. * Update the sampling mode of a given texture
  35835. * @param texture defines the texture to update
  35836. * @param wrapU defines the texture wrap mode of the u coordinates
  35837. * @param wrapV defines the texture wrap mode of the v coordinates
  35838. * @param wrapR defines the texture wrap mode of the r coordinates
  35839. */
  35840. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  35841. /** @hidden */
  35842. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  35843. width: number;
  35844. height: number;
  35845. layers?: number;
  35846. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  35847. /** @hidden */
  35848. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  35849. /** @hidden */
  35850. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  35851. /**
  35852. * Update a portion of an internal texture
  35853. * @param texture defines the texture to update
  35854. * @param imageData defines the data to store into the texture
  35855. * @param xOffset defines the x coordinates of the update rectangle
  35856. * @param yOffset defines the y coordinates of the update rectangle
  35857. * @param width defines the width of the update rectangle
  35858. * @param height defines the height of the update rectangle
  35859. * @param faceIndex defines the face index if texture is a cube (0 by default)
  35860. * @param lod defines the lod level to update (0 by default)
  35861. */
  35862. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  35863. /** @hidden */
  35864. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  35865. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  35866. private _prepareWebGLTexture;
  35867. /** @hidden */
  35868. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  35869. private _getDepthStencilBuffer;
  35870. /** @hidden */
  35871. _releaseFramebufferObjects(texture: InternalTexture): void;
  35872. /** @hidden */
  35873. _releaseTexture(texture: InternalTexture): void;
  35874. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  35875. protected _setProgram(program: WebGLProgram): void;
  35876. protected _boundUniforms: {
  35877. [key: number]: WebGLUniformLocation;
  35878. };
  35879. /**
  35880. * Binds an effect to the webGL context
  35881. * @param effect defines the effect to bind
  35882. */
  35883. bindSamplers(effect: Effect): void;
  35884. private _activateCurrentTexture;
  35885. /** @hidden */
  35886. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  35887. /** @hidden */
  35888. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  35889. /**
  35890. * Unbind all textures from the webGL context
  35891. */
  35892. unbindAllTextures(): void;
  35893. /**
  35894. * Sets a texture to the according uniform.
  35895. * @param channel The texture channel
  35896. * @param uniform The uniform to set
  35897. * @param texture The texture to apply
  35898. */
  35899. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  35900. private _bindSamplerUniformToChannel;
  35901. private _getTextureWrapMode;
  35902. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  35903. /**
  35904. * Sets an array of texture to the webGL context
  35905. * @param channel defines the channel where the texture array must be set
  35906. * @param uniform defines the associated uniform location
  35907. * @param textures defines the array of textures to bind
  35908. */
  35909. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  35910. /** @hidden */
  35911. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  35912. private _setTextureParameterFloat;
  35913. private _setTextureParameterInteger;
  35914. /**
  35915. * Unbind all vertex attributes from the webGL context
  35916. */
  35917. unbindAllAttributes(): void;
  35918. /**
  35919. * 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
  35920. */
  35921. releaseEffects(): void;
  35922. /**
  35923. * Dispose and release all associated resources
  35924. */
  35925. dispose(): void;
  35926. /**
  35927. * Attach a new callback raised when context lost event is fired
  35928. * @param callback defines the callback to call
  35929. */
  35930. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35931. /**
  35932. * Attach a new callback raised when context restored event is fired
  35933. * @param callback defines the callback to call
  35934. */
  35935. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35936. /**
  35937. * Get the current error code of the webGL context
  35938. * @returns the error code
  35939. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  35940. */
  35941. getError(): number;
  35942. private _canRenderToFloatFramebuffer;
  35943. private _canRenderToHalfFloatFramebuffer;
  35944. private _canRenderToFramebuffer;
  35945. /** @hidden */
  35946. _getWebGLTextureType(type: number): number;
  35947. /** @hidden */
  35948. _getInternalFormat(format: number): number;
  35949. /** @hidden */
  35950. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  35951. /** @hidden */
  35952. _getRGBAMultiSampleBufferFormat(type: number): number;
  35953. /** @hidden */
  35954. _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;
  35955. /**
  35956. * Loads a file from a url
  35957. * @param url url to load
  35958. * @param onSuccess callback called when the file successfully loads
  35959. * @param onProgress callback called while file is loading (if the server supports this mode)
  35960. * @param offlineProvider defines the offline provider for caching
  35961. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35962. * @param onError callback called when the file fails to load
  35963. * @returns a file request object
  35964. * @hidden
  35965. */
  35966. 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;
  35967. /**
  35968. * Reads pixels from the current frame buffer. Please note that this function can be slow
  35969. * @param x defines the x coordinate of the rectangle where pixels must be read
  35970. * @param y defines the y coordinate of the rectangle where pixels must be read
  35971. * @param width defines the width of the rectangle where pixels must be read
  35972. * @param height defines the height of the rectangle where pixels must be read
  35973. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  35974. * @returns a Uint8Array containing RGBA colors
  35975. */
  35976. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  35977. private static _isSupported;
  35978. /**
  35979. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  35980. * @returns true if the engine can be created
  35981. * @ignorenaming
  35982. */
  35983. static isSupported(): boolean;
  35984. /**
  35985. * Find the next highest power of two.
  35986. * @param x Number to start search from.
  35987. * @return Next highest power of two.
  35988. */
  35989. static CeilingPOT(x: number): number;
  35990. /**
  35991. * Find the next lowest power of two.
  35992. * @param x Number to start search from.
  35993. * @return Next lowest power of two.
  35994. */
  35995. static FloorPOT(x: number): number;
  35996. /**
  35997. * Find the nearest power of two.
  35998. * @param x Number to start search from.
  35999. * @return Next nearest power of two.
  36000. */
  36001. static NearestPOT(x: number): number;
  36002. /**
  36003. * Get the closest exponent of two
  36004. * @param value defines the value to approximate
  36005. * @param max defines the maximum value to return
  36006. * @param mode defines how to define the closest value
  36007. * @returns closest exponent of two of the given value
  36008. */
  36009. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36010. /**
  36011. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36012. * @param func - the function to be called
  36013. * @param requester - the object that will request the next frame. Falls back to window.
  36014. * @returns frame number
  36015. */
  36016. static QueueNewFrame(func: () => void, requester?: any): number;
  36017. /**
  36018. * Gets host document
  36019. * @returns the host document object
  36020. */
  36021. getHostDocument(): Nullable<Document>;
  36022. }
  36023. }
  36024. declare module BABYLON {
  36025. /**
  36026. * Class representing spherical harmonics coefficients to the 3rd degree
  36027. */
  36028. export class SphericalHarmonics {
  36029. /**
  36030. * Defines whether or not the harmonics have been prescaled for rendering.
  36031. */
  36032. preScaled: boolean;
  36033. /**
  36034. * The l0,0 coefficients of the spherical harmonics
  36035. */
  36036. l00: Vector3;
  36037. /**
  36038. * The l1,-1 coefficients of the spherical harmonics
  36039. */
  36040. l1_1: Vector3;
  36041. /**
  36042. * The l1,0 coefficients of the spherical harmonics
  36043. */
  36044. l10: Vector3;
  36045. /**
  36046. * The l1,1 coefficients of the spherical harmonics
  36047. */
  36048. l11: Vector3;
  36049. /**
  36050. * The l2,-2 coefficients of the spherical harmonics
  36051. */
  36052. l2_2: Vector3;
  36053. /**
  36054. * The l2,-1 coefficients of the spherical harmonics
  36055. */
  36056. l2_1: Vector3;
  36057. /**
  36058. * The l2,0 coefficients of the spherical harmonics
  36059. */
  36060. l20: Vector3;
  36061. /**
  36062. * The l2,1 coefficients of the spherical harmonics
  36063. */
  36064. l21: Vector3;
  36065. /**
  36066. * The l2,2 coefficients of the spherical harmonics
  36067. */
  36068. l22: Vector3;
  36069. /**
  36070. * Adds a light to the spherical harmonics
  36071. * @param direction the direction of the light
  36072. * @param color the color of the light
  36073. * @param deltaSolidAngle the delta solid angle of the light
  36074. */
  36075. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36076. /**
  36077. * Scales the spherical harmonics by the given amount
  36078. * @param scale the amount to scale
  36079. */
  36080. scaleInPlace(scale: number): void;
  36081. /**
  36082. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36083. *
  36084. * ```
  36085. * E_lm = A_l * L_lm
  36086. * ```
  36087. *
  36088. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36089. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36090. * the scaling factors are given in equation 9.
  36091. */
  36092. convertIncidentRadianceToIrradiance(): void;
  36093. /**
  36094. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36095. *
  36096. * ```
  36097. * L = (1/pi) * E * rho
  36098. * ```
  36099. *
  36100. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36101. */
  36102. convertIrradianceToLambertianRadiance(): void;
  36103. /**
  36104. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36105. * required operations at run time.
  36106. *
  36107. * This is simply done by scaling back the SH with Ylm constants parameter.
  36108. * The trigonometric part being applied by the shader at run time.
  36109. */
  36110. preScaleForRendering(): void;
  36111. /**
  36112. * Constructs a spherical harmonics from an array.
  36113. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36114. * @returns the spherical harmonics
  36115. */
  36116. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36117. /**
  36118. * Gets the spherical harmonics from polynomial
  36119. * @param polynomial the spherical polynomial
  36120. * @returns the spherical harmonics
  36121. */
  36122. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36123. }
  36124. /**
  36125. * Class representing spherical polynomial coefficients to the 3rd degree
  36126. */
  36127. export class SphericalPolynomial {
  36128. private _harmonics;
  36129. /**
  36130. * The spherical harmonics used to create the polynomials.
  36131. */
  36132. get preScaledHarmonics(): SphericalHarmonics;
  36133. /**
  36134. * The x coefficients of the spherical polynomial
  36135. */
  36136. x: Vector3;
  36137. /**
  36138. * The y coefficients of the spherical polynomial
  36139. */
  36140. y: Vector3;
  36141. /**
  36142. * The z coefficients of the spherical polynomial
  36143. */
  36144. z: Vector3;
  36145. /**
  36146. * The xx coefficients of the spherical polynomial
  36147. */
  36148. xx: Vector3;
  36149. /**
  36150. * The yy coefficients of the spherical polynomial
  36151. */
  36152. yy: Vector3;
  36153. /**
  36154. * The zz coefficients of the spherical polynomial
  36155. */
  36156. zz: Vector3;
  36157. /**
  36158. * The xy coefficients of the spherical polynomial
  36159. */
  36160. xy: Vector3;
  36161. /**
  36162. * The yz coefficients of the spherical polynomial
  36163. */
  36164. yz: Vector3;
  36165. /**
  36166. * The zx coefficients of the spherical polynomial
  36167. */
  36168. zx: Vector3;
  36169. /**
  36170. * Adds an ambient color to the spherical polynomial
  36171. * @param color the color to add
  36172. */
  36173. addAmbient(color: Color3): void;
  36174. /**
  36175. * Scales the spherical polynomial by the given amount
  36176. * @param scale the amount to scale
  36177. */
  36178. scaleInPlace(scale: number): void;
  36179. /**
  36180. * Gets the spherical polynomial from harmonics
  36181. * @param harmonics the spherical harmonics
  36182. * @returns the spherical polynomial
  36183. */
  36184. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36185. /**
  36186. * Constructs a spherical polynomial from an array.
  36187. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36188. * @returns the spherical polynomial
  36189. */
  36190. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36191. }
  36192. }
  36193. declare module BABYLON {
  36194. /**
  36195. * Defines the source of the internal texture
  36196. */
  36197. export enum InternalTextureSource {
  36198. /**
  36199. * The source of the texture data is unknown
  36200. */
  36201. Unknown = 0,
  36202. /**
  36203. * Texture data comes from an URL
  36204. */
  36205. Url = 1,
  36206. /**
  36207. * Texture data is only used for temporary storage
  36208. */
  36209. Temp = 2,
  36210. /**
  36211. * Texture data comes from raw data (ArrayBuffer)
  36212. */
  36213. Raw = 3,
  36214. /**
  36215. * Texture content is dynamic (video or dynamic texture)
  36216. */
  36217. Dynamic = 4,
  36218. /**
  36219. * Texture content is generated by rendering to it
  36220. */
  36221. RenderTarget = 5,
  36222. /**
  36223. * Texture content is part of a multi render target process
  36224. */
  36225. MultiRenderTarget = 6,
  36226. /**
  36227. * Texture data comes from a cube data file
  36228. */
  36229. Cube = 7,
  36230. /**
  36231. * Texture data comes from a raw cube data
  36232. */
  36233. CubeRaw = 8,
  36234. /**
  36235. * Texture data come from a prefiltered cube data file
  36236. */
  36237. CubePrefiltered = 9,
  36238. /**
  36239. * Texture content is raw 3D data
  36240. */
  36241. Raw3D = 10,
  36242. /**
  36243. * Texture content is raw 2D array data
  36244. */
  36245. Raw2DArray = 11,
  36246. /**
  36247. * Texture content is a depth texture
  36248. */
  36249. Depth = 12,
  36250. /**
  36251. * Texture data comes from a raw cube data encoded with RGBD
  36252. */
  36253. CubeRawRGBD = 13
  36254. }
  36255. /**
  36256. * Class used to store data associated with WebGL texture data for the engine
  36257. * This class should not be used directly
  36258. */
  36259. export class InternalTexture {
  36260. /** @hidden */
  36261. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36262. /**
  36263. * Defines if the texture is ready
  36264. */
  36265. isReady: boolean;
  36266. /**
  36267. * Defines if the texture is a cube texture
  36268. */
  36269. isCube: boolean;
  36270. /**
  36271. * Defines if the texture contains 3D data
  36272. */
  36273. is3D: boolean;
  36274. /**
  36275. * Defines if the texture contains 2D array data
  36276. */
  36277. is2DArray: boolean;
  36278. /**
  36279. * Defines if the texture contains multiview data
  36280. */
  36281. isMultiview: boolean;
  36282. /**
  36283. * Gets the URL used to load this texture
  36284. */
  36285. url: string;
  36286. /**
  36287. * Gets the sampling mode of the texture
  36288. */
  36289. samplingMode: number;
  36290. /**
  36291. * Gets a boolean indicating if the texture needs mipmaps generation
  36292. */
  36293. generateMipMaps: boolean;
  36294. /**
  36295. * Gets the number of samples used by the texture (WebGL2+ only)
  36296. */
  36297. samples: number;
  36298. /**
  36299. * Gets the type of the texture (int, float...)
  36300. */
  36301. type: number;
  36302. /**
  36303. * Gets the format of the texture (RGB, RGBA...)
  36304. */
  36305. format: number;
  36306. /**
  36307. * Observable called when the texture is loaded
  36308. */
  36309. onLoadedObservable: Observable<InternalTexture>;
  36310. /**
  36311. * Gets the width of the texture
  36312. */
  36313. width: number;
  36314. /**
  36315. * Gets the height of the texture
  36316. */
  36317. height: number;
  36318. /**
  36319. * Gets the depth of the texture
  36320. */
  36321. depth: number;
  36322. /**
  36323. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36324. */
  36325. baseWidth: number;
  36326. /**
  36327. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36328. */
  36329. baseHeight: number;
  36330. /**
  36331. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36332. */
  36333. baseDepth: number;
  36334. /**
  36335. * Gets a boolean indicating if the texture is inverted on Y axis
  36336. */
  36337. invertY: boolean;
  36338. /** @hidden */
  36339. _invertVScale: boolean;
  36340. /** @hidden */
  36341. _associatedChannel: number;
  36342. /** @hidden */
  36343. _source: InternalTextureSource;
  36344. /** @hidden */
  36345. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36346. /** @hidden */
  36347. _bufferView: Nullable<ArrayBufferView>;
  36348. /** @hidden */
  36349. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36350. /** @hidden */
  36351. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36352. /** @hidden */
  36353. _size: number;
  36354. /** @hidden */
  36355. _extension: string;
  36356. /** @hidden */
  36357. _files: Nullable<string[]>;
  36358. /** @hidden */
  36359. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36360. /** @hidden */
  36361. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36362. /** @hidden */
  36363. _framebuffer: Nullable<WebGLFramebuffer>;
  36364. /** @hidden */
  36365. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36366. /** @hidden */
  36367. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36368. /** @hidden */
  36369. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36370. /** @hidden */
  36371. _attachments: Nullable<number[]>;
  36372. /** @hidden */
  36373. _textureArray: Nullable<InternalTexture[]>;
  36374. /** @hidden */
  36375. _cachedCoordinatesMode: Nullable<number>;
  36376. /** @hidden */
  36377. _cachedWrapU: Nullable<number>;
  36378. /** @hidden */
  36379. _cachedWrapV: Nullable<number>;
  36380. /** @hidden */
  36381. _cachedWrapR: Nullable<number>;
  36382. /** @hidden */
  36383. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36384. /** @hidden */
  36385. _isDisabled: boolean;
  36386. /** @hidden */
  36387. _compression: Nullable<string>;
  36388. /** @hidden */
  36389. _generateStencilBuffer: boolean;
  36390. /** @hidden */
  36391. _generateDepthBuffer: boolean;
  36392. /** @hidden */
  36393. _comparisonFunction: number;
  36394. /** @hidden */
  36395. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36396. /** @hidden */
  36397. _lodGenerationScale: number;
  36398. /** @hidden */
  36399. _lodGenerationOffset: number;
  36400. /** @hidden */
  36401. _depthStencilTexture: Nullable<InternalTexture>;
  36402. /** @hidden */
  36403. _colorTextureArray: Nullable<WebGLTexture>;
  36404. /** @hidden */
  36405. _depthStencilTextureArray: Nullable<WebGLTexture>;
  36406. /** @hidden */
  36407. _lodTextureHigh: Nullable<BaseTexture>;
  36408. /** @hidden */
  36409. _lodTextureMid: Nullable<BaseTexture>;
  36410. /** @hidden */
  36411. _lodTextureLow: Nullable<BaseTexture>;
  36412. /** @hidden */
  36413. _isRGBD: boolean;
  36414. /** @hidden */
  36415. _linearSpecularLOD: boolean;
  36416. /** @hidden */
  36417. _irradianceTexture: Nullable<BaseTexture>;
  36418. /** @hidden */
  36419. _webGLTexture: Nullable<WebGLTexture>;
  36420. /** @hidden */
  36421. _references: number;
  36422. private _engine;
  36423. /**
  36424. * Gets the Engine the texture belongs to.
  36425. * @returns The babylon engine
  36426. */
  36427. getEngine(): ThinEngine;
  36428. /**
  36429. * Gets the data source type of the texture
  36430. */
  36431. get source(): InternalTextureSource;
  36432. /**
  36433. * Creates a new InternalTexture
  36434. * @param engine defines the engine to use
  36435. * @param source defines the type of data that will be used
  36436. * @param delayAllocation if the texture allocation should be delayed (default: false)
  36437. */
  36438. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  36439. /**
  36440. * Increments the number of references (ie. the number of Texture that point to it)
  36441. */
  36442. incrementReferences(): void;
  36443. /**
  36444. * Change the size of the texture (not the size of the content)
  36445. * @param width defines the new width
  36446. * @param height defines the new height
  36447. * @param depth defines the new depth (1 by default)
  36448. */
  36449. updateSize(width: int, height: int, depth?: int): void;
  36450. /** @hidden */
  36451. _rebuild(): void;
  36452. /** @hidden */
  36453. _swapAndDie(target: InternalTexture): void;
  36454. /**
  36455. * Dispose the current allocated resources
  36456. */
  36457. dispose(): void;
  36458. }
  36459. }
  36460. declare module BABYLON {
  36461. /**
  36462. * Class used to work with sound analyzer using fast fourier transform (FFT)
  36463. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36464. */
  36465. export class Analyser {
  36466. /**
  36467. * Gets or sets the smoothing
  36468. * @ignorenaming
  36469. */
  36470. SMOOTHING: number;
  36471. /**
  36472. * Gets or sets the FFT table size
  36473. * @ignorenaming
  36474. */
  36475. FFT_SIZE: number;
  36476. /**
  36477. * Gets or sets the bar graph amplitude
  36478. * @ignorenaming
  36479. */
  36480. BARGRAPHAMPLITUDE: number;
  36481. /**
  36482. * Gets or sets the position of the debug canvas
  36483. * @ignorenaming
  36484. */
  36485. DEBUGCANVASPOS: {
  36486. x: number;
  36487. y: number;
  36488. };
  36489. /**
  36490. * Gets or sets the debug canvas size
  36491. * @ignorenaming
  36492. */
  36493. DEBUGCANVASSIZE: {
  36494. width: number;
  36495. height: number;
  36496. };
  36497. private _byteFreqs;
  36498. private _byteTime;
  36499. private _floatFreqs;
  36500. private _webAudioAnalyser;
  36501. private _debugCanvas;
  36502. private _debugCanvasContext;
  36503. private _scene;
  36504. private _registerFunc;
  36505. private _audioEngine;
  36506. /**
  36507. * Creates a new analyser
  36508. * @param scene defines hosting scene
  36509. */
  36510. constructor(scene: Scene);
  36511. /**
  36512. * Get the number of data values you will have to play with for the visualization
  36513. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  36514. * @returns a number
  36515. */
  36516. getFrequencyBinCount(): number;
  36517. /**
  36518. * Gets the current frequency data as a byte array
  36519. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36520. * @returns a Uint8Array
  36521. */
  36522. getByteFrequencyData(): Uint8Array;
  36523. /**
  36524. * Gets the current waveform as a byte array
  36525. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  36526. * @returns a Uint8Array
  36527. */
  36528. getByteTimeDomainData(): Uint8Array;
  36529. /**
  36530. * Gets the current frequency data as a float array
  36531. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36532. * @returns a Float32Array
  36533. */
  36534. getFloatFrequencyData(): Float32Array;
  36535. /**
  36536. * Renders the debug canvas
  36537. */
  36538. drawDebugCanvas(): void;
  36539. /**
  36540. * Stops rendering the debug canvas and removes it
  36541. */
  36542. stopDebugCanvas(): void;
  36543. /**
  36544. * Connects two audio nodes
  36545. * @param inputAudioNode defines first node to connect
  36546. * @param outputAudioNode defines second node to connect
  36547. */
  36548. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  36549. /**
  36550. * Releases all associated resources
  36551. */
  36552. dispose(): void;
  36553. }
  36554. }
  36555. declare module BABYLON {
  36556. /**
  36557. * This represents an audio engine and it is responsible
  36558. * to play, synchronize and analyse sounds throughout the application.
  36559. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36560. */
  36561. export interface IAudioEngine extends IDisposable {
  36562. /**
  36563. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36564. */
  36565. readonly canUseWebAudio: boolean;
  36566. /**
  36567. * Gets the current AudioContext if available.
  36568. */
  36569. readonly audioContext: Nullable<AudioContext>;
  36570. /**
  36571. * The master gain node defines the global audio volume of your audio engine.
  36572. */
  36573. readonly masterGain: GainNode;
  36574. /**
  36575. * Gets whether or not mp3 are supported by your browser.
  36576. */
  36577. readonly isMP3supported: boolean;
  36578. /**
  36579. * Gets whether or not ogg are supported by your browser.
  36580. */
  36581. readonly isOGGsupported: boolean;
  36582. /**
  36583. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36584. * @ignoreNaming
  36585. */
  36586. WarnedWebAudioUnsupported: boolean;
  36587. /**
  36588. * Defines if the audio engine relies on a custom unlocked button.
  36589. * In this case, the embedded button will not be displayed.
  36590. */
  36591. useCustomUnlockedButton: boolean;
  36592. /**
  36593. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  36594. */
  36595. readonly unlocked: boolean;
  36596. /**
  36597. * Event raised when audio has been unlocked on the browser.
  36598. */
  36599. onAudioUnlockedObservable: Observable<AudioEngine>;
  36600. /**
  36601. * Event raised when audio has been locked on the browser.
  36602. */
  36603. onAudioLockedObservable: Observable<AudioEngine>;
  36604. /**
  36605. * Flags the audio engine in Locked state.
  36606. * This happens due to new browser policies preventing audio to autoplay.
  36607. */
  36608. lock(): void;
  36609. /**
  36610. * Unlocks the audio engine once a user action has been done on the dom.
  36611. * This is helpful to resume play once browser policies have been satisfied.
  36612. */
  36613. unlock(): void;
  36614. /**
  36615. * Gets the global volume sets on the master gain.
  36616. * @returns the global volume if set or -1 otherwise
  36617. */
  36618. getGlobalVolume(): number;
  36619. /**
  36620. * Sets the global volume of your experience (sets on the master gain).
  36621. * @param newVolume Defines the new global volume of the application
  36622. */
  36623. setGlobalVolume(newVolume: number): void;
  36624. /**
  36625. * Connect the audio engine to an audio analyser allowing some amazing
  36626. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36627. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36628. * @param analyser The analyser to connect to the engine
  36629. */
  36630. connectToAnalyser(analyser: Analyser): void;
  36631. }
  36632. /**
  36633. * This represents the default audio engine used in babylon.
  36634. * It is responsible to play, synchronize and analyse sounds throughout the application.
  36635. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36636. */
  36637. export class AudioEngine implements IAudioEngine {
  36638. private _audioContext;
  36639. private _audioContextInitialized;
  36640. private _muteButton;
  36641. private _hostElement;
  36642. /**
  36643. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36644. */
  36645. canUseWebAudio: boolean;
  36646. /**
  36647. * The master gain node defines the global audio volume of your audio engine.
  36648. */
  36649. masterGain: GainNode;
  36650. /**
  36651. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36652. * @ignoreNaming
  36653. */
  36654. WarnedWebAudioUnsupported: boolean;
  36655. /**
  36656. * Gets whether or not mp3 are supported by your browser.
  36657. */
  36658. isMP3supported: boolean;
  36659. /**
  36660. * Gets whether or not ogg are supported by your browser.
  36661. */
  36662. isOGGsupported: boolean;
  36663. /**
  36664. * Gets whether audio has been unlocked on the device.
  36665. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  36666. * a user interaction has happened.
  36667. */
  36668. unlocked: boolean;
  36669. /**
  36670. * Defines if the audio engine relies on a custom unlocked button.
  36671. * In this case, the embedded button will not be displayed.
  36672. */
  36673. useCustomUnlockedButton: boolean;
  36674. /**
  36675. * Event raised when audio has been unlocked on the browser.
  36676. */
  36677. onAudioUnlockedObservable: Observable<AudioEngine>;
  36678. /**
  36679. * Event raised when audio has been locked on the browser.
  36680. */
  36681. onAudioLockedObservable: Observable<AudioEngine>;
  36682. /**
  36683. * Gets the current AudioContext if available.
  36684. */
  36685. get audioContext(): Nullable<AudioContext>;
  36686. private _connectedAnalyser;
  36687. /**
  36688. * Instantiates a new audio engine.
  36689. *
  36690. * There should be only one per page as some browsers restrict the number
  36691. * of audio contexts you can create.
  36692. * @param hostElement defines the host element where to display the mute icon if necessary
  36693. */
  36694. constructor(hostElement?: Nullable<HTMLElement>);
  36695. /**
  36696. * Flags the audio engine in Locked state.
  36697. * This happens due to new browser policies preventing audio to autoplay.
  36698. */
  36699. lock(): void;
  36700. /**
  36701. * Unlocks the audio engine once a user action has been done on the dom.
  36702. * This is helpful to resume play once browser policies have been satisfied.
  36703. */
  36704. unlock(): void;
  36705. private _resumeAudioContext;
  36706. private _initializeAudioContext;
  36707. private _tryToRun;
  36708. private _triggerRunningState;
  36709. private _triggerSuspendedState;
  36710. private _displayMuteButton;
  36711. private _moveButtonToTopLeft;
  36712. private _onResize;
  36713. private _hideMuteButton;
  36714. /**
  36715. * Destroy and release the resources associated with the audio ccontext.
  36716. */
  36717. dispose(): void;
  36718. /**
  36719. * Gets the global volume sets on the master gain.
  36720. * @returns the global volume if set or -1 otherwise
  36721. */
  36722. getGlobalVolume(): number;
  36723. /**
  36724. * Sets the global volume of your experience (sets on the master gain).
  36725. * @param newVolume Defines the new global volume of the application
  36726. */
  36727. setGlobalVolume(newVolume: number): void;
  36728. /**
  36729. * Connect the audio engine to an audio analyser allowing some amazing
  36730. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36731. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36732. * @param analyser The analyser to connect to the engine
  36733. */
  36734. connectToAnalyser(analyser: Analyser): void;
  36735. }
  36736. }
  36737. declare module BABYLON {
  36738. /**
  36739. * Interface used to present a loading screen while loading a scene
  36740. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36741. */
  36742. export interface ILoadingScreen {
  36743. /**
  36744. * Function called to display the loading screen
  36745. */
  36746. displayLoadingUI: () => void;
  36747. /**
  36748. * Function called to hide the loading screen
  36749. */
  36750. hideLoadingUI: () => void;
  36751. /**
  36752. * Gets or sets the color to use for the background
  36753. */
  36754. loadingUIBackgroundColor: string;
  36755. /**
  36756. * Gets or sets the text to display while loading
  36757. */
  36758. loadingUIText: string;
  36759. }
  36760. /**
  36761. * Class used for the default loading screen
  36762. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36763. */
  36764. export class DefaultLoadingScreen implements ILoadingScreen {
  36765. private _renderingCanvas;
  36766. private _loadingText;
  36767. private _loadingDivBackgroundColor;
  36768. private _loadingDiv;
  36769. private _loadingTextDiv;
  36770. /** Gets or sets the logo url to use for the default loading screen */
  36771. static DefaultLogoUrl: string;
  36772. /** Gets or sets the spinner url to use for the default loading screen */
  36773. static DefaultSpinnerUrl: string;
  36774. /**
  36775. * Creates a new default loading screen
  36776. * @param _renderingCanvas defines the canvas used to render the scene
  36777. * @param _loadingText defines the default text to display
  36778. * @param _loadingDivBackgroundColor defines the default background color
  36779. */
  36780. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  36781. /**
  36782. * Function called to display the loading screen
  36783. */
  36784. displayLoadingUI(): void;
  36785. /**
  36786. * Function called to hide the loading screen
  36787. */
  36788. hideLoadingUI(): void;
  36789. /**
  36790. * Gets or sets the text to display while loading
  36791. */
  36792. set loadingUIText(text: string);
  36793. get loadingUIText(): string;
  36794. /**
  36795. * Gets or sets the color to use for the background
  36796. */
  36797. get loadingUIBackgroundColor(): string;
  36798. set loadingUIBackgroundColor(color: string);
  36799. private _resizeLoadingUI;
  36800. }
  36801. }
  36802. declare module BABYLON {
  36803. /**
  36804. * Interface for any object that can request an animation frame
  36805. */
  36806. export interface ICustomAnimationFrameRequester {
  36807. /**
  36808. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  36809. */
  36810. renderFunction?: Function;
  36811. /**
  36812. * Called to request the next frame to render to
  36813. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  36814. */
  36815. requestAnimationFrame: Function;
  36816. /**
  36817. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  36818. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  36819. */
  36820. requestID?: number;
  36821. }
  36822. }
  36823. declare module BABYLON {
  36824. /**
  36825. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  36826. */
  36827. export class PerformanceMonitor {
  36828. private _enabled;
  36829. private _rollingFrameTime;
  36830. private _lastFrameTimeMs;
  36831. /**
  36832. * constructor
  36833. * @param frameSampleSize The number of samples required to saturate the sliding window
  36834. */
  36835. constructor(frameSampleSize?: number);
  36836. /**
  36837. * Samples current frame
  36838. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  36839. */
  36840. sampleFrame(timeMs?: number): void;
  36841. /**
  36842. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  36843. */
  36844. get averageFrameTime(): number;
  36845. /**
  36846. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  36847. */
  36848. get averageFrameTimeVariance(): number;
  36849. /**
  36850. * Returns the frame time of the most recent frame
  36851. */
  36852. get instantaneousFrameTime(): number;
  36853. /**
  36854. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  36855. */
  36856. get averageFPS(): number;
  36857. /**
  36858. * Returns the average framerate in frames per second using the most recent frame time
  36859. */
  36860. get instantaneousFPS(): number;
  36861. /**
  36862. * Returns true if enough samples have been taken to completely fill the sliding window
  36863. */
  36864. get isSaturated(): boolean;
  36865. /**
  36866. * Enables contributions to the sliding window sample set
  36867. */
  36868. enable(): void;
  36869. /**
  36870. * Disables contributions to the sliding window sample set
  36871. * Samples will not be interpolated over the disabled period
  36872. */
  36873. disable(): void;
  36874. /**
  36875. * Returns true if sampling is enabled
  36876. */
  36877. get isEnabled(): boolean;
  36878. /**
  36879. * Resets performance monitor
  36880. */
  36881. reset(): void;
  36882. }
  36883. /**
  36884. * RollingAverage
  36885. *
  36886. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  36887. */
  36888. export class RollingAverage {
  36889. /**
  36890. * Current average
  36891. */
  36892. average: number;
  36893. /**
  36894. * Current variance
  36895. */
  36896. variance: number;
  36897. protected _samples: Array<number>;
  36898. protected _sampleCount: number;
  36899. protected _pos: number;
  36900. protected _m2: number;
  36901. /**
  36902. * constructor
  36903. * @param length The number of samples required to saturate the sliding window
  36904. */
  36905. constructor(length: number);
  36906. /**
  36907. * Adds a sample to the sample set
  36908. * @param v The sample value
  36909. */
  36910. add(v: number): void;
  36911. /**
  36912. * Returns previously added values or null if outside of history or outside the sliding window domain
  36913. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  36914. * @return Value previously recorded with add() or null if outside of range
  36915. */
  36916. history(i: number): number;
  36917. /**
  36918. * Returns true if enough samples have been taken to completely fill the sliding window
  36919. * @return true if sample-set saturated
  36920. */
  36921. isSaturated(): boolean;
  36922. /**
  36923. * Resets the rolling average (equivalent to 0 samples taken so far)
  36924. */
  36925. reset(): void;
  36926. /**
  36927. * Wraps a value around the sample range boundaries
  36928. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  36929. * @return Wrapped position in sample range
  36930. */
  36931. protected _wrapPosition(i: number): number;
  36932. }
  36933. }
  36934. declare module BABYLON {
  36935. /**
  36936. * This class is used to track a performance counter which is number based.
  36937. * The user has access to many properties which give statistics of different nature.
  36938. *
  36939. * The implementer can track two kinds of Performance Counter: time and count.
  36940. * 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.
  36941. * 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.
  36942. */
  36943. export class PerfCounter {
  36944. /**
  36945. * Gets or sets a global boolean to turn on and off all the counters
  36946. */
  36947. static Enabled: boolean;
  36948. /**
  36949. * Returns the smallest value ever
  36950. */
  36951. get min(): number;
  36952. /**
  36953. * Returns the biggest value ever
  36954. */
  36955. get max(): number;
  36956. /**
  36957. * Returns the average value since the performance counter is running
  36958. */
  36959. get average(): number;
  36960. /**
  36961. * Returns the average value of the last second the counter was monitored
  36962. */
  36963. get lastSecAverage(): number;
  36964. /**
  36965. * Returns the current value
  36966. */
  36967. get current(): number;
  36968. /**
  36969. * Gets the accumulated total
  36970. */
  36971. get total(): number;
  36972. /**
  36973. * Gets the total value count
  36974. */
  36975. get count(): number;
  36976. /**
  36977. * Creates a new counter
  36978. */
  36979. constructor();
  36980. /**
  36981. * Call this method to start monitoring a new frame.
  36982. * 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.
  36983. */
  36984. fetchNewFrame(): void;
  36985. /**
  36986. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  36987. * @param newCount the count value to add to the monitored count
  36988. * @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.
  36989. */
  36990. addCount(newCount: number, fetchResult: boolean): void;
  36991. /**
  36992. * Start monitoring this performance counter
  36993. */
  36994. beginMonitoring(): void;
  36995. /**
  36996. * Compute the time lapsed since the previous beginMonitoring() call.
  36997. * @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
  36998. */
  36999. endMonitoring(newFrame?: boolean): void;
  37000. private _fetchResult;
  37001. private _startMonitoringTime;
  37002. private _min;
  37003. private _max;
  37004. private _average;
  37005. private _current;
  37006. private _totalValueCount;
  37007. private _totalAccumulated;
  37008. private _lastSecAverage;
  37009. private _lastSecAccumulated;
  37010. private _lastSecTime;
  37011. private _lastSecValueCount;
  37012. }
  37013. }
  37014. declare module BABYLON {
  37015. interface ThinEngine {
  37016. /**
  37017. * Sets alpha constants used by some alpha blending modes
  37018. * @param r defines the red component
  37019. * @param g defines the green component
  37020. * @param b defines the blue component
  37021. * @param a defines the alpha component
  37022. */
  37023. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  37024. /**
  37025. * Sets the current alpha mode
  37026. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  37027. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  37028. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37029. */
  37030. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  37031. /**
  37032. * Gets the current alpha mode
  37033. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37034. * @returns the current alpha mode
  37035. */
  37036. getAlphaMode(): number;
  37037. /**
  37038. * Sets the current alpha equation
  37039. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  37040. */
  37041. setAlphaEquation(equation: number): void;
  37042. /**
  37043. * Gets the current alpha equation.
  37044. * @returns the current alpha equation
  37045. */
  37046. getAlphaEquation(): number;
  37047. }
  37048. }
  37049. declare module BABYLON {
  37050. interface ThinEngine {
  37051. /** @hidden */
  37052. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37053. }
  37054. }
  37055. declare module BABYLON {
  37056. /**
  37057. * Defines the interface used by display changed events
  37058. */
  37059. export interface IDisplayChangedEventArgs {
  37060. /** Gets the vrDisplay object (if any) */
  37061. vrDisplay: Nullable<any>;
  37062. /** Gets a boolean indicating if webVR is supported */
  37063. vrSupported: boolean;
  37064. }
  37065. /**
  37066. * Defines the interface used by objects containing a viewport (like a camera)
  37067. */
  37068. interface IViewportOwnerLike {
  37069. /**
  37070. * Gets or sets the viewport
  37071. */
  37072. viewport: IViewportLike;
  37073. }
  37074. /**
  37075. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37076. */
  37077. export class Engine extends ThinEngine {
  37078. /** Defines that alpha blending is disabled */
  37079. static readonly ALPHA_DISABLE: number;
  37080. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37081. static readonly ALPHA_ADD: number;
  37082. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37083. static readonly ALPHA_COMBINE: number;
  37084. /** Defines that alpha blending to DEST - SRC * DEST */
  37085. static readonly ALPHA_SUBTRACT: number;
  37086. /** Defines that alpha blending to SRC * DEST */
  37087. static readonly ALPHA_MULTIPLY: number;
  37088. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37089. static readonly ALPHA_MAXIMIZED: number;
  37090. /** Defines that alpha blending to SRC + DEST */
  37091. static readonly ALPHA_ONEONE: number;
  37092. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37093. static readonly ALPHA_PREMULTIPLIED: number;
  37094. /**
  37095. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37096. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37097. */
  37098. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37099. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37100. static readonly ALPHA_INTERPOLATE: number;
  37101. /**
  37102. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37103. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37104. */
  37105. static readonly ALPHA_SCREENMODE: number;
  37106. /** Defines that the ressource is not delayed*/
  37107. static readonly DELAYLOADSTATE_NONE: number;
  37108. /** Defines that the ressource was successfully delay loaded */
  37109. static readonly DELAYLOADSTATE_LOADED: number;
  37110. /** Defines that the ressource is currently delay loading */
  37111. static readonly DELAYLOADSTATE_LOADING: number;
  37112. /** Defines that the ressource is delayed and has not started loading */
  37113. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37114. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37115. static readonly NEVER: number;
  37116. /** 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 */
  37117. static readonly ALWAYS: number;
  37118. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37119. static readonly LESS: number;
  37120. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37121. static readonly EQUAL: number;
  37122. /** 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 */
  37123. static readonly LEQUAL: number;
  37124. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37125. static readonly GREATER: number;
  37126. /** 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 */
  37127. static readonly GEQUAL: number;
  37128. /** 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 */
  37129. static readonly NOTEQUAL: number;
  37130. /** Passed to stencilOperation to specify that stencil value must be kept */
  37131. static readonly KEEP: number;
  37132. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37133. static readonly REPLACE: number;
  37134. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37135. static readonly INCR: number;
  37136. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37137. static readonly DECR: number;
  37138. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37139. static readonly INVERT: number;
  37140. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37141. static readonly INCR_WRAP: number;
  37142. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37143. static readonly DECR_WRAP: number;
  37144. /** Texture is not repeating outside of 0..1 UVs */
  37145. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37146. /** Texture is repeating outside of 0..1 UVs */
  37147. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37148. /** Texture is repeating and mirrored */
  37149. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37150. /** ALPHA */
  37151. static readonly TEXTUREFORMAT_ALPHA: number;
  37152. /** LUMINANCE */
  37153. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37154. /** LUMINANCE_ALPHA */
  37155. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37156. /** RGB */
  37157. static readonly TEXTUREFORMAT_RGB: number;
  37158. /** RGBA */
  37159. static readonly TEXTUREFORMAT_RGBA: number;
  37160. /** RED */
  37161. static readonly TEXTUREFORMAT_RED: number;
  37162. /** RED (2nd reference) */
  37163. static readonly TEXTUREFORMAT_R: number;
  37164. /** RG */
  37165. static readonly TEXTUREFORMAT_RG: number;
  37166. /** RED_INTEGER */
  37167. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37168. /** RED_INTEGER (2nd reference) */
  37169. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37170. /** RG_INTEGER */
  37171. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37172. /** RGB_INTEGER */
  37173. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37174. /** RGBA_INTEGER */
  37175. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37176. /** UNSIGNED_BYTE */
  37177. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37178. /** UNSIGNED_BYTE (2nd reference) */
  37179. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37180. /** FLOAT */
  37181. static readonly TEXTURETYPE_FLOAT: number;
  37182. /** HALF_FLOAT */
  37183. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37184. /** BYTE */
  37185. static readonly TEXTURETYPE_BYTE: number;
  37186. /** SHORT */
  37187. static readonly TEXTURETYPE_SHORT: number;
  37188. /** UNSIGNED_SHORT */
  37189. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37190. /** INT */
  37191. static readonly TEXTURETYPE_INT: number;
  37192. /** UNSIGNED_INT */
  37193. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37194. /** UNSIGNED_SHORT_4_4_4_4 */
  37195. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37196. /** UNSIGNED_SHORT_5_5_5_1 */
  37197. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37198. /** UNSIGNED_SHORT_5_6_5 */
  37199. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37200. /** UNSIGNED_INT_2_10_10_10_REV */
  37201. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37202. /** UNSIGNED_INT_24_8 */
  37203. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37204. /** UNSIGNED_INT_10F_11F_11F_REV */
  37205. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37206. /** UNSIGNED_INT_5_9_9_9_REV */
  37207. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37208. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37209. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37210. /** nearest is mag = nearest and min = nearest and mip = linear */
  37211. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37212. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37213. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37214. /** Trilinear is mag = linear and min = linear and mip = linear */
  37215. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37216. /** nearest is mag = nearest and min = nearest and mip = linear */
  37217. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37218. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37219. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37220. /** Trilinear is mag = linear and min = linear and mip = linear */
  37221. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37222. /** mag = nearest and min = nearest and mip = nearest */
  37223. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37224. /** mag = nearest and min = linear and mip = nearest */
  37225. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37226. /** mag = nearest and min = linear and mip = linear */
  37227. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37228. /** mag = nearest and min = linear and mip = none */
  37229. static readonly TEXTURE_NEAREST_LINEAR: number;
  37230. /** mag = nearest and min = nearest and mip = none */
  37231. static readonly TEXTURE_NEAREST_NEAREST: number;
  37232. /** mag = linear and min = nearest and mip = nearest */
  37233. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37234. /** mag = linear and min = nearest and mip = linear */
  37235. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37236. /** mag = linear and min = linear and mip = none */
  37237. static readonly TEXTURE_LINEAR_LINEAR: number;
  37238. /** mag = linear and min = nearest and mip = none */
  37239. static readonly TEXTURE_LINEAR_NEAREST: number;
  37240. /** Explicit coordinates mode */
  37241. static readonly TEXTURE_EXPLICIT_MODE: number;
  37242. /** Spherical coordinates mode */
  37243. static readonly TEXTURE_SPHERICAL_MODE: number;
  37244. /** Planar coordinates mode */
  37245. static readonly TEXTURE_PLANAR_MODE: number;
  37246. /** Cubic coordinates mode */
  37247. static readonly TEXTURE_CUBIC_MODE: number;
  37248. /** Projection coordinates mode */
  37249. static readonly TEXTURE_PROJECTION_MODE: number;
  37250. /** Skybox coordinates mode */
  37251. static readonly TEXTURE_SKYBOX_MODE: number;
  37252. /** Inverse Cubic coordinates mode */
  37253. static readonly TEXTURE_INVCUBIC_MODE: number;
  37254. /** Equirectangular coordinates mode */
  37255. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37256. /** Equirectangular Fixed coordinates mode */
  37257. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37258. /** Equirectangular Fixed Mirrored coordinates mode */
  37259. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37260. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37261. static readonly SCALEMODE_FLOOR: number;
  37262. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37263. static readonly SCALEMODE_NEAREST: number;
  37264. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37265. static readonly SCALEMODE_CEILING: number;
  37266. /**
  37267. * Returns the current npm package of the sdk
  37268. */
  37269. static get NpmPackage(): string;
  37270. /**
  37271. * Returns the current version of the framework
  37272. */
  37273. static get Version(): string;
  37274. /** Gets the list of created engines */
  37275. static get Instances(): Engine[];
  37276. /**
  37277. * Gets the latest created engine
  37278. */
  37279. static get LastCreatedEngine(): Nullable<Engine>;
  37280. /**
  37281. * Gets the latest created scene
  37282. */
  37283. static get LastCreatedScene(): Nullable<Scene>;
  37284. /**
  37285. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37286. * @param flag defines which part of the materials must be marked as dirty
  37287. * @param predicate defines a predicate used to filter which materials should be affected
  37288. */
  37289. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37290. /**
  37291. * Method called to create the default loading screen.
  37292. * This can be overriden in your own app.
  37293. * @param canvas The rendering canvas element
  37294. * @returns The loading screen
  37295. */
  37296. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37297. /**
  37298. * Method called to create the default rescale post process on each engine.
  37299. */
  37300. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37301. /**
  37302. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37303. **/
  37304. enableOfflineSupport: boolean;
  37305. /**
  37306. * 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)
  37307. **/
  37308. disableManifestCheck: boolean;
  37309. /**
  37310. * Gets the list of created scenes
  37311. */
  37312. scenes: Scene[];
  37313. /**
  37314. * Event raised when a new scene is created
  37315. */
  37316. onNewSceneAddedObservable: Observable<Scene>;
  37317. /**
  37318. * Gets the list of created postprocesses
  37319. */
  37320. postProcesses: PostProcess[];
  37321. /**
  37322. * Gets a boolean indicating if the pointer is currently locked
  37323. */
  37324. isPointerLock: boolean;
  37325. /**
  37326. * Observable event triggered each time the rendering canvas is resized
  37327. */
  37328. onResizeObservable: Observable<Engine>;
  37329. /**
  37330. * Observable event triggered each time the canvas loses focus
  37331. */
  37332. onCanvasBlurObservable: Observable<Engine>;
  37333. /**
  37334. * Observable event triggered each time the canvas gains focus
  37335. */
  37336. onCanvasFocusObservable: Observable<Engine>;
  37337. /**
  37338. * Observable event triggered each time the canvas receives pointerout event
  37339. */
  37340. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37341. /**
  37342. * Observable raised when the engine begins a new frame
  37343. */
  37344. onBeginFrameObservable: Observable<Engine>;
  37345. /**
  37346. * If set, will be used to request the next animation frame for the render loop
  37347. */
  37348. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37349. /**
  37350. * Observable raised when the engine ends the current frame
  37351. */
  37352. onEndFrameObservable: Observable<Engine>;
  37353. /**
  37354. * Observable raised when the engine is about to compile a shader
  37355. */
  37356. onBeforeShaderCompilationObservable: Observable<Engine>;
  37357. /**
  37358. * Observable raised when the engine has jsut compiled a shader
  37359. */
  37360. onAfterShaderCompilationObservable: Observable<Engine>;
  37361. /**
  37362. * Gets the audio engine
  37363. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37364. * @ignorenaming
  37365. */
  37366. static audioEngine: IAudioEngine;
  37367. /**
  37368. * Default AudioEngine factory responsible of creating the Audio Engine.
  37369. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37370. */
  37371. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37372. /**
  37373. * Default offline support factory responsible of creating a tool used to store data locally.
  37374. * By default, this will create a Database object if the workload has been embedded.
  37375. */
  37376. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  37377. private _loadingScreen;
  37378. private _pointerLockRequested;
  37379. private _rescalePostProcess;
  37380. private _deterministicLockstep;
  37381. private _lockstepMaxSteps;
  37382. private _timeStep;
  37383. protected get _supportsHardwareTextureRescaling(): boolean;
  37384. private _fps;
  37385. private _deltaTime;
  37386. /** @hidden */
  37387. _drawCalls: PerfCounter;
  37388. /** 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 */
  37389. canvasTabIndex: number;
  37390. /**
  37391. * Turn this value on if you want to pause FPS computation when in background
  37392. */
  37393. disablePerformanceMonitorInBackground: boolean;
  37394. private _performanceMonitor;
  37395. /**
  37396. * Gets the performance monitor attached to this engine
  37397. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  37398. */
  37399. get performanceMonitor(): PerformanceMonitor;
  37400. private _onFocus;
  37401. private _onBlur;
  37402. private _onCanvasPointerOut;
  37403. private _onCanvasBlur;
  37404. private _onCanvasFocus;
  37405. private _onFullscreenChange;
  37406. private _onPointerLockChange;
  37407. /**
  37408. * Gets the HTML element used to attach event listeners
  37409. * @returns a HTML element
  37410. */
  37411. getInputElement(): Nullable<HTMLElement>;
  37412. /**
  37413. * Creates a new engine
  37414. * @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
  37415. * @param antialias defines enable antialiasing (default: false)
  37416. * @param options defines further options to be sent to the getContext() function
  37417. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  37418. */
  37419. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  37420. /**
  37421. * Gets current aspect ratio
  37422. * @param viewportOwner defines the camera to use to get the aspect ratio
  37423. * @param useScreen defines if screen size must be used (or the current render target if any)
  37424. * @returns a number defining the aspect ratio
  37425. */
  37426. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  37427. /**
  37428. * Gets current screen aspect ratio
  37429. * @returns a number defining the aspect ratio
  37430. */
  37431. getScreenAspectRatio(): number;
  37432. /**
  37433. * Gets the client rect of the HTML canvas attached with the current webGL context
  37434. * @returns a client rectanglee
  37435. */
  37436. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  37437. /**
  37438. * Gets the client rect of the HTML element used for events
  37439. * @returns a client rectanglee
  37440. */
  37441. getInputElementClientRect(): Nullable<ClientRect>;
  37442. /**
  37443. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  37444. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37445. * @returns true if engine is in deterministic lock step mode
  37446. */
  37447. isDeterministicLockStep(): boolean;
  37448. /**
  37449. * Gets the max steps when engine is running in deterministic lock step
  37450. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37451. * @returns the max steps
  37452. */
  37453. getLockstepMaxSteps(): number;
  37454. /**
  37455. * Returns the time in ms between steps when using deterministic lock step.
  37456. * @returns time step in (ms)
  37457. */
  37458. getTimeStep(): number;
  37459. /**
  37460. * Force the mipmap generation for the given render target texture
  37461. * @param texture defines the render target texture to use
  37462. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  37463. */
  37464. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  37465. /** States */
  37466. /**
  37467. * Set various states to the webGL context
  37468. * @param culling defines backface culling state
  37469. * @param zOffset defines the value to apply to zOffset (0 by default)
  37470. * @param force defines if states must be applied even if cache is up to date
  37471. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  37472. */
  37473. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  37474. /**
  37475. * Set the z offset to apply to current rendering
  37476. * @param value defines the offset to apply
  37477. */
  37478. setZOffset(value: number): void;
  37479. /**
  37480. * Gets the current value of the zOffset
  37481. * @returns the current zOffset state
  37482. */
  37483. getZOffset(): number;
  37484. /**
  37485. * Enable or disable depth buffering
  37486. * @param enable defines the state to set
  37487. */
  37488. setDepthBuffer(enable: boolean): void;
  37489. /**
  37490. * Gets a boolean indicating if depth writing is enabled
  37491. * @returns the current depth writing state
  37492. */
  37493. getDepthWrite(): boolean;
  37494. /**
  37495. * Enable or disable depth writing
  37496. * @param enable defines the state to set
  37497. */
  37498. setDepthWrite(enable: boolean): void;
  37499. /**
  37500. * Gets a boolean indicating if stencil buffer is enabled
  37501. * @returns the current stencil buffer state
  37502. */
  37503. getStencilBuffer(): boolean;
  37504. /**
  37505. * Enable or disable the stencil buffer
  37506. * @param enable defines if the stencil buffer must be enabled or disabled
  37507. */
  37508. setStencilBuffer(enable: boolean): void;
  37509. /**
  37510. * Gets the current stencil mask
  37511. * @returns a number defining the new stencil mask to use
  37512. */
  37513. getStencilMask(): number;
  37514. /**
  37515. * Sets the current stencil mask
  37516. * @param mask defines the new stencil mask to use
  37517. */
  37518. setStencilMask(mask: number): void;
  37519. /**
  37520. * Gets the current stencil function
  37521. * @returns a number defining the stencil function to use
  37522. */
  37523. getStencilFunction(): number;
  37524. /**
  37525. * Gets the current stencil reference value
  37526. * @returns a number defining the stencil reference value to use
  37527. */
  37528. getStencilFunctionReference(): number;
  37529. /**
  37530. * Gets the current stencil mask
  37531. * @returns a number defining the stencil mask to use
  37532. */
  37533. getStencilFunctionMask(): number;
  37534. /**
  37535. * Sets the current stencil function
  37536. * @param stencilFunc defines the new stencil function to use
  37537. */
  37538. setStencilFunction(stencilFunc: number): void;
  37539. /**
  37540. * Sets the current stencil reference
  37541. * @param reference defines the new stencil reference to use
  37542. */
  37543. setStencilFunctionReference(reference: number): void;
  37544. /**
  37545. * Sets the current stencil mask
  37546. * @param mask defines the new stencil mask to use
  37547. */
  37548. setStencilFunctionMask(mask: number): void;
  37549. /**
  37550. * Gets the current stencil operation when stencil fails
  37551. * @returns a number defining stencil operation to use when stencil fails
  37552. */
  37553. getStencilOperationFail(): number;
  37554. /**
  37555. * Gets the current stencil operation when depth fails
  37556. * @returns a number defining stencil operation to use when depth fails
  37557. */
  37558. getStencilOperationDepthFail(): number;
  37559. /**
  37560. * Gets the current stencil operation when stencil passes
  37561. * @returns a number defining stencil operation to use when stencil passes
  37562. */
  37563. getStencilOperationPass(): number;
  37564. /**
  37565. * Sets the stencil operation to use when stencil fails
  37566. * @param operation defines the stencil operation to use when stencil fails
  37567. */
  37568. setStencilOperationFail(operation: number): void;
  37569. /**
  37570. * Sets the stencil operation to use when depth fails
  37571. * @param operation defines the stencil operation to use when depth fails
  37572. */
  37573. setStencilOperationDepthFail(operation: number): void;
  37574. /**
  37575. * Sets the stencil operation to use when stencil passes
  37576. * @param operation defines the stencil operation to use when stencil passes
  37577. */
  37578. setStencilOperationPass(operation: number): void;
  37579. /**
  37580. * Sets a boolean indicating if the dithering state is enabled or disabled
  37581. * @param value defines the dithering state
  37582. */
  37583. setDitheringState(value: boolean): void;
  37584. /**
  37585. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  37586. * @param value defines the rasterizer state
  37587. */
  37588. setRasterizerState(value: boolean): void;
  37589. /**
  37590. * Gets the current depth function
  37591. * @returns a number defining the depth function
  37592. */
  37593. getDepthFunction(): Nullable<number>;
  37594. /**
  37595. * Sets the current depth function
  37596. * @param depthFunc defines the function to use
  37597. */
  37598. setDepthFunction(depthFunc: number): void;
  37599. /**
  37600. * Sets the current depth function to GREATER
  37601. */
  37602. setDepthFunctionToGreater(): void;
  37603. /**
  37604. * Sets the current depth function to GEQUAL
  37605. */
  37606. setDepthFunctionToGreaterOrEqual(): void;
  37607. /**
  37608. * Sets the current depth function to LESS
  37609. */
  37610. setDepthFunctionToLess(): void;
  37611. /**
  37612. * Sets the current depth function to LEQUAL
  37613. */
  37614. setDepthFunctionToLessOrEqual(): void;
  37615. private _cachedStencilBuffer;
  37616. private _cachedStencilFunction;
  37617. private _cachedStencilMask;
  37618. private _cachedStencilOperationPass;
  37619. private _cachedStencilOperationFail;
  37620. private _cachedStencilOperationDepthFail;
  37621. private _cachedStencilReference;
  37622. /**
  37623. * Caches the the state of the stencil buffer
  37624. */
  37625. cacheStencilState(): void;
  37626. /**
  37627. * Restores the state of the stencil buffer
  37628. */
  37629. restoreStencilState(): void;
  37630. /**
  37631. * Directly set the WebGL Viewport
  37632. * @param x defines the x coordinate of the viewport (in screen space)
  37633. * @param y defines the y coordinate of the viewport (in screen space)
  37634. * @param width defines the width of the viewport (in screen space)
  37635. * @param height defines the height of the viewport (in screen space)
  37636. * @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
  37637. */
  37638. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  37639. /**
  37640. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  37641. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37642. * @param y defines the y-coordinate of the corner of the clear rectangle
  37643. * @param width defines the width of the clear rectangle
  37644. * @param height defines the height of the clear rectangle
  37645. * @param clearColor defines the clear color
  37646. */
  37647. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  37648. /**
  37649. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  37650. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37651. * @param y defines the y-coordinate of the corner of the clear rectangle
  37652. * @param width defines the width of the clear rectangle
  37653. * @param height defines the height of the clear rectangle
  37654. */
  37655. enableScissor(x: number, y: number, width: number, height: number): void;
  37656. /**
  37657. * Disable previously set scissor test rectangle
  37658. */
  37659. disableScissor(): void;
  37660. protected _reportDrawCall(): void;
  37661. /**
  37662. * Initializes a webVR display and starts listening to display change events
  37663. * The onVRDisplayChangedObservable will be notified upon these changes
  37664. * @returns The onVRDisplayChangedObservable
  37665. */
  37666. initWebVR(): Observable<IDisplayChangedEventArgs>;
  37667. /** @hidden */
  37668. _prepareVRComponent(): void;
  37669. /** @hidden */
  37670. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  37671. /** @hidden */
  37672. _submitVRFrame(): void;
  37673. /**
  37674. * Call this function to leave webVR mode
  37675. * Will do nothing if webVR is not supported or if there is no webVR device
  37676. * @see https://doc.babylonjs.com/how_to/webvr_camera
  37677. */
  37678. disableVR(): void;
  37679. /**
  37680. * Gets a boolean indicating that the system is in VR mode and is presenting
  37681. * @returns true if VR mode is engaged
  37682. */
  37683. isVRPresenting(): boolean;
  37684. /** @hidden */
  37685. _requestVRFrame(): void;
  37686. /** @hidden */
  37687. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37688. /**
  37689. * Gets the source code of the vertex shader associated with a specific webGL program
  37690. * @param program defines the program to use
  37691. * @returns a string containing the source code of the vertex shader associated with the program
  37692. */
  37693. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  37694. /**
  37695. * Gets the source code of the fragment shader associated with a specific webGL program
  37696. * @param program defines the program to use
  37697. * @returns a string containing the source code of the fragment shader associated with the program
  37698. */
  37699. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  37700. /**
  37701. * Sets a depth stencil texture from a render target to the according uniform.
  37702. * @param channel The texture channel
  37703. * @param uniform The uniform to set
  37704. * @param texture The render target texture containing the depth stencil texture to apply
  37705. */
  37706. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  37707. /**
  37708. * Sets a texture to the webGL context from a postprocess
  37709. * @param channel defines the channel to use
  37710. * @param postProcess defines the source postprocess
  37711. */
  37712. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  37713. /**
  37714. * Binds the output of the passed in post process to the texture channel specified
  37715. * @param channel The channel the texture should be bound to
  37716. * @param postProcess The post process which's output should be bound
  37717. */
  37718. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  37719. protected _rebuildBuffers(): void;
  37720. /** @hidden */
  37721. _renderFrame(): void;
  37722. _renderLoop(): void;
  37723. /** @hidden */
  37724. _renderViews(): boolean;
  37725. /**
  37726. * Toggle full screen mode
  37727. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37728. */
  37729. switchFullscreen(requestPointerLock: boolean): void;
  37730. /**
  37731. * Enters full screen mode
  37732. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37733. */
  37734. enterFullscreen(requestPointerLock: boolean): void;
  37735. /**
  37736. * Exits full screen mode
  37737. */
  37738. exitFullscreen(): void;
  37739. /**
  37740. * Enters Pointerlock mode
  37741. */
  37742. enterPointerlock(): void;
  37743. /**
  37744. * Exits Pointerlock mode
  37745. */
  37746. exitPointerlock(): void;
  37747. /**
  37748. * Begin a new frame
  37749. */
  37750. beginFrame(): void;
  37751. /**
  37752. * Enf the current frame
  37753. */
  37754. endFrame(): void;
  37755. resize(): void;
  37756. /**
  37757. * Force a specific size of the canvas
  37758. * @param width defines the new canvas' width
  37759. * @param height defines the new canvas' height
  37760. * @returns true if the size was changed
  37761. */
  37762. setSize(width: number, height: number): boolean;
  37763. /**
  37764. * Updates a dynamic vertex buffer.
  37765. * @param vertexBuffer the vertex buffer to update
  37766. * @param data the data used to update the vertex buffer
  37767. * @param byteOffset the byte offset of the data
  37768. * @param byteLength the byte length of the data
  37769. */
  37770. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  37771. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37772. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37773. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37774. _releaseTexture(texture: InternalTexture): void;
  37775. /**
  37776. * @hidden
  37777. * Rescales a texture
  37778. * @param source input texutre
  37779. * @param destination destination texture
  37780. * @param scene scene to use to render the resize
  37781. * @param internalFormat format to use when resizing
  37782. * @param onComplete callback to be called when resize has completed
  37783. */
  37784. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37785. /**
  37786. * Gets the current framerate
  37787. * @returns a number representing the framerate
  37788. */
  37789. getFps(): number;
  37790. /**
  37791. * Gets the time spent between current and previous frame
  37792. * @returns a number representing the delta time in ms
  37793. */
  37794. getDeltaTime(): number;
  37795. private _measureFps;
  37796. /** @hidden */
  37797. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  37798. /**
  37799. * Update a dynamic index buffer
  37800. * @param indexBuffer defines the target index buffer
  37801. * @param indices defines the data to update
  37802. * @param offset defines the offset in the target index buffer where update should start
  37803. */
  37804. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  37805. /**
  37806. * Updates the sample count of a render target texture
  37807. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  37808. * @param texture defines the texture to update
  37809. * @param samples defines the sample count to set
  37810. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  37811. */
  37812. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  37813. /**
  37814. * Updates a depth texture Comparison Mode and Function.
  37815. * If the comparison Function is equal to 0, the mode will be set to none.
  37816. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  37817. * @param texture The texture to set the comparison function for
  37818. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  37819. */
  37820. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  37821. /**
  37822. * Creates a webGL buffer to use with instanciation
  37823. * @param capacity defines the size of the buffer
  37824. * @returns the webGL buffer
  37825. */
  37826. createInstancesBuffer(capacity: number): DataBuffer;
  37827. /**
  37828. * Delete a webGL buffer used with instanciation
  37829. * @param buffer defines the webGL buffer to delete
  37830. */
  37831. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  37832. private _clientWaitAsync;
  37833. /** @hidden */
  37834. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  37835. dispose(): void;
  37836. private _disableTouchAction;
  37837. /**
  37838. * Display the loading screen
  37839. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37840. */
  37841. displayLoadingUI(): void;
  37842. /**
  37843. * Hide the loading screen
  37844. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37845. */
  37846. hideLoadingUI(): void;
  37847. /**
  37848. * Gets the current loading screen object
  37849. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37850. */
  37851. get loadingScreen(): ILoadingScreen;
  37852. /**
  37853. * Sets the current loading screen object
  37854. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37855. */
  37856. set loadingScreen(loadingScreen: ILoadingScreen);
  37857. /**
  37858. * Sets the current loading screen text
  37859. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37860. */
  37861. set loadingUIText(text: string);
  37862. /**
  37863. * Sets the current loading screen background color
  37864. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37865. */
  37866. set loadingUIBackgroundColor(color: string);
  37867. /** Pointerlock and fullscreen */
  37868. /**
  37869. * Ask the browser to promote the current element to pointerlock mode
  37870. * @param element defines the DOM element to promote
  37871. */
  37872. static _RequestPointerlock(element: HTMLElement): void;
  37873. /**
  37874. * Asks the browser to exit pointerlock mode
  37875. */
  37876. static _ExitPointerlock(): void;
  37877. /**
  37878. * Ask the browser to promote the current element to fullscreen rendering mode
  37879. * @param element defines the DOM element to promote
  37880. */
  37881. static _RequestFullscreen(element: HTMLElement): void;
  37882. /**
  37883. * Asks the browser to exit fullscreen mode
  37884. */
  37885. static _ExitFullscreen(): void;
  37886. }
  37887. }
  37888. declare module BABYLON {
  37889. /**
  37890. * The engine store class is responsible to hold all the instances of Engine and Scene created
  37891. * during the life time of the application.
  37892. */
  37893. export class EngineStore {
  37894. /** Gets the list of created engines */
  37895. static Instances: Engine[];
  37896. /** @hidden */
  37897. static _LastCreatedScene: Nullable<Scene>;
  37898. /**
  37899. * Gets the latest created engine
  37900. */
  37901. static get LastCreatedEngine(): Nullable<Engine>;
  37902. /**
  37903. * Gets the latest created scene
  37904. */
  37905. static get LastCreatedScene(): Nullable<Scene>;
  37906. /**
  37907. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37908. * @ignorenaming
  37909. */
  37910. static UseFallbackTexture: boolean;
  37911. /**
  37912. * Texture content used if a texture cannot loaded
  37913. * @ignorenaming
  37914. */
  37915. static FallbackTexture: string;
  37916. }
  37917. }
  37918. declare module BABYLON {
  37919. /**
  37920. * Helper class that provides a small promise polyfill
  37921. */
  37922. export class PromisePolyfill {
  37923. /**
  37924. * Static function used to check if the polyfill is required
  37925. * If this is the case then the function will inject the polyfill to window.Promise
  37926. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  37927. */
  37928. static Apply(force?: boolean): void;
  37929. }
  37930. }
  37931. declare module BABYLON {
  37932. /**
  37933. * Interface for screenshot methods with describe argument called `size` as object with options
  37934. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  37935. */
  37936. export interface IScreenshotSize {
  37937. /**
  37938. * number in pixels for canvas height
  37939. */
  37940. height?: number;
  37941. /**
  37942. * multiplier allowing render at a higher or lower resolution
  37943. * If value is defined then height and width will be ignored and taken from camera
  37944. */
  37945. precision?: number;
  37946. /**
  37947. * number in pixels for canvas width
  37948. */
  37949. width?: number;
  37950. }
  37951. }
  37952. declare module BABYLON {
  37953. interface IColor4Like {
  37954. r: float;
  37955. g: float;
  37956. b: float;
  37957. a: float;
  37958. }
  37959. /**
  37960. * Class containing a set of static utilities functions
  37961. */
  37962. export class Tools {
  37963. /**
  37964. * Gets or sets the base URL to use to load assets
  37965. */
  37966. static get BaseUrl(): string;
  37967. static set BaseUrl(value: string);
  37968. /**
  37969. * Enable/Disable Custom HTTP Request Headers globally.
  37970. * default = false
  37971. * @see CustomRequestHeaders
  37972. */
  37973. static UseCustomRequestHeaders: boolean;
  37974. /**
  37975. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  37976. * i.e. when loading files, where the server/service expects an Authorization header
  37977. */
  37978. static CustomRequestHeaders: {
  37979. [key: string]: string;
  37980. };
  37981. /**
  37982. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  37983. */
  37984. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  37985. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  37986. /**
  37987. * Default behaviour for cors in the application.
  37988. * It can be a string if the expected behavior is identical in the entire app.
  37989. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  37990. */
  37991. static get CorsBehavior(): string | ((url: string | string[]) => string);
  37992. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  37993. /**
  37994. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37995. * @ignorenaming
  37996. */
  37997. static get UseFallbackTexture(): boolean;
  37998. static set UseFallbackTexture(value: boolean);
  37999. /**
  38000. * Use this object to register external classes like custom textures or material
  38001. * to allow the laoders to instantiate them
  38002. */
  38003. static get RegisteredExternalClasses(): {
  38004. [key: string]: Object;
  38005. };
  38006. static set RegisteredExternalClasses(classes: {
  38007. [key: string]: Object;
  38008. });
  38009. /**
  38010. * Texture content used if a texture cannot loaded
  38011. * @ignorenaming
  38012. */
  38013. static get fallbackTexture(): string;
  38014. static set fallbackTexture(value: string);
  38015. /**
  38016. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38017. * @param u defines the coordinate on X axis
  38018. * @param v defines the coordinate on Y axis
  38019. * @param width defines the width of the source data
  38020. * @param height defines the height of the source data
  38021. * @param pixels defines the source byte array
  38022. * @param color defines the output color
  38023. */
  38024. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38025. /**
  38026. * Interpolates between a and b via alpha
  38027. * @param a The lower value (returned when alpha = 0)
  38028. * @param b The upper value (returned when alpha = 1)
  38029. * @param alpha The interpolation-factor
  38030. * @return The mixed value
  38031. */
  38032. static Mix(a: number, b: number, alpha: number): number;
  38033. /**
  38034. * Tries to instantiate a new object from a given class name
  38035. * @param className defines the class name to instantiate
  38036. * @returns the new object or null if the system was not able to do the instantiation
  38037. */
  38038. static Instantiate(className: string): any;
  38039. /**
  38040. * Provides a slice function that will work even on IE
  38041. * @param data defines the array to slice
  38042. * @param start defines the start of the data (optional)
  38043. * @param end defines the end of the data (optional)
  38044. * @returns the new sliced array
  38045. */
  38046. static Slice<T>(data: T, start?: number, end?: number): T;
  38047. /**
  38048. * Polyfill for setImmediate
  38049. * @param action defines the action to execute after the current execution block
  38050. */
  38051. static SetImmediate(action: () => void): void;
  38052. /**
  38053. * Function indicating if a number is an exponent of 2
  38054. * @param value defines the value to test
  38055. * @returns true if the value is an exponent of 2
  38056. */
  38057. static IsExponentOfTwo(value: number): boolean;
  38058. private static _tmpFloatArray;
  38059. /**
  38060. * Returns the nearest 32-bit single precision float representation of a Number
  38061. * @param value A Number. If the parameter is of a different type, it will get converted
  38062. * to a number or to NaN if it cannot be converted
  38063. * @returns number
  38064. */
  38065. static FloatRound(value: number): number;
  38066. /**
  38067. * Extracts the filename from a path
  38068. * @param path defines the path to use
  38069. * @returns the filename
  38070. */
  38071. static GetFilename(path: string): string;
  38072. /**
  38073. * Extracts the "folder" part of a path (everything before the filename).
  38074. * @param uri The URI to extract the info from
  38075. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38076. * @returns The "folder" part of the path
  38077. */
  38078. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38079. /**
  38080. * Extracts text content from a DOM element hierarchy
  38081. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38082. */
  38083. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38084. /**
  38085. * Convert an angle in radians to degrees
  38086. * @param angle defines the angle to convert
  38087. * @returns the angle in degrees
  38088. */
  38089. static ToDegrees(angle: number): number;
  38090. /**
  38091. * Convert an angle in degrees to radians
  38092. * @param angle defines the angle to convert
  38093. * @returns the angle in radians
  38094. */
  38095. static ToRadians(angle: number): number;
  38096. /**
  38097. * Returns an array if obj is not an array
  38098. * @param obj defines the object to evaluate as an array
  38099. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38100. * @returns either obj directly if obj is an array or a new array containing obj
  38101. */
  38102. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38103. /**
  38104. * Gets the pointer prefix to use
  38105. * @param engine defines the engine we are finding the prefix for
  38106. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38107. */
  38108. static GetPointerPrefix(engine: Engine): string;
  38109. /**
  38110. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38111. * @param url define the url we are trying
  38112. * @param element define the dom element where to configure the cors policy
  38113. */
  38114. static SetCorsBehavior(url: string | string[], element: {
  38115. crossOrigin: string | null;
  38116. }): void;
  38117. /**
  38118. * Removes unwanted characters from an url
  38119. * @param url defines the url to clean
  38120. * @returns the cleaned url
  38121. */
  38122. static CleanUrl(url: string): string;
  38123. /**
  38124. * Gets or sets a function used to pre-process url before using them to load assets
  38125. */
  38126. static get PreprocessUrl(): (url: string) => string;
  38127. static set PreprocessUrl(processor: (url: string) => string);
  38128. /**
  38129. * Loads an image as an HTMLImageElement.
  38130. * @param input url string, ArrayBuffer, or Blob to load
  38131. * @param onLoad callback called when the image successfully loads
  38132. * @param onError callback called when the image fails to load
  38133. * @param offlineProvider offline provider for caching
  38134. * @param mimeType optional mime type
  38135. * @returns the HTMLImageElement of the loaded image
  38136. */
  38137. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38138. /**
  38139. * Loads a file from a url
  38140. * @param url url string, ArrayBuffer, or Blob to load
  38141. * @param onSuccess callback called when the file successfully loads
  38142. * @param onProgress callback called while file is loading (if the server supports this mode)
  38143. * @param offlineProvider defines the offline provider for caching
  38144. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38145. * @param onError callback called when the file fails to load
  38146. * @returns a file request object
  38147. */
  38148. 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;
  38149. /**
  38150. * Loads a file from a url
  38151. * @param url the file url to load
  38152. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38153. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38154. */
  38155. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38156. /**
  38157. * Load a script (identified by an url). When the url returns, the
  38158. * content of this file is added into a new script element, attached to the DOM (body element)
  38159. * @param scriptUrl defines the url of the script to laod
  38160. * @param onSuccess defines the callback called when the script is loaded
  38161. * @param onError defines the callback to call if an error occurs
  38162. * @param scriptId defines the id of the script element
  38163. */
  38164. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38165. /**
  38166. * Load an asynchronous script (identified by an url). When the url returns, the
  38167. * content of this file is added into a new script element, attached to the DOM (body element)
  38168. * @param scriptUrl defines the url of the script to laod
  38169. * @param scriptId defines the id of the script element
  38170. * @returns a promise request object
  38171. */
  38172. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38173. /**
  38174. * Loads a file from a blob
  38175. * @param fileToLoad defines the blob to use
  38176. * @param callback defines the callback to call when data is loaded
  38177. * @param progressCallback defines the callback to call during loading process
  38178. * @returns a file request object
  38179. */
  38180. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38181. /**
  38182. * Reads a file from a File object
  38183. * @param file defines the file to load
  38184. * @param onSuccess defines the callback to call when data is loaded
  38185. * @param onProgress defines the callback to call during loading process
  38186. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38187. * @param onError defines the callback to call when an error occurs
  38188. * @returns a file request object
  38189. */
  38190. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38191. /**
  38192. * Creates a data url from a given string content
  38193. * @param content defines the content to convert
  38194. * @returns the new data url link
  38195. */
  38196. static FileAsURL(content: string): string;
  38197. /**
  38198. * Format the given number to a specific decimal format
  38199. * @param value defines the number to format
  38200. * @param decimals defines the number of decimals to use
  38201. * @returns the formatted string
  38202. */
  38203. static Format(value: number, decimals?: number): string;
  38204. /**
  38205. * Tries to copy an object by duplicating every property
  38206. * @param source defines the source object
  38207. * @param destination defines the target object
  38208. * @param doNotCopyList defines a list of properties to avoid
  38209. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38210. */
  38211. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38212. /**
  38213. * Gets a boolean indicating if the given object has no own property
  38214. * @param obj defines the object to test
  38215. * @returns true if object has no own property
  38216. */
  38217. static IsEmpty(obj: any): boolean;
  38218. /**
  38219. * Function used to register events at window level
  38220. * @param windowElement defines the Window object to use
  38221. * @param events defines the events to register
  38222. */
  38223. static RegisterTopRootEvents(windowElement: Window, events: {
  38224. name: string;
  38225. handler: Nullable<(e: FocusEvent) => any>;
  38226. }[]): void;
  38227. /**
  38228. * Function used to unregister events from window level
  38229. * @param windowElement defines the Window object to use
  38230. * @param events defines the events to unregister
  38231. */
  38232. static UnregisterTopRootEvents(windowElement: Window, events: {
  38233. name: string;
  38234. handler: Nullable<(e: FocusEvent) => any>;
  38235. }[]): void;
  38236. /**
  38237. * @ignore
  38238. */
  38239. static _ScreenshotCanvas: HTMLCanvasElement;
  38240. /**
  38241. * Dumps the current bound framebuffer
  38242. * @param width defines the rendering width
  38243. * @param height defines the rendering height
  38244. * @param engine defines the hosting engine
  38245. * @param successCallback defines the callback triggered once the data are available
  38246. * @param mimeType defines the mime type of the result
  38247. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38248. */
  38249. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38250. /**
  38251. * Converts the canvas data to blob.
  38252. * This acts as a polyfill for browsers not supporting the to blob function.
  38253. * @param canvas Defines the canvas to extract the data from
  38254. * @param successCallback Defines the callback triggered once the data are available
  38255. * @param mimeType Defines the mime type of the result
  38256. */
  38257. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38258. /**
  38259. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38260. * @param successCallback defines the callback triggered once the data are available
  38261. * @param mimeType defines the mime type of the result
  38262. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38263. */
  38264. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38265. /**
  38266. * Downloads a blob in the browser
  38267. * @param blob defines the blob to download
  38268. * @param fileName defines the name of the downloaded file
  38269. */
  38270. static Download(blob: Blob, fileName: string): void;
  38271. /**
  38272. * Captures a screenshot of the current rendering
  38273. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38274. * @param engine defines the rendering engine
  38275. * @param camera defines the source camera
  38276. * @param size This parameter can be set to a single number or to an object with the
  38277. * following (optional) properties: precision, width, height. If a single number is passed,
  38278. * it will be used for both width and height. If an object is passed, the screenshot size
  38279. * will be derived from the parameters. The precision property is a multiplier allowing
  38280. * rendering at a higher or lower resolution
  38281. * @param successCallback defines the callback receives a single parameter which contains the
  38282. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38283. * src parameter of an <img> to display it
  38284. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38285. * Check your browser for supported MIME types
  38286. */
  38287. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38288. /**
  38289. * Captures a screenshot of the current rendering
  38290. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38291. * @param engine defines the rendering engine
  38292. * @param camera defines the source camera
  38293. * @param size This parameter can be set to a single number or to an object with the
  38294. * following (optional) properties: precision, width, height. If a single number is passed,
  38295. * it will be used for both width and height. If an object is passed, the screenshot size
  38296. * will be derived from the parameters. The precision property is a multiplier allowing
  38297. * rendering at a higher or lower resolution
  38298. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38299. * Check your browser for supported MIME types
  38300. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38301. * to the src parameter of an <img> to display it
  38302. */
  38303. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38304. /**
  38305. * Generates an image screenshot from the specified camera.
  38306. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38307. * @param engine The engine to use for rendering
  38308. * @param camera The camera to use for rendering
  38309. * @param size This parameter can be set to a single number or to an object with the
  38310. * following (optional) properties: precision, width, height. If a single number is passed,
  38311. * it will be used for both width and height. If an object is passed, the screenshot size
  38312. * will be derived from the parameters. The precision property is a multiplier allowing
  38313. * rendering at a higher or lower resolution
  38314. * @param successCallback The callback receives a single parameter which contains the
  38315. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38316. * src parameter of an <img> to display it
  38317. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38318. * Check your browser for supported MIME types
  38319. * @param samples Texture samples (default: 1)
  38320. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38321. * @param fileName A name for for the downloaded file.
  38322. */
  38323. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38324. /**
  38325. * Generates an image screenshot from the specified camera.
  38326. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38327. * @param engine The engine to use for rendering
  38328. * @param camera The camera to use for rendering
  38329. * @param size This parameter can be set to a single number or to an object with the
  38330. * following (optional) properties: precision, width, height. If a single number is passed,
  38331. * it will be used for both width and height. If an object is passed, the screenshot size
  38332. * will be derived from the parameters. The precision property is a multiplier allowing
  38333. * rendering at a higher or lower resolution
  38334. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38335. * Check your browser for supported MIME types
  38336. * @param samples Texture samples (default: 1)
  38337. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38338. * @param fileName A name for for the downloaded file.
  38339. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38340. * to the src parameter of an <img> to display it
  38341. */
  38342. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38343. /**
  38344. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38345. * Be aware Math.random() could cause collisions, but:
  38346. * "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"
  38347. * @returns a pseudo random id
  38348. */
  38349. static RandomId(): string;
  38350. /**
  38351. * Test if the given uri is a base64 string
  38352. * @param uri The uri to test
  38353. * @return True if the uri is a base64 string or false otherwise
  38354. */
  38355. static IsBase64(uri: string): boolean;
  38356. /**
  38357. * Decode the given base64 uri.
  38358. * @param uri The uri to decode
  38359. * @return The decoded base64 data.
  38360. */
  38361. static DecodeBase64(uri: string): ArrayBuffer;
  38362. /**
  38363. * Gets the absolute url.
  38364. * @param url the input url
  38365. * @return the absolute url
  38366. */
  38367. static GetAbsoluteUrl(url: string): string;
  38368. /**
  38369. * No log
  38370. */
  38371. static readonly NoneLogLevel: number;
  38372. /**
  38373. * Only message logs
  38374. */
  38375. static readonly MessageLogLevel: number;
  38376. /**
  38377. * Only warning logs
  38378. */
  38379. static readonly WarningLogLevel: number;
  38380. /**
  38381. * Only error logs
  38382. */
  38383. static readonly ErrorLogLevel: number;
  38384. /**
  38385. * All logs
  38386. */
  38387. static readonly AllLogLevel: number;
  38388. /**
  38389. * Gets a value indicating the number of loading errors
  38390. * @ignorenaming
  38391. */
  38392. static get errorsCount(): number;
  38393. /**
  38394. * Callback called when a new log is added
  38395. */
  38396. static OnNewCacheEntry: (entry: string) => void;
  38397. /**
  38398. * Log a message to the console
  38399. * @param message defines the message to log
  38400. */
  38401. static Log(message: string): void;
  38402. /**
  38403. * Write a warning message to the console
  38404. * @param message defines the message to log
  38405. */
  38406. static Warn(message: string): void;
  38407. /**
  38408. * Write an error message to the console
  38409. * @param message defines the message to log
  38410. */
  38411. static Error(message: string): void;
  38412. /**
  38413. * Gets current log cache (list of logs)
  38414. */
  38415. static get LogCache(): string;
  38416. /**
  38417. * Clears the log cache
  38418. */
  38419. static ClearLogCache(): void;
  38420. /**
  38421. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38422. */
  38423. static set LogLevels(level: number);
  38424. /**
  38425. * Checks if the window object exists
  38426. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  38427. */
  38428. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  38429. /**
  38430. * No performance log
  38431. */
  38432. static readonly PerformanceNoneLogLevel: number;
  38433. /**
  38434. * Use user marks to log performance
  38435. */
  38436. static readonly PerformanceUserMarkLogLevel: number;
  38437. /**
  38438. * Log performance to the console
  38439. */
  38440. static readonly PerformanceConsoleLogLevel: number;
  38441. private static _performance;
  38442. /**
  38443. * Sets the current performance log level
  38444. */
  38445. static set PerformanceLogLevel(level: number);
  38446. private static _StartPerformanceCounterDisabled;
  38447. private static _EndPerformanceCounterDisabled;
  38448. private static _StartUserMark;
  38449. private static _EndUserMark;
  38450. private static _StartPerformanceConsole;
  38451. private static _EndPerformanceConsole;
  38452. /**
  38453. * Starts a performance counter
  38454. */
  38455. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38456. /**
  38457. * Ends a specific performance coutner
  38458. */
  38459. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38460. /**
  38461. * Gets either window.performance.now() if supported or Date.now() else
  38462. */
  38463. static get Now(): number;
  38464. /**
  38465. * This method will return the name of the class used to create the instance of the given object.
  38466. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  38467. * @param object the object to get the class name from
  38468. * @param isType defines if the object is actually a type
  38469. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  38470. */
  38471. static GetClassName(object: any, isType?: boolean): string;
  38472. /**
  38473. * Gets the first element of an array satisfying a given predicate
  38474. * @param array defines the array to browse
  38475. * @param predicate defines the predicate to use
  38476. * @returns null if not found or the element
  38477. */
  38478. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  38479. /**
  38480. * This method will return the name of the full name of the class, including its owning module (if any).
  38481. * 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).
  38482. * @param object the object to get the class name from
  38483. * @param isType defines if the object is actually a type
  38484. * @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.
  38485. * @ignorenaming
  38486. */
  38487. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  38488. /**
  38489. * Returns a promise that resolves after the given amount of time.
  38490. * @param delay Number of milliseconds to delay
  38491. * @returns Promise that resolves after the given amount of time
  38492. */
  38493. static DelayAsync(delay: number): Promise<void>;
  38494. /**
  38495. * Utility function to detect if the current user agent is Safari
  38496. * @returns whether or not the current user agent is safari
  38497. */
  38498. static IsSafari(): boolean;
  38499. }
  38500. /**
  38501. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  38502. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  38503. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  38504. * @param name The name of the class, case should be preserved
  38505. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  38506. */
  38507. export function className(name: string, module?: string): (target: Object) => void;
  38508. /**
  38509. * An implementation of a loop for asynchronous functions.
  38510. */
  38511. export class AsyncLoop {
  38512. /**
  38513. * Defines the number of iterations for the loop
  38514. */
  38515. iterations: number;
  38516. /**
  38517. * Defines the current index of the loop.
  38518. */
  38519. index: number;
  38520. private _done;
  38521. private _fn;
  38522. private _successCallback;
  38523. /**
  38524. * Constructor.
  38525. * @param iterations the number of iterations.
  38526. * @param func the function to run each iteration
  38527. * @param successCallback the callback that will be called upon succesful execution
  38528. * @param offset starting offset.
  38529. */
  38530. constructor(
  38531. /**
  38532. * Defines the number of iterations for the loop
  38533. */
  38534. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  38535. /**
  38536. * Execute the next iteration. Must be called after the last iteration was finished.
  38537. */
  38538. executeNext(): void;
  38539. /**
  38540. * Break the loop and run the success callback.
  38541. */
  38542. breakLoop(): void;
  38543. /**
  38544. * Create and run an async loop.
  38545. * @param iterations the number of iterations.
  38546. * @param fn the function to run each iteration
  38547. * @param successCallback the callback that will be called upon succesful execution
  38548. * @param offset starting offset.
  38549. * @returns the created async loop object
  38550. */
  38551. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  38552. /**
  38553. * A for-loop that will run a given number of iterations synchronous and the rest async.
  38554. * @param iterations total number of iterations
  38555. * @param syncedIterations number of synchronous iterations in each async iteration.
  38556. * @param fn the function to call each iteration.
  38557. * @param callback a success call back that will be called when iterating stops.
  38558. * @param breakFunction a break condition (optional)
  38559. * @param timeout timeout settings for the setTimeout function. default - 0.
  38560. * @returns the created async loop object
  38561. */
  38562. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  38563. }
  38564. }
  38565. declare module BABYLON {
  38566. /**
  38567. * This class implement a typical dictionary using a string as key and the generic type T as value.
  38568. * The underlying implementation relies on an associative array to ensure the best performances.
  38569. * The value can be anything including 'null' but except 'undefined'
  38570. */
  38571. export class StringDictionary<T> {
  38572. /**
  38573. * This will clear this dictionary and copy the content from the 'source' one.
  38574. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  38575. * @param source the dictionary to take the content from and copy to this dictionary
  38576. */
  38577. copyFrom(source: StringDictionary<T>): void;
  38578. /**
  38579. * Get a value based from its key
  38580. * @param key the given key to get the matching value from
  38581. * @return the value if found, otherwise undefined is returned
  38582. */
  38583. get(key: string): T | undefined;
  38584. /**
  38585. * Get a value from its key or add it if it doesn't exist.
  38586. * This method will ensure you that a given key/data will be present in the dictionary.
  38587. * @param key the given key to get the matching value from
  38588. * @param factory the factory that will create the value if the key is not present in the dictionary.
  38589. * The factory will only be invoked if there's no data for the given key.
  38590. * @return the value corresponding to the key.
  38591. */
  38592. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  38593. /**
  38594. * Get a value from its key if present in the dictionary otherwise add it
  38595. * @param key the key to get the value from
  38596. * @param val if there's no such key/value pair in the dictionary add it with this value
  38597. * @return the value corresponding to the key
  38598. */
  38599. getOrAdd(key: string, val: T): T;
  38600. /**
  38601. * Check if there's a given key in the dictionary
  38602. * @param key the key to check for
  38603. * @return true if the key is present, false otherwise
  38604. */
  38605. contains(key: string): boolean;
  38606. /**
  38607. * Add a new key and its corresponding value
  38608. * @param key the key to add
  38609. * @param value the value corresponding to the key
  38610. * @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
  38611. */
  38612. add(key: string, value: T): boolean;
  38613. /**
  38614. * Update a specific value associated to a key
  38615. * @param key defines the key to use
  38616. * @param value defines the value to store
  38617. * @returns true if the value was updated (or false if the key was not found)
  38618. */
  38619. set(key: string, value: T): boolean;
  38620. /**
  38621. * Get the element of the given key and remove it from the dictionary
  38622. * @param key defines the key to search
  38623. * @returns the value associated with the key or null if not found
  38624. */
  38625. getAndRemove(key: string): Nullable<T>;
  38626. /**
  38627. * Remove a key/value from the dictionary.
  38628. * @param key the key to remove
  38629. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  38630. */
  38631. remove(key: string): boolean;
  38632. /**
  38633. * Clear the whole content of the dictionary
  38634. */
  38635. clear(): void;
  38636. /**
  38637. * Gets the current count
  38638. */
  38639. get count(): number;
  38640. /**
  38641. * Execute a callback on each key/val of the dictionary.
  38642. * Note that you can remove any element in this dictionary in the callback implementation
  38643. * @param callback the callback to execute on a given key/value pair
  38644. */
  38645. forEach(callback: (key: string, val: T) => void): void;
  38646. /**
  38647. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  38648. * If the callback returns null or undefined the method will iterate to the next key/value pair
  38649. * Note that you can remove any element in this dictionary in the callback implementation
  38650. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  38651. * @returns the first item
  38652. */
  38653. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  38654. private _count;
  38655. private _data;
  38656. }
  38657. }
  38658. declare module BABYLON {
  38659. /** @hidden */
  38660. export interface ICollisionCoordinator {
  38661. createCollider(): Collider;
  38662. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38663. init(scene: Scene): void;
  38664. }
  38665. /** @hidden */
  38666. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  38667. private _scene;
  38668. private _scaledPosition;
  38669. private _scaledVelocity;
  38670. private _finalPosition;
  38671. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38672. createCollider(): Collider;
  38673. init(scene: Scene): void;
  38674. private _collideWithWorld;
  38675. }
  38676. }
  38677. declare module BABYLON {
  38678. /**
  38679. * Class used to manage all inputs for the scene.
  38680. */
  38681. export class InputManager {
  38682. /** The distance in pixel that you have to move to prevent some events */
  38683. static DragMovementThreshold: number;
  38684. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  38685. static LongPressDelay: number;
  38686. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  38687. static DoubleClickDelay: number;
  38688. /** If you need to check double click without raising a single click at first click, enable this flag */
  38689. static ExclusiveDoubleClickMode: boolean;
  38690. private _wheelEventName;
  38691. private _onPointerMove;
  38692. private _onPointerDown;
  38693. private _onPointerUp;
  38694. private _initClickEvent;
  38695. private _initActionManager;
  38696. private _delayedSimpleClick;
  38697. private _delayedSimpleClickTimeout;
  38698. private _previousDelayedSimpleClickTimeout;
  38699. private _meshPickProceed;
  38700. private _previousButtonPressed;
  38701. private _currentPickResult;
  38702. private _previousPickResult;
  38703. private _totalPointersPressed;
  38704. private _doubleClickOccured;
  38705. private _pointerOverMesh;
  38706. private _pickedDownMesh;
  38707. private _pickedUpMesh;
  38708. private _pointerX;
  38709. private _pointerY;
  38710. private _unTranslatedPointerX;
  38711. private _unTranslatedPointerY;
  38712. private _startingPointerPosition;
  38713. private _previousStartingPointerPosition;
  38714. private _startingPointerTime;
  38715. private _previousStartingPointerTime;
  38716. private _pointerCaptures;
  38717. private _onKeyDown;
  38718. private _onKeyUp;
  38719. private _onCanvasFocusObserver;
  38720. private _onCanvasBlurObserver;
  38721. private _scene;
  38722. /**
  38723. * Creates a new InputManager
  38724. * @param scene defines the hosting scene
  38725. */
  38726. constructor(scene: Scene);
  38727. /**
  38728. * Gets the mesh that is currently under the pointer
  38729. */
  38730. get meshUnderPointer(): Nullable<AbstractMesh>;
  38731. /**
  38732. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  38733. */
  38734. get unTranslatedPointer(): Vector2;
  38735. /**
  38736. * Gets or sets the current on-screen X position of the pointer
  38737. */
  38738. get pointerX(): number;
  38739. set pointerX(value: number);
  38740. /**
  38741. * Gets or sets the current on-screen Y position of the pointer
  38742. */
  38743. get pointerY(): number;
  38744. set pointerY(value: number);
  38745. private _updatePointerPosition;
  38746. private _processPointerMove;
  38747. private _setRayOnPointerInfo;
  38748. private _checkPrePointerObservable;
  38749. /**
  38750. * Use this method to simulate a pointer move on a mesh
  38751. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38752. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38753. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38754. */
  38755. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38756. /**
  38757. * Use this method to simulate a pointer down on a mesh
  38758. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38759. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38760. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38761. */
  38762. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38763. private _processPointerDown;
  38764. /** @hidden */
  38765. _isPointerSwiping(): boolean;
  38766. /**
  38767. * Use this method to simulate a pointer up on a mesh
  38768. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38769. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38770. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38771. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  38772. */
  38773. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  38774. private _processPointerUp;
  38775. /**
  38776. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  38777. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  38778. * @returns true if the pointer was captured
  38779. */
  38780. isPointerCaptured(pointerId?: number): boolean;
  38781. /**
  38782. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  38783. * @param attachUp defines if you want to attach events to pointerup
  38784. * @param attachDown defines if you want to attach events to pointerdown
  38785. * @param attachMove defines if you want to attach events to pointermove
  38786. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  38787. */
  38788. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  38789. /**
  38790. * Detaches all event handlers
  38791. */
  38792. detachControl(): void;
  38793. /**
  38794. * Force the value of meshUnderPointer
  38795. * @param mesh defines the mesh to use
  38796. */
  38797. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  38798. /**
  38799. * Gets the mesh under the pointer
  38800. * @returns a Mesh or null if no mesh is under the pointer
  38801. */
  38802. getPointerOverMesh(): Nullable<AbstractMesh>;
  38803. }
  38804. }
  38805. declare module BABYLON {
  38806. /**
  38807. * This class defines the direct association between an animation and a target
  38808. */
  38809. export class TargetedAnimation {
  38810. /**
  38811. * Animation to perform
  38812. */
  38813. animation: Animation;
  38814. /**
  38815. * Target to animate
  38816. */
  38817. target: any;
  38818. /**
  38819. * Returns the string "TargetedAnimation"
  38820. * @returns "TargetedAnimation"
  38821. */
  38822. getClassName(): string;
  38823. /**
  38824. * Serialize the object
  38825. * @returns the JSON object representing the current entity
  38826. */
  38827. serialize(): any;
  38828. }
  38829. /**
  38830. * Use this class to create coordinated animations on multiple targets
  38831. */
  38832. export class AnimationGroup implements IDisposable {
  38833. /** The name of the animation group */
  38834. name: string;
  38835. private _scene;
  38836. private _targetedAnimations;
  38837. private _animatables;
  38838. private _from;
  38839. private _to;
  38840. private _isStarted;
  38841. private _isPaused;
  38842. private _speedRatio;
  38843. private _loopAnimation;
  38844. private _isAdditive;
  38845. /**
  38846. * Gets or sets the unique id of the node
  38847. */
  38848. uniqueId: number;
  38849. /**
  38850. * This observable will notify when one animation have ended
  38851. */
  38852. onAnimationEndObservable: Observable<TargetedAnimation>;
  38853. /**
  38854. * Observer raised when one animation loops
  38855. */
  38856. onAnimationLoopObservable: Observable<TargetedAnimation>;
  38857. /**
  38858. * Observer raised when all animations have looped
  38859. */
  38860. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  38861. /**
  38862. * This observable will notify when all animations have ended.
  38863. */
  38864. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  38865. /**
  38866. * This observable will notify when all animations have paused.
  38867. */
  38868. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  38869. /**
  38870. * This observable will notify when all animations are playing.
  38871. */
  38872. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  38873. /**
  38874. * Gets the first frame
  38875. */
  38876. get from(): number;
  38877. /**
  38878. * Gets the last frame
  38879. */
  38880. get to(): number;
  38881. /**
  38882. * Define if the animations are started
  38883. */
  38884. get isStarted(): boolean;
  38885. /**
  38886. * Gets a value indicating that the current group is playing
  38887. */
  38888. get isPlaying(): boolean;
  38889. /**
  38890. * Gets or sets the speed ratio to use for all animations
  38891. */
  38892. get speedRatio(): number;
  38893. /**
  38894. * Gets or sets the speed ratio to use for all animations
  38895. */
  38896. set speedRatio(value: number);
  38897. /**
  38898. * Gets or sets if all animations should loop or not
  38899. */
  38900. get loopAnimation(): boolean;
  38901. set loopAnimation(value: boolean);
  38902. /**
  38903. * Gets or sets if all animations should be evaluated additively
  38904. */
  38905. get isAdditive(): boolean;
  38906. set isAdditive(value: boolean);
  38907. /**
  38908. * Gets the targeted animations for this animation group
  38909. */
  38910. get targetedAnimations(): Array<TargetedAnimation>;
  38911. /**
  38912. * returning the list of animatables controlled by this animation group.
  38913. */
  38914. get animatables(): Array<Animatable>;
  38915. /**
  38916. * Gets the list of target animations
  38917. */
  38918. get children(): TargetedAnimation[];
  38919. /**
  38920. * Instantiates a new Animation Group.
  38921. * This helps managing several animations at once.
  38922. * @see https://doc.babylonjs.com/how_to/group
  38923. * @param name Defines the name of the group
  38924. * @param scene Defines the scene the group belongs to
  38925. */
  38926. constructor(
  38927. /** The name of the animation group */
  38928. name: string, scene?: Nullable<Scene>);
  38929. /**
  38930. * Add an animation (with its target) in the group
  38931. * @param animation defines the animation we want to add
  38932. * @param target defines the target of the animation
  38933. * @returns the TargetedAnimation object
  38934. */
  38935. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  38936. /**
  38937. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  38938. * It can add constant keys at begin or end
  38939. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  38940. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  38941. * @returns the animation group
  38942. */
  38943. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  38944. private _animationLoopCount;
  38945. private _animationLoopFlags;
  38946. private _processLoop;
  38947. /**
  38948. * Start all animations on given targets
  38949. * @param loop defines if animations must loop
  38950. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  38951. * @param from defines the from key (optional)
  38952. * @param to defines the to key (optional)
  38953. * @param isAdditive defines the additive state for the resulting animatables (optional)
  38954. * @returns the current animation group
  38955. */
  38956. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  38957. /**
  38958. * Pause all animations
  38959. * @returns the animation group
  38960. */
  38961. pause(): AnimationGroup;
  38962. /**
  38963. * Play all animations to initial state
  38964. * This function will start() the animations if they were not started or will restart() them if they were paused
  38965. * @param loop defines if animations must loop
  38966. * @returns the animation group
  38967. */
  38968. play(loop?: boolean): AnimationGroup;
  38969. /**
  38970. * Reset all animations to initial state
  38971. * @returns the animation group
  38972. */
  38973. reset(): AnimationGroup;
  38974. /**
  38975. * Restart animations from key 0
  38976. * @returns the animation group
  38977. */
  38978. restart(): AnimationGroup;
  38979. /**
  38980. * Stop all animations
  38981. * @returns the animation group
  38982. */
  38983. stop(): AnimationGroup;
  38984. /**
  38985. * Set animation weight for all animatables
  38986. * @param weight defines the weight to use
  38987. * @return the animationGroup
  38988. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  38989. */
  38990. setWeightForAllAnimatables(weight: number): AnimationGroup;
  38991. /**
  38992. * Synchronize and normalize all animatables with a source animatable
  38993. * @param root defines the root animatable to synchronize with
  38994. * @return the animationGroup
  38995. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  38996. */
  38997. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  38998. /**
  38999. * Goes to a specific frame in this animation group
  39000. * @param frame the frame number to go to
  39001. * @return the animationGroup
  39002. */
  39003. goToFrame(frame: number): AnimationGroup;
  39004. /**
  39005. * Dispose all associated resources
  39006. */
  39007. dispose(): void;
  39008. private _checkAnimationGroupEnded;
  39009. /**
  39010. * Clone the current animation group and returns a copy
  39011. * @param newName defines the name of the new group
  39012. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39013. * @returns the new aniamtion group
  39014. */
  39015. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39016. /**
  39017. * Serializes the animationGroup to an object
  39018. * @returns Serialized object
  39019. */
  39020. serialize(): any;
  39021. /**
  39022. * Returns a new AnimationGroup object parsed from the source provided.
  39023. * @param parsedAnimationGroup defines the source
  39024. * @param scene defines the scene that will receive the animationGroup
  39025. * @returns a new AnimationGroup
  39026. */
  39027. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39028. /**
  39029. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39030. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39031. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39032. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39033. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39034. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39035. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39036. */
  39037. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39038. /**
  39039. * Returns the string "AnimationGroup"
  39040. * @returns "AnimationGroup"
  39041. */
  39042. getClassName(): string;
  39043. /**
  39044. * Creates a detailled string about the object
  39045. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39046. * @returns a string representing the object
  39047. */
  39048. toString(fullDetails?: boolean): string;
  39049. }
  39050. }
  39051. declare module BABYLON {
  39052. /**
  39053. * Define an interface for all classes that will hold resources
  39054. */
  39055. export interface IDisposable {
  39056. /**
  39057. * Releases all held resources
  39058. */
  39059. dispose(): void;
  39060. }
  39061. /** Interface defining initialization parameters for Scene class */
  39062. export interface SceneOptions {
  39063. /**
  39064. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39065. * It will improve performance when the number of geometries becomes important.
  39066. */
  39067. useGeometryUniqueIdsMap?: boolean;
  39068. /**
  39069. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39070. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39071. */
  39072. useMaterialMeshMap?: boolean;
  39073. /**
  39074. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39075. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39076. */
  39077. useClonedMeshMap?: boolean;
  39078. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39079. virtual?: boolean;
  39080. }
  39081. /**
  39082. * Represents a scene to be rendered by the engine.
  39083. * @see https://doc.babylonjs.com/features/scene
  39084. */
  39085. export class Scene extends AbstractScene implements IAnimatable {
  39086. /** The fog is deactivated */
  39087. static readonly FOGMODE_NONE: number;
  39088. /** The fog density is following an exponential function */
  39089. static readonly FOGMODE_EXP: number;
  39090. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39091. static readonly FOGMODE_EXP2: number;
  39092. /** The fog density is following a linear function. */
  39093. static readonly FOGMODE_LINEAR: number;
  39094. /**
  39095. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39096. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39097. */
  39098. static MinDeltaTime: number;
  39099. /**
  39100. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39101. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39102. */
  39103. static MaxDeltaTime: number;
  39104. /**
  39105. * Factory used to create the default material.
  39106. * @param name The name of the material to create
  39107. * @param scene The scene to create the material for
  39108. * @returns The default material
  39109. */
  39110. static DefaultMaterialFactory(scene: Scene): Material;
  39111. /**
  39112. * Factory used to create the a collision coordinator.
  39113. * @returns The collision coordinator
  39114. */
  39115. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39116. /** @hidden */
  39117. _inputManager: InputManager;
  39118. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39119. cameraToUseForPointers: Nullable<Camera>;
  39120. /** @hidden */
  39121. readonly _isScene: boolean;
  39122. /** @hidden */
  39123. _blockEntityCollection: boolean;
  39124. /**
  39125. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39126. */
  39127. autoClear: boolean;
  39128. /**
  39129. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39130. */
  39131. autoClearDepthAndStencil: boolean;
  39132. /**
  39133. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39134. */
  39135. clearColor: Color4;
  39136. /**
  39137. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39138. */
  39139. ambientColor: Color3;
  39140. /**
  39141. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39142. * It should only be one of the following (if not the default embedded one):
  39143. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39144. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39145. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39146. * The material properties need to be setup according to the type of texture in use.
  39147. */
  39148. environmentBRDFTexture: BaseTexture;
  39149. /** @hidden */
  39150. protected _environmentTexture: Nullable<BaseTexture>;
  39151. /**
  39152. * Texture used in all pbr material as the reflection texture.
  39153. * As in the majority of the scene they are the same (exception for multi room and so on),
  39154. * this is easier to reference from here than from all the materials.
  39155. */
  39156. get environmentTexture(): Nullable<BaseTexture>;
  39157. /**
  39158. * Texture used in all pbr material as the reflection texture.
  39159. * As in the majority of the scene they are the same (exception for multi room and so on),
  39160. * this is easier to set here than in all the materials.
  39161. */
  39162. set environmentTexture(value: Nullable<BaseTexture>);
  39163. /** @hidden */
  39164. protected _environmentIntensity: number;
  39165. /**
  39166. * Intensity of the environment in all pbr material.
  39167. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39168. * As in the majority of the scene they are the same (exception for multi room and so on),
  39169. * this is easier to reference from here than from all the materials.
  39170. */
  39171. get environmentIntensity(): number;
  39172. /**
  39173. * Intensity of the environment in all pbr material.
  39174. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39175. * As in the majority of the scene they are the same (exception for multi room and so on),
  39176. * this is easier to set here than in all the materials.
  39177. */
  39178. set environmentIntensity(value: number);
  39179. /** @hidden */
  39180. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39181. /**
  39182. * Default image processing configuration used either in the rendering
  39183. * Forward main pass or through the imageProcessingPostProcess if present.
  39184. * As in the majority of the scene they are the same (exception for multi camera),
  39185. * this is easier to reference from here than from all the materials and post process.
  39186. *
  39187. * No setter as we it is a shared configuration, you can set the values instead.
  39188. */
  39189. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39190. private _forceWireframe;
  39191. /**
  39192. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39193. */
  39194. set forceWireframe(value: boolean);
  39195. get forceWireframe(): boolean;
  39196. private _skipFrustumClipping;
  39197. /**
  39198. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39199. */
  39200. set skipFrustumClipping(value: boolean);
  39201. get skipFrustumClipping(): boolean;
  39202. private _forcePointsCloud;
  39203. /**
  39204. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39205. */
  39206. set forcePointsCloud(value: boolean);
  39207. get forcePointsCloud(): boolean;
  39208. /**
  39209. * Gets or sets the active clipplane 1
  39210. */
  39211. clipPlane: Nullable<Plane>;
  39212. /**
  39213. * Gets or sets the active clipplane 2
  39214. */
  39215. clipPlane2: Nullable<Plane>;
  39216. /**
  39217. * Gets or sets the active clipplane 3
  39218. */
  39219. clipPlane3: Nullable<Plane>;
  39220. /**
  39221. * Gets or sets the active clipplane 4
  39222. */
  39223. clipPlane4: Nullable<Plane>;
  39224. /**
  39225. * Gets or sets the active clipplane 5
  39226. */
  39227. clipPlane5: Nullable<Plane>;
  39228. /**
  39229. * Gets or sets the active clipplane 6
  39230. */
  39231. clipPlane6: Nullable<Plane>;
  39232. /**
  39233. * Gets or sets a boolean indicating if animations are enabled
  39234. */
  39235. animationsEnabled: boolean;
  39236. private _animationPropertiesOverride;
  39237. /**
  39238. * Gets or sets the animation properties override
  39239. */
  39240. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39241. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39242. /**
  39243. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39244. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39245. */
  39246. useConstantAnimationDeltaTime: boolean;
  39247. /**
  39248. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39249. * Please note that it requires to run a ray cast through the scene on every frame
  39250. */
  39251. constantlyUpdateMeshUnderPointer: boolean;
  39252. /**
  39253. * Defines the HTML cursor to use when hovering over interactive elements
  39254. */
  39255. hoverCursor: string;
  39256. /**
  39257. * Defines the HTML default cursor to use (empty by default)
  39258. */
  39259. defaultCursor: string;
  39260. /**
  39261. * Defines whether cursors are handled by the scene.
  39262. */
  39263. doNotHandleCursors: boolean;
  39264. /**
  39265. * This is used to call preventDefault() on pointer down
  39266. * in order to block unwanted artifacts like system double clicks
  39267. */
  39268. preventDefaultOnPointerDown: boolean;
  39269. /**
  39270. * This is used to call preventDefault() on pointer up
  39271. * in order to block unwanted artifacts like system double clicks
  39272. */
  39273. preventDefaultOnPointerUp: boolean;
  39274. /**
  39275. * Gets or sets user defined metadata
  39276. */
  39277. metadata: any;
  39278. /**
  39279. * For internal use only. Please do not use.
  39280. */
  39281. reservedDataStore: any;
  39282. /**
  39283. * Gets the name of the plugin used to load this scene (null by default)
  39284. */
  39285. loadingPluginName: string;
  39286. /**
  39287. * Use this array to add regular expressions used to disable offline support for specific urls
  39288. */
  39289. disableOfflineSupportExceptionRules: RegExp[];
  39290. /**
  39291. * An event triggered when the scene is disposed.
  39292. */
  39293. onDisposeObservable: Observable<Scene>;
  39294. private _onDisposeObserver;
  39295. /** Sets a function to be executed when this scene is disposed. */
  39296. set onDispose(callback: () => void);
  39297. /**
  39298. * An event triggered before rendering the scene (right after animations and physics)
  39299. */
  39300. onBeforeRenderObservable: Observable<Scene>;
  39301. private _onBeforeRenderObserver;
  39302. /** Sets a function to be executed before rendering this scene */
  39303. set beforeRender(callback: Nullable<() => void>);
  39304. /**
  39305. * An event triggered after rendering the scene
  39306. */
  39307. onAfterRenderObservable: Observable<Scene>;
  39308. /**
  39309. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39310. */
  39311. onAfterRenderCameraObservable: Observable<Camera>;
  39312. private _onAfterRenderObserver;
  39313. /** Sets a function to be executed after rendering this scene */
  39314. set afterRender(callback: Nullable<() => void>);
  39315. /**
  39316. * An event triggered before animating the scene
  39317. */
  39318. onBeforeAnimationsObservable: Observable<Scene>;
  39319. /**
  39320. * An event triggered after animations processing
  39321. */
  39322. onAfterAnimationsObservable: Observable<Scene>;
  39323. /**
  39324. * An event triggered before draw calls are ready to be sent
  39325. */
  39326. onBeforeDrawPhaseObservable: Observable<Scene>;
  39327. /**
  39328. * An event triggered after draw calls have been sent
  39329. */
  39330. onAfterDrawPhaseObservable: Observable<Scene>;
  39331. /**
  39332. * An event triggered when the scene is ready
  39333. */
  39334. onReadyObservable: Observable<Scene>;
  39335. /**
  39336. * An event triggered before rendering a camera
  39337. */
  39338. onBeforeCameraRenderObservable: Observable<Camera>;
  39339. private _onBeforeCameraRenderObserver;
  39340. /** Sets a function to be executed before rendering a camera*/
  39341. set beforeCameraRender(callback: () => void);
  39342. /**
  39343. * An event triggered after rendering a camera
  39344. */
  39345. onAfterCameraRenderObservable: Observable<Camera>;
  39346. private _onAfterCameraRenderObserver;
  39347. /** Sets a function to be executed after rendering a camera*/
  39348. set afterCameraRender(callback: () => void);
  39349. /**
  39350. * An event triggered when active meshes evaluation is about to start
  39351. */
  39352. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  39353. /**
  39354. * An event triggered when active meshes evaluation is done
  39355. */
  39356. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  39357. /**
  39358. * An event triggered when particles rendering is about to start
  39359. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39360. */
  39361. onBeforeParticlesRenderingObservable: Observable<Scene>;
  39362. /**
  39363. * An event triggered when particles rendering is done
  39364. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39365. */
  39366. onAfterParticlesRenderingObservable: Observable<Scene>;
  39367. /**
  39368. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  39369. */
  39370. onDataLoadedObservable: Observable<Scene>;
  39371. /**
  39372. * An event triggered when a camera is created
  39373. */
  39374. onNewCameraAddedObservable: Observable<Camera>;
  39375. /**
  39376. * An event triggered when a camera is removed
  39377. */
  39378. onCameraRemovedObservable: Observable<Camera>;
  39379. /**
  39380. * An event triggered when a light is created
  39381. */
  39382. onNewLightAddedObservable: Observable<Light>;
  39383. /**
  39384. * An event triggered when a light is removed
  39385. */
  39386. onLightRemovedObservable: Observable<Light>;
  39387. /**
  39388. * An event triggered when a geometry is created
  39389. */
  39390. onNewGeometryAddedObservable: Observable<Geometry>;
  39391. /**
  39392. * An event triggered when a geometry is removed
  39393. */
  39394. onGeometryRemovedObservable: Observable<Geometry>;
  39395. /**
  39396. * An event triggered when a transform node is created
  39397. */
  39398. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  39399. /**
  39400. * An event triggered when a transform node is removed
  39401. */
  39402. onTransformNodeRemovedObservable: Observable<TransformNode>;
  39403. /**
  39404. * An event triggered when a mesh is created
  39405. */
  39406. onNewMeshAddedObservable: Observable<AbstractMesh>;
  39407. /**
  39408. * An event triggered when a mesh is removed
  39409. */
  39410. onMeshRemovedObservable: Observable<AbstractMesh>;
  39411. /**
  39412. * An event triggered when a skeleton is created
  39413. */
  39414. onNewSkeletonAddedObservable: Observable<Skeleton>;
  39415. /**
  39416. * An event triggered when a skeleton is removed
  39417. */
  39418. onSkeletonRemovedObservable: Observable<Skeleton>;
  39419. /**
  39420. * An event triggered when a material is created
  39421. */
  39422. onNewMaterialAddedObservable: Observable<Material>;
  39423. /**
  39424. * An event triggered when a material is removed
  39425. */
  39426. onMaterialRemovedObservable: Observable<Material>;
  39427. /**
  39428. * An event triggered when a texture is created
  39429. */
  39430. onNewTextureAddedObservable: Observable<BaseTexture>;
  39431. /**
  39432. * An event triggered when a texture is removed
  39433. */
  39434. onTextureRemovedObservable: Observable<BaseTexture>;
  39435. /**
  39436. * An event triggered when render targets are about to be rendered
  39437. * Can happen multiple times per frame.
  39438. */
  39439. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  39440. /**
  39441. * An event triggered when render targets were rendered.
  39442. * Can happen multiple times per frame.
  39443. */
  39444. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  39445. /**
  39446. * An event triggered before calculating deterministic simulation step
  39447. */
  39448. onBeforeStepObservable: Observable<Scene>;
  39449. /**
  39450. * An event triggered after calculating deterministic simulation step
  39451. */
  39452. onAfterStepObservable: Observable<Scene>;
  39453. /**
  39454. * An event triggered when the activeCamera property is updated
  39455. */
  39456. onActiveCameraChanged: Observable<Scene>;
  39457. /**
  39458. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  39459. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39460. * 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)
  39461. */
  39462. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39463. /**
  39464. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  39465. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39466. * 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)
  39467. */
  39468. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39469. /**
  39470. * This Observable will when a mesh has been imported into the scene.
  39471. */
  39472. onMeshImportedObservable: Observable<AbstractMesh>;
  39473. /**
  39474. * This Observable will when an animation file has been imported into the scene.
  39475. */
  39476. onAnimationFileImportedObservable: Observable<Scene>;
  39477. /**
  39478. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  39479. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  39480. */
  39481. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  39482. /** @hidden */
  39483. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  39484. /**
  39485. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  39486. */
  39487. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  39488. /**
  39489. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  39490. */
  39491. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  39492. /**
  39493. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  39494. */
  39495. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  39496. /** Callback called when a pointer move is detected */
  39497. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39498. /** Callback called when a pointer down is detected */
  39499. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39500. /** Callback called when a pointer up is detected */
  39501. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  39502. /** Callback called when a pointer pick is detected */
  39503. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  39504. /**
  39505. * 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).
  39506. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  39507. */
  39508. onPrePointerObservable: Observable<PointerInfoPre>;
  39509. /**
  39510. * Observable event triggered each time an input event is received from the rendering canvas
  39511. */
  39512. onPointerObservable: Observable<PointerInfo>;
  39513. /**
  39514. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  39515. */
  39516. get unTranslatedPointer(): Vector2;
  39517. /**
  39518. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  39519. */
  39520. static get DragMovementThreshold(): number;
  39521. static set DragMovementThreshold(value: number);
  39522. /**
  39523. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  39524. */
  39525. static get LongPressDelay(): number;
  39526. static set LongPressDelay(value: number);
  39527. /**
  39528. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  39529. */
  39530. static get DoubleClickDelay(): number;
  39531. static set DoubleClickDelay(value: number);
  39532. /** If you need to check double click without raising a single click at first click, enable this flag */
  39533. static get ExclusiveDoubleClickMode(): boolean;
  39534. static set ExclusiveDoubleClickMode(value: boolean);
  39535. /** @hidden */
  39536. _mirroredCameraPosition: Nullable<Vector3>;
  39537. /**
  39538. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  39539. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  39540. */
  39541. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  39542. /**
  39543. * Observable event triggered each time an keyboard event is received from the hosting window
  39544. */
  39545. onKeyboardObservable: Observable<KeyboardInfo>;
  39546. private _useRightHandedSystem;
  39547. /**
  39548. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  39549. */
  39550. set useRightHandedSystem(value: boolean);
  39551. get useRightHandedSystem(): boolean;
  39552. private _timeAccumulator;
  39553. private _currentStepId;
  39554. private _currentInternalStep;
  39555. /**
  39556. * Sets the step Id used by deterministic lock step
  39557. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39558. * @param newStepId defines the step Id
  39559. */
  39560. setStepId(newStepId: number): void;
  39561. /**
  39562. * Gets the step Id used by deterministic lock step
  39563. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39564. * @returns the step Id
  39565. */
  39566. getStepId(): number;
  39567. /**
  39568. * Gets the internal step used by deterministic lock step
  39569. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39570. * @returns the internal step
  39571. */
  39572. getInternalStep(): number;
  39573. private _fogEnabled;
  39574. /**
  39575. * Gets or sets a boolean indicating if fog is enabled on this scene
  39576. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39577. * (Default is true)
  39578. */
  39579. set fogEnabled(value: boolean);
  39580. get fogEnabled(): boolean;
  39581. private _fogMode;
  39582. /**
  39583. * Gets or sets the fog mode to use
  39584. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39585. * | mode | value |
  39586. * | --- | --- |
  39587. * | FOGMODE_NONE | 0 |
  39588. * | FOGMODE_EXP | 1 |
  39589. * | FOGMODE_EXP2 | 2 |
  39590. * | FOGMODE_LINEAR | 3 |
  39591. */
  39592. set fogMode(value: number);
  39593. get fogMode(): number;
  39594. /**
  39595. * Gets or sets the fog color to use
  39596. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39597. * (Default is Color3(0.2, 0.2, 0.3))
  39598. */
  39599. fogColor: Color3;
  39600. /**
  39601. * Gets or sets the fog density to use
  39602. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39603. * (Default is 0.1)
  39604. */
  39605. fogDensity: number;
  39606. /**
  39607. * Gets or sets the fog start distance to use
  39608. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39609. * (Default is 0)
  39610. */
  39611. fogStart: number;
  39612. /**
  39613. * Gets or sets the fog end distance to use
  39614. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39615. * (Default is 1000)
  39616. */
  39617. fogEnd: number;
  39618. /**
  39619. * Flag indicating that the frame buffer binding is handled by another component
  39620. */
  39621. prePass: boolean;
  39622. private _shadowsEnabled;
  39623. /**
  39624. * Gets or sets a boolean indicating if shadows are enabled on this scene
  39625. */
  39626. set shadowsEnabled(value: boolean);
  39627. get shadowsEnabled(): boolean;
  39628. private _lightsEnabled;
  39629. /**
  39630. * Gets or sets a boolean indicating if lights are enabled on this scene
  39631. */
  39632. set lightsEnabled(value: boolean);
  39633. get lightsEnabled(): boolean;
  39634. /** All of the active cameras added to this scene. */
  39635. activeCameras: Camera[];
  39636. /** @hidden */
  39637. _activeCamera: Nullable<Camera>;
  39638. /** Gets or sets the current active camera */
  39639. get activeCamera(): Nullable<Camera>;
  39640. set activeCamera(value: Nullable<Camera>);
  39641. private _defaultMaterial;
  39642. /** The default material used on meshes when no material is affected */
  39643. get defaultMaterial(): Material;
  39644. /** The default material used on meshes when no material is affected */
  39645. set defaultMaterial(value: Material);
  39646. private _texturesEnabled;
  39647. /**
  39648. * Gets or sets a boolean indicating if textures are enabled on this scene
  39649. */
  39650. set texturesEnabled(value: boolean);
  39651. get texturesEnabled(): boolean;
  39652. /**
  39653. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  39654. */
  39655. physicsEnabled: boolean;
  39656. /**
  39657. * Gets or sets a boolean indicating if particles are enabled on this scene
  39658. */
  39659. particlesEnabled: boolean;
  39660. /**
  39661. * Gets or sets a boolean indicating if sprites are enabled on this scene
  39662. */
  39663. spritesEnabled: boolean;
  39664. private _skeletonsEnabled;
  39665. /**
  39666. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  39667. */
  39668. set skeletonsEnabled(value: boolean);
  39669. get skeletonsEnabled(): boolean;
  39670. /**
  39671. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  39672. */
  39673. lensFlaresEnabled: boolean;
  39674. /**
  39675. * Gets or sets a boolean indicating if collisions are enabled on this scene
  39676. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39677. */
  39678. collisionsEnabled: boolean;
  39679. private _collisionCoordinator;
  39680. /** @hidden */
  39681. get collisionCoordinator(): ICollisionCoordinator;
  39682. /**
  39683. * Defines the gravity applied to this scene (used only for collisions)
  39684. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39685. */
  39686. gravity: Vector3;
  39687. /**
  39688. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  39689. */
  39690. postProcessesEnabled: boolean;
  39691. /**
  39692. * The list of postprocesses added to the scene
  39693. */
  39694. postProcesses: PostProcess[];
  39695. /**
  39696. * Gets the current postprocess manager
  39697. */
  39698. postProcessManager: PostProcessManager;
  39699. /**
  39700. * Gets or sets a boolean indicating if render targets are enabled on this scene
  39701. */
  39702. renderTargetsEnabled: boolean;
  39703. /**
  39704. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  39705. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  39706. */
  39707. dumpNextRenderTargets: boolean;
  39708. /**
  39709. * The list of user defined render targets added to the scene
  39710. */
  39711. customRenderTargets: RenderTargetTexture[];
  39712. /**
  39713. * Defines if texture loading must be delayed
  39714. * If true, textures will only be loaded when they need to be rendered
  39715. */
  39716. useDelayedTextureLoading: boolean;
  39717. /**
  39718. * Gets the list of meshes imported to the scene through SceneLoader
  39719. */
  39720. importedMeshesFiles: String[];
  39721. /**
  39722. * Gets or sets a boolean indicating if probes are enabled on this scene
  39723. */
  39724. probesEnabled: boolean;
  39725. /**
  39726. * Gets or sets the current offline provider to use to store scene data
  39727. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  39728. */
  39729. offlineProvider: IOfflineProvider;
  39730. /**
  39731. * Gets or sets the action manager associated with the scene
  39732. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  39733. */
  39734. actionManager: AbstractActionManager;
  39735. private _meshesForIntersections;
  39736. /**
  39737. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  39738. */
  39739. proceduralTexturesEnabled: boolean;
  39740. private _engine;
  39741. private _totalVertices;
  39742. /** @hidden */
  39743. _activeIndices: PerfCounter;
  39744. /** @hidden */
  39745. _activeParticles: PerfCounter;
  39746. /** @hidden */
  39747. _activeBones: PerfCounter;
  39748. private _animationRatio;
  39749. /** @hidden */
  39750. _animationTimeLast: number;
  39751. /** @hidden */
  39752. _animationTime: number;
  39753. /**
  39754. * Gets or sets a general scale for animation speed
  39755. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  39756. */
  39757. animationTimeScale: number;
  39758. /** @hidden */
  39759. _cachedMaterial: Nullable<Material>;
  39760. /** @hidden */
  39761. _cachedEffect: Nullable<Effect>;
  39762. /** @hidden */
  39763. _cachedVisibility: Nullable<number>;
  39764. private _renderId;
  39765. private _frameId;
  39766. private _executeWhenReadyTimeoutId;
  39767. private _intermediateRendering;
  39768. private _viewUpdateFlag;
  39769. private _projectionUpdateFlag;
  39770. /** @hidden */
  39771. _toBeDisposed: Nullable<IDisposable>[];
  39772. private _activeRequests;
  39773. /** @hidden */
  39774. _pendingData: any[];
  39775. private _isDisposed;
  39776. /**
  39777. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  39778. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  39779. */
  39780. dispatchAllSubMeshesOfActiveMeshes: boolean;
  39781. private _activeMeshes;
  39782. private _processedMaterials;
  39783. private _renderTargets;
  39784. /** @hidden */
  39785. _activeParticleSystems: SmartArray<IParticleSystem>;
  39786. private _activeSkeletons;
  39787. private _softwareSkinnedMeshes;
  39788. private _renderingManager;
  39789. /** @hidden */
  39790. _activeAnimatables: Animatable[];
  39791. private _transformMatrix;
  39792. private _sceneUbo;
  39793. /** @hidden */
  39794. _viewMatrix: Matrix;
  39795. private _projectionMatrix;
  39796. /** @hidden */
  39797. _forcedViewPosition: Nullable<Vector3>;
  39798. /** @hidden */
  39799. _frustumPlanes: Plane[];
  39800. /**
  39801. * Gets the list of frustum planes (built from the active camera)
  39802. */
  39803. get frustumPlanes(): Plane[];
  39804. /**
  39805. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  39806. * This is useful if there are more lights that the maximum simulteanous authorized
  39807. */
  39808. requireLightSorting: boolean;
  39809. /** @hidden */
  39810. readonly useMaterialMeshMap: boolean;
  39811. /** @hidden */
  39812. readonly useClonedMeshMap: boolean;
  39813. private _externalData;
  39814. private _uid;
  39815. /**
  39816. * @hidden
  39817. * Backing store of defined scene components.
  39818. */
  39819. _components: ISceneComponent[];
  39820. /**
  39821. * @hidden
  39822. * Backing store of defined scene components.
  39823. */
  39824. _serializableComponents: ISceneSerializableComponent[];
  39825. /**
  39826. * List of components to register on the next registration step.
  39827. */
  39828. private _transientComponents;
  39829. /**
  39830. * Registers the transient components if needed.
  39831. */
  39832. private _registerTransientComponents;
  39833. /**
  39834. * @hidden
  39835. * Add a component to the scene.
  39836. * Note that the ccomponent could be registered on th next frame if this is called after
  39837. * the register component stage.
  39838. * @param component Defines the component to add to the scene
  39839. */
  39840. _addComponent(component: ISceneComponent): void;
  39841. /**
  39842. * @hidden
  39843. * Gets a component from the scene.
  39844. * @param name defines the name of the component to retrieve
  39845. * @returns the component or null if not present
  39846. */
  39847. _getComponent(name: string): Nullable<ISceneComponent>;
  39848. /**
  39849. * @hidden
  39850. * Defines the actions happening before camera updates.
  39851. */
  39852. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  39853. /**
  39854. * @hidden
  39855. * Defines the actions happening before clear the canvas.
  39856. */
  39857. _beforeClearStage: Stage<SimpleStageAction>;
  39858. /**
  39859. * @hidden
  39860. * Defines the actions when collecting render targets for the frame.
  39861. */
  39862. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  39863. /**
  39864. * @hidden
  39865. * Defines the actions happening for one camera in the frame.
  39866. */
  39867. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  39868. /**
  39869. * @hidden
  39870. * Defines the actions happening during the per mesh ready checks.
  39871. */
  39872. _isReadyForMeshStage: Stage<MeshStageAction>;
  39873. /**
  39874. * @hidden
  39875. * Defines the actions happening before evaluate active mesh checks.
  39876. */
  39877. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  39878. /**
  39879. * @hidden
  39880. * Defines the actions happening during the evaluate sub mesh checks.
  39881. */
  39882. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  39883. /**
  39884. * @hidden
  39885. * Defines the actions happening during the active mesh stage.
  39886. */
  39887. _activeMeshStage: Stage<ActiveMeshStageAction>;
  39888. /**
  39889. * @hidden
  39890. * Defines the actions happening during the per camera render target step.
  39891. */
  39892. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  39893. /**
  39894. * @hidden
  39895. * Defines the actions happening just before the active camera is drawing.
  39896. */
  39897. _beforeCameraDrawStage: Stage<CameraStageAction>;
  39898. /**
  39899. * @hidden
  39900. * Defines the actions happening just before a render target is drawing.
  39901. */
  39902. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  39903. /**
  39904. * @hidden
  39905. * Defines the actions happening just before a rendering group is drawing.
  39906. */
  39907. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  39908. /**
  39909. * @hidden
  39910. * Defines the actions happening just before a mesh is drawing.
  39911. */
  39912. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  39913. /**
  39914. * @hidden
  39915. * Defines the actions happening just after a mesh has been drawn.
  39916. */
  39917. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  39918. /**
  39919. * @hidden
  39920. * Defines the actions happening just after a rendering group has been drawn.
  39921. */
  39922. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  39923. /**
  39924. * @hidden
  39925. * Defines the actions happening just after the active camera has been drawn.
  39926. */
  39927. _afterCameraDrawStage: Stage<CameraStageAction>;
  39928. /**
  39929. * @hidden
  39930. * Defines the actions happening just after a render target has been drawn.
  39931. */
  39932. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  39933. /**
  39934. * @hidden
  39935. * Defines the actions happening just after rendering all cameras and computing intersections.
  39936. */
  39937. _afterRenderStage: Stage<SimpleStageAction>;
  39938. /**
  39939. * @hidden
  39940. * Defines the actions happening when a pointer move event happens.
  39941. */
  39942. _pointerMoveStage: Stage<PointerMoveStageAction>;
  39943. /**
  39944. * @hidden
  39945. * Defines the actions happening when a pointer down event happens.
  39946. */
  39947. _pointerDownStage: Stage<PointerUpDownStageAction>;
  39948. /**
  39949. * @hidden
  39950. * Defines the actions happening when a pointer up event happens.
  39951. */
  39952. _pointerUpStage: Stage<PointerUpDownStageAction>;
  39953. /**
  39954. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  39955. */
  39956. private geometriesByUniqueId;
  39957. /**
  39958. * Creates a new Scene
  39959. * @param engine defines the engine to use to render this scene
  39960. * @param options defines the scene options
  39961. */
  39962. constructor(engine: Engine, options?: SceneOptions);
  39963. /**
  39964. * Gets a string idenfifying the name of the class
  39965. * @returns "Scene" string
  39966. */
  39967. getClassName(): string;
  39968. private _defaultMeshCandidates;
  39969. /**
  39970. * @hidden
  39971. */
  39972. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  39973. private _defaultSubMeshCandidates;
  39974. /**
  39975. * @hidden
  39976. */
  39977. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  39978. /**
  39979. * Sets the default candidate providers for the scene.
  39980. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  39981. * and getCollidingSubMeshCandidates to their default function
  39982. */
  39983. setDefaultCandidateProviders(): void;
  39984. /**
  39985. * Gets the mesh that is currently under the pointer
  39986. */
  39987. get meshUnderPointer(): Nullable<AbstractMesh>;
  39988. /**
  39989. * Gets or sets the current on-screen X position of the pointer
  39990. */
  39991. get pointerX(): number;
  39992. set pointerX(value: number);
  39993. /**
  39994. * Gets or sets the current on-screen Y position of the pointer
  39995. */
  39996. get pointerY(): number;
  39997. set pointerY(value: number);
  39998. /**
  39999. * Gets the cached material (ie. the latest rendered one)
  40000. * @returns the cached material
  40001. */
  40002. getCachedMaterial(): Nullable<Material>;
  40003. /**
  40004. * Gets the cached effect (ie. the latest rendered one)
  40005. * @returns the cached effect
  40006. */
  40007. getCachedEffect(): Nullable<Effect>;
  40008. /**
  40009. * Gets the cached visibility state (ie. the latest rendered one)
  40010. * @returns the cached visibility state
  40011. */
  40012. getCachedVisibility(): Nullable<number>;
  40013. /**
  40014. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40015. * @param material defines the current material
  40016. * @param effect defines the current effect
  40017. * @param visibility defines the current visibility state
  40018. * @returns true if one parameter is not cached
  40019. */
  40020. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40021. /**
  40022. * Gets the engine associated with the scene
  40023. * @returns an Engine
  40024. */
  40025. getEngine(): Engine;
  40026. /**
  40027. * Gets the total number of vertices rendered per frame
  40028. * @returns the total number of vertices rendered per frame
  40029. */
  40030. getTotalVertices(): number;
  40031. /**
  40032. * Gets the performance counter for total vertices
  40033. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40034. */
  40035. get totalVerticesPerfCounter(): PerfCounter;
  40036. /**
  40037. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40038. * @returns the total number of active indices rendered per frame
  40039. */
  40040. getActiveIndices(): number;
  40041. /**
  40042. * Gets the performance counter for active indices
  40043. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40044. */
  40045. get totalActiveIndicesPerfCounter(): PerfCounter;
  40046. /**
  40047. * Gets the total number of active particles rendered per frame
  40048. * @returns the total number of active particles rendered per frame
  40049. */
  40050. getActiveParticles(): number;
  40051. /**
  40052. * Gets the performance counter for active particles
  40053. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40054. */
  40055. get activeParticlesPerfCounter(): PerfCounter;
  40056. /**
  40057. * Gets the total number of active bones rendered per frame
  40058. * @returns the total number of active bones rendered per frame
  40059. */
  40060. getActiveBones(): number;
  40061. /**
  40062. * Gets the performance counter for active bones
  40063. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40064. */
  40065. get activeBonesPerfCounter(): PerfCounter;
  40066. /**
  40067. * Gets the array of active meshes
  40068. * @returns an array of AbstractMesh
  40069. */
  40070. getActiveMeshes(): SmartArray<AbstractMesh>;
  40071. /**
  40072. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40073. * @returns a number
  40074. */
  40075. getAnimationRatio(): number;
  40076. /**
  40077. * Gets an unique Id for the current render phase
  40078. * @returns a number
  40079. */
  40080. getRenderId(): number;
  40081. /**
  40082. * Gets an unique Id for the current frame
  40083. * @returns a number
  40084. */
  40085. getFrameId(): number;
  40086. /** Call this function if you want to manually increment the render Id*/
  40087. incrementRenderId(): void;
  40088. private _createUbo;
  40089. /**
  40090. * Use this method to simulate a pointer move on a mesh
  40091. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40092. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40093. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40094. * @returns the current scene
  40095. */
  40096. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40097. /**
  40098. * Use this method to simulate a pointer down on a mesh
  40099. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40100. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40101. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40102. * @returns the current scene
  40103. */
  40104. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40105. /**
  40106. * Use this method to simulate a pointer up on a mesh
  40107. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40108. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40109. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40110. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40111. * @returns the current scene
  40112. */
  40113. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40114. /**
  40115. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40116. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40117. * @returns true if the pointer was captured
  40118. */
  40119. isPointerCaptured(pointerId?: number): boolean;
  40120. /**
  40121. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40122. * @param attachUp defines if you want to attach events to pointerup
  40123. * @param attachDown defines if you want to attach events to pointerdown
  40124. * @param attachMove defines if you want to attach events to pointermove
  40125. */
  40126. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40127. /** Detaches all event handlers*/
  40128. detachControl(): void;
  40129. /**
  40130. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40131. * Delay loaded resources are not taking in account
  40132. * @return true if all required resources are ready
  40133. */
  40134. isReady(): boolean;
  40135. /** Resets all cached information relative to material (including effect and visibility) */
  40136. resetCachedMaterial(): void;
  40137. /**
  40138. * Registers a function to be called before every frame render
  40139. * @param func defines the function to register
  40140. */
  40141. registerBeforeRender(func: () => void): void;
  40142. /**
  40143. * Unregisters a function called before every frame render
  40144. * @param func defines the function to unregister
  40145. */
  40146. unregisterBeforeRender(func: () => void): void;
  40147. /**
  40148. * Registers a function to be called after every frame render
  40149. * @param func defines the function to register
  40150. */
  40151. registerAfterRender(func: () => void): void;
  40152. /**
  40153. * Unregisters a function called after every frame render
  40154. * @param func defines the function to unregister
  40155. */
  40156. unregisterAfterRender(func: () => void): void;
  40157. private _executeOnceBeforeRender;
  40158. /**
  40159. * The provided function will run before render once and will be disposed afterwards.
  40160. * A timeout delay can be provided so that the function will be executed in N ms.
  40161. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40162. * @param func The function to be executed.
  40163. * @param timeout optional delay in ms
  40164. */
  40165. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40166. /** @hidden */
  40167. _addPendingData(data: any): void;
  40168. /** @hidden */
  40169. _removePendingData(data: any): void;
  40170. /**
  40171. * Returns the number of items waiting to be loaded
  40172. * @returns the number of items waiting to be loaded
  40173. */
  40174. getWaitingItemsCount(): number;
  40175. /**
  40176. * Returns a boolean indicating if the scene is still loading data
  40177. */
  40178. get isLoading(): boolean;
  40179. /**
  40180. * Registers a function to be executed when the scene is ready
  40181. * @param {Function} func - the function to be executed
  40182. */
  40183. executeWhenReady(func: () => void): void;
  40184. /**
  40185. * Returns a promise that resolves when the scene is ready
  40186. * @returns A promise that resolves when the scene is ready
  40187. */
  40188. whenReadyAsync(): Promise<void>;
  40189. /** @hidden */
  40190. _checkIsReady(): void;
  40191. /**
  40192. * Gets all animatable attached to the scene
  40193. */
  40194. get animatables(): Animatable[];
  40195. /**
  40196. * Resets the last animation time frame.
  40197. * Useful to override when animations start running when loading a scene for the first time.
  40198. */
  40199. resetLastAnimationTimeFrame(): void;
  40200. /**
  40201. * Gets the current view matrix
  40202. * @returns a Matrix
  40203. */
  40204. getViewMatrix(): Matrix;
  40205. /**
  40206. * Gets the current projection matrix
  40207. * @returns a Matrix
  40208. */
  40209. getProjectionMatrix(): Matrix;
  40210. /**
  40211. * Gets the current transform matrix
  40212. * @returns a Matrix made of View * Projection
  40213. */
  40214. getTransformMatrix(): Matrix;
  40215. /**
  40216. * Sets the current transform matrix
  40217. * @param viewL defines the View matrix to use
  40218. * @param projectionL defines the Projection matrix to use
  40219. * @param viewR defines the right View matrix to use (if provided)
  40220. * @param projectionR defines the right Projection matrix to use (if provided)
  40221. */
  40222. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40223. /**
  40224. * Gets the uniform buffer used to store scene data
  40225. * @returns a UniformBuffer
  40226. */
  40227. getSceneUniformBuffer(): UniformBuffer;
  40228. /**
  40229. * Gets an unique (relatively to the current scene) Id
  40230. * @returns an unique number for the scene
  40231. */
  40232. getUniqueId(): number;
  40233. /**
  40234. * Add a mesh to the list of scene's meshes
  40235. * @param newMesh defines the mesh to add
  40236. * @param recursive if all child meshes should also be added to the scene
  40237. */
  40238. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40239. /**
  40240. * Remove a mesh for the list of scene's meshes
  40241. * @param toRemove defines the mesh to remove
  40242. * @param recursive if all child meshes should also be removed from the scene
  40243. * @returns the index where the mesh was in the mesh list
  40244. */
  40245. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40246. /**
  40247. * Add a transform node to the list of scene's transform nodes
  40248. * @param newTransformNode defines the transform node to add
  40249. */
  40250. addTransformNode(newTransformNode: TransformNode): void;
  40251. /**
  40252. * Remove a transform node for the list of scene's transform nodes
  40253. * @param toRemove defines the transform node to remove
  40254. * @returns the index where the transform node was in the transform node list
  40255. */
  40256. removeTransformNode(toRemove: TransformNode): number;
  40257. /**
  40258. * Remove a skeleton for the list of scene's skeletons
  40259. * @param toRemove defines the skeleton to remove
  40260. * @returns the index where the skeleton was in the skeleton list
  40261. */
  40262. removeSkeleton(toRemove: Skeleton): number;
  40263. /**
  40264. * Remove a morph target for the list of scene's morph targets
  40265. * @param toRemove defines the morph target to remove
  40266. * @returns the index where the morph target was in the morph target list
  40267. */
  40268. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40269. /**
  40270. * Remove a light for the list of scene's lights
  40271. * @param toRemove defines the light to remove
  40272. * @returns the index where the light was in the light list
  40273. */
  40274. removeLight(toRemove: Light): number;
  40275. /**
  40276. * Remove a camera for the list of scene's cameras
  40277. * @param toRemove defines the camera to remove
  40278. * @returns the index where the camera was in the camera list
  40279. */
  40280. removeCamera(toRemove: Camera): number;
  40281. /**
  40282. * Remove a particle system for the list of scene's particle systems
  40283. * @param toRemove defines the particle system to remove
  40284. * @returns the index where the particle system was in the particle system list
  40285. */
  40286. removeParticleSystem(toRemove: IParticleSystem): number;
  40287. /**
  40288. * Remove a animation for the list of scene's animations
  40289. * @param toRemove defines the animation to remove
  40290. * @returns the index where the animation was in the animation list
  40291. */
  40292. removeAnimation(toRemove: Animation): number;
  40293. /**
  40294. * Will stop the animation of the given target
  40295. * @param target - the target
  40296. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40297. * @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)
  40298. */
  40299. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40300. /**
  40301. * Removes the given animation group from this scene.
  40302. * @param toRemove The animation group to remove
  40303. * @returns The index of the removed animation group
  40304. */
  40305. removeAnimationGroup(toRemove: AnimationGroup): number;
  40306. /**
  40307. * Removes the given multi-material from this scene.
  40308. * @param toRemove The multi-material to remove
  40309. * @returns The index of the removed multi-material
  40310. */
  40311. removeMultiMaterial(toRemove: MultiMaterial): number;
  40312. /**
  40313. * Removes the given material from this scene.
  40314. * @param toRemove The material to remove
  40315. * @returns The index of the removed material
  40316. */
  40317. removeMaterial(toRemove: Material): number;
  40318. /**
  40319. * Removes the given action manager from this scene.
  40320. * @param toRemove The action manager to remove
  40321. * @returns The index of the removed action manager
  40322. */
  40323. removeActionManager(toRemove: AbstractActionManager): number;
  40324. /**
  40325. * Removes the given texture from this scene.
  40326. * @param toRemove The texture to remove
  40327. * @returns The index of the removed texture
  40328. */
  40329. removeTexture(toRemove: BaseTexture): number;
  40330. /**
  40331. * Adds the given light to this scene
  40332. * @param newLight The light to add
  40333. */
  40334. addLight(newLight: Light): void;
  40335. /**
  40336. * Sorts the list list based on light priorities
  40337. */
  40338. sortLightsByPriority(): void;
  40339. /**
  40340. * Adds the given camera to this scene
  40341. * @param newCamera The camera to add
  40342. */
  40343. addCamera(newCamera: Camera): void;
  40344. /**
  40345. * Adds the given skeleton to this scene
  40346. * @param newSkeleton The skeleton to add
  40347. */
  40348. addSkeleton(newSkeleton: Skeleton): void;
  40349. /**
  40350. * Adds the given particle system to this scene
  40351. * @param newParticleSystem The particle system to add
  40352. */
  40353. addParticleSystem(newParticleSystem: IParticleSystem): void;
  40354. /**
  40355. * Adds the given animation to this scene
  40356. * @param newAnimation The animation to add
  40357. */
  40358. addAnimation(newAnimation: Animation): void;
  40359. /**
  40360. * Adds the given animation group to this scene.
  40361. * @param newAnimationGroup The animation group to add
  40362. */
  40363. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  40364. /**
  40365. * Adds the given multi-material to this scene
  40366. * @param newMultiMaterial The multi-material to add
  40367. */
  40368. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  40369. /**
  40370. * Adds the given material to this scene
  40371. * @param newMaterial The material to add
  40372. */
  40373. addMaterial(newMaterial: Material): void;
  40374. /**
  40375. * Adds the given morph target to this scene
  40376. * @param newMorphTargetManager The morph target to add
  40377. */
  40378. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  40379. /**
  40380. * Adds the given geometry to this scene
  40381. * @param newGeometry The geometry to add
  40382. */
  40383. addGeometry(newGeometry: Geometry): void;
  40384. /**
  40385. * Adds the given action manager to this scene
  40386. * @param newActionManager The action manager to add
  40387. */
  40388. addActionManager(newActionManager: AbstractActionManager): void;
  40389. /**
  40390. * Adds the given texture to this scene.
  40391. * @param newTexture The texture to add
  40392. */
  40393. addTexture(newTexture: BaseTexture): void;
  40394. /**
  40395. * Switch active camera
  40396. * @param newCamera defines the new active camera
  40397. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  40398. */
  40399. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  40400. /**
  40401. * sets the active camera of the scene using its ID
  40402. * @param id defines the camera's ID
  40403. * @return the new active camera or null if none found.
  40404. */
  40405. setActiveCameraByID(id: string): Nullable<Camera>;
  40406. /**
  40407. * sets the active camera of the scene using its name
  40408. * @param name defines the camera's name
  40409. * @returns the new active camera or null if none found.
  40410. */
  40411. setActiveCameraByName(name: string): Nullable<Camera>;
  40412. /**
  40413. * get an animation group using its name
  40414. * @param name defines the material's name
  40415. * @return the animation group or null if none found.
  40416. */
  40417. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  40418. /**
  40419. * Get a material using its unique id
  40420. * @param uniqueId defines the material's unique id
  40421. * @return the material or null if none found.
  40422. */
  40423. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  40424. /**
  40425. * get a material using its id
  40426. * @param id defines the material's ID
  40427. * @return the material or null if none found.
  40428. */
  40429. getMaterialByID(id: string): Nullable<Material>;
  40430. /**
  40431. * Gets a the last added material using a given id
  40432. * @param id defines the material's ID
  40433. * @return the last material with the given id or null if none found.
  40434. */
  40435. getLastMaterialByID(id: string): Nullable<Material>;
  40436. /**
  40437. * Gets a material using its name
  40438. * @param name defines the material's name
  40439. * @return the material or null if none found.
  40440. */
  40441. getMaterialByName(name: string): Nullable<Material>;
  40442. /**
  40443. * Get a texture using its unique id
  40444. * @param uniqueId defines the texture's unique id
  40445. * @return the texture or null if none found.
  40446. */
  40447. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  40448. /**
  40449. * Gets a camera using its id
  40450. * @param id defines the id to look for
  40451. * @returns the camera or null if not found
  40452. */
  40453. getCameraByID(id: string): Nullable<Camera>;
  40454. /**
  40455. * Gets a camera using its unique id
  40456. * @param uniqueId defines the unique id to look for
  40457. * @returns the camera or null if not found
  40458. */
  40459. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  40460. /**
  40461. * Gets a camera using its name
  40462. * @param name defines the camera's name
  40463. * @return the camera or null if none found.
  40464. */
  40465. getCameraByName(name: string): Nullable<Camera>;
  40466. /**
  40467. * Gets a bone using its id
  40468. * @param id defines the bone's id
  40469. * @return the bone or null if not found
  40470. */
  40471. getBoneByID(id: string): Nullable<Bone>;
  40472. /**
  40473. * Gets a bone using its id
  40474. * @param name defines the bone's name
  40475. * @return the bone or null if not found
  40476. */
  40477. getBoneByName(name: string): Nullable<Bone>;
  40478. /**
  40479. * Gets a light node using its name
  40480. * @param name defines the the light's name
  40481. * @return the light or null if none found.
  40482. */
  40483. getLightByName(name: string): Nullable<Light>;
  40484. /**
  40485. * Gets a light node using its id
  40486. * @param id defines the light's id
  40487. * @return the light or null if none found.
  40488. */
  40489. getLightByID(id: string): Nullable<Light>;
  40490. /**
  40491. * Gets a light node using its scene-generated unique ID
  40492. * @param uniqueId defines the light's unique id
  40493. * @return the light or null if none found.
  40494. */
  40495. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  40496. /**
  40497. * Gets a particle system by id
  40498. * @param id defines the particle system id
  40499. * @return the corresponding system or null if none found
  40500. */
  40501. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  40502. /**
  40503. * Gets a geometry using its ID
  40504. * @param id defines the geometry's id
  40505. * @return the geometry or null if none found.
  40506. */
  40507. getGeometryByID(id: string): Nullable<Geometry>;
  40508. private _getGeometryByUniqueID;
  40509. /**
  40510. * Add a new geometry to this scene
  40511. * @param geometry defines the geometry to be added to the scene.
  40512. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  40513. * @return a boolean defining if the geometry was added or not
  40514. */
  40515. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  40516. /**
  40517. * Removes an existing geometry
  40518. * @param geometry defines the geometry to be removed from the scene
  40519. * @return a boolean defining if the geometry was removed or not
  40520. */
  40521. removeGeometry(geometry: Geometry): boolean;
  40522. /**
  40523. * Gets the list of geometries attached to the scene
  40524. * @returns an array of Geometry
  40525. */
  40526. getGeometries(): Geometry[];
  40527. /**
  40528. * Gets the first added mesh found of a given ID
  40529. * @param id defines the id to search for
  40530. * @return the mesh found or null if not found at all
  40531. */
  40532. getMeshByID(id: string): Nullable<AbstractMesh>;
  40533. /**
  40534. * Gets a list of meshes using their id
  40535. * @param id defines the id to search for
  40536. * @returns a list of meshes
  40537. */
  40538. getMeshesByID(id: string): Array<AbstractMesh>;
  40539. /**
  40540. * Gets the first added transform node found of a given ID
  40541. * @param id defines the id to search for
  40542. * @return the found transform node or null if not found at all.
  40543. */
  40544. getTransformNodeByID(id: string): Nullable<TransformNode>;
  40545. /**
  40546. * Gets a transform node with its auto-generated unique id
  40547. * @param uniqueId efines the unique id to search for
  40548. * @return the found transform node or null if not found at all.
  40549. */
  40550. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  40551. /**
  40552. * Gets a list of transform nodes using their id
  40553. * @param id defines the id to search for
  40554. * @returns a list of transform nodes
  40555. */
  40556. getTransformNodesByID(id: string): Array<TransformNode>;
  40557. /**
  40558. * Gets a mesh with its auto-generated unique id
  40559. * @param uniqueId defines the unique id to search for
  40560. * @return the found mesh or null if not found at all.
  40561. */
  40562. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  40563. /**
  40564. * Gets a the last added mesh using a given id
  40565. * @param id defines the id to search for
  40566. * @return the found mesh or null if not found at all.
  40567. */
  40568. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  40569. /**
  40570. * Gets a the last added node (Mesh, Camera, Light) using a given id
  40571. * @param id defines the id to search for
  40572. * @return the found node or null if not found at all
  40573. */
  40574. getLastEntryByID(id: string): Nullable<Node>;
  40575. /**
  40576. * Gets a node (Mesh, Camera, Light) using a given id
  40577. * @param id defines the id to search for
  40578. * @return the found node or null if not found at all
  40579. */
  40580. getNodeByID(id: string): Nullable<Node>;
  40581. /**
  40582. * Gets a node (Mesh, Camera, Light) using a given name
  40583. * @param name defines the name to search for
  40584. * @return the found node or null if not found at all.
  40585. */
  40586. getNodeByName(name: string): Nullable<Node>;
  40587. /**
  40588. * Gets a mesh using a given name
  40589. * @param name defines the name to search for
  40590. * @return the found mesh or null if not found at all.
  40591. */
  40592. getMeshByName(name: string): Nullable<AbstractMesh>;
  40593. /**
  40594. * Gets a transform node using a given name
  40595. * @param name defines the name to search for
  40596. * @return the found transform node or null if not found at all.
  40597. */
  40598. getTransformNodeByName(name: string): Nullable<TransformNode>;
  40599. /**
  40600. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  40601. * @param id defines the id to search for
  40602. * @return the found skeleton or null if not found at all.
  40603. */
  40604. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  40605. /**
  40606. * Gets a skeleton using a given auto generated unique id
  40607. * @param uniqueId defines the unique id to search for
  40608. * @return the found skeleton or null if not found at all.
  40609. */
  40610. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  40611. /**
  40612. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  40613. * @param id defines the id to search for
  40614. * @return the found skeleton or null if not found at all.
  40615. */
  40616. getSkeletonById(id: string): Nullable<Skeleton>;
  40617. /**
  40618. * Gets a skeleton using a given name
  40619. * @param name defines the name to search for
  40620. * @return the found skeleton or null if not found at all.
  40621. */
  40622. getSkeletonByName(name: string): Nullable<Skeleton>;
  40623. /**
  40624. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  40625. * @param id defines the id to search for
  40626. * @return the found morph target manager or null if not found at all.
  40627. */
  40628. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  40629. /**
  40630. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  40631. * @param id defines the id to search for
  40632. * @return the found morph target or null if not found at all.
  40633. */
  40634. getMorphTargetById(id: string): Nullable<MorphTarget>;
  40635. /**
  40636. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  40637. * @param name defines the name to search for
  40638. * @return the found morph target or null if not found at all.
  40639. */
  40640. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  40641. /**
  40642. * Gets a boolean indicating if the given mesh is active
  40643. * @param mesh defines the mesh to look for
  40644. * @returns true if the mesh is in the active list
  40645. */
  40646. isActiveMesh(mesh: AbstractMesh): boolean;
  40647. /**
  40648. * Return a unique id as a string which can serve as an identifier for the scene
  40649. */
  40650. get uid(): string;
  40651. /**
  40652. * Add an externaly attached data from its key.
  40653. * This method call will fail and return false, if such key already exists.
  40654. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  40655. * @param key the unique key that identifies the data
  40656. * @param data the data object to associate to the key for this Engine instance
  40657. * @return true if no such key were already present and the data was added successfully, false otherwise
  40658. */
  40659. addExternalData<T>(key: string, data: T): boolean;
  40660. /**
  40661. * Get an externaly attached data from its key
  40662. * @param key the unique key that identifies the data
  40663. * @return the associated data, if present (can be null), or undefined if not present
  40664. */
  40665. getExternalData<T>(key: string): Nullable<T>;
  40666. /**
  40667. * Get an externaly attached data from its key, create it using a factory if it's not already present
  40668. * @param key the unique key that identifies the data
  40669. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  40670. * @return the associated data, can be null if the factory returned null.
  40671. */
  40672. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  40673. /**
  40674. * Remove an externaly attached data from the Engine instance
  40675. * @param key the unique key that identifies the data
  40676. * @return true if the data was successfully removed, false if it doesn't exist
  40677. */
  40678. removeExternalData(key: string): boolean;
  40679. private _evaluateSubMesh;
  40680. /**
  40681. * Clear the processed materials smart array preventing retention point in material dispose.
  40682. */
  40683. freeProcessedMaterials(): void;
  40684. private _preventFreeActiveMeshesAndRenderingGroups;
  40685. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  40686. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  40687. * when disposing several meshes in a row or a hierarchy of meshes.
  40688. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  40689. */
  40690. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  40691. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  40692. /**
  40693. * Clear the active meshes smart array preventing retention point in mesh dispose.
  40694. */
  40695. freeActiveMeshes(): void;
  40696. /**
  40697. * Clear the info related to rendering groups preventing retention points during dispose.
  40698. */
  40699. freeRenderingGroups(): void;
  40700. /** @hidden */
  40701. _isInIntermediateRendering(): boolean;
  40702. /**
  40703. * Lambda returning the list of potentially active meshes.
  40704. */
  40705. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  40706. /**
  40707. * Lambda returning the list of potentially active sub meshes.
  40708. */
  40709. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  40710. /**
  40711. * Lambda returning the list of potentially intersecting sub meshes.
  40712. */
  40713. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  40714. /**
  40715. * Lambda returning the list of potentially colliding sub meshes.
  40716. */
  40717. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  40718. private _activeMeshesFrozen;
  40719. private _skipEvaluateActiveMeshesCompletely;
  40720. /**
  40721. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  40722. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  40723. * @returns the current scene
  40724. */
  40725. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  40726. /**
  40727. * Use this function to restart evaluating active meshes on every frame
  40728. * @returns the current scene
  40729. */
  40730. unfreezeActiveMeshes(): Scene;
  40731. private _evaluateActiveMeshes;
  40732. private _activeMesh;
  40733. /**
  40734. * Update the transform matrix to update from the current active camera
  40735. * @param force defines a boolean used to force the update even if cache is up to date
  40736. */
  40737. updateTransformMatrix(force?: boolean): void;
  40738. private _bindFrameBuffer;
  40739. /** @hidden */
  40740. _allowPostProcessClearColor: boolean;
  40741. /** @hidden */
  40742. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  40743. private _processSubCameras;
  40744. private _checkIntersections;
  40745. /** @hidden */
  40746. _advancePhysicsEngineStep(step: number): void;
  40747. /**
  40748. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  40749. */
  40750. getDeterministicFrameTime: () => number;
  40751. /** @hidden */
  40752. _animate(): void;
  40753. /** Execute all animations (for a frame) */
  40754. animate(): void;
  40755. /**
  40756. * Render the scene
  40757. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  40758. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  40759. */
  40760. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  40761. /**
  40762. * Freeze all materials
  40763. * A frozen material will not be updatable but should be faster to render
  40764. */
  40765. freezeMaterials(): void;
  40766. /**
  40767. * Unfreeze all materials
  40768. * A frozen material will not be updatable but should be faster to render
  40769. */
  40770. unfreezeMaterials(): void;
  40771. /**
  40772. * Releases all held ressources
  40773. */
  40774. dispose(): void;
  40775. /**
  40776. * Gets if the scene is already disposed
  40777. */
  40778. get isDisposed(): boolean;
  40779. /**
  40780. * Call this function to reduce memory footprint of the scene.
  40781. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  40782. */
  40783. clearCachedVertexData(): void;
  40784. /**
  40785. * This function will remove the local cached buffer data from texture.
  40786. * It will save memory but will prevent the texture from being rebuilt
  40787. */
  40788. cleanCachedTextureBuffer(): void;
  40789. /**
  40790. * Get the world extend vectors with an optional filter
  40791. *
  40792. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  40793. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  40794. */
  40795. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  40796. min: Vector3;
  40797. max: Vector3;
  40798. };
  40799. /**
  40800. * Creates a ray that can be used to pick in the scene
  40801. * @param x defines the x coordinate of the origin (on-screen)
  40802. * @param y defines the y coordinate of the origin (on-screen)
  40803. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  40804. * @param camera defines the camera to use for the picking
  40805. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  40806. * @returns a Ray
  40807. */
  40808. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  40809. /**
  40810. * Creates a ray that can be used to pick in the scene
  40811. * @param x defines the x coordinate of the origin (on-screen)
  40812. * @param y defines the y coordinate of the origin (on-screen)
  40813. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  40814. * @param result defines the ray where to store the picking ray
  40815. * @param camera defines the camera to use for the picking
  40816. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  40817. * @returns the current scene
  40818. */
  40819. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  40820. /**
  40821. * Creates a ray that can be used to pick in the scene
  40822. * @param x defines the x coordinate of the origin (on-screen)
  40823. * @param y defines the y coordinate of the origin (on-screen)
  40824. * @param camera defines the camera to use for the picking
  40825. * @returns a Ray
  40826. */
  40827. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  40828. /**
  40829. * Creates a ray that can be used to pick in the scene
  40830. * @param x defines the x coordinate of the origin (on-screen)
  40831. * @param y defines the y coordinate of the origin (on-screen)
  40832. * @param result defines the ray where to store the picking ray
  40833. * @param camera defines the camera to use for the picking
  40834. * @returns the current scene
  40835. */
  40836. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  40837. /** Launch a ray to try to pick a mesh in the scene
  40838. * @param x position on screen
  40839. * @param y position on screen
  40840. * @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
  40841. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40842. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40843. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40844. * @returns a PickingInfo
  40845. */
  40846. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  40847. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  40848. * @param x position on screen
  40849. * @param y position on screen
  40850. * @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
  40851. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40852. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40853. * @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)
  40854. */
  40855. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  40856. /** Use the given ray to pick a mesh in the scene
  40857. * @param ray The ray to use to pick meshes
  40858. * @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
  40859. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40860. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40861. * @returns a PickingInfo
  40862. */
  40863. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  40864. /**
  40865. * Launch a ray to try to pick a mesh in the scene
  40866. * @param x X position on screen
  40867. * @param y Y position on screen
  40868. * @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
  40869. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40870. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40871. * @returns an array of PickingInfo
  40872. */
  40873. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40874. /**
  40875. * Launch a ray to try to pick a mesh in the scene
  40876. * @param ray Ray to use
  40877. * @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
  40878. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40879. * @returns an array of PickingInfo
  40880. */
  40881. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40882. /**
  40883. * Force the value of meshUnderPointer
  40884. * @param mesh defines the mesh to use
  40885. */
  40886. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  40887. /**
  40888. * Gets the mesh under the pointer
  40889. * @returns a Mesh or null if no mesh is under the pointer
  40890. */
  40891. getPointerOverMesh(): Nullable<AbstractMesh>;
  40892. /** @hidden */
  40893. _rebuildGeometries(): void;
  40894. /** @hidden */
  40895. _rebuildTextures(): void;
  40896. private _getByTags;
  40897. /**
  40898. * Get a list of meshes by tags
  40899. * @param tagsQuery defines the tags query to use
  40900. * @param forEach defines a predicate used to filter results
  40901. * @returns an array of Mesh
  40902. */
  40903. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  40904. /**
  40905. * Get a list of cameras by tags
  40906. * @param tagsQuery defines the tags query to use
  40907. * @param forEach defines a predicate used to filter results
  40908. * @returns an array of Camera
  40909. */
  40910. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  40911. /**
  40912. * Get a list of lights by tags
  40913. * @param tagsQuery defines the tags query to use
  40914. * @param forEach defines a predicate used to filter results
  40915. * @returns an array of Light
  40916. */
  40917. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  40918. /**
  40919. * Get a list of materials by tags
  40920. * @param tagsQuery defines the tags query to use
  40921. * @param forEach defines a predicate used to filter results
  40922. * @returns an array of Material
  40923. */
  40924. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  40925. /**
  40926. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  40927. * This allowed control for front to back rendering or reversly depending of the special needs.
  40928. *
  40929. * @param renderingGroupId The rendering group id corresponding to its index
  40930. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  40931. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  40932. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  40933. */
  40934. 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;
  40935. /**
  40936. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  40937. *
  40938. * @param renderingGroupId The rendering group id corresponding to its index
  40939. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  40940. * @param depth Automatically clears depth between groups if true and autoClear is true.
  40941. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  40942. */
  40943. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  40944. /**
  40945. * Gets the current auto clear configuration for one rendering group of the rendering
  40946. * manager.
  40947. * @param index the rendering group index to get the information for
  40948. * @returns The auto clear setup for the requested rendering group
  40949. */
  40950. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  40951. private _blockMaterialDirtyMechanism;
  40952. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  40953. get blockMaterialDirtyMechanism(): boolean;
  40954. set blockMaterialDirtyMechanism(value: boolean);
  40955. /**
  40956. * Will flag all materials as dirty to trigger new shader compilation
  40957. * @param flag defines the flag used to specify which material part must be marked as dirty
  40958. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  40959. */
  40960. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  40961. /** @hidden */
  40962. _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;
  40963. /** @hidden */
  40964. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40965. /** @hidden */
  40966. _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;
  40967. /** @hidden */
  40968. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  40969. /** @hidden */
  40970. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  40971. /** @hidden */
  40972. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40973. }
  40974. }
  40975. declare module BABYLON {
  40976. /**
  40977. * Set of assets to keep when moving a scene into an asset container.
  40978. */
  40979. export class KeepAssets extends AbstractScene {
  40980. }
  40981. /**
  40982. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  40983. */
  40984. export class InstantiatedEntries {
  40985. /**
  40986. * List of new root nodes (eg. nodes with no parent)
  40987. */
  40988. rootNodes: TransformNode[];
  40989. /**
  40990. * List of new skeletons
  40991. */
  40992. skeletons: Skeleton[];
  40993. /**
  40994. * List of new animation groups
  40995. */
  40996. animationGroups: AnimationGroup[];
  40997. }
  40998. /**
  40999. * Container with a set of assets that can be added or removed from a scene.
  41000. */
  41001. export class AssetContainer extends AbstractScene {
  41002. private _wasAddedToScene;
  41003. /**
  41004. * The scene the AssetContainer belongs to.
  41005. */
  41006. scene: Scene;
  41007. /**
  41008. * Instantiates an AssetContainer.
  41009. * @param scene The scene the AssetContainer belongs to.
  41010. */
  41011. constructor(scene: Scene);
  41012. /**
  41013. * Instantiate or clone all meshes and add the new ones to the scene.
  41014. * Skeletons and animation groups will all be cloned
  41015. * @param nameFunction defines an optional function used to get new names for clones
  41016. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41017. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41018. */
  41019. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41020. /**
  41021. * Adds all the assets from the container to the scene.
  41022. */
  41023. addAllToScene(): void;
  41024. /**
  41025. * Removes all the assets in the container from the scene
  41026. */
  41027. removeAllFromScene(): void;
  41028. /**
  41029. * Disposes all the assets in the container
  41030. */
  41031. dispose(): void;
  41032. private _moveAssets;
  41033. /**
  41034. * Removes all the assets contained in the scene and adds them to the container.
  41035. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41036. */
  41037. moveAllFromScene(keepAssets?: KeepAssets): void;
  41038. /**
  41039. * 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.
  41040. * @returns the root mesh
  41041. */
  41042. createRootMesh(): Mesh;
  41043. /**
  41044. * Merge animations (direct and animation groups) from this asset container into a scene
  41045. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41046. * @param animatables set of animatables to retarget to a node from the scene
  41047. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41048. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41049. */
  41050. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41051. }
  41052. }
  41053. declare module BABYLON {
  41054. /**
  41055. * Defines how the parser contract is defined.
  41056. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41057. */
  41058. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41059. /**
  41060. * Defines how the individual parser contract is defined.
  41061. * These parser can parse an individual asset
  41062. */
  41063. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41064. /**
  41065. * Base class of the scene acting as a container for the different elements composing a scene.
  41066. * This class is dynamically extended by the different components of the scene increasing
  41067. * flexibility and reducing coupling
  41068. */
  41069. export abstract class AbstractScene {
  41070. /**
  41071. * Stores the list of available parsers in the application.
  41072. */
  41073. private static _BabylonFileParsers;
  41074. /**
  41075. * Stores the list of available individual parsers in the application.
  41076. */
  41077. private static _IndividualBabylonFileParsers;
  41078. /**
  41079. * Adds a parser in the list of available ones
  41080. * @param name Defines the name of the parser
  41081. * @param parser Defines the parser to add
  41082. */
  41083. static AddParser(name: string, parser: BabylonFileParser): void;
  41084. /**
  41085. * Gets a general parser from the list of avaialble ones
  41086. * @param name Defines the name of the parser
  41087. * @returns the requested parser or null
  41088. */
  41089. static GetParser(name: string): Nullable<BabylonFileParser>;
  41090. /**
  41091. * Adds n individual parser in the list of available ones
  41092. * @param name Defines the name of the parser
  41093. * @param parser Defines the parser to add
  41094. */
  41095. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41096. /**
  41097. * Gets an individual parser from the list of avaialble ones
  41098. * @param name Defines the name of the parser
  41099. * @returns the requested parser or null
  41100. */
  41101. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41102. /**
  41103. * Parser json data and populate both a scene and its associated container object
  41104. * @param jsonData Defines the data to parse
  41105. * @param scene Defines the scene to parse the data for
  41106. * @param container Defines the container attached to the parsing sequence
  41107. * @param rootUrl Defines the root url of the data
  41108. */
  41109. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41110. /**
  41111. * Gets the list of root nodes (ie. nodes with no parent)
  41112. */
  41113. rootNodes: Node[];
  41114. /** All of the cameras added to this scene
  41115. * @see https://doc.babylonjs.com/babylon101/cameras
  41116. */
  41117. cameras: Camera[];
  41118. /**
  41119. * All of the lights added to this scene
  41120. * @see https://doc.babylonjs.com/babylon101/lights
  41121. */
  41122. lights: Light[];
  41123. /**
  41124. * All of the (abstract) meshes added to this scene
  41125. */
  41126. meshes: AbstractMesh[];
  41127. /**
  41128. * The list of skeletons added to the scene
  41129. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41130. */
  41131. skeletons: Skeleton[];
  41132. /**
  41133. * All of the particle systems added to this scene
  41134. * @see https://doc.babylonjs.com/babylon101/particles
  41135. */
  41136. particleSystems: IParticleSystem[];
  41137. /**
  41138. * Gets a list of Animations associated with the scene
  41139. */
  41140. animations: Animation[];
  41141. /**
  41142. * All of the animation groups added to this scene
  41143. * @see https://doc.babylonjs.com/how_to/group
  41144. */
  41145. animationGroups: AnimationGroup[];
  41146. /**
  41147. * All of the multi-materials added to this scene
  41148. * @see https://doc.babylonjs.com/how_to/multi_materials
  41149. */
  41150. multiMaterials: MultiMaterial[];
  41151. /**
  41152. * All of the materials added to this scene
  41153. * In the context of a Scene, it is not supposed to be modified manually.
  41154. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41155. * Note also that the order of the Material within the array is not significant and might change.
  41156. * @see https://doc.babylonjs.com/babylon101/materials
  41157. */
  41158. materials: Material[];
  41159. /**
  41160. * The list of morph target managers added to the scene
  41161. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41162. */
  41163. morphTargetManagers: MorphTargetManager[];
  41164. /**
  41165. * The list of geometries used in the scene.
  41166. */
  41167. geometries: Geometry[];
  41168. /**
  41169. * All of the tranform nodes added to this scene
  41170. * In the context of a Scene, it is not supposed to be modified manually.
  41171. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41172. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41173. * @see https://doc.babylonjs.com/how_to/transformnode
  41174. */
  41175. transformNodes: TransformNode[];
  41176. /**
  41177. * ActionManagers available on the scene.
  41178. */
  41179. actionManagers: AbstractActionManager[];
  41180. /**
  41181. * Textures to keep.
  41182. */
  41183. textures: BaseTexture[];
  41184. /**
  41185. * Environment texture for the scene
  41186. */
  41187. environmentTexture: Nullable<BaseTexture>;
  41188. /**
  41189. * @returns all meshes, lights, cameras, transformNodes and bones
  41190. */
  41191. getNodes(): Array<Node>;
  41192. }
  41193. }
  41194. declare module BABYLON {
  41195. /**
  41196. * Interface used to define options for Sound class
  41197. */
  41198. export interface ISoundOptions {
  41199. /**
  41200. * Does the sound autoplay once loaded.
  41201. */
  41202. autoplay?: boolean;
  41203. /**
  41204. * Does the sound loop after it finishes playing once.
  41205. */
  41206. loop?: boolean;
  41207. /**
  41208. * Sound's volume
  41209. */
  41210. volume?: number;
  41211. /**
  41212. * Is it a spatial sound?
  41213. */
  41214. spatialSound?: boolean;
  41215. /**
  41216. * Maximum distance to hear that sound
  41217. */
  41218. maxDistance?: number;
  41219. /**
  41220. * Uses user defined attenuation function
  41221. */
  41222. useCustomAttenuation?: boolean;
  41223. /**
  41224. * Define the roll off factor of spatial sounds.
  41225. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41226. */
  41227. rolloffFactor?: number;
  41228. /**
  41229. * Define the reference distance the sound should be heard perfectly.
  41230. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41231. */
  41232. refDistance?: number;
  41233. /**
  41234. * Define the distance attenuation model the sound will follow.
  41235. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41236. */
  41237. distanceModel?: string;
  41238. /**
  41239. * Defines the playback speed (1 by default)
  41240. */
  41241. playbackRate?: number;
  41242. /**
  41243. * Defines if the sound is from a streaming source
  41244. */
  41245. streaming?: boolean;
  41246. /**
  41247. * Defines an optional length (in seconds) inside the sound file
  41248. */
  41249. length?: number;
  41250. /**
  41251. * Defines an optional offset (in seconds) inside the sound file
  41252. */
  41253. offset?: number;
  41254. /**
  41255. * If true, URLs will not be required to state the audio file codec to use.
  41256. */
  41257. skipCodecCheck?: boolean;
  41258. }
  41259. /**
  41260. * Defines a sound that can be played in the application.
  41261. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41262. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41263. */
  41264. export class Sound {
  41265. /**
  41266. * The name of the sound in the scene.
  41267. */
  41268. name: string;
  41269. /**
  41270. * Does the sound autoplay once loaded.
  41271. */
  41272. autoplay: boolean;
  41273. /**
  41274. * Does the sound loop after it finishes playing once.
  41275. */
  41276. loop: boolean;
  41277. /**
  41278. * Does the sound use a custom attenuation curve to simulate the falloff
  41279. * happening when the source gets further away from the camera.
  41280. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41281. */
  41282. useCustomAttenuation: boolean;
  41283. /**
  41284. * The sound track id this sound belongs to.
  41285. */
  41286. soundTrackId: number;
  41287. /**
  41288. * Is this sound currently played.
  41289. */
  41290. isPlaying: boolean;
  41291. /**
  41292. * Is this sound currently paused.
  41293. */
  41294. isPaused: boolean;
  41295. /**
  41296. * Does this sound enables spatial sound.
  41297. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41298. */
  41299. spatialSound: boolean;
  41300. /**
  41301. * Define the reference distance the sound should be heard perfectly.
  41302. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41303. */
  41304. refDistance: number;
  41305. /**
  41306. * Define the roll off factor of spatial sounds.
  41307. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41308. */
  41309. rolloffFactor: number;
  41310. /**
  41311. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  41312. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41313. */
  41314. maxDistance: number;
  41315. /**
  41316. * Define the distance attenuation model the sound will follow.
  41317. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41318. */
  41319. distanceModel: string;
  41320. /**
  41321. * @hidden
  41322. * Back Compat
  41323. **/
  41324. onended: () => any;
  41325. /**
  41326. * Gets or sets an object used to store user defined information for the sound.
  41327. */
  41328. metadata: any;
  41329. /**
  41330. * Observable event when the current playing sound finishes.
  41331. */
  41332. onEndedObservable: Observable<Sound>;
  41333. private _panningModel;
  41334. private _playbackRate;
  41335. private _streaming;
  41336. private _startTime;
  41337. private _startOffset;
  41338. private _position;
  41339. /** @hidden */
  41340. _positionInEmitterSpace: boolean;
  41341. private _localDirection;
  41342. private _volume;
  41343. private _isReadyToPlay;
  41344. private _isDirectional;
  41345. private _readyToPlayCallback;
  41346. private _audioBuffer;
  41347. private _soundSource;
  41348. private _streamingSource;
  41349. private _soundPanner;
  41350. private _soundGain;
  41351. private _inputAudioNode;
  41352. private _outputAudioNode;
  41353. private _coneInnerAngle;
  41354. private _coneOuterAngle;
  41355. private _coneOuterGain;
  41356. private _scene;
  41357. private _connectedTransformNode;
  41358. private _customAttenuationFunction;
  41359. private _registerFunc;
  41360. private _isOutputConnected;
  41361. private _htmlAudioElement;
  41362. private _urlType;
  41363. private _length?;
  41364. private _offset?;
  41365. /** @hidden */
  41366. static _SceneComponentInitialization: (scene: Scene) => void;
  41367. /**
  41368. * Create a sound and attach it to a scene
  41369. * @param name Name of your sound
  41370. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  41371. * @param scene defines the scene the sound belongs to
  41372. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  41373. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  41374. */
  41375. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  41376. /**
  41377. * Release the sound and its associated resources
  41378. */
  41379. dispose(): void;
  41380. /**
  41381. * Gets if the sounds is ready to be played or not.
  41382. * @returns true if ready, otherwise false
  41383. */
  41384. isReady(): boolean;
  41385. private _soundLoaded;
  41386. /**
  41387. * Sets the data of the sound from an audiobuffer
  41388. * @param audioBuffer The audioBuffer containing the data
  41389. */
  41390. setAudioBuffer(audioBuffer: AudioBuffer): void;
  41391. /**
  41392. * Updates the current sounds options such as maxdistance, loop...
  41393. * @param options A JSON object containing values named as the object properties
  41394. */
  41395. updateOptions(options: ISoundOptions): void;
  41396. private _createSpatialParameters;
  41397. private _updateSpatialParameters;
  41398. /**
  41399. * Switch the panning model to HRTF:
  41400. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41401. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41402. */
  41403. switchPanningModelToHRTF(): void;
  41404. /**
  41405. * Switch the panning model to Equal Power:
  41406. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41407. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41408. */
  41409. switchPanningModelToEqualPower(): void;
  41410. private _switchPanningModel;
  41411. /**
  41412. * Connect this sound to a sound track audio node like gain...
  41413. * @param soundTrackAudioNode the sound track audio node to connect to
  41414. */
  41415. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  41416. /**
  41417. * Transform this sound into a directional source
  41418. * @param coneInnerAngle Size of the inner cone in degree
  41419. * @param coneOuterAngle Size of the outer cone in degree
  41420. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  41421. */
  41422. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  41423. /**
  41424. * Gets or sets the inner angle for the directional cone.
  41425. */
  41426. get directionalConeInnerAngle(): number;
  41427. /**
  41428. * Gets or sets the inner angle for the directional cone.
  41429. */
  41430. set directionalConeInnerAngle(value: number);
  41431. /**
  41432. * Gets or sets the outer angle for the directional cone.
  41433. */
  41434. get directionalConeOuterAngle(): number;
  41435. /**
  41436. * Gets or sets the outer angle for the directional cone.
  41437. */
  41438. set directionalConeOuterAngle(value: number);
  41439. /**
  41440. * Sets the position of the emitter if spatial sound is enabled
  41441. * @param newPosition Defines the new posisiton
  41442. */
  41443. setPosition(newPosition: Vector3): void;
  41444. /**
  41445. * Sets the local direction of the emitter if spatial sound is enabled
  41446. * @param newLocalDirection Defines the new local direction
  41447. */
  41448. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  41449. private _updateDirection;
  41450. /** @hidden */
  41451. updateDistanceFromListener(): void;
  41452. /**
  41453. * Sets a new custom attenuation function for the sound.
  41454. * @param callback Defines the function used for the attenuation
  41455. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41456. */
  41457. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  41458. /**
  41459. * Play the sound
  41460. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  41461. * @param offset (optional) Start the sound at a specific time in seconds
  41462. * @param length (optional) Sound duration (in seconds)
  41463. */
  41464. play(time?: number, offset?: number, length?: number): void;
  41465. private _onended;
  41466. /**
  41467. * Stop the sound
  41468. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  41469. */
  41470. stop(time?: number): void;
  41471. /**
  41472. * Put the sound in pause
  41473. */
  41474. pause(): void;
  41475. /**
  41476. * Sets a dedicated volume for this sounds
  41477. * @param newVolume Define the new volume of the sound
  41478. * @param time Define time for gradual change to new volume
  41479. */
  41480. setVolume(newVolume: number, time?: number): void;
  41481. /**
  41482. * Set the sound play back rate
  41483. * @param newPlaybackRate Define the playback rate the sound should be played at
  41484. */
  41485. setPlaybackRate(newPlaybackRate: number): void;
  41486. /**
  41487. * Gets the volume of the sound.
  41488. * @returns the volume of the sound
  41489. */
  41490. getVolume(): number;
  41491. /**
  41492. * Attach the sound to a dedicated mesh
  41493. * @param transformNode The transform node to connect the sound with
  41494. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41495. */
  41496. attachToMesh(transformNode: TransformNode): void;
  41497. /**
  41498. * Detach the sound from the previously attached mesh
  41499. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41500. */
  41501. detachFromMesh(): void;
  41502. private _onRegisterAfterWorldMatrixUpdate;
  41503. /**
  41504. * Clone the current sound in the scene.
  41505. * @returns the new sound clone
  41506. */
  41507. clone(): Nullable<Sound>;
  41508. /**
  41509. * Gets the current underlying audio buffer containing the data
  41510. * @returns the audio buffer
  41511. */
  41512. getAudioBuffer(): Nullable<AudioBuffer>;
  41513. /**
  41514. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  41515. * @returns the source node
  41516. */
  41517. getSoundSource(): Nullable<AudioBufferSourceNode>;
  41518. /**
  41519. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  41520. * @returns the gain node
  41521. */
  41522. getSoundGain(): Nullable<GainNode>;
  41523. /**
  41524. * Serializes the Sound in a JSON representation
  41525. * @returns the JSON representation of the sound
  41526. */
  41527. serialize(): any;
  41528. /**
  41529. * Parse a JSON representation of a sound to innstantiate in a given scene
  41530. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  41531. * @param scene Define the scene the new parsed sound should be created in
  41532. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  41533. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  41534. * @returns the newly parsed sound
  41535. */
  41536. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  41537. }
  41538. }
  41539. declare module BABYLON {
  41540. /**
  41541. * This defines an action helpful to play a defined sound on a triggered action.
  41542. */
  41543. export class PlaySoundAction extends Action {
  41544. private _sound;
  41545. /**
  41546. * Instantiate the action
  41547. * @param triggerOptions defines the trigger options
  41548. * @param sound defines the sound to play
  41549. * @param condition defines the trigger related conditions
  41550. */
  41551. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41552. /** @hidden */
  41553. _prepare(): void;
  41554. /**
  41555. * Execute the action and play the sound.
  41556. */
  41557. execute(): void;
  41558. /**
  41559. * Serializes the actions and its related information.
  41560. * @param parent defines the object to serialize in
  41561. * @returns the serialized object
  41562. */
  41563. serialize(parent: any): any;
  41564. }
  41565. /**
  41566. * This defines an action helpful to stop a defined sound on a triggered action.
  41567. */
  41568. export class StopSoundAction extends Action {
  41569. private _sound;
  41570. /**
  41571. * Instantiate the action
  41572. * @param triggerOptions defines the trigger options
  41573. * @param sound defines the sound to stop
  41574. * @param condition defines the trigger related conditions
  41575. */
  41576. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41577. /** @hidden */
  41578. _prepare(): void;
  41579. /**
  41580. * Execute the action and stop the sound.
  41581. */
  41582. execute(): void;
  41583. /**
  41584. * Serializes the actions and its related information.
  41585. * @param parent defines the object to serialize in
  41586. * @returns the serialized object
  41587. */
  41588. serialize(parent: any): any;
  41589. }
  41590. }
  41591. declare module BABYLON {
  41592. /**
  41593. * This defines an action responsible to change the value of a property
  41594. * by interpolating between its current value and the newly set one once triggered.
  41595. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41596. */
  41597. export class InterpolateValueAction extends Action {
  41598. /**
  41599. * Defines the path of the property where the value should be interpolated
  41600. */
  41601. propertyPath: string;
  41602. /**
  41603. * Defines the target value at the end of the interpolation.
  41604. */
  41605. value: any;
  41606. /**
  41607. * Defines the time it will take for the property to interpolate to the value.
  41608. */
  41609. duration: number;
  41610. /**
  41611. * Defines if the other scene animations should be stopped when the action has been triggered
  41612. */
  41613. stopOtherAnimations?: boolean;
  41614. /**
  41615. * Defines a callback raised once the interpolation animation has been done.
  41616. */
  41617. onInterpolationDone?: () => void;
  41618. /**
  41619. * Observable triggered once the interpolation animation has been done.
  41620. */
  41621. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  41622. private _target;
  41623. private _effectiveTarget;
  41624. private _property;
  41625. /**
  41626. * Instantiate the action
  41627. * @param triggerOptions defines the trigger options
  41628. * @param target defines the object containing the value to interpolate
  41629. * @param propertyPath defines the path to the property in the target object
  41630. * @param value defines the target value at the end of the interpolation
  41631. * @param duration deines the time it will take for the property to interpolate to the value.
  41632. * @param condition defines the trigger related conditions
  41633. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  41634. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  41635. */
  41636. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  41637. /** @hidden */
  41638. _prepare(): void;
  41639. /**
  41640. * Execute the action starts the value interpolation.
  41641. */
  41642. execute(): void;
  41643. /**
  41644. * Serializes the actions and its related information.
  41645. * @param parent defines the object to serialize in
  41646. * @returns the serialized object
  41647. */
  41648. serialize(parent: any): any;
  41649. }
  41650. }
  41651. declare module BABYLON {
  41652. /**
  41653. * Options allowed during the creation of a sound track.
  41654. */
  41655. export interface ISoundTrackOptions {
  41656. /**
  41657. * The volume the sound track should take during creation
  41658. */
  41659. volume?: number;
  41660. /**
  41661. * Define if the sound track is the main sound track of the scene
  41662. */
  41663. mainTrack?: boolean;
  41664. }
  41665. /**
  41666. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  41667. * It will be also used in a future release to apply effects on a specific track.
  41668. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  41669. */
  41670. export class SoundTrack {
  41671. /**
  41672. * The unique identifier of the sound track in the scene.
  41673. */
  41674. id: number;
  41675. /**
  41676. * The list of sounds included in the sound track.
  41677. */
  41678. soundCollection: Array<Sound>;
  41679. private _outputAudioNode;
  41680. private _scene;
  41681. private _connectedAnalyser;
  41682. private _options;
  41683. private _isInitialized;
  41684. /**
  41685. * Creates a new sound track.
  41686. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  41687. * @param scene Define the scene the sound track belongs to
  41688. * @param options
  41689. */
  41690. constructor(scene: Scene, options?: ISoundTrackOptions);
  41691. private _initializeSoundTrackAudioGraph;
  41692. /**
  41693. * Release the sound track and its associated resources
  41694. */
  41695. dispose(): void;
  41696. /**
  41697. * Adds a sound to this sound track
  41698. * @param sound define the cound to add
  41699. * @ignoreNaming
  41700. */
  41701. AddSound(sound: Sound): void;
  41702. /**
  41703. * Removes a sound to this sound track
  41704. * @param sound define the cound to remove
  41705. * @ignoreNaming
  41706. */
  41707. RemoveSound(sound: Sound): void;
  41708. /**
  41709. * Set a global volume for the full sound track.
  41710. * @param newVolume Define the new volume of the sound track
  41711. */
  41712. setVolume(newVolume: number): void;
  41713. /**
  41714. * Switch the panning model to HRTF:
  41715. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41716. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41717. */
  41718. switchPanningModelToHRTF(): void;
  41719. /**
  41720. * Switch the panning model to Equal Power:
  41721. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41722. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41723. */
  41724. switchPanningModelToEqualPower(): void;
  41725. /**
  41726. * Connect the sound track to an audio analyser allowing some amazing
  41727. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41728. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41729. * @param analyser The analyser to connect to the engine
  41730. */
  41731. connectToAnalyser(analyser: Analyser): void;
  41732. }
  41733. }
  41734. declare module BABYLON {
  41735. interface AbstractScene {
  41736. /**
  41737. * The list of sounds used in the scene.
  41738. */
  41739. sounds: Nullable<Array<Sound>>;
  41740. }
  41741. interface Scene {
  41742. /**
  41743. * @hidden
  41744. * Backing field
  41745. */
  41746. _mainSoundTrack: SoundTrack;
  41747. /**
  41748. * The main sound track played by the scene.
  41749. * It cotains your primary collection of sounds.
  41750. */
  41751. mainSoundTrack: SoundTrack;
  41752. /**
  41753. * The list of sound tracks added to the scene
  41754. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41755. */
  41756. soundTracks: Nullable<Array<SoundTrack>>;
  41757. /**
  41758. * Gets a sound using a given name
  41759. * @param name defines the name to search for
  41760. * @return the found sound or null if not found at all.
  41761. */
  41762. getSoundByName(name: string): Nullable<Sound>;
  41763. /**
  41764. * Gets or sets if audio support is enabled
  41765. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41766. */
  41767. audioEnabled: boolean;
  41768. /**
  41769. * Gets or sets if audio will be output to headphones
  41770. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41771. */
  41772. headphone: boolean;
  41773. /**
  41774. * Gets or sets custom audio listener position provider
  41775. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41776. */
  41777. audioListenerPositionProvider: Nullable<() => Vector3>;
  41778. /**
  41779. * Gets or sets a refresh rate when using 3D audio positioning
  41780. */
  41781. audioPositioningRefreshRate: number;
  41782. }
  41783. /**
  41784. * Defines the sound scene component responsible to manage any sounds
  41785. * in a given scene.
  41786. */
  41787. export class AudioSceneComponent implements ISceneSerializableComponent {
  41788. /**
  41789. * The component name helpfull to identify the component in the list of scene components.
  41790. */
  41791. readonly name: string;
  41792. /**
  41793. * The scene the component belongs to.
  41794. */
  41795. scene: Scene;
  41796. private _audioEnabled;
  41797. /**
  41798. * Gets whether audio is enabled or not.
  41799. * Please use related enable/disable method to switch state.
  41800. */
  41801. get audioEnabled(): boolean;
  41802. private _headphone;
  41803. /**
  41804. * Gets whether audio is outputing to headphone or not.
  41805. * Please use the according Switch methods to change output.
  41806. */
  41807. get headphone(): boolean;
  41808. /**
  41809. * Gets or sets a refresh rate when using 3D audio positioning
  41810. */
  41811. audioPositioningRefreshRate: number;
  41812. private _audioListenerPositionProvider;
  41813. /**
  41814. * Gets the current audio listener position provider
  41815. */
  41816. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  41817. /**
  41818. * Sets a custom listener position for all sounds in the scene
  41819. * By default, this is the position of the first active camera
  41820. */
  41821. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  41822. /**
  41823. * Creates a new instance of the component for the given scene
  41824. * @param scene Defines the scene to register the component in
  41825. */
  41826. constructor(scene: Scene);
  41827. /**
  41828. * Registers the component in a given scene
  41829. */
  41830. register(): void;
  41831. /**
  41832. * Rebuilds the elements related to this component in case of
  41833. * context lost for instance.
  41834. */
  41835. rebuild(): void;
  41836. /**
  41837. * Serializes the component data to the specified json object
  41838. * @param serializationObject The object to serialize to
  41839. */
  41840. serialize(serializationObject: any): void;
  41841. /**
  41842. * Adds all the elements from the container to the scene
  41843. * @param container the container holding the elements
  41844. */
  41845. addFromContainer(container: AbstractScene): void;
  41846. /**
  41847. * Removes all the elements in the container from the scene
  41848. * @param container contains the elements to remove
  41849. * @param dispose if the removed element should be disposed (default: false)
  41850. */
  41851. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  41852. /**
  41853. * Disposes the component and the associated ressources.
  41854. */
  41855. dispose(): void;
  41856. /**
  41857. * Disables audio in the associated scene.
  41858. */
  41859. disableAudio(): void;
  41860. /**
  41861. * Enables audio in the associated scene.
  41862. */
  41863. enableAudio(): void;
  41864. /**
  41865. * Switch audio to headphone output.
  41866. */
  41867. switchAudioModeForHeadphones(): void;
  41868. /**
  41869. * Switch audio to normal speakers.
  41870. */
  41871. switchAudioModeForNormalSpeakers(): void;
  41872. private _cachedCameraDirection;
  41873. private _cachedCameraPosition;
  41874. private _lastCheck;
  41875. private _afterRender;
  41876. }
  41877. }
  41878. declare module BABYLON {
  41879. /**
  41880. * Wraps one or more Sound objects and selects one with random weight for playback.
  41881. */
  41882. export class WeightedSound {
  41883. /** When true a Sound will be selected and played when the current playing Sound completes. */
  41884. loop: boolean;
  41885. private _coneInnerAngle;
  41886. private _coneOuterAngle;
  41887. private _volume;
  41888. /** A Sound is currently playing. */
  41889. isPlaying: boolean;
  41890. /** A Sound is currently paused. */
  41891. isPaused: boolean;
  41892. private _sounds;
  41893. private _weights;
  41894. private _currentIndex?;
  41895. /**
  41896. * Creates a new WeightedSound from the list of sounds given.
  41897. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  41898. * @param sounds Array of Sounds that will be selected from.
  41899. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  41900. */
  41901. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  41902. /**
  41903. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  41904. */
  41905. get directionalConeInnerAngle(): number;
  41906. /**
  41907. * The size of cone in degress for a directional sound in which there will be no attenuation.
  41908. */
  41909. set directionalConeInnerAngle(value: number);
  41910. /**
  41911. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  41912. * Listener angles between innerAngle and outerAngle will falloff linearly.
  41913. */
  41914. get directionalConeOuterAngle(): number;
  41915. /**
  41916. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  41917. * Listener angles between innerAngle and outerAngle will falloff linearly.
  41918. */
  41919. set directionalConeOuterAngle(value: number);
  41920. /**
  41921. * Playback volume.
  41922. */
  41923. get volume(): number;
  41924. /**
  41925. * Playback volume.
  41926. */
  41927. set volume(value: number);
  41928. private _onended;
  41929. /**
  41930. * Suspend playback
  41931. */
  41932. pause(): void;
  41933. /**
  41934. * Stop playback
  41935. */
  41936. stop(): void;
  41937. /**
  41938. * Start playback.
  41939. * @param startOffset Position the clip head at a specific time in seconds.
  41940. */
  41941. play(startOffset?: number): void;
  41942. }
  41943. }
  41944. declare module BABYLON {
  41945. /**
  41946. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  41947. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41948. */
  41949. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  41950. /**
  41951. * Gets the name of the behavior.
  41952. */
  41953. get name(): string;
  41954. /**
  41955. * The easing function used by animations
  41956. */
  41957. static EasingFunction: BackEase;
  41958. /**
  41959. * The easing mode used by animations
  41960. */
  41961. static EasingMode: number;
  41962. /**
  41963. * The duration of the animation, in milliseconds
  41964. */
  41965. transitionDuration: number;
  41966. /**
  41967. * Length of the distance animated by the transition when lower radius is reached
  41968. */
  41969. lowerRadiusTransitionRange: number;
  41970. /**
  41971. * Length of the distance animated by the transition when upper radius is reached
  41972. */
  41973. upperRadiusTransitionRange: number;
  41974. private _autoTransitionRange;
  41975. /**
  41976. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  41977. */
  41978. get autoTransitionRange(): boolean;
  41979. /**
  41980. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  41981. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  41982. */
  41983. set autoTransitionRange(value: boolean);
  41984. private _attachedCamera;
  41985. private _onAfterCheckInputsObserver;
  41986. private _onMeshTargetChangedObserver;
  41987. /**
  41988. * Initializes the behavior.
  41989. */
  41990. init(): void;
  41991. /**
  41992. * Attaches the behavior to its arc rotate camera.
  41993. * @param camera Defines the camera to attach the behavior to
  41994. */
  41995. attach(camera: ArcRotateCamera): void;
  41996. /**
  41997. * Detaches the behavior from its current arc rotate camera.
  41998. */
  41999. detach(): void;
  42000. private _radiusIsAnimating;
  42001. private _radiusBounceTransition;
  42002. private _animatables;
  42003. private _cachedWheelPrecision;
  42004. /**
  42005. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42006. * @param radiusLimit The limit to check against.
  42007. * @return Bool to indicate if at limit.
  42008. */
  42009. private _isRadiusAtLimit;
  42010. /**
  42011. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42012. * @param radiusDelta The delta by which to animate to. Can be negative.
  42013. */
  42014. private _applyBoundRadiusAnimation;
  42015. /**
  42016. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42017. */
  42018. protected _clearAnimationLocks(): void;
  42019. /**
  42020. * Stops and removes all animations that have been applied to the camera
  42021. */
  42022. stopAllAnimations(): void;
  42023. }
  42024. }
  42025. declare module BABYLON {
  42026. /**
  42027. * 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.
  42028. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42029. */
  42030. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42031. /**
  42032. * Gets the name of the behavior.
  42033. */
  42034. get name(): string;
  42035. private _mode;
  42036. private _radiusScale;
  42037. private _positionScale;
  42038. private _defaultElevation;
  42039. private _elevationReturnTime;
  42040. private _elevationReturnWaitTime;
  42041. private _zoomStopsAnimation;
  42042. private _framingTime;
  42043. /**
  42044. * The easing function used by animations
  42045. */
  42046. static EasingFunction: ExponentialEase;
  42047. /**
  42048. * The easing mode used by animations
  42049. */
  42050. static EasingMode: number;
  42051. /**
  42052. * Sets the current mode used by the behavior
  42053. */
  42054. set mode(mode: number);
  42055. /**
  42056. * Gets current mode used by the behavior.
  42057. */
  42058. get mode(): number;
  42059. /**
  42060. * Sets the scale applied to the radius (1 by default)
  42061. */
  42062. set radiusScale(radius: number);
  42063. /**
  42064. * Gets the scale applied to the radius
  42065. */
  42066. get radiusScale(): number;
  42067. /**
  42068. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42069. */
  42070. set positionScale(scale: number);
  42071. /**
  42072. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42073. */
  42074. get positionScale(): number;
  42075. /**
  42076. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42077. * behaviour is triggered, in radians.
  42078. */
  42079. set defaultElevation(elevation: number);
  42080. /**
  42081. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42082. * behaviour is triggered, in radians.
  42083. */
  42084. get defaultElevation(): number;
  42085. /**
  42086. * Sets the time (in milliseconds) taken to return to the default beta position.
  42087. * Negative value indicates camera should not return to default.
  42088. */
  42089. set elevationReturnTime(speed: number);
  42090. /**
  42091. * Gets the time (in milliseconds) taken to return to the default beta position.
  42092. * Negative value indicates camera should not return to default.
  42093. */
  42094. get elevationReturnTime(): number;
  42095. /**
  42096. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42097. */
  42098. set elevationReturnWaitTime(time: number);
  42099. /**
  42100. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42101. */
  42102. get elevationReturnWaitTime(): number;
  42103. /**
  42104. * Sets the flag that indicates if user zooming should stop animation.
  42105. */
  42106. set zoomStopsAnimation(flag: boolean);
  42107. /**
  42108. * Gets the flag that indicates if user zooming should stop animation.
  42109. */
  42110. get zoomStopsAnimation(): boolean;
  42111. /**
  42112. * Sets the transition time when framing the mesh, in milliseconds
  42113. */
  42114. set framingTime(time: number);
  42115. /**
  42116. * Gets the transition time when framing the mesh, in milliseconds
  42117. */
  42118. get framingTime(): number;
  42119. /**
  42120. * Define if the behavior should automatically change the configured
  42121. * camera limits and sensibilities.
  42122. */
  42123. autoCorrectCameraLimitsAndSensibility: boolean;
  42124. private _onPrePointerObservableObserver;
  42125. private _onAfterCheckInputsObserver;
  42126. private _onMeshTargetChangedObserver;
  42127. private _attachedCamera;
  42128. private _isPointerDown;
  42129. private _lastInteractionTime;
  42130. /**
  42131. * Initializes the behavior.
  42132. */
  42133. init(): void;
  42134. /**
  42135. * Attaches the behavior to its arc rotate camera.
  42136. * @param camera Defines the camera to attach the behavior to
  42137. */
  42138. attach(camera: ArcRotateCamera): void;
  42139. /**
  42140. * Detaches the behavior from its current arc rotate camera.
  42141. */
  42142. detach(): void;
  42143. private _animatables;
  42144. private _betaIsAnimating;
  42145. private _betaTransition;
  42146. private _radiusTransition;
  42147. private _vectorTransition;
  42148. /**
  42149. * Targets the given mesh and updates zoom level accordingly.
  42150. * @param mesh The mesh to target.
  42151. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42152. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42153. */
  42154. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42155. /**
  42156. * Targets the given mesh with its children and updates zoom level accordingly.
  42157. * @param mesh The mesh to target.
  42158. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42159. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42160. */
  42161. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42162. /**
  42163. * Targets the given meshes with their children and updates zoom level accordingly.
  42164. * @param meshes The mesh to target.
  42165. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42166. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42167. */
  42168. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42169. /**
  42170. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42171. * @param minimumWorld Determines the smaller position of the bounding box extend
  42172. * @param maximumWorld Determines the bigger position of the bounding box extend
  42173. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42174. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42175. */
  42176. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42177. /**
  42178. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42179. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42180. * frustum width.
  42181. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42182. * to fully enclose the mesh in the viewing frustum.
  42183. */
  42184. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42185. /**
  42186. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42187. * is automatically returned to its default position (expected to be above ground plane).
  42188. */
  42189. private _maintainCameraAboveGround;
  42190. /**
  42191. * Returns the frustum slope based on the canvas ratio and camera FOV
  42192. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42193. */
  42194. private _getFrustumSlope;
  42195. /**
  42196. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42197. */
  42198. private _clearAnimationLocks;
  42199. /**
  42200. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42201. */
  42202. private _applyUserInteraction;
  42203. /**
  42204. * Stops and removes all animations that have been applied to the camera
  42205. */
  42206. stopAllAnimations(): void;
  42207. /**
  42208. * Gets a value indicating if the user is moving the camera
  42209. */
  42210. get isUserIsMoving(): boolean;
  42211. /**
  42212. * The camera can move all the way towards the mesh.
  42213. */
  42214. static IgnoreBoundsSizeMode: number;
  42215. /**
  42216. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42217. */
  42218. static FitFrustumSidesMode: number;
  42219. }
  42220. }
  42221. declare module BABYLON {
  42222. /**
  42223. * Base class for Camera Pointer Inputs.
  42224. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42225. * for example usage.
  42226. */
  42227. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42228. /**
  42229. * Defines the camera the input is attached to.
  42230. */
  42231. abstract camera: Camera;
  42232. /**
  42233. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42234. */
  42235. protected _altKey: boolean;
  42236. protected _ctrlKey: boolean;
  42237. protected _metaKey: boolean;
  42238. protected _shiftKey: boolean;
  42239. /**
  42240. * Which mouse buttons were pressed at time of last mouse event.
  42241. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  42242. */
  42243. protected _buttonsPressed: number;
  42244. /**
  42245. * Defines the buttons associated with the input to handle camera move.
  42246. */
  42247. buttons: number[];
  42248. /**
  42249. * Attach the input controls to a specific dom element to get the input from.
  42250. * @param element Defines the element the controls should be listened from
  42251. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42252. */
  42253. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42254. /**
  42255. * Detach the current controls from the specified dom element.
  42256. * @param element Defines the element to stop listening the inputs from
  42257. */
  42258. detachControl(element: Nullable<HTMLElement>): void;
  42259. /**
  42260. * Gets the class name of the current input.
  42261. * @returns the class name
  42262. */
  42263. getClassName(): string;
  42264. /**
  42265. * Get the friendly name associated with the input class.
  42266. * @returns the input friendly name
  42267. */
  42268. getSimpleName(): string;
  42269. /**
  42270. * Called on pointer POINTERDOUBLETAP event.
  42271. * Override this method to provide functionality on POINTERDOUBLETAP event.
  42272. */
  42273. protected onDoubleTap(type: string): void;
  42274. /**
  42275. * Called on pointer POINTERMOVE event if only a single touch is active.
  42276. * Override this method to provide functionality.
  42277. */
  42278. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42279. /**
  42280. * Called on pointer POINTERMOVE event if multiple touches are active.
  42281. * Override this method to provide functionality.
  42282. */
  42283. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42284. /**
  42285. * Called on JS contextmenu event.
  42286. * Override this method to provide functionality.
  42287. */
  42288. protected onContextMenu(evt: PointerEvent): void;
  42289. /**
  42290. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42291. * press.
  42292. * Override this method to provide functionality.
  42293. */
  42294. protected onButtonDown(evt: PointerEvent): void;
  42295. /**
  42296. * Called each time a new POINTERUP event occurs. Ie, for each button
  42297. * release.
  42298. * Override this method to provide functionality.
  42299. */
  42300. protected onButtonUp(evt: PointerEvent): void;
  42301. /**
  42302. * Called when window becomes inactive.
  42303. * Override this method to provide functionality.
  42304. */
  42305. protected onLostFocus(): void;
  42306. private _pointerInput;
  42307. private _observer;
  42308. private _onLostFocus;
  42309. private pointA;
  42310. private pointB;
  42311. }
  42312. }
  42313. declare module BABYLON {
  42314. /**
  42315. * Manage the pointers inputs to control an arc rotate camera.
  42316. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42317. */
  42318. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  42319. /**
  42320. * Defines the camera the input is attached to.
  42321. */
  42322. camera: ArcRotateCamera;
  42323. /**
  42324. * Gets the class name of the current input.
  42325. * @returns the class name
  42326. */
  42327. getClassName(): string;
  42328. /**
  42329. * Defines the buttons associated with the input to handle camera move.
  42330. */
  42331. buttons: number[];
  42332. /**
  42333. * Defines the pointer angular sensibility along the X axis or how fast is
  42334. * the camera rotating.
  42335. */
  42336. angularSensibilityX: number;
  42337. /**
  42338. * Defines the pointer angular sensibility along the Y axis or how fast is
  42339. * the camera rotating.
  42340. */
  42341. angularSensibilityY: number;
  42342. /**
  42343. * Defines the pointer pinch precision or how fast is the camera zooming.
  42344. */
  42345. pinchPrecision: number;
  42346. /**
  42347. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42348. * from 0.
  42349. * It defines the percentage of current camera.radius to use as delta when
  42350. * pinch zoom is used.
  42351. */
  42352. pinchDeltaPercentage: number;
  42353. /**
  42354. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42355. * that any object in the plane at the camera's target point will scale
  42356. * perfectly with finger motion.
  42357. * Overrides pinchDeltaPercentage and pinchPrecision.
  42358. */
  42359. useNaturalPinchZoom: boolean;
  42360. /**
  42361. * Defines the pointer panning sensibility or how fast is the camera moving.
  42362. */
  42363. panningSensibility: number;
  42364. /**
  42365. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  42366. */
  42367. multiTouchPanning: boolean;
  42368. /**
  42369. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  42370. * zoom (pinch) through multitouch.
  42371. */
  42372. multiTouchPanAndZoom: boolean;
  42373. /**
  42374. * Revers pinch action direction.
  42375. */
  42376. pinchInwards: boolean;
  42377. private _isPanClick;
  42378. private _twoFingerActivityCount;
  42379. private _isPinching;
  42380. /**
  42381. * Called on pointer POINTERMOVE event if only a single touch is active.
  42382. */
  42383. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42384. /**
  42385. * Called on pointer POINTERDOUBLETAP event.
  42386. */
  42387. protected onDoubleTap(type: string): void;
  42388. /**
  42389. * Called on pointer POINTERMOVE event if multiple touches are active.
  42390. */
  42391. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42392. /**
  42393. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42394. * press.
  42395. */
  42396. protected onButtonDown(evt: PointerEvent): void;
  42397. /**
  42398. * Called each time a new POINTERUP event occurs. Ie, for each button
  42399. * release.
  42400. */
  42401. protected onButtonUp(evt: PointerEvent): void;
  42402. /**
  42403. * Called when window becomes inactive.
  42404. */
  42405. protected onLostFocus(): void;
  42406. }
  42407. }
  42408. declare module BABYLON {
  42409. /**
  42410. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  42411. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42412. */
  42413. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  42414. /**
  42415. * Defines the camera the input is attached to.
  42416. */
  42417. camera: ArcRotateCamera;
  42418. /**
  42419. * Defines the list of key codes associated with the up action (increase alpha)
  42420. */
  42421. keysUp: number[];
  42422. /**
  42423. * Defines the list of key codes associated with the down action (decrease alpha)
  42424. */
  42425. keysDown: number[];
  42426. /**
  42427. * Defines the list of key codes associated with the left action (increase beta)
  42428. */
  42429. keysLeft: number[];
  42430. /**
  42431. * Defines the list of key codes associated with the right action (decrease beta)
  42432. */
  42433. keysRight: number[];
  42434. /**
  42435. * Defines the list of key codes associated with the reset action.
  42436. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  42437. */
  42438. keysReset: number[];
  42439. /**
  42440. * Defines the panning sensibility of the inputs.
  42441. * (How fast is the camera panning)
  42442. */
  42443. panningSensibility: number;
  42444. /**
  42445. * Defines the zooming sensibility of the inputs.
  42446. * (How fast is the camera zooming)
  42447. */
  42448. zoomingSensibility: number;
  42449. /**
  42450. * Defines whether maintaining the alt key down switch the movement mode from
  42451. * orientation to zoom.
  42452. */
  42453. useAltToZoom: boolean;
  42454. /**
  42455. * Rotation speed of the camera
  42456. */
  42457. angularSpeed: number;
  42458. private _keys;
  42459. private _ctrlPressed;
  42460. private _altPressed;
  42461. private _onCanvasBlurObserver;
  42462. private _onKeyboardObserver;
  42463. private _engine;
  42464. private _scene;
  42465. /**
  42466. * Attach the input controls to a specific dom element to get the input from.
  42467. * @param element Defines the element the controls should be listened from
  42468. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42469. */
  42470. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42471. /**
  42472. * Detach the current controls from the specified dom element.
  42473. * @param element Defines the element to stop listening the inputs from
  42474. */
  42475. detachControl(element: Nullable<HTMLElement>): void;
  42476. /**
  42477. * Update the current camera state depending on the inputs that have been used this frame.
  42478. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42479. */
  42480. checkInputs(): void;
  42481. /**
  42482. * Gets the class name of the current intput.
  42483. * @returns the class name
  42484. */
  42485. getClassName(): string;
  42486. /**
  42487. * Get the friendly name associated with the input class.
  42488. * @returns the input friendly name
  42489. */
  42490. getSimpleName(): string;
  42491. }
  42492. }
  42493. declare module BABYLON {
  42494. /**
  42495. * Manage the mouse wheel inputs to control an arc rotate camera.
  42496. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42497. */
  42498. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  42499. /**
  42500. * Defines the camera the input is attached to.
  42501. */
  42502. camera: ArcRotateCamera;
  42503. /**
  42504. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42505. */
  42506. wheelPrecision: number;
  42507. /**
  42508. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  42509. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  42510. */
  42511. wheelDeltaPercentage: number;
  42512. private _wheel;
  42513. private _observer;
  42514. private computeDeltaFromMouseWheelLegacyEvent;
  42515. /**
  42516. * Attach the input controls to a specific dom element to get the input from.
  42517. * @param element Defines the element the controls should be listened from
  42518. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42519. */
  42520. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42521. /**
  42522. * Detach the current controls from the specified dom element.
  42523. * @param element Defines the element to stop listening the inputs from
  42524. */
  42525. detachControl(element: Nullable<HTMLElement>): void;
  42526. /**
  42527. * Gets the class name of the current intput.
  42528. * @returns the class name
  42529. */
  42530. getClassName(): string;
  42531. /**
  42532. * Get the friendly name associated with the input class.
  42533. * @returns the input friendly name
  42534. */
  42535. getSimpleName(): string;
  42536. }
  42537. }
  42538. declare module BABYLON {
  42539. /**
  42540. * Default Inputs manager for the ArcRotateCamera.
  42541. * It groups all the default supported inputs for ease of use.
  42542. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42543. */
  42544. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  42545. /**
  42546. * Instantiates a new ArcRotateCameraInputsManager.
  42547. * @param camera Defines the camera the inputs belong to
  42548. */
  42549. constructor(camera: ArcRotateCamera);
  42550. /**
  42551. * Add mouse wheel input support to the input manager.
  42552. * @returns the current input manager
  42553. */
  42554. addMouseWheel(): ArcRotateCameraInputsManager;
  42555. /**
  42556. * Add pointers input support to the input manager.
  42557. * @returns the current input manager
  42558. */
  42559. addPointers(): ArcRotateCameraInputsManager;
  42560. /**
  42561. * Add keyboard input support to the input manager.
  42562. * @returns the current input manager
  42563. */
  42564. addKeyboard(): ArcRotateCameraInputsManager;
  42565. }
  42566. }
  42567. declare module BABYLON {
  42568. /**
  42569. * This represents an orbital type of camera.
  42570. *
  42571. * 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.
  42572. * 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.
  42573. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  42574. */
  42575. export class ArcRotateCamera extends TargetCamera {
  42576. /**
  42577. * Defines the rotation angle of the camera along the longitudinal axis.
  42578. */
  42579. alpha: number;
  42580. /**
  42581. * Defines the rotation angle of the camera along the latitudinal axis.
  42582. */
  42583. beta: number;
  42584. /**
  42585. * Defines the radius of the camera from it s target point.
  42586. */
  42587. radius: number;
  42588. protected _target: Vector3;
  42589. protected _targetHost: Nullable<AbstractMesh>;
  42590. /**
  42591. * Defines the target point of the camera.
  42592. * The camera looks towards it form the radius distance.
  42593. */
  42594. get target(): Vector3;
  42595. set target(value: Vector3);
  42596. /**
  42597. * Define the current local position of the camera in the scene
  42598. */
  42599. get position(): Vector3;
  42600. set position(newPosition: Vector3);
  42601. protected _upVector: Vector3;
  42602. protected _upToYMatrix: Matrix;
  42603. protected _YToUpMatrix: Matrix;
  42604. /**
  42605. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  42606. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  42607. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  42608. */
  42609. set upVector(vec: Vector3);
  42610. get upVector(): Vector3;
  42611. /**
  42612. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  42613. */
  42614. setMatUp(): void;
  42615. /**
  42616. * Current inertia value on the longitudinal axis.
  42617. * The bigger this number the longer it will take for the camera to stop.
  42618. */
  42619. inertialAlphaOffset: number;
  42620. /**
  42621. * Current inertia value on the latitudinal axis.
  42622. * The bigger this number the longer it will take for the camera to stop.
  42623. */
  42624. inertialBetaOffset: number;
  42625. /**
  42626. * Current inertia value on the radius axis.
  42627. * The bigger this number the longer it will take for the camera to stop.
  42628. */
  42629. inertialRadiusOffset: number;
  42630. /**
  42631. * Minimum allowed angle on the longitudinal axis.
  42632. * This can help limiting how the Camera is able to move in the scene.
  42633. */
  42634. lowerAlphaLimit: Nullable<number>;
  42635. /**
  42636. * Maximum allowed angle on the longitudinal axis.
  42637. * This can help limiting how the Camera is able to move in the scene.
  42638. */
  42639. upperAlphaLimit: Nullable<number>;
  42640. /**
  42641. * Minimum allowed angle on the latitudinal axis.
  42642. * This can help limiting how the Camera is able to move in the scene.
  42643. */
  42644. lowerBetaLimit: number;
  42645. /**
  42646. * Maximum allowed angle on the latitudinal axis.
  42647. * This can help limiting how the Camera is able to move in the scene.
  42648. */
  42649. upperBetaLimit: number;
  42650. /**
  42651. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  42652. * This can help limiting how the Camera is able to move in the scene.
  42653. */
  42654. lowerRadiusLimit: Nullable<number>;
  42655. /**
  42656. * Maximum allowed distance of the camera to the target (The camera can not get further).
  42657. * This can help limiting how the Camera is able to move in the scene.
  42658. */
  42659. upperRadiusLimit: Nullable<number>;
  42660. /**
  42661. * Defines the current inertia value used during panning of the camera along the X axis.
  42662. */
  42663. inertialPanningX: number;
  42664. /**
  42665. * Defines the current inertia value used during panning of the camera along the Y axis.
  42666. */
  42667. inertialPanningY: number;
  42668. /**
  42669. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  42670. * Basically if your fingers moves away from more than this distance you will be considered
  42671. * in pinch mode.
  42672. */
  42673. pinchToPanMaxDistance: number;
  42674. /**
  42675. * Defines the maximum distance the camera can pan.
  42676. * This could help keeping the cammera always in your scene.
  42677. */
  42678. panningDistanceLimit: Nullable<number>;
  42679. /**
  42680. * Defines the target of the camera before paning.
  42681. */
  42682. panningOriginTarget: Vector3;
  42683. /**
  42684. * Defines the value of the inertia used during panning.
  42685. * 0 would mean stop inertia and one would mean no decelleration at all.
  42686. */
  42687. panningInertia: number;
  42688. /**
  42689. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  42690. */
  42691. get angularSensibilityX(): number;
  42692. set angularSensibilityX(value: number);
  42693. /**
  42694. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  42695. */
  42696. get angularSensibilityY(): number;
  42697. set angularSensibilityY(value: number);
  42698. /**
  42699. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  42700. */
  42701. get pinchPrecision(): number;
  42702. set pinchPrecision(value: number);
  42703. /**
  42704. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  42705. * It will be used instead of pinchDeltaPrecision if different from 0.
  42706. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42707. */
  42708. get pinchDeltaPercentage(): number;
  42709. set pinchDeltaPercentage(value: number);
  42710. /**
  42711. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  42712. * and pinch delta percentage.
  42713. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42714. * that any object in the plane at the camera's target point will scale
  42715. * perfectly with finger motion.
  42716. */
  42717. get useNaturalPinchZoom(): boolean;
  42718. set useNaturalPinchZoom(value: boolean);
  42719. /**
  42720. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  42721. */
  42722. get panningSensibility(): number;
  42723. set panningSensibility(value: number);
  42724. /**
  42725. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  42726. */
  42727. get keysUp(): number[];
  42728. set keysUp(value: number[]);
  42729. /**
  42730. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  42731. */
  42732. get keysDown(): number[];
  42733. set keysDown(value: number[]);
  42734. /**
  42735. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  42736. */
  42737. get keysLeft(): number[];
  42738. set keysLeft(value: number[]);
  42739. /**
  42740. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  42741. */
  42742. get keysRight(): number[];
  42743. set keysRight(value: number[]);
  42744. /**
  42745. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42746. */
  42747. get wheelPrecision(): number;
  42748. set wheelPrecision(value: number);
  42749. /**
  42750. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  42751. * It will be used instead of pinchDeltaPrecision if different from 0.
  42752. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42753. */
  42754. get wheelDeltaPercentage(): number;
  42755. set wheelDeltaPercentage(value: number);
  42756. /**
  42757. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  42758. */
  42759. zoomOnFactor: number;
  42760. /**
  42761. * Defines a screen offset for the camera position.
  42762. */
  42763. targetScreenOffset: Vector2;
  42764. /**
  42765. * Allows the camera to be completely reversed.
  42766. * If false the camera can not arrive upside down.
  42767. */
  42768. allowUpsideDown: boolean;
  42769. /**
  42770. * Define if double tap/click is used to restore the previously saved state of the camera.
  42771. */
  42772. useInputToRestoreState: boolean;
  42773. /** @hidden */
  42774. _viewMatrix: Matrix;
  42775. /** @hidden */
  42776. _useCtrlForPanning: boolean;
  42777. /** @hidden */
  42778. _panningMouseButton: number;
  42779. /**
  42780. * Defines the input associated to the camera.
  42781. */
  42782. inputs: ArcRotateCameraInputsManager;
  42783. /** @hidden */
  42784. _reset: () => void;
  42785. /**
  42786. * Defines the allowed panning axis.
  42787. */
  42788. panningAxis: Vector3;
  42789. protected _localDirection: Vector3;
  42790. protected _transformedDirection: Vector3;
  42791. private _bouncingBehavior;
  42792. /**
  42793. * Gets the bouncing behavior of the camera if it has been enabled.
  42794. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42795. */
  42796. get bouncingBehavior(): Nullable<BouncingBehavior>;
  42797. /**
  42798. * Defines if the bouncing behavior of the camera is enabled on the camera.
  42799. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42800. */
  42801. get useBouncingBehavior(): boolean;
  42802. set useBouncingBehavior(value: boolean);
  42803. private _framingBehavior;
  42804. /**
  42805. * Gets the framing behavior of the camera if it has been enabled.
  42806. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42807. */
  42808. get framingBehavior(): Nullable<FramingBehavior>;
  42809. /**
  42810. * Defines if the framing behavior of the camera is enabled on the camera.
  42811. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42812. */
  42813. get useFramingBehavior(): boolean;
  42814. set useFramingBehavior(value: boolean);
  42815. private _autoRotationBehavior;
  42816. /**
  42817. * Gets the auto rotation behavior of the camera if it has been enabled.
  42818. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42819. */
  42820. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  42821. /**
  42822. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  42823. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42824. */
  42825. get useAutoRotationBehavior(): boolean;
  42826. set useAutoRotationBehavior(value: boolean);
  42827. /**
  42828. * Observable triggered when the mesh target has been changed on the camera.
  42829. */
  42830. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  42831. /**
  42832. * Event raised when the camera is colliding with a mesh.
  42833. */
  42834. onCollide: (collidedMesh: AbstractMesh) => void;
  42835. /**
  42836. * Defines whether the camera should check collision with the objects oh the scene.
  42837. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  42838. */
  42839. checkCollisions: boolean;
  42840. /**
  42841. * Defines the collision radius of the camera.
  42842. * This simulates a sphere around the camera.
  42843. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  42844. */
  42845. collisionRadius: Vector3;
  42846. protected _collider: Collider;
  42847. protected _previousPosition: Vector3;
  42848. protected _collisionVelocity: Vector3;
  42849. protected _newPosition: Vector3;
  42850. protected _previousAlpha: number;
  42851. protected _previousBeta: number;
  42852. protected _previousRadius: number;
  42853. protected _collisionTriggered: boolean;
  42854. protected _targetBoundingCenter: Nullable<Vector3>;
  42855. private _computationVector;
  42856. /**
  42857. * Instantiates a new ArcRotateCamera in a given scene
  42858. * @param name Defines the name of the camera
  42859. * @param alpha Defines the camera rotation along the logitudinal axis
  42860. * @param beta Defines the camera rotation along the latitudinal axis
  42861. * @param radius Defines the camera distance from its target
  42862. * @param target Defines the camera target
  42863. * @param scene Defines the scene the camera belongs to
  42864. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  42865. */
  42866. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  42867. /** @hidden */
  42868. _initCache(): void;
  42869. /** @hidden */
  42870. _updateCache(ignoreParentClass?: boolean): void;
  42871. protected _getTargetPosition(): Vector3;
  42872. private _storedAlpha;
  42873. private _storedBeta;
  42874. private _storedRadius;
  42875. private _storedTarget;
  42876. private _storedTargetScreenOffset;
  42877. /**
  42878. * Stores the current state of the camera (alpha, beta, radius and target)
  42879. * @returns the camera itself
  42880. */
  42881. storeState(): Camera;
  42882. /**
  42883. * @hidden
  42884. * Restored camera state. You must call storeState() first
  42885. */
  42886. _restoreStateValues(): boolean;
  42887. /** @hidden */
  42888. _isSynchronizedViewMatrix(): boolean;
  42889. /**
  42890. * Attached controls to the current camera.
  42891. * @param element Defines the element the controls should be listened from
  42892. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42893. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  42894. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  42895. */
  42896. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  42897. /**
  42898. * Detach the current controls from the camera.
  42899. * The camera will stop reacting to inputs.
  42900. * @param element Defines the element to stop listening the inputs from
  42901. */
  42902. detachControl(element: HTMLElement): void;
  42903. /** @hidden */
  42904. _checkInputs(): void;
  42905. protected _checkLimits(): void;
  42906. /**
  42907. * Rebuilds angles (alpha, beta) and radius from the give position and target
  42908. */
  42909. rebuildAnglesAndRadius(): void;
  42910. /**
  42911. * Use a position to define the current camera related information like alpha, beta and radius
  42912. * @param position Defines the position to set the camera at
  42913. */
  42914. setPosition(position: Vector3): void;
  42915. /**
  42916. * Defines the target the camera should look at.
  42917. * This will automatically adapt alpha beta and radius to fit within the new target.
  42918. * @param target Defines the new target as a Vector or a mesh
  42919. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  42920. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  42921. */
  42922. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  42923. /** @hidden */
  42924. _getViewMatrix(): Matrix;
  42925. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  42926. /**
  42927. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  42928. * @param meshes Defines the mesh to zoom on
  42929. * @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)
  42930. */
  42931. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  42932. /**
  42933. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  42934. * The target will be changed but the radius
  42935. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  42936. * @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)
  42937. */
  42938. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  42939. min: Vector3;
  42940. max: Vector3;
  42941. distance: number;
  42942. }, doNotUpdateMaxZ?: boolean): void;
  42943. /**
  42944. * @override
  42945. * Override Camera.createRigCamera
  42946. */
  42947. createRigCamera(name: string, cameraIndex: number): Camera;
  42948. /**
  42949. * @hidden
  42950. * @override
  42951. * Override Camera._updateRigCameras
  42952. */
  42953. _updateRigCameras(): void;
  42954. /**
  42955. * Destroy the camera and release the current resources hold by it.
  42956. */
  42957. dispose(): void;
  42958. /**
  42959. * Gets the current object class name.
  42960. * @return the class name
  42961. */
  42962. getClassName(): string;
  42963. }
  42964. }
  42965. declare module BABYLON {
  42966. /**
  42967. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  42968. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42969. */
  42970. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  42971. /**
  42972. * Gets the name of the behavior.
  42973. */
  42974. get name(): string;
  42975. private _zoomStopsAnimation;
  42976. private _idleRotationSpeed;
  42977. private _idleRotationWaitTime;
  42978. private _idleRotationSpinupTime;
  42979. /**
  42980. * Sets the flag that indicates if user zooming should stop animation.
  42981. */
  42982. set zoomStopsAnimation(flag: boolean);
  42983. /**
  42984. * Gets the flag that indicates if user zooming should stop animation.
  42985. */
  42986. get zoomStopsAnimation(): boolean;
  42987. /**
  42988. * Sets the default speed at which the camera rotates around the model.
  42989. */
  42990. set idleRotationSpeed(speed: number);
  42991. /**
  42992. * Gets the default speed at which the camera rotates around the model.
  42993. */
  42994. get idleRotationSpeed(): number;
  42995. /**
  42996. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  42997. */
  42998. set idleRotationWaitTime(time: number);
  42999. /**
  43000. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43001. */
  43002. get idleRotationWaitTime(): number;
  43003. /**
  43004. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43005. */
  43006. set idleRotationSpinupTime(time: number);
  43007. /**
  43008. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43009. */
  43010. get idleRotationSpinupTime(): number;
  43011. /**
  43012. * Gets a value indicating if the camera is currently rotating because of this behavior
  43013. */
  43014. get rotationInProgress(): boolean;
  43015. private _onPrePointerObservableObserver;
  43016. private _onAfterCheckInputsObserver;
  43017. private _attachedCamera;
  43018. private _isPointerDown;
  43019. private _lastFrameTime;
  43020. private _lastInteractionTime;
  43021. private _cameraRotationSpeed;
  43022. /**
  43023. * Initializes the behavior.
  43024. */
  43025. init(): void;
  43026. /**
  43027. * Attaches the behavior to its arc rotate camera.
  43028. * @param camera Defines the camera to attach the behavior to
  43029. */
  43030. attach(camera: ArcRotateCamera): void;
  43031. /**
  43032. * Detaches the behavior from its current arc rotate camera.
  43033. */
  43034. detach(): void;
  43035. /**
  43036. * Returns true if user is scrolling.
  43037. * @return true if user is scrolling.
  43038. */
  43039. private _userIsZooming;
  43040. private _lastFrameRadius;
  43041. private _shouldAnimationStopForInteraction;
  43042. /**
  43043. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43044. */
  43045. private _applyUserInteraction;
  43046. private _userIsMoving;
  43047. }
  43048. }
  43049. declare module BABYLON {
  43050. /**
  43051. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43052. */
  43053. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43054. private ui;
  43055. /**
  43056. * The name of the behavior
  43057. */
  43058. name: string;
  43059. /**
  43060. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43061. */
  43062. distanceAwayFromFace: number;
  43063. /**
  43064. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43065. */
  43066. distanceAwayFromBottomOfFace: number;
  43067. private _faceVectors;
  43068. private _target;
  43069. private _scene;
  43070. private _onRenderObserver;
  43071. private _tmpMatrix;
  43072. private _tmpVector;
  43073. /**
  43074. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43075. * @param ui The transform node that should be attched to the mesh
  43076. */
  43077. constructor(ui: TransformNode);
  43078. /**
  43079. * Initializes the behavior
  43080. */
  43081. init(): void;
  43082. private _closestFace;
  43083. private _zeroVector;
  43084. private _lookAtTmpMatrix;
  43085. private _lookAtToRef;
  43086. /**
  43087. * Attaches the AttachToBoxBehavior to the passed in mesh
  43088. * @param target The mesh that the specified node will be attached to
  43089. */
  43090. attach(target: Mesh): void;
  43091. /**
  43092. * Detaches the behavior from the mesh
  43093. */
  43094. detach(): void;
  43095. }
  43096. }
  43097. declare module BABYLON {
  43098. /**
  43099. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43100. */
  43101. export class FadeInOutBehavior implements Behavior<Mesh> {
  43102. /**
  43103. * Time in milliseconds to delay before fading in (Default: 0)
  43104. */
  43105. delay: number;
  43106. /**
  43107. * Time in milliseconds for the mesh to fade in (Default: 300)
  43108. */
  43109. fadeInTime: number;
  43110. private _millisecondsPerFrame;
  43111. private _hovered;
  43112. private _hoverValue;
  43113. private _ownerNode;
  43114. /**
  43115. * Instatiates the FadeInOutBehavior
  43116. */
  43117. constructor();
  43118. /**
  43119. * The name of the behavior
  43120. */
  43121. get name(): string;
  43122. /**
  43123. * Initializes the behavior
  43124. */
  43125. init(): void;
  43126. /**
  43127. * Attaches the fade behavior on the passed in mesh
  43128. * @param ownerNode The mesh that will be faded in/out once attached
  43129. */
  43130. attach(ownerNode: Mesh): void;
  43131. /**
  43132. * Detaches the behavior from the mesh
  43133. */
  43134. detach(): void;
  43135. /**
  43136. * Triggers the mesh to begin fading in or out
  43137. * @param value if the object should fade in or out (true to fade in)
  43138. */
  43139. fadeIn(value: boolean): void;
  43140. private _update;
  43141. private _setAllVisibility;
  43142. }
  43143. }
  43144. declare module BABYLON {
  43145. /**
  43146. * Class containing a set of static utilities functions for managing Pivots
  43147. * @hidden
  43148. */
  43149. export class PivotTools {
  43150. private static _PivotCached;
  43151. private static _OldPivotPoint;
  43152. private static _PivotTranslation;
  43153. private static _PivotTmpVector;
  43154. /** @hidden */
  43155. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43156. /** @hidden */
  43157. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43158. }
  43159. }
  43160. declare module BABYLON {
  43161. /**
  43162. * Class containing static functions to help procedurally build meshes
  43163. */
  43164. export class PlaneBuilder {
  43165. /**
  43166. * Creates a plane mesh
  43167. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43168. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43169. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43170. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43171. * * 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
  43172. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43173. * @param name defines the name of the mesh
  43174. * @param options defines the options used to create the mesh
  43175. * @param scene defines the hosting scene
  43176. * @returns the plane mesh
  43177. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43178. */
  43179. static CreatePlane(name: string, options: {
  43180. size?: number;
  43181. width?: number;
  43182. height?: number;
  43183. sideOrientation?: number;
  43184. frontUVs?: Vector4;
  43185. backUVs?: Vector4;
  43186. updatable?: boolean;
  43187. sourcePlane?: Plane;
  43188. }, scene?: Nullable<Scene>): Mesh;
  43189. }
  43190. }
  43191. declare module BABYLON {
  43192. /**
  43193. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  43194. */
  43195. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  43196. private static _AnyMouseID;
  43197. /**
  43198. * Abstract mesh the behavior is set on
  43199. */
  43200. attachedNode: AbstractMesh;
  43201. private _dragPlane;
  43202. private _scene;
  43203. private _pointerObserver;
  43204. private _beforeRenderObserver;
  43205. private static _planeScene;
  43206. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  43207. /**
  43208. * 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)
  43209. */
  43210. maxDragAngle: number;
  43211. /**
  43212. * @hidden
  43213. */
  43214. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  43215. /**
  43216. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43217. */
  43218. currentDraggingPointerID: number;
  43219. /**
  43220. * The last position where the pointer hit the drag plane in world space
  43221. */
  43222. lastDragPosition: Vector3;
  43223. /**
  43224. * If the behavior is currently in a dragging state
  43225. */
  43226. dragging: boolean;
  43227. /**
  43228. * 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)
  43229. */
  43230. dragDeltaRatio: number;
  43231. /**
  43232. * If the drag plane orientation should be updated during the dragging (Default: true)
  43233. */
  43234. updateDragPlane: boolean;
  43235. private _debugMode;
  43236. private _moving;
  43237. /**
  43238. * Fires each time the attached mesh is dragged with the pointer
  43239. * * delta between last drag position and current drag position in world space
  43240. * * dragDistance along the drag axis
  43241. * * dragPlaneNormal normal of the current drag plane used during the drag
  43242. * * dragPlanePoint in world space where the drag intersects the drag plane
  43243. */
  43244. onDragObservable: Observable<{
  43245. delta: Vector3;
  43246. dragPlanePoint: Vector3;
  43247. dragPlaneNormal: Vector3;
  43248. dragDistance: number;
  43249. pointerId: number;
  43250. }>;
  43251. /**
  43252. * Fires each time a drag begins (eg. mouse down on mesh)
  43253. */
  43254. onDragStartObservable: Observable<{
  43255. dragPlanePoint: Vector3;
  43256. pointerId: number;
  43257. }>;
  43258. /**
  43259. * Fires each time a drag ends (eg. mouse release after drag)
  43260. */
  43261. onDragEndObservable: Observable<{
  43262. dragPlanePoint: Vector3;
  43263. pointerId: number;
  43264. }>;
  43265. /**
  43266. * If the attached mesh should be moved when dragged
  43267. */
  43268. moveAttached: boolean;
  43269. /**
  43270. * If the drag behavior will react to drag events (Default: true)
  43271. */
  43272. enabled: boolean;
  43273. /**
  43274. * If pointer events should start and release the drag (Default: true)
  43275. */
  43276. startAndReleaseDragOnPointerEvents: boolean;
  43277. /**
  43278. * If camera controls should be detached during the drag
  43279. */
  43280. detachCameraControls: boolean;
  43281. /**
  43282. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  43283. */
  43284. useObjectOrientationForDragging: boolean;
  43285. private _options;
  43286. /**
  43287. * Gets the options used by the behavior
  43288. */
  43289. get options(): {
  43290. dragAxis?: Vector3;
  43291. dragPlaneNormal?: Vector3;
  43292. };
  43293. /**
  43294. * Sets the options used by the behavior
  43295. */
  43296. set options(options: {
  43297. dragAxis?: Vector3;
  43298. dragPlaneNormal?: Vector3;
  43299. });
  43300. /**
  43301. * Creates a pointer drag behavior that can be attached to a mesh
  43302. * @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)
  43303. */
  43304. constructor(options?: {
  43305. dragAxis?: Vector3;
  43306. dragPlaneNormal?: Vector3;
  43307. });
  43308. /**
  43309. * Predicate to determine if it is valid to move the object to a new position when it is moved
  43310. */
  43311. validateDrag: (targetPosition: Vector3) => boolean;
  43312. /**
  43313. * The name of the behavior
  43314. */
  43315. get name(): string;
  43316. /**
  43317. * Initializes the behavior
  43318. */
  43319. init(): void;
  43320. private _tmpVector;
  43321. private _alternatePickedPoint;
  43322. private _worldDragAxis;
  43323. private _targetPosition;
  43324. private _attachedElement;
  43325. /**
  43326. * Attaches the drag behavior the passed in mesh
  43327. * @param ownerNode The mesh that will be dragged around once attached
  43328. * @param predicate Predicate to use for pick filtering
  43329. */
  43330. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  43331. /**
  43332. * Force relase the drag action by code.
  43333. */
  43334. releaseDrag(): void;
  43335. private _startDragRay;
  43336. private _lastPointerRay;
  43337. /**
  43338. * Simulates the start of a pointer drag event on the behavior
  43339. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  43340. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  43341. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  43342. */
  43343. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43344. private _startDrag;
  43345. private _dragDelta;
  43346. private _moveDrag;
  43347. private _pickWithRayOnDragPlane;
  43348. private _pointA;
  43349. private _pointC;
  43350. private _localAxis;
  43351. private _lookAt;
  43352. private _updateDragPlanePosition;
  43353. /**
  43354. * Detaches the behavior from the mesh
  43355. */
  43356. detach(): void;
  43357. }
  43358. }
  43359. declare module BABYLON {
  43360. /**
  43361. * A behavior that when attached to a mesh will allow the mesh to be scaled
  43362. */
  43363. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  43364. private _dragBehaviorA;
  43365. private _dragBehaviorB;
  43366. private _startDistance;
  43367. private _initialScale;
  43368. private _targetScale;
  43369. private _ownerNode;
  43370. private _sceneRenderObserver;
  43371. /**
  43372. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  43373. */
  43374. constructor();
  43375. /**
  43376. * The name of the behavior
  43377. */
  43378. get name(): string;
  43379. /**
  43380. * Initializes the behavior
  43381. */
  43382. init(): void;
  43383. private _getCurrentDistance;
  43384. /**
  43385. * Attaches the scale behavior the passed in mesh
  43386. * @param ownerNode The mesh that will be scaled around once attached
  43387. */
  43388. attach(ownerNode: Mesh): void;
  43389. /**
  43390. * Detaches the behavior from the mesh
  43391. */
  43392. detach(): void;
  43393. }
  43394. }
  43395. declare module BABYLON {
  43396. /**
  43397. * 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
  43398. */
  43399. export class SixDofDragBehavior implements Behavior<Mesh> {
  43400. private static _virtualScene;
  43401. private _ownerNode;
  43402. private _sceneRenderObserver;
  43403. private _scene;
  43404. private _targetPosition;
  43405. private _virtualOriginMesh;
  43406. private _virtualDragMesh;
  43407. private _pointerObserver;
  43408. private _moving;
  43409. private _startingOrientation;
  43410. private _attachedElement;
  43411. /**
  43412. * 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)
  43413. */
  43414. private zDragFactor;
  43415. /**
  43416. * If the object should rotate to face the drag origin
  43417. */
  43418. rotateDraggedObject: boolean;
  43419. /**
  43420. * If the behavior is currently in a dragging state
  43421. */
  43422. dragging: boolean;
  43423. /**
  43424. * 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)
  43425. */
  43426. dragDeltaRatio: number;
  43427. /**
  43428. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43429. */
  43430. currentDraggingPointerID: number;
  43431. /**
  43432. * If camera controls should be detached during the drag
  43433. */
  43434. detachCameraControls: boolean;
  43435. /**
  43436. * Fires each time a drag starts
  43437. */
  43438. onDragStartObservable: Observable<{}>;
  43439. /**
  43440. * Fires each time a drag ends (eg. mouse release after drag)
  43441. */
  43442. onDragEndObservable: Observable<{}>;
  43443. /**
  43444. * 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
  43445. */
  43446. constructor();
  43447. /**
  43448. * The name of the behavior
  43449. */
  43450. get name(): string;
  43451. /**
  43452. * Initializes the behavior
  43453. */
  43454. init(): void;
  43455. /**
  43456. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  43457. */
  43458. private get _pointerCamera();
  43459. /**
  43460. * Attaches the scale behavior the passed in mesh
  43461. * @param ownerNode The mesh that will be scaled around once attached
  43462. */
  43463. attach(ownerNode: Mesh): void;
  43464. /**
  43465. * Detaches the behavior from the mesh
  43466. */
  43467. detach(): void;
  43468. }
  43469. }
  43470. declare module BABYLON {
  43471. /**
  43472. * Class used to apply inverse kinematics to bones
  43473. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  43474. */
  43475. export class BoneIKController {
  43476. private static _tmpVecs;
  43477. private static _tmpQuat;
  43478. private static _tmpMats;
  43479. /**
  43480. * Gets or sets the target mesh
  43481. */
  43482. targetMesh: AbstractMesh;
  43483. /** Gets or sets the mesh used as pole */
  43484. poleTargetMesh: AbstractMesh;
  43485. /**
  43486. * Gets or sets the bone used as pole
  43487. */
  43488. poleTargetBone: Nullable<Bone>;
  43489. /**
  43490. * Gets or sets the target position
  43491. */
  43492. targetPosition: Vector3;
  43493. /**
  43494. * Gets or sets the pole target position
  43495. */
  43496. poleTargetPosition: Vector3;
  43497. /**
  43498. * Gets or sets the pole target local offset
  43499. */
  43500. poleTargetLocalOffset: Vector3;
  43501. /**
  43502. * Gets or sets the pole angle
  43503. */
  43504. poleAngle: number;
  43505. /**
  43506. * Gets or sets the mesh associated with the controller
  43507. */
  43508. mesh: AbstractMesh;
  43509. /**
  43510. * 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)
  43511. */
  43512. slerpAmount: number;
  43513. private _bone1Quat;
  43514. private _bone1Mat;
  43515. private _bone2Ang;
  43516. private _bone1;
  43517. private _bone2;
  43518. private _bone1Length;
  43519. private _bone2Length;
  43520. private _maxAngle;
  43521. private _maxReach;
  43522. private _rightHandedSystem;
  43523. private _bendAxis;
  43524. private _slerping;
  43525. private _adjustRoll;
  43526. /**
  43527. * Gets or sets maximum allowed angle
  43528. */
  43529. get maxAngle(): number;
  43530. set maxAngle(value: number);
  43531. /**
  43532. * Creates a new BoneIKController
  43533. * @param mesh defines the mesh to control
  43534. * @param bone defines the bone to control
  43535. * @param options defines options to set up the controller
  43536. */
  43537. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  43538. targetMesh?: AbstractMesh;
  43539. poleTargetMesh?: AbstractMesh;
  43540. poleTargetBone?: Bone;
  43541. poleTargetLocalOffset?: Vector3;
  43542. poleAngle?: number;
  43543. bendAxis?: Vector3;
  43544. maxAngle?: number;
  43545. slerpAmount?: number;
  43546. });
  43547. private _setMaxAngle;
  43548. /**
  43549. * Force the controller to update the bones
  43550. */
  43551. update(): void;
  43552. }
  43553. }
  43554. declare module BABYLON {
  43555. /**
  43556. * Class used to make a bone look toward a point in space
  43557. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  43558. */
  43559. export class BoneLookController {
  43560. private static _tmpVecs;
  43561. private static _tmpQuat;
  43562. private static _tmpMats;
  43563. /**
  43564. * The target Vector3 that the bone will look at
  43565. */
  43566. target: Vector3;
  43567. /**
  43568. * The mesh that the bone is attached to
  43569. */
  43570. mesh: AbstractMesh;
  43571. /**
  43572. * The bone that will be looking to the target
  43573. */
  43574. bone: Bone;
  43575. /**
  43576. * The up axis of the coordinate system that is used when the bone is rotated
  43577. */
  43578. upAxis: Vector3;
  43579. /**
  43580. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  43581. */
  43582. upAxisSpace: Space;
  43583. /**
  43584. * Used to make an adjustment to the yaw of the bone
  43585. */
  43586. adjustYaw: number;
  43587. /**
  43588. * Used to make an adjustment to the pitch of the bone
  43589. */
  43590. adjustPitch: number;
  43591. /**
  43592. * Used to make an adjustment to the roll of the bone
  43593. */
  43594. adjustRoll: number;
  43595. /**
  43596. * 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)
  43597. */
  43598. slerpAmount: number;
  43599. private _minYaw;
  43600. private _maxYaw;
  43601. private _minPitch;
  43602. private _maxPitch;
  43603. private _minYawSin;
  43604. private _minYawCos;
  43605. private _maxYawSin;
  43606. private _maxYawCos;
  43607. private _midYawConstraint;
  43608. private _minPitchTan;
  43609. private _maxPitchTan;
  43610. private _boneQuat;
  43611. private _slerping;
  43612. private _transformYawPitch;
  43613. private _transformYawPitchInv;
  43614. private _firstFrameSkipped;
  43615. private _yawRange;
  43616. private _fowardAxis;
  43617. /**
  43618. * Gets or sets the minimum yaw angle that the bone can look to
  43619. */
  43620. get minYaw(): number;
  43621. set minYaw(value: number);
  43622. /**
  43623. * Gets or sets the maximum yaw angle that the bone can look to
  43624. */
  43625. get maxYaw(): number;
  43626. set maxYaw(value: number);
  43627. /**
  43628. * Gets or sets the minimum pitch angle that the bone can look to
  43629. */
  43630. get minPitch(): number;
  43631. set minPitch(value: number);
  43632. /**
  43633. * Gets or sets the maximum pitch angle that the bone can look to
  43634. */
  43635. get maxPitch(): number;
  43636. set maxPitch(value: number);
  43637. /**
  43638. * Create a BoneLookController
  43639. * @param mesh the mesh that the bone belongs to
  43640. * @param bone the bone that will be looking to the target
  43641. * @param target the target Vector3 to look at
  43642. * @param options optional settings:
  43643. * * maxYaw: the maximum angle the bone will yaw to
  43644. * * minYaw: the minimum angle the bone will yaw to
  43645. * * maxPitch: the maximum angle the bone will pitch to
  43646. * * minPitch: the minimum angle the bone will yaw to
  43647. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  43648. * * upAxis: the up axis of the coordinate system
  43649. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  43650. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  43651. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  43652. * * adjustYaw: used to make an adjustment to the yaw of the bone
  43653. * * adjustPitch: used to make an adjustment to the pitch of the bone
  43654. * * adjustRoll: used to make an adjustment to the roll of the bone
  43655. **/
  43656. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  43657. maxYaw?: number;
  43658. minYaw?: number;
  43659. maxPitch?: number;
  43660. minPitch?: number;
  43661. slerpAmount?: number;
  43662. upAxis?: Vector3;
  43663. upAxisSpace?: Space;
  43664. yawAxis?: Vector3;
  43665. pitchAxis?: Vector3;
  43666. adjustYaw?: number;
  43667. adjustPitch?: number;
  43668. adjustRoll?: number;
  43669. });
  43670. /**
  43671. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  43672. */
  43673. update(): void;
  43674. private _getAngleDiff;
  43675. private _getAngleBetween;
  43676. private _isAngleBetween;
  43677. }
  43678. }
  43679. declare module BABYLON {
  43680. /**
  43681. * Manage the gamepad inputs to control an arc rotate camera.
  43682. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43683. */
  43684. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  43685. /**
  43686. * Defines the camera the input is attached to.
  43687. */
  43688. camera: ArcRotateCamera;
  43689. /**
  43690. * Defines the gamepad the input is gathering event from.
  43691. */
  43692. gamepad: Nullable<Gamepad>;
  43693. /**
  43694. * Defines the gamepad rotation sensiblity.
  43695. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43696. */
  43697. gamepadRotationSensibility: number;
  43698. /**
  43699. * Defines the gamepad move sensiblity.
  43700. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43701. */
  43702. gamepadMoveSensibility: number;
  43703. private _yAxisScale;
  43704. /**
  43705. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  43706. */
  43707. get invertYAxis(): boolean;
  43708. set invertYAxis(value: boolean);
  43709. private _onGamepadConnectedObserver;
  43710. private _onGamepadDisconnectedObserver;
  43711. /**
  43712. * Attach the input controls to a specific dom element to get the input from.
  43713. * @param element Defines the element the controls should be listened from
  43714. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43715. */
  43716. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43717. /**
  43718. * Detach the current controls from the specified dom element.
  43719. * @param element Defines the element to stop listening the inputs from
  43720. */
  43721. detachControl(element: Nullable<HTMLElement>): void;
  43722. /**
  43723. * Update the current camera state depending on the inputs that have been used this frame.
  43724. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43725. */
  43726. checkInputs(): void;
  43727. /**
  43728. * Gets the class name of the current intput.
  43729. * @returns the class name
  43730. */
  43731. getClassName(): string;
  43732. /**
  43733. * Get the friendly name associated with the input class.
  43734. * @returns the input friendly name
  43735. */
  43736. getSimpleName(): string;
  43737. }
  43738. }
  43739. declare module BABYLON {
  43740. interface ArcRotateCameraInputsManager {
  43741. /**
  43742. * Add orientation input support to the input manager.
  43743. * @returns the current input manager
  43744. */
  43745. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  43746. }
  43747. /**
  43748. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  43749. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43750. */
  43751. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  43752. /**
  43753. * Defines the camera the input is attached to.
  43754. */
  43755. camera: ArcRotateCamera;
  43756. /**
  43757. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  43758. */
  43759. alphaCorrection: number;
  43760. /**
  43761. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  43762. */
  43763. gammaCorrection: number;
  43764. private _alpha;
  43765. private _gamma;
  43766. private _dirty;
  43767. private _deviceOrientationHandler;
  43768. /**
  43769. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  43770. */
  43771. constructor();
  43772. /**
  43773. * Attach the input controls to a specific dom element to get the input from.
  43774. * @param element Defines the element the controls should be listened from
  43775. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43776. */
  43777. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43778. /** @hidden */
  43779. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  43780. /**
  43781. * Update the current camera state depending on the inputs that have been used this frame.
  43782. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43783. */
  43784. checkInputs(): void;
  43785. /**
  43786. * Detach the current controls from the specified dom element.
  43787. * @param element Defines the element to stop listening the inputs from
  43788. */
  43789. detachControl(element: Nullable<HTMLElement>): void;
  43790. /**
  43791. * Gets the class name of the current intput.
  43792. * @returns the class name
  43793. */
  43794. getClassName(): string;
  43795. /**
  43796. * Get the friendly name associated with the input class.
  43797. * @returns the input friendly name
  43798. */
  43799. getSimpleName(): string;
  43800. }
  43801. }
  43802. declare module BABYLON {
  43803. /**
  43804. * Listen to mouse events to control the camera.
  43805. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43806. */
  43807. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  43808. /**
  43809. * Defines the camera the input is attached to.
  43810. */
  43811. camera: FlyCamera;
  43812. /**
  43813. * Defines if touch is enabled. (Default is true.)
  43814. */
  43815. touchEnabled: boolean;
  43816. /**
  43817. * Defines the buttons associated with the input to handle camera rotation.
  43818. */
  43819. buttons: number[];
  43820. /**
  43821. * Assign buttons for Yaw control.
  43822. */
  43823. buttonsYaw: number[];
  43824. /**
  43825. * Assign buttons for Pitch control.
  43826. */
  43827. buttonsPitch: number[];
  43828. /**
  43829. * Assign buttons for Roll control.
  43830. */
  43831. buttonsRoll: number[];
  43832. /**
  43833. * Detect if any button is being pressed while mouse is moved.
  43834. * -1 = Mouse locked.
  43835. * 0 = Left button.
  43836. * 1 = Middle Button.
  43837. * 2 = Right Button.
  43838. */
  43839. activeButton: number;
  43840. /**
  43841. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  43842. * Higher values reduce its sensitivity.
  43843. */
  43844. angularSensibility: number;
  43845. private _mousemoveCallback;
  43846. private _observer;
  43847. private _rollObserver;
  43848. private previousPosition;
  43849. private noPreventDefault;
  43850. private element;
  43851. /**
  43852. * Listen to mouse events to control the camera.
  43853. * @param touchEnabled Define if touch is enabled. (Default is true.)
  43854. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43855. */
  43856. constructor(touchEnabled?: boolean);
  43857. /**
  43858. * Attach the mouse control to the HTML DOM element.
  43859. * @param element Defines the element that listens to the input events.
  43860. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  43861. */
  43862. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43863. /**
  43864. * Detach the current controls from the specified dom element.
  43865. * @param element Defines the element to stop listening the inputs from
  43866. */
  43867. detachControl(element: Nullable<HTMLElement>): void;
  43868. /**
  43869. * Gets the class name of the current input.
  43870. * @returns the class name.
  43871. */
  43872. getClassName(): string;
  43873. /**
  43874. * Get the friendly name associated with the input class.
  43875. * @returns the input's friendly name.
  43876. */
  43877. getSimpleName(): string;
  43878. private _pointerInput;
  43879. private _onMouseMove;
  43880. /**
  43881. * Rotate camera by mouse offset.
  43882. */
  43883. private rotateCamera;
  43884. }
  43885. }
  43886. declare module BABYLON {
  43887. /**
  43888. * Default Inputs manager for the FlyCamera.
  43889. * It groups all the default supported inputs for ease of use.
  43890. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43891. */
  43892. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  43893. /**
  43894. * Instantiates a new FlyCameraInputsManager.
  43895. * @param camera Defines the camera the inputs belong to.
  43896. */
  43897. constructor(camera: FlyCamera);
  43898. /**
  43899. * Add keyboard input support to the input manager.
  43900. * @returns the new FlyCameraKeyboardMoveInput().
  43901. */
  43902. addKeyboard(): FlyCameraInputsManager;
  43903. /**
  43904. * Add mouse input support to the input manager.
  43905. * @param touchEnabled Enable touch screen support.
  43906. * @returns the new FlyCameraMouseInput().
  43907. */
  43908. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  43909. }
  43910. }
  43911. declare module BABYLON {
  43912. /**
  43913. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43914. * such as in a 3D Space Shooter or a Flight Simulator.
  43915. */
  43916. export class FlyCamera extends TargetCamera {
  43917. /**
  43918. * Define the collision ellipsoid of the camera.
  43919. * This is helpful for simulating a camera body, like a player's body.
  43920. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43921. */
  43922. ellipsoid: Vector3;
  43923. /**
  43924. * Define an offset for the position of the ellipsoid around the camera.
  43925. * This can be helpful if the camera is attached away from the player's body center,
  43926. * such as at its head.
  43927. */
  43928. ellipsoidOffset: Vector3;
  43929. /**
  43930. * Enable or disable collisions of the camera with the rest of the scene objects.
  43931. */
  43932. checkCollisions: boolean;
  43933. /**
  43934. * Enable or disable gravity on the camera.
  43935. */
  43936. applyGravity: boolean;
  43937. /**
  43938. * Define the current direction the camera is moving to.
  43939. */
  43940. cameraDirection: Vector3;
  43941. /**
  43942. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  43943. * This overrides and empties cameraRotation.
  43944. */
  43945. rotationQuaternion: Quaternion;
  43946. /**
  43947. * Track Roll to maintain the wanted Rolling when looking around.
  43948. */
  43949. _trackRoll: number;
  43950. /**
  43951. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  43952. */
  43953. rollCorrect: number;
  43954. /**
  43955. * Mimic a banked turn, Rolling the camera when Yawing.
  43956. * It's recommended to use rollCorrect = 10 for faster banking correction.
  43957. */
  43958. bankedTurn: boolean;
  43959. /**
  43960. * Limit in radians for how much Roll banking will add. (Default: 90°)
  43961. */
  43962. bankedTurnLimit: number;
  43963. /**
  43964. * Value of 0 disables the banked Roll.
  43965. * Value of 1 is equal to the Yaw angle in radians.
  43966. */
  43967. bankedTurnMultiplier: number;
  43968. /**
  43969. * The inputs manager loads all the input sources, such as keyboard and mouse.
  43970. */
  43971. inputs: FlyCameraInputsManager;
  43972. /**
  43973. * Gets the input sensibility for mouse input.
  43974. * Higher values reduce sensitivity.
  43975. */
  43976. get angularSensibility(): number;
  43977. /**
  43978. * Sets the input sensibility for a mouse input.
  43979. * Higher values reduce sensitivity.
  43980. */
  43981. set angularSensibility(value: number);
  43982. /**
  43983. * Get the keys for camera movement forward.
  43984. */
  43985. get keysForward(): number[];
  43986. /**
  43987. * Set the keys for camera movement forward.
  43988. */
  43989. set keysForward(value: number[]);
  43990. /**
  43991. * Get the keys for camera movement backward.
  43992. */
  43993. get keysBackward(): number[];
  43994. set keysBackward(value: number[]);
  43995. /**
  43996. * Get the keys for camera movement up.
  43997. */
  43998. get keysUp(): number[];
  43999. /**
  44000. * Set the keys for camera movement up.
  44001. */
  44002. set keysUp(value: number[]);
  44003. /**
  44004. * Get the keys for camera movement down.
  44005. */
  44006. get keysDown(): number[];
  44007. /**
  44008. * Set the keys for camera movement down.
  44009. */
  44010. set keysDown(value: number[]);
  44011. /**
  44012. * Get the keys for camera movement left.
  44013. */
  44014. get keysLeft(): number[];
  44015. /**
  44016. * Set the keys for camera movement left.
  44017. */
  44018. set keysLeft(value: number[]);
  44019. /**
  44020. * Set the keys for camera movement right.
  44021. */
  44022. get keysRight(): number[];
  44023. /**
  44024. * Set the keys for camera movement right.
  44025. */
  44026. set keysRight(value: number[]);
  44027. /**
  44028. * Event raised when the camera collides with a mesh in the scene.
  44029. */
  44030. onCollide: (collidedMesh: AbstractMesh) => void;
  44031. private _collider;
  44032. private _needMoveForGravity;
  44033. private _oldPosition;
  44034. private _diffPosition;
  44035. private _newPosition;
  44036. /** @hidden */
  44037. _localDirection: Vector3;
  44038. /** @hidden */
  44039. _transformedDirection: Vector3;
  44040. /**
  44041. * Instantiates a FlyCamera.
  44042. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44043. * such as in a 3D Space Shooter or a Flight Simulator.
  44044. * @param name Define the name of the camera in the scene.
  44045. * @param position Define the starting position of the camera in the scene.
  44046. * @param scene Define the scene the camera belongs to.
  44047. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44048. */
  44049. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44050. /**
  44051. * Attach a control to the HTML DOM element.
  44052. * @param element Defines the element that listens to the input events.
  44053. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44054. */
  44055. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44056. /**
  44057. * Detach a control from the HTML DOM element.
  44058. * The camera will stop reacting to that input.
  44059. * @param element Defines the element that listens to the input events.
  44060. */
  44061. detachControl(element: HTMLElement): void;
  44062. private _collisionMask;
  44063. /**
  44064. * Get the mask that the camera ignores in collision events.
  44065. */
  44066. get collisionMask(): number;
  44067. /**
  44068. * Set the mask that the camera ignores in collision events.
  44069. */
  44070. set collisionMask(mask: number);
  44071. /** @hidden */
  44072. _collideWithWorld(displacement: Vector3): void;
  44073. /** @hidden */
  44074. private _onCollisionPositionChange;
  44075. /** @hidden */
  44076. _checkInputs(): void;
  44077. /** @hidden */
  44078. _decideIfNeedsToMove(): boolean;
  44079. /** @hidden */
  44080. _updatePosition(): void;
  44081. /**
  44082. * Restore the Roll to its target value at the rate specified.
  44083. * @param rate - Higher means slower restoring.
  44084. * @hidden
  44085. */
  44086. restoreRoll(rate: number): void;
  44087. /**
  44088. * Destroy the camera and release the current resources held by it.
  44089. */
  44090. dispose(): void;
  44091. /**
  44092. * Get the current object class name.
  44093. * @returns the class name.
  44094. */
  44095. getClassName(): string;
  44096. }
  44097. }
  44098. declare module BABYLON {
  44099. /**
  44100. * Listen to keyboard events to control the camera.
  44101. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44102. */
  44103. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44104. /**
  44105. * Defines the camera the input is attached to.
  44106. */
  44107. camera: FlyCamera;
  44108. /**
  44109. * The list of keyboard keys used to control the forward move of the camera.
  44110. */
  44111. keysForward: number[];
  44112. /**
  44113. * The list of keyboard keys used to control the backward move of the camera.
  44114. */
  44115. keysBackward: number[];
  44116. /**
  44117. * The list of keyboard keys used to control the forward move of the camera.
  44118. */
  44119. keysUp: number[];
  44120. /**
  44121. * The list of keyboard keys used to control the backward move of the camera.
  44122. */
  44123. keysDown: number[];
  44124. /**
  44125. * The list of keyboard keys used to control the right strafe move of the camera.
  44126. */
  44127. keysRight: number[];
  44128. /**
  44129. * The list of keyboard keys used to control the left strafe move of the camera.
  44130. */
  44131. keysLeft: number[];
  44132. private _keys;
  44133. private _onCanvasBlurObserver;
  44134. private _onKeyboardObserver;
  44135. private _engine;
  44136. private _scene;
  44137. /**
  44138. * Attach the input controls to a specific dom element to get the input from.
  44139. * @param element Defines the element the controls should be listened from
  44140. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44141. */
  44142. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44143. /**
  44144. * Detach the current controls from the specified dom element.
  44145. * @param element Defines the element to stop listening the inputs from
  44146. */
  44147. detachControl(element: Nullable<HTMLElement>): void;
  44148. /**
  44149. * Gets the class name of the current intput.
  44150. * @returns the class name
  44151. */
  44152. getClassName(): string;
  44153. /** @hidden */
  44154. _onLostFocus(e: FocusEvent): void;
  44155. /**
  44156. * Get the friendly name associated with the input class.
  44157. * @returns the input friendly name
  44158. */
  44159. getSimpleName(): string;
  44160. /**
  44161. * Update the current camera state depending on the inputs that have been used this frame.
  44162. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44163. */
  44164. checkInputs(): void;
  44165. }
  44166. }
  44167. declare module BABYLON {
  44168. /**
  44169. * Manage the mouse wheel inputs to control a follow camera.
  44170. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44171. */
  44172. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  44173. /**
  44174. * Defines the camera the input is attached to.
  44175. */
  44176. camera: FollowCamera;
  44177. /**
  44178. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  44179. */
  44180. axisControlRadius: boolean;
  44181. /**
  44182. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  44183. */
  44184. axisControlHeight: boolean;
  44185. /**
  44186. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  44187. */
  44188. axisControlRotation: boolean;
  44189. /**
  44190. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  44191. * relation to mouseWheel events.
  44192. */
  44193. wheelPrecision: number;
  44194. /**
  44195. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44196. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44197. */
  44198. wheelDeltaPercentage: number;
  44199. private _wheel;
  44200. private _observer;
  44201. /**
  44202. * Attach the input controls to a specific dom element to get the input from.
  44203. * @param element Defines the element the controls should be listened from
  44204. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44205. */
  44206. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44207. /**
  44208. * Detach the current controls from the specified dom element.
  44209. * @param element Defines the element to stop listening the inputs from
  44210. */
  44211. detachControl(element: Nullable<HTMLElement>): void;
  44212. /**
  44213. * Gets the class name of the current intput.
  44214. * @returns the class name
  44215. */
  44216. getClassName(): string;
  44217. /**
  44218. * Get the friendly name associated with the input class.
  44219. * @returns the input friendly name
  44220. */
  44221. getSimpleName(): string;
  44222. }
  44223. }
  44224. declare module BABYLON {
  44225. /**
  44226. * Manage the pointers inputs to control an follow camera.
  44227. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44228. */
  44229. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  44230. /**
  44231. * Defines the camera the input is attached to.
  44232. */
  44233. camera: FollowCamera;
  44234. /**
  44235. * Gets the class name of the current input.
  44236. * @returns the class name
  44237. */
  44238. getClassName(): string;
  44239. /**
  44240. * Defines the pointer angular sensibility along the X axis or how fast is
  44241. * the camera rotating.
  44242. * A negative number will reverse the axis direction.
  44243. */
  44244. angularSensibilityX: number;
  44245. /**
  44246. * Defines the pointer angular sensibility along the Y axis or how fast is
  44247. * the camera rotating.
  44248. * A negative number will reverse the axis direction.
  44249. */
  44250. angularSensibilityY: number;
  44251. /**
  44252. * Defines the pointer pinch precision or how fast is the camera zooming.
  44253. * A negative number will reverse the axis direction.
  44254. */
  44255. pinchPrecision: number;
  44256. /**
  44257. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44258. * from 0.
  44259. * It defines the percentage of current camera.radius to use as delta when
  44260. * pinch zoom is used.
  44261. */
  44262. pinchDeltaPercentage: number;
  44263. /**
  44264. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  44265. */
  44266. axisXControlRadius: boolean;
  44267. /**
  44268. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  44269. */
  44270. axisXControlHeight: boolean;
  44271. /**
  44272. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  44273. */
  44274. axisXControlRotation: boolean;
  44275. /**
  44276. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  44277. */
  44278. axisYControlRadius: boolean;
  44279. /**
  44280. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  44281. */
  44282. axisYControlHeight: boolean;
  44283. /**
  44284. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  44285. */
  44286. axisYControlRotation: boolean;
  44287. /**
  44288. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  44289. */
  44290. axisPinchControlRadius: boolean;
  44291. /**
  44292. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  44293. */
  44294. axisPinchControlHeight: boolean;
  44295. /**
  44296. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  44297. */
  44298. axisPinchControlRotation: boolean;
  44299. /**
  44300. * Log error messages if basic misconfiguration has occurred.
  44301. */
  44302. warningEnable: boolean;
  44303. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44304. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44305. private _warningCounter;
  44306. private _warning;
  44307. }
  44308. }
  44309. declare module BABYLON {
  44310. /**
  44311. * Default Inputs manager for the FollowCamera.
  44312. * It groups all the default supported inputs for ease of use.
  44313. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44314. */
  44315. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  44316. /**
  44317. * Instantiates a new FollowCameraInputsManager.
  44318. * @param camera Defines the camera the inputs belong to
  44319. */
  44320. constructor(camera: FollowCamera);
  44321. /**
  44322. * Add keyboard input support to the input manager.
  44323. * @returns the current input manager
  44324. */
  44325. addKeyboard(): FollowCameraInputsManager;
  44326. /**
  44327. * Add mouse wheel input support to the input manager.
  44328. * @returns the current input manager
  44329. */
  44330. addMouseWheel(): FollowCameraInputsManager;
  44331. /**
  44332. * Add pointers input support to the input manager.
  44333. * @returns the current input manager
  44334. */
  44335. addPointers(): FollowCameraInputsManager;
  44336. /**
  44337. * Add orientation input support to the input manager.
  44338. * @returns the current input manager
  44339. */
  44340. addVRDeviceOrientation(): FollowCameraInputsManager;
  44341. }
  44342. }
  44343. declare module BABYLON {
  44344. /**
  44345. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  44346. * an arc rotate version arcFollowCamera are available.
  44347. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44348. */
  44349. export class FollowCamera extends TargetCamera {
  44350. /**
  44351. * Distance the follow camera should follow an object at
  44352. */
  44353. radius: number;
  44354. /**
  44355. * Minimum allowed distance of the camera to the axis of rotation
  44356. * (The camera can not get closer).
  44357. * This can help limiting how the Camera is able to move in the scene.
  44358. */
  44359. lowerRadiusLimit: Nullable<number>;
  44360. /**
  44361. * Maximum allowed distance of the camera to the axis of rotation
  44362. * (The camera can not get further).
  44363. * This can help limiting how the Camera is able to move in the scene.
  44364. */
  44365. upperRadiusLimit: Nullable<number>;
  44366. /**
  44367. * Define a rotation offset between the camera and the object it follows
  44368. */
  44369. rotationOffset: number;
  44370. /**
  44371. * Minimum allowed angle to camera position relative to target object.
  44372. * This can help limiting how the Camera is able to move in the scene.
  44373. */
  44374. lowerRotationOffsetLimit: Nullable<number>;
  44375. /**
  44376. * Maximum allowed angle to camera position relative to target object.
  44377. * This can help limiting how the Camera is able to move in the scene.
  44378. */
  44379. upperRotationOffsetLimit: Nullable<number>;
  44380. /**
  44381. * Define a height offset between the camera and the object it follows.
  44382. * It can help following an object from the top (like a car chaing a plane)
  44383. */
  44384. heightOffset: number;
  44385. /**
  44386. * Minimum allowed height of camera position relative to target object.
  44387. * This can help limiting how the Camera is able to move in the scene.
  44388. */
  44389. lowerHeightOffsetLimit: Nullable<number>;
  44390. /**
  44391. * Maximum allowed height of camera position relative to target object.
  44392. * This can help limiting how the Camera is able to move in the scene.
  44393. */
  44394. upperHeightOffsetLimit: Nullable<number>;
  44395. /**
  44396. * Define how fast the camera can accelerate to follow it s target.
  44397. */
  44398. cameraAcceleration: number;
  44399. /**
  44400. * Define the speed limit of the camera following an object.
  44401. */
  44402. maxCameraSpeed: number;
  44403. /**
  44404. * Define the target of the camera.
  44405. */
  44406. lockedTarget: Nullable<AbstractMesh>;
  44407. /**
  44408. * Defines the input associated with the camera.
  44409. */
  44410. inputs: FollowCameraInputsManager;
  44411. /**
  44412. * Instantiates the follow camera.
  44413. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44414. * @param name Define the name of the camera in the scene
  44415. * @param position Define the position of the camera
  44416. * @param scene Define the scene the camera belong to
  44417. * @param lockedTarget Define the target of the camera
  44418. */
  44419. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  44420. private _follow;
  44421. /**
  44422. * Attached controls to the current camera.
  44423. * @param element Defines the element the controls should be listened from
  44424. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44425. */
  44426. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44427. /**
  44428. * Detach the current controls from the camera.
  44429. * The camera will stop reacting to inputs.
  44430. * @param element Defines the element to stop listening the inputs from
  44431. */
  44432. detachControl(element: HTMLElement): void;
  44433. /** @hidden */
  44434. _checkInputs(): void;
  44435. private _checkLimits;
  44436. /**
  44437. * Gets the camera class name.
  44438. * @returns the class name
  44439. */
  44440. getClassName(): string;
  44441. }
  44442. /**
  44443. * Arc Rotate version of the follow camera.
  44444. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  44445. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44446. */
  44447. export class ArcFollowCamera extends TargetCamera {
  44448. /** The longitudinal angle of the camera */
  44449. alpha: number;
  44450. /** The latitudinal angle of the camera */
  44451. beta: number;
  44452. /** The radius of the camera from its target */
  44453. radius: number;
  44454. /** Define the camera target (the mesh it should follow) */
  44455. target: Nullable<AbstractMesh>;
  44456. private _cartesianCoordinates;
  44457. /**
  44458. * Instantiates a new ArcFollowCamera
  44459. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44460. * @param name Define the name of the camera
  44461. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  44462. * @param beta Define the rotation angle of the camera around the elevation axis
  44463. * @param radius Define the radius of the camera from its target point
  44464. * @param target Define the target of the camera
  44465. * @param scene Define the scene the camera belongs to
  44466. */
  44467. constructor(name: string,
  44468. /** The longitudinal angle of the camera */
  44469. alpha: number,
  44470. /** The latitudinal angle of the camera */
  44471. beta: number,
  44472. /** The radius of the camera from its target */
  44473. radius: number,
  44474. /** Define the camera target (the mesh it should follow) */
  44475. target: Nullable<AbstractMesh>, scene: Scene);
  44476. private _follow;
  44477. /** @hidden */
  44478. _checkInputs(): void;
  44479. /**
  44480. * Returns the class name of the object.
  44481. * It is mostly used internally for serialization purposes.
  44482. */
  44483. getClassName(): string;
  44484. }
  44485. }
  44486. declare module BABYLON {
  44487. /**
  44488. * Manage the keyboard inputs to control the movement of a follow camera.
  44489. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44490. */
  44491. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  44492. /**
  44493. * Defines the camera the input is attached to.
  44494. */
  44495. camera: FollowCamera;
  44496. /**
  44497. * Defines the list of key codes associated with the up action (increase heightOffset)
  44498. */
  44499. keysHeightOffsetIncr: number[];
  44500. /**
  44501. * Defines the list of key codes associated with the down action (decrease heightOffset)
  44502. */
  44503. keysHeightOffsetDecr: number[];
  44504. /**
  44505. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  44506. */
  44507. keysHeightOffsetModifierAlt: boolean;
  44508. /**
  44509. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  44510. */
  44511. keysHeightOffsetModifierCtrl: boolean;
  44512. /**
  44513. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  44514. */
  44515. keysHeightOffsetModifierShift: boolean;
  44516. /**
  44517. * Defines the list of key codes associated with the left action (increase rotationOffset)
  44518. */
  44519. keysRotationOffsetIncr: number[];
  44520. /**
  44521. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  44522. */
  44523. keysRotationOffsetDecr: number[];
  44524. /**
  44525. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  44526. */
  44527. keysRotationOffsetModifierAlt: boolean;
  44528. /**
  44529. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  44530. */
  44531. keysRotationOffsetModifierCtrl: boolean;
  44532. /**
  44533. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  44534. */
  44535. keysRotationOffsetModifierShift: boolean;
  44536. /**
  44537. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  44538. */
  44539. keysRadiusIncr: number[];
  44540. /**
  44541. * Defines the list of key codes associated with the zoom-out action (increase radius)
  44542. */
  44543. keysRadiusDecr: number[];
  44544. /**
  44545. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  44546. */
  44547. keysRadiusModifierAlt: boolean;
  44548. /**
  44549. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  44550. */
  44551. keysRadiusModifierCtrl: boolean;
  44552. /**
  44553. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  44554. */
  44555. keysRadiusModifierShift: boolean;
  44556. /**
  44557. * Defines the rate of change of heightOffset.
  44558. */
  44559. heightSensibility: number;
  44560. /**
  44561. * Defines the rate of change of rotationOffset.
  44562. */
  44563. rotationSensibility: number;
  44564. /**
  44565. * Defines the rate of change of radius.
  44566. */
  44567. radiusSensibility: number;
  44568. private _keys;
  44569. private _ctrlPressed;
  44570. private _altPressed;
  44571. private _shiftPressed;
  44572. private _onCanvasBlurObserver;
  44573. private _onKeyboardObserver;
  44574. private _engine;
  44575. private _scene;
  44576. /**
  44577. * Attach the input controls to a specific dom element to get the input from.
  44578. * @param element Defines the element the controls should be listened from
  44579. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44580. */
  44581. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44582. /**
  44583. * Detach the current controls from the specified dom element.
  44584. * @param element Defines the element to stop listening the inputs from
  44585. */
  44586. detachControl(element: Nullable<HTMLElement>): void;
  44587. /**
  44588. * Update the current camera state depending on the inputs that have been used this frame.
  44589. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44590. */
  44591. checkInputs(): void;
  44592. /**
  44593. * Gets the class name of the current input.
  44594. * @returns the class name
  44595. */
  44596. getClassName(): string;
  44597. /**
  44598. * Get the friendly name associated with the input class.
  44599. * @returns the input friendly name
  44600. */
  44601. getSimpleName(): string;
  44602. /**
  44603. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44604. * allow modification of the heightOffset value.
  44605. */
  44606. private _modifierHeightOffset;
  44607. /**
  44608. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44609. * allow modification of the rotationOffset value.
  44610. */
  44611. private _modifierRotationOffset;
  44612. /**
  44613. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44614. * allow modification of the radius value.
  44615. */
  44616. private _modifierRadius;
  44617. }
  44618. }
  44619. declare module BABYLON {
  44620. interface FreeCameraInputsManager {
  44621. /**
  44622. * @hidden
  44623. */
  44624. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  44625. /**
  44626. * Add orientation input support to the input manager.
  44627. * @returns the current input manager
  44628. */
  44629. addDeviceOrientation(): FreeCameraInputsManager;
  44630. }
  44631. /**
  44632. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  44633. * Screen rotation is taken into account.
  44634. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44635. */
  44636. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  44637. private _camera;
  44638. private _screenOrientationAngle;
  44639. private _constantTranform;
  44640. private _screenQuaternion;
  44641. private _alpha;
  44642. private _beta;
  44643. private _gamma;
  44644. /**
  44645. * Can be used to detect if a device orientation sensor is available on a device
  44646. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  44647. * @returns a promise that will resolve on orientation change
  44648. */
  44649. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  44650. /**
  44651. * @hidden
  44652. */
  44653. _onDeviceOrientationChangedObservable: Observable<void>;
  44654. /**
  44655. * Instantiates a new input
  44656. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44657. */
  44658. constructor();
  44659. /**
  44660. * Define the camera controlled by the input.
  44661. */
  44662. get camera(): FreeCamera;
  44663. set camera(camera: FreeCamera);
  44664. /**
  44665. * Attach the input controls to a specific dom element to get the input from.
  44666. * @param element Defines the element the controls should be listened from
  44667. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44668. */
  44669. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44670. private _orientationChanged;
  44671. private _deviceOrientation;
  44672. /**
  44673. * Detach the current controls from the specified dom element.
  44674. * @param element Defines the element to stop listening the inputs from
  44675. */
  44676. detachControl(element: Nullable<HTMLElement>): void;
  44677. /**
  44678. * Update the current camera state depending on the inputs that have been used this frame.
  44679. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44680. */
  44681. checkInputs(): void;
  44682. /**
  44683. * Gets the class name of the current intput.
  44684. * @returns the class name
  44685. */
  44686. getClassName(): string;
  44687. /**
  44688. * Get the friendly name associated with the input class.
  44689. * @returns the input friendly name
  44690. */
  44691. getSimpleName(): string;
  44692. }
  44693. }
  44694. declare module BABYLON {
  44695. /**
  44696. * Manage the gamepad inputs to control a free camera.
  44697. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44698. */
  44699. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  44700. /**
  44701. * Define the camera the input is attached to.
  44702. */
  44703. camera: FreeCamera;
  44704. /**
  44705. * Define the Gamepad controlling the input
  44706. */
  44707. gamepad: Nullable<Gamepad>;
  44708. /**
  44709. * Defines the gamepad rotation sensiblity.
  44710. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44711. */
  44712. gamepadAngularSensibility: number;
  44713. /**
  44714. * Defines the gamepad move sensiblity.
  44715. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44716. */
  44717. gamepadMoveSensibility: number;
  44718. private _yAxisScale;
  44719. /**
  44720. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44721. */
  44722. get invertYAxis(): boolean;
  44723. set invertYAxis(value: boolean);
  44724. private _onGamepadConnectedObserver;
  44725. private _onGamepadDisconnectedObserver;
  44726. private _cameraTransform;
  44727. private _deltaTransform;
  44728. private _vector3;
  44729. private _vector2;
  44730. /**
  44731. * Attach the input controls to a specific dom element to get the input from.
  44732. * @param element Defines the element the controls should be listened from
  44733. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44734. */
  44735. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44736. /**
  44737. * Detach the current controls from the specified dom element.
  44738. * @param element Defines the element to stop listening the inputs from
  44739. */
  44740. detachControl(element: Nullable<HTMLElement>): void;
  44741. /**
  44742. * Update the current camera state depending on the inputs that have been used this frame.
  44743. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44744. */
  44745. checkInputs(): void;
  44746. /**
  44747. * Gets the class name of the current intput.
  44748. * @returns the class name
  44749. */
  44750. getClassName(): string;
  44751. /**
  44752. * Get the friendly name associated with the input class.
  44753. * @returns the input friendly name
  44754. */
  44755. getSimpleName(): string;
  44756. }
  44757. }
  44758. declare module BABYLON {
  44759. /**
  44760. * Defines the potential axis of a Joystick
  44761. */
  44762. export enum JoystickAxis {
  44763. /** X axis */
  44764. X = 0,
  44765. /** Y axis */
  44766. Y = 1,
  44767. /** Z axis */
  44768. Z = 2
  44769. }
  44770. /**
  44771. * Represents the different customization options available
  44772. * for VirtualJoystick
  44773. */
  44774. interface VirtualJoystickCustomizations {
  44775. /**
  44776. * Size of the joystick's puck
  44777. */
  44778. puckSize: number;
  44779. /**
  44780. * Size of the joystick's container
  44781. */
  44782. containerSize: number;
  44783. /**
  44784. * Color of the joystick && puck
  44785. */
  44786. color: string;
  44787. /**
  44788. * Image URL for the joystick's puck
  44789. */
  44790. puckImage?: string;
  44791. /**
  44792. * Image URL for the joystick's container
  44793. */
  44794. containerImage?: string;
  44795. /**
  44796. * Defines the unmoving position of the joystick container
  44797. */
  44798. position?: {
  44799. x: number;
  44800. y: number;
  44801. };
  44802. /**
  44803. * Defines whether or not the joystick container is always visible
  44804. */
  44805. alwaysVisible: boolean;
  44806. /**
  44807. * Defines whether or not to limit the movement of the puck to the joystick's container
  44808. */
  44809. limitToContainer: boolean;
  44810. }
  44811. /**
  44812. * Class used to define virtual joystick (used in touch mode)
  44813. */
  44814. export class VirtualJoystick {
  44815. /**
  44816. * Gets or sets a boolean indicating that left and right values must be inverted
  44817. */
  44818. reverseLeftRight: boolean;
  44819. /**
  44820. * Gets or sets a boolean indicating that up and down values must be inverted
  44821. */
  44822. reverseUpDown: boolean;
  44823. /**
  44824. * Gets the offset value for the position (ie. the change of the position value)
  44825. */
  44826. deltaPosition: Vector3;
  44827. /**
  44828. * Gets a boolean indicating if the virtual joystick was pressed
  44829. */
  44830. pressed: boolean;
  44831. /**
  44832. * Canvas the virtual joystick will render onto, default z-index of this is 5
  44833. */
  44834. static Canvas: Nullable<HTMLCanvasElement>;
  44835. /**
  44836. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  44837. */
  44838. limitToContainer: boolean;
  44839. private static _globalJoystickIndex;
  44840. private static _alwaysVisibleSticks;
  44841. private static vjCanvasContext;
  44842. private static vjCanvasWidth;
  44843. private static vjCanvasHeight;
  44844. private static halfWidth;
  44845. private static _GetDefaultOptions;
  44846. private _action;
  44847. private _axisTargetedByLeftAndRight;
  44848. private _axisTargetedByUpAndDown;
  44849. private _joystickSensibility;
  44850. private _inversedSensibility;
  44851. private _joystickPointerID;
  44852. private _joystickColor;
  44853. private _joystickPointerPos;
  44854. private _joystickPreviousPointerPos;
  44855. private _joystickPointerStartPos;
  44856. private _deltaJoystickVector;
  44857. private _leftJoystick;
  44858. private _touches;
  44859. private _joystickPosition;
  44860. private _alwaysVisible;
  44861. private _puckImage;
  44862. private _containerImage;
  44863. private _joystickPuckSize;
  44864. private _joystickContainerSize;
  44865. private _clearPuckSize;
  44866. private _clearContainerSize;
  44867. private _clearPuckSizeOffset;
  44868. private _clearContainerSizeOffset;
  44869. private _onPointerDownHandlerRef;
  44870. private _onPointerMoveHandlerRef;
  44871. private _onPointerUpHandlerRef;
  44872. private _onResize;
  44873. /**
  44874. * Creates a new virtual joystick
  44875. * @param leftJoystick defines that the joystick is for left hand (false by default)
  44876. * @param customizations Defines the options we want to customize the VirtualJoystick
  44877. */
  44878. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  44879. /**
  44880. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  44881. * @param newJoystickSensibility defines the new sensibility
  44882. */
  44883. setJoystickSensibility(newJoystickSensibility: number): void;
  44884. private _onPointerDown;
  44885. private _onPointerMove;
  44886. private _onPointerUp;
  44887. /**
  44888. * Change the color of the virtual joystick
  44889. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  44890. */
  44891. setJoystickColor(newColor: string): void;
  44892. /**
  44893. * Size of the joystick's container
  44894. */
  44895. set containerSize(newSize: number);
  44896. get containerSize(): number;
  44897. /**
  44898. * Size of the joystick's puck
  44899. */
  44900. set puckSize(newSize: number);
  44901. get puckSize(): number;
  44902. /**
  44903. * Clears the set position of the joystick
  44904. */
  44905. clearPosition(): void;
  44906. /**
  44907. * Defines whether or not the joystick container is always visible
  44908. */
  44909. set alwaysVisible(value: boolean);
  44910. get alwaysVisible(): boolean;
  44911. /**
  44912. * Sets the constant position of the Joystick container
  44913. * @param x X axis coordinate
  44914. * @param y Y axis coordinate
  44915. */
  44916. setPosition(x: number, y: number): void;
  44917. /**
  44918. * Defines a callback to call when the joystick is touched
  44919. * @param action defines the callback
  44920. */
  44921. setActionOnTouch(action: () => any): void;
  44922. /**
  44923. * Defines which axis you'd like to control for left & right
  44924. * @param axis defines the axis to use
  44925. */
  44926. setAxisForLeftRight(axis: JoystickAxis): void;
  44927. /**
  44928. * Defines which axis you'd like to control for up & down
  44929. * @param axis defines the axis to use
  44930. */
  44931. setAxisForUpDown(axis: JoystickAxis): void;
  44932. /**
  44933. * Clears the canvas from the previous puck / container draw
  44934. */
  44935. private _clearPreviousDraw;
  44936. /**
  44937. * Loads `urlPath` to be used for the container's image
  44938. * @param urlPath defines the urlPath of an image to use
  44939. */
  44940. setContainerImage(urlPath: string): void;
  44941. /**
  44942. * Loads `urlPath` to be used for the puck's image
  44943. * @param urlPath defines the urlPath of an image to use
  44944. */
  44945. setPuckImage(urlPath: string): void;
  44946. /**
  44947. * Draws the Virtual Joystick's container
  44948. */
  44949. private _drawContainer;
  44950. /**
  44951. * Draws the Virtual Joystick's puck
  44952. */
  44953. private _drawPuck;
  44954. private _drawVirtualJoystick;
  44955. /**
  44956. * Release internal HTML canvas
  44957. */
  44958. releaseCanvas(): void;
  44959. }
  44960. }
  44961. declare module BABYLON {
  44962. interface FreeCameraInputsManager {
  44963. /**
  44964. * Add virtual joystick input support to the input manager.
  44965. * @returns the current input manager
  44966. */
  44967. addVirtualJoystick(): FreeCameraInputsManager;
  44968. }
  44969. /**
  44970. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  44971. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44972. */
  44973. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  44974. /**
  44975. * Defines the camera the input is attached to.
  44976. */
  44977. camera: FreeCamera;
  44978. private _leftjoystick;
  44979. private _rightjoystick;
  44980. /**
  44981. * Gets the left stick of the virtual joystick.
  44982. * @returns The virtual Joystick
  44983. */
  44984. getLeftJoystick(): VirtualJoystick;
  44985. /**
  44986. * Gets the right stick of the virtual joystick.
  44987. * @returns The virtual Joystick
  44988. */
  44989. getRightJoystick(): VirtualJoystick;
  44990. /**
  44991. * Update the current camera state depending on the inputs that have been used this frame.
  44992. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44993. */
  44994. checkInputs(): void;
  44995. /**
  44996. * Attach the input controls to a specific dom element to get the input from.
  44997. * @param element Defines the element the controls should be listened from
  44998. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44999. */
  45000. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45001. /**
  45002. * Detach the current controls from the specified dom element.
  45003. * @param element Defines the element to stop listening the inputs from
  45004. */
  45005. detachControl(element: Nullable<HTMLElement>): void;
  45006. /**
  45007. * Gets the class name of the current intput.
  45008. * @returns the class name
  45009. */
  45010. getClassName(): string;
  45011. /**
  45012. * Get the friendly name associated with the input class.
  45013. * @returns the input friendly name
  45014. */
  45015. getSimpleName(): string;
  45016. }
  45017. }
  45018. declare module BABYLON {
  45019. /**
  45020. * This represents a FPS type of camera controlled by touch.
  45021. * This is like a universal camera minus the Gamepad controls.
  45022. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45023. */
  45024. export class TouchCamera extends FreeCamera {
  45025. /**
  45026. * Defines the touch sensibility for rotation.
  45027. * The higher the faster.
  45028. */
  45029. get touchAngularSensibility(): number;
  45030. set touchAngularSensibility(value: number);
  45031. /**
  45032. * Defines the touch sensibility for move.
  45033. * The higher the faster.
  45034. */
  45035. get touchMoveSensibility(): number;
  45036. set touchMoveSensibility(value: number);
  45037. /**
  45038. * Instantiates a new touch camera.
  45039. * This represents a FPS type of camera controlled by touch.
  45040. * This is like a universal camera minus the Gamepad controls.
  45041. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45042. * @param name Define the name of the camera in the scene
  45043. * @param position Define the start position of the camera in the scene
  45044. * @param scene Define the scene the camera belongs to
  45045. */
  45046. constructor(name: string, position: Vector3, scene: Scene);
  45047. /**
  45048. * Gets the current object class name.
  45049. * @return the class name
  45050. */
  45051. getClassName(): string;
  45052. /** @hidden */
  45053. _setupInputs(): void;
  45054. }
  45055. }
  45056. declare module BABYLON {
  45057. /**
  45058. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45059. * being tilted forward or back and left or right.
  45060. */
  45061. export class DeviceOrientationCamera extends FreeCamera {
  45062. private _initialQuaternion;
  45063. private _quaternionCache;
  45064. private _tmpDragQuaternion;
  45065. private _disablePointerInputWhenUsingDeviceOrientation;
  45066. /**
  45067. * Creates a new device orientation camera
  45068. * @param name The name of the camera
  45069. * @param position The start position camera
  45070. * @param scene The scene the camera belongs to
  45071. */
  45072. constructor(name: string, position: Vector3, scene: Scene);
  45073. /**
  45074. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  45075. */
  45076. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  45077. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  45078. private _dragFactor;
  45079. /**
  45080. * Enabled turning on the y axis when the orientation sensor is active
  45081. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  45082. */
  45083. enableHorizontalDragging(dragFactor?: number): void;
  45084. /**
  45085. * Gets the current instance class name ("DeviceOrientationCamera").
  45086. * This helps avoiding instanceof at run time.
  45087. * @returns the class name
  45088. */
  45089. getClassName(): string;
  45090. /**
  45091. * @hidden
  45092. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  45093. */
  45094. _checkInputs(): void;
  45095. /**
  45096. * Reset the camera to its default orientation on the specified axis only.
  45097. * @param axis The axis to reset
  45098. */
  45099. resetToCurrentRotation(axis?: Axis): void;
  45100. }
  45101. }
  45102. declare module BABYLON {
  45103. /**
  45104. * Defines supported buttons for XBox360 compatible gamepads
  45105. */
  45106. export enum Xbox360Button {
  45107. /** A */
  45108. A = 0,
  45109. /** B */
  45110. B = 1,
  45111. /** X */
  45112. X = 2,
  45113. /** Y */
  45114. Y = 3,
  45115. /** Left button */
  45116. LB = 4,
  45117. /** Right button */
  45118. RB = 5,
  45119. /** Back */
  45120. Back = 8,
  45121. /** Start */
  45122. Start = 9,
  45123. /** Left stick */
  45124. LeftStick = 10,
  45125. /** Right stick */
  45126. RightStick = 11
  45127. }
  45128. /** Defines values for XBox360 DPad */
  45129. export enum Xbox360Dpad {
  45130. /** Up */
  45131. Up = 12,
  45132. /** Down */
  45133. Down = 13,
  45134. /** Left */
  45135. Left = 14,
  45136. /** Right */
  45137. Right = 15
  45138. }
  45139. /**
  45140. * Defines a XBox360 gamepad
  45141. */
  45142. export class Xbox360Pad extends Gamepad {
  45143. private _leftTrigger;
  45144. private _rightTrigger;
  45145. private _onlefttriggerchanged;
  45146. private _onrighttriggerchanged;
  45147. private _onbuttondown;
  45148. private _onbuttonup;
  45149. private _ondpaddown;
  45150. private _ondpadup;
  45151. /** Observable raised when a button is pressed */
  45152. onButtonDownObservable: Observable<Xbox360Button>;
  45153. /** Observable raised when a button is released */
  45154. onButtonUpObservable: Observable<Xbox360Button>;
  45155. /** Observable raised when a pad is pressed */
  45156. onPadDownObservable: Observable<Xbox360Dpad>;
  45157. /** Observable raised when a pad is released */
  45158. onPadUpObservable: Observable<Xbox360Dpad>;
  45159. private _buttonA;
  45160. private _buttonB;
  45161. private _buttonX;
  45162. private _buttonY;
  45163. private _buttonBack;
  45164. private _buttonStart;
  45165. private _buttonLB;
  45166. private _buttonRB;
  45167. private _buttonLeftStick;
  45168. private _buttonRightStick;
  45169. private _dPadUp;
  45170. private _dPadDown;
  45171. private _dPadLeft;
  45172. private _dPadRight;
  45173. private _isXboxOnePad;
  45174. /**
  45175. * Creates a new XBox360 gamepad object
  45176. * @param id defines the id of this gamepad
  45177. * @param index defines its index
  45178. * @param gamepad defines the internal HTML gamepad object
  45179. * @param xboxOne defines if it is a XBox One gamepad
  45180. */
  45181. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  45182. /**
  45183. * Defines the callback to call when left trigger is pressed
  45184. * @param callback defines the callback to use
  45185. */
  45186. onlefttriggerchanged(callback: (value: number) => void): void;
  45187. /**
  45188. * Defines the callback to call when right trigger is pressed
  45189. * @param callback defines the callback to use
  45190. */
  45191. onrighttriggerchanged(callback: (value: number) => void): void;
  45192. /**
  45193. * Gets the left trigger value
  45194. */
  45195. get leftTrigger(): number;
  45196. /**
  45197. * Sets the left trigger value
  45198. */
  45199. set leftTrigger(newValue: number);
  45200. /**
  45201. * Gets the right trigger value
  45202. */
  45203. get rightTrigger(): number;
  45204. /**
  45205. * Sets the right trigger value
  45206. */
  45207. set rightTrigger(newValue: number);
  45208. /**
  45209. * Defines the callback to call when a button is pressed
  45210. * @param callback defines the callback to use
  45211. */
  45212. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  45213. /**
  45214. * Defines the callback to call when a button is released
  45215. * @param callback defines the callback to use
  45216. */
  45217. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  45218. /**
  45219. * Defines the callback to call when a pad is pressed
  45220. * @param callback defines the callback to use
  45221. */
  45222. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  45223. /**
  45224. * Defines the callback to call when a pad is released
  45225. * @param callback defines the callback to use
  45226. */
  45227. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  45228. private _setButtonValue;
  45229. private _setDPadValue;
  45230. /**
  45231. * Gets the value of the `A` button
  45232. */
  45233. get buttonA(): number;
  45234. /**
  45235. * Sets the value of the `A` button
  45236. */
  45237. set buttonA(value: number);
  45238. /**
  45239. * Gets the value of the `B` button
  45240. */
  45241. get buttonB(): number;
  45242. /**
  45243. * Sets the value of the `B` button
  45244. */
  45245. set buttonB(value: number);
  45246. /**
  45247. * Gets the value of the `X` button
  45248. */
  45249. get buttonX(): number;
  45250. /**
  45251. * Sets the value of the `X` button
  45252. */
  45253. set buttonX(value: number);
  45254. /**
  45255. * Gets the value of the `Y` button
  45256. */
  45257. get buttonY(): number;
  45258. /**
  45259. * Sets the value of the `Y` button
  45260. */
  45261. set buttonY(value: number);
  45262. /**
  45263. * Gets the value of the `Start` button
  45264. */
  45265. get buttonStart(): number;
  45266. /**
  45267. * Sets the value of the `Start` button
  45268. */
  45269. set buttonStart(value: number);
  45270. /**
  45271. * Gets the value of the `Back` button
  45272. */
  45273. get buttonBack(): number;
  45274. /**
  45275. * Sets the value of the `Back` button
  45276. */
  45277. set buttonBack(value: number);
  45278. /**
  45279. * Gets the value of the `Left` button
  45280. */
  45281. get buttonLB(): number;
  45282. /**
  45283. * Sets the value of the `Left` button
  45284. */
  45285. set buttonLB(value: number);
  45286. /**
  45287. * Gets the value of the `Right` button
  45288. */
  45289. get buttonRB(): number;
  45290. /**
  45291. * Sets the value of the `Right` button
  45292. */
  45293. set buttonRB(value: number);
  45294. /**
  45295. * Gets the value of the Left joystick
  45296. */
  45297. get buttonLeftStick(): number;
  45298. /**
  45299. * Sets the value of the Left joystick
  45300. */
  45301. set buttonLeftStick(value: number);
  45302. /**
  45303. * Gets the value of the Right joystick
  45304. */
  45305. get buttonRightStick(): number;
  45306. /**
  45307. * Sets the value of the Right joystick
  45308. */
  45309. set buttonRightStick(value: number);
  45310. /**
  45311. * Gets the value of D-pad up
  45312. */
  45313. get dPadUp(): number;
  45314. /**
  45315. * Sets the value of D-pad up
  45316. */
  45317. set dPadUp(value: number);
  45318. /**
  45319. * Gets the value of D-pad down
  45320. */
  45321. get dPadDown(): number;
  45322. /**
  45323. * Sets the value of D-pad down
  45324. */
  45325. set dPadDown(value: number);
  45326. /**
  45327. * Gets the value of D-pad left
  45328. */
  45329. get dPadLeft(): number;
  45330. /**
  45331. * Sets the value of D-pad left
  45332. */
  45333. set dPadLeft(value: number);
  45334. /**
  45335. * Gets the value of D-pad right
  45336. */
  45337. get dPadRight(): number;
  45338. /**
  45339. * Sets the value of D-pad right
  45340. */
  45341. set dPadRight(value: number);
  45342. /**
  45343. * Force the gamepad to synchronize with device values
  45344. */
  45345. update(): void;
  45346. /**
  45347. * Disposes the gamepad
  45348. */
  45349. dispose(): void;
  45350. }
  45351. }
  45352. declare module BABYLON {
  45353. /**
  45354. * Defines supported buttons for DualShock compatible gamepads
  45355. */
  45356. export enum DualShockButton {
  45357. /** Cross */
  45358. Cross = 0,
  45359. /** Circle */
  45360. Circle = 1,
  45361. /** Square */
  45362. Square = 2,
  45363. /** Triangle */
  45364. Triangle = 3,
  45365. /** L1 */
  45366. L1 = 4,
  45367. /** R1 */
  45368. R1 = 5,
  45369. /** Share */
  45370. Share = 8,
  45371. /** Options */
  45372. Options = 9,
  45373. /** Left stick */
  45374. LeftStick = 10,
  45375. /** Right stick */
  45376. RightStick = 11
  45377. }
  45378. /** Defines values for DualShock DPad */
  45379. export enum DualShockDpad {
  45380. /** Up */
  45381. Up = 12,
  45382. /** Down */
  45383. Down = 13,
  45384. /** Left */
  45385. Left = 14,
  45386. /** Right */
  45387. Right = 15
  45388. }
  45389. /**
  45390. * Defines a DualShock gamepad
  45391. */
  45392. export class DualShockPad extends Gamepad {
  45393. private _leftTrigger;
  45394. private _rightTrigger;
  45395. private _onlefttriggerchanged;
  45396. private _onrighttriggerchanged;
  45397. private _onbuttondown;
  45398. private _onbuttonup;
  45399. private _ondpaddown;
  45400. private _ondpadup;
  45401. /** Observable raised when a button is pressed */
  45402. onButtonDownObservable: Observable<DualShockButton>;
  45403. /** Observable raised when a button is released */
  45404. onButtonUpObservable: Observable<DualShockButton>;
  45405. /** Observable raised when a pad is pressed */
  45406. onPadDownObservable: Observable<DualShockDpad>;
  45407. /** Observable raised when a pad is released */
  45408. onPadUpObservable: Observable<DualShockDpad>;
  45409. private _buttonCross;
  45410. private _buttonCircle;
  45411. private _buttonSquare;
  45412. private _buttonTriangle;
  45413. private _buttonShare;
  45414. private _buttonOptions;
  45415. private _buttonL1;
  45416. private _buttonR1;
  45417. private _buttonLeftStick;
  45418. private _buttonRightStick;
  45419. private _dPadUp;
  45420. private _dPadDown;
  45421. private _dPadLeft;
  45422. private _dPadRight;
  45423. /**
  45424. * Creates a new DualShock gamepad object
  45425. * @param id defines the id of this gamepad
  45426. * @param index defines its index
  45427. * @param gamepad defines the internal HTML gamepad object
  45428. */
  45429. constructor(id: string, index: number, gamepad: any);
  45430. /**
  45431. * Defines the callback to call when left trigger is pressed
  45432. * @param callback defines the callback to use
  45433. */
  45434. onlefttriggerchanged(callback: (value: number) => void): void;
  45435. /**
  45436. * Defines the callback to call when right trigger is pressed
  45437. * @param callback defines the callback to use
  45438. */
  45439. onrighttriggerchanged(callback: (value: number) => void): void;
  45440. /**
  45441. * Gets the left trigger value
  45442. */
  45443. get leftTrigger(): number;
  45444. /**
  45445. * Sets the left trigger value
  45446. */
  45447. set leftTrigger(newValue: number);
  45448. /**
  45449. * Gets the right trigger value
  45450. */
  45451. get rightTrigger(): number;
  45452. /**
  45453. * Sets the right trigger value
  45454. */
  45455. set rightTrigger(newValue: number);
  45456. /**
  45457. * Defines the callback to call when a button is pressed
  45458. * @param callback defines the callback to use
  45459. */
  45460. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  45461. /**
  45462. * Defines the callback to call when a button is released
  45463. * @param callback defines the callback to use
  45464. */
  45465. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  45466. /**
  45467. * Defines the callback to call when a pad is pressed
  45468. * @param callback defines the callback to use
  45469. */
  45470. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  45471. /**
  45472. * Defines the callback to call when a pad is released
  45473. * @param callback defines the callback to use
  45474. */
  45475. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  45476. private _setButtonValue;
  45477. private _setDPadValue;
  45478. /**
  45479. * Gets the value of the `Cross` button
  45480. */
  45481. get buttonCross(): number;
  45482. /**
  45483. * Sets the value of the `Cross` button
  45484. */
  45485. set buttonCross(value: number);
  45486. /**
  45487. * Gets the value of the `Circle` button
  45488. */
  45489. get buttonCircle(): number;
  45490. /**
  45491. * Sets the value of the `Circle` button
  45492. */
  45493. set buttonCircle(value: number);
  45494. /**
  45495. * Gets the value of the `Square` button
  45496. */
  45497. get buttonSquare(): number;
  45498. /**
  45499. * Sets the value of the `Square` button
  45500. */
  45501. set buttonSquare(value: number);
  45502. /**
  45503. * Gets the value of the `Triangle` button
  45504. */
  45505. get buttonTriangle(): number;
  45506. /**
  45507. * Sets the value of the `Triangle` button
  45508. */
  45509. set buttonTriangle(value: number);
  45510. /**
  45511. * Gets the value of the `Options` button
  45512. */
  45513. get buttonOptions(): number;
  45514. /**
  45515. * Sets the value of the `Options` button
  45516. */
  45517. set buttonOptions(value: number);
  45518. /**
  45519. * Gets the value of the `Share` button
  45520. */
  45521. get buttonShare(): number;
  45522. /**
  45523. * Sets the value of the `Share` button
  45524. */
  45525. set buttonShare(value: number);
  45526. /**
  45527. * Gets the value of the `L1` button
  45528. */
  45529. get buttonL1(): number;
  45530. /**
  45531. * Sets the value of the `L1` button
  45532. */
  45533. set buttonL1(value: number);
  45534. /**
  45535. * Gets the value of the `R1` button
  45536. */
  45537. get buttonR1(): number;
  45538. /**
  45539. * Sets the value of the `R1` button
  45540. */
  45541. set buttonR1(value: number);
  45542. /**
  45543. * Gets the value of the Left joystick
  45544. */
  45545. get buttonLeftStick(): number;
  45546. /**
  45547. * Sets the value of the Left joystick
  45548. */
  45549. set buttonLeftStick(value: number);
  45550. /**
  45551. * Gets the value of the Right joystick
  45552. */
  45553. get buttonRightStick(): number;
  45554. /**
  45555. * Sets the value of the Right joystick
  45556. */
  45557. set buttonRightStick(value: number);
  45558. /**
  45559. * Gets the value of D-pad up
  45560. */
  45561. get dPadUp(): number;
  45562. /**
  45563. * Sets the value of D-pad up
  45564. */
  45565. set dPadUp(value: number);
  45566. /**
  45567. * Gets the value of D-pad down
  45568. */
  45569. get dPadDown(): number;
  45570. /**
  45571. * Sets the value of D-pad down
  45572. */
  45573. set dPadDown(value: number);
  45574. /**
  45575. * Gets the value of D-pad left
  45576. */
  45577. get dPadLeft(): number;
  45578. /**
  45579. * Sets the value of D-pad left
  45580. */
  45581. set dPadLeft(value: number);
  45582. /**
  45583. * Gets the value of D-pad right
  45584. */
  45585. get dPadRight(): number;
  45586. /**
  45587. * Sets the value of D-pad right
  45588. */
  45589. set dPadRight(value: number);
  45590. /**
  45591. * Force the gamepad to synchronize with device values
  45592. */
  45593. update(): void;
  45594. /**
  45595. * Disposes the gamepad
  45596. */
  45597. dispose(): void;
  45598. }
  45599. }
  45600. declare module BABYLON {
  45601. /**
  45602. * Manager for handling gamepads
  45603. */
  45604. export class GamepadManager {
  45605. private _scene?;
  45606. private _babylonGamepads;
  45607. private _oneGamepadConnected;
  45608. /** @hidden */
  45609. _isMonitoring: boolean;
  45610. private _gamepadEventSupported;
  45611. private _gamepadSupport?;
  45612. /**
  45613. * observable to be triggered when the gamepad controller has been connected
  45614. */
  45615. onGamepadConnectedObservable: Observable<Gamepad>;
  45616. /**
  45617. * observable to be triggered when the gamepad controller has been disconnected
  45618. */
  45619. onGamepadDisconnectedObservable: Observable<Gamepad>;
  45620. private _onGamepadConnectedEvent;
  45621. private _onGamepadDisconnectedEvent;
  45622. /**
  45623. * Initializes the gamepad manager
  45624. * @param _scene BabylonJS scene
  45625. */
  45626. constructor(_scene?: Scene | undefined);
  45627. /**
  45628. * The gamepads in the game pad manager
  45629. */
  45630. get gamepads(): Gamepad[];
  45631. /**
  45632. * Get the gamepad controllers based on type
  45633. * @param type The type of gamepad controller
  45634. * @returns Nullable gamepad
  45635. */
  45636. getGamepadByType(type?: number): Nullable<Gamepad>;
  45637. /**
  45638. * Disposes the gamepad manager
  45639. */
  45640. dispose(): void;
  45641. private _addNewGamepad;
  45642. private _startMonitoringGamepads;
  45643. private _stopMonitoringGamepads;
  45644. /** @hidden */
  45645. _checkGamepadsStatus(): void;
  45646. private _updateGamepadObjects;
  45647. }
  45648. }
  45649. declare module BABYLON {
  45650. interface Scene {
  45651. /** @hidden */
  45652. _gamepadManager: Nullable<GamepadManager>;
  45653. /**
  45654. * Gets the gamepad manager associated with the scene
  45655. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  45656. */
  45657. gamepadManager: GamepadManager;
  45658. }
  45659. /**
  45660. * Interface representing a free camera inputs manager
  45661. */
  45662. interface FreeCameraInputsManager {
  45663. /**
  45664. * Adds gamepad input support to the FreeCameraInputsManager.
  45665. * @returns the FreeCameraInputsManager
  45666. */
  45667. addGamepad(): FreeCameraInputsManager;
  45668. }
  45669. /**
  45670. * Interface representing an arc rotate camera inputs manager
  45671. */
  45672. interface ArcRotateCameraInputsManager {
  45673. /**
  45674. * Adds gamepad input support to the ArcRotateCamera InputManager.
  45675. * @returns the camera inputs manager
  45676. */
  45677. addGamepad(): ArcRotateCameraInputsManager;
  45678. }
  45679. /**
  45680. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  45681. */
  45682. export class GamepadSystemSceneComponent implements ISceneComponent {
  45683. /**
  45684. * The component name helpfull to identify the component in the list of scene components.
  45685. */
  45686. readonly name: string;
  45687. /**
  45688. * The scene the component belongs to.
  45689. */
  45690. scene: Scene;
  45691. /**
  45692. * Creates a new instance of the component for the given scene
  45693. * @param scene Defines the scene to register the component in
  45694. */
  45695. constructor(scene: Scene);
  45696. /**
  45697. * Registers the component in a given scene
  45698. */
  45699. register(): void;
  45700. /**
  45701. * Rebuilds the elements related to this component in case of
  45702. * context lost for instance.
  45703. */
  45704. rebuild(): void;
  45705. /**
  45706. * Disposes the component and the associated ressources
  45707. */
  45708. dispose(): void;
  45709. private _beforeCameraUpdate;
  45710. }
  45711. }
  45712. declare module BABYLON {
  45713. /**
  45714. * 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,
  45715. * which still works and will still be found in many Playgrounds.
  45716. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45717. */
  45718. export class UniversalCamera extends TouchCamera {
  45719. /**
  45720. * Defines the gamepad rotation sensiblity.
  45721. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45722. */
  45723. get gamepadAngularSensibility(): number;
  45724. set gamepadAngularSensibility(value: number);
  45725. /**
  45726. * Defines the gamepad move sensiblity.
  45727. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45728. */
  45729. get gamepadMoveSensibility(): number;
  45730. set gamepadMoveSensibility(value: number);
  45731. /**
  45732. * 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,
  45733. * which still works and will still be found in many Playgrounds.
  45734. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45735. * @param name Define the name of the camera in the scene
  45736. * @param position Define the start position of the camera in the scene
  45737. * @param scene Define the scene the camera belongs to
  45738. */
  45739. constructor(name: string, position: Vector3, scene: Scene);
  45740. /**
  45741. * Gets the current object class name.
  45742. * @return the class name
  45743. */
  45744. getClassName(): string;
  45745. }
  45746. }
  45747. declare module BABYLON {
  45748. /**
  45749. * This represents a FPS type of camera. This is only here for back compat purpose.
  45750. * Please use the UniversalCamera instead as both are identical.
  45751. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45752. */
  45753. export class GamepadCamera extends UniversalCamera {
  45754. /**
  45755. * Instantiates a new Gamepad Camera
  45756. * This represents a FPS type of camera. This is only here for back compat purpose.
  45757. * Please use the UniversalCamera instead as both are identical.
  45758. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45759. * @param name Define the name of the camera in the scene
  45760. * @param position Define the start position of the camera in the scene
  45761. * @param scene Define the scene the camera belongs to
  45762. */
  45763. constructor(name: string, position: Vector3, scene: Scene);
  45764. /**
  45765. * Gets the current object class name.
  45766. * @return the class name
  45767. */
  45768. getClassName(): string;
  45769. }
  45770. }
  45771. declare module BABYLON {
  45772. /** @hidden */
  45773. export var passPixelShader: {
  45774. name: string;
  45775. shader: string;
  45776. };
  45777. }
  45778. declare module BABYLON {
  45779. /** @hidden */
  45780. export var passCubePixelShader: {
  45781. name: string;
  45782. shader: string;
  45783. };
  45784. }
  45785. declare module BABYLON {
  45786. /**
  45787. * PassPostProcess which produces an output the same as it's input
  45788. */
  45789. export class PassPostProcess extends PostProcess {
  45790. /**
  45791. * Creates the PassPostProcess
  45792. * @param name The name of the effect.
  45793. * @param options The required width/height ratio to downsize to before computing the render pass.
  45794. * @param camera The camera to apply the render pass to.
  45795. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  45796. * @param engine The engine which the post process will be applied. (default: current engine)
  45797. * @param reusable If the post process can be reused on the same frame. (default: false)
  45798. * @param textureType The type of texture to be used when performing the post processing.
  45799. * @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)
  45800. */
  45801. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  45802. }
  45803. /**
  45804. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  45805. */
  45806. export class PassCubePostProcess extends PostProcess {
  45807. private _face;
  45808. /**
  45809. * Gets or sets the cube face to display.
  45810. * * 0 is +X
  45811. * * 1 is -X
  45812. * * 2 is +Y
  45813. * * 3 is -Y
  45814. * * 4 is +Z
  45815. * * 5 is -Z
  45816. */
  45817. get face(): number;
  45818. set face(value: number);
  45819. /**
  45820. * Creates the PassCubePostProcess
  45821. * @param name The name of the effect.
  45822. * @param options The required width/height ratio to downsize to before computing the render pass.
  45823. * @param camera The camera to apply the render pass to.
  45824. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  45825. * @param engine The engine which the post process will be applied. (default: current engine)
  45826. * @param reusable If the post process can be reused on the same frame. (default: false)
  45827. * @param textureType The type of texture to be used when performing the post processing.
  45828. * @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)
  45829. */
  45830. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  45831. }
  45832. }
  45833. declare module BABYLON {
  45834. /** @hidden */
  45835. export var anaglyphPixelShader: {
  45836. name: string;
  45837. shader: string;
  45838. };
  45839. }
  45840. declare module BABYLON {
  45841. /**
  45842. * Postprocess used to generate anaglyphic rendering
  45843. */
  45844. export class AnaglyphPostProcess extends PostProcess {
  45845. private _passedProcess;
  45846. /**
  45847. * Creates a new AnaglyphPostProcess
  45848. * @param name defines postprocess name
  45849. * @param options defines creation options or target ratio scale
  45850. * @param rigCameras defines cameras using this postprocess
  45851. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  45852. * @param engine defines hosting engine
  45853. * @param reusable defines if the postprocess will be reused multiple times per frame
  45854. */
  45855. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  45856. }
  45857. }
  45858. declare module BABYLON {
  45859. /**
  45860. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  45861. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45862. */
  45863. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  45864. /**
  45865. * Creates a new AnaglyphArcRotateCamera
  45866. * @param name defines camera name
  45867. * @param alpha defines alpha angle (in radians)
  45868. * @param beta defines beta angle (in radians)
  45869. * @param radius defines radius
  45870. * @param target defines camera target
  45871. * @param interaxialDistance defines distance between each color axis
  45872. * @param scene defines the hosting scene
  45873. */
  45874. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  45875. /**
  45876. * Gets camera class name
  45877. * @returns AnaglyphArcRotateCamera
  45878. */
  45879. getClassName(): string;
  45880. }
  45881. }
  45882. declare module BABYLON {
  45883. /**
  45884. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  45885. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45886. */
  45887. export class AnaglyphFreeCamera extends FreeCamera {
  45888. /**
  45889. * Creates a new AnaglyphFreeCamera
  45890. * @param name defines camera name
  45891. * @param position defines initial position
  45892. * @param interaxialDistance defines distance between each color axis
  45893. * @param scene defines the hosting scene
  45894. */
  45895. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45896. /**
  45897. * Gets camera class name
  45898. * @returns AnaglyphFreeCamera
  45899. */
  45900. getClassName(): string;
  45901. }
  45902. }
  45903. declare module BABYLON {
  45904. /**
  45905. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  45906. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45907. */
  45908. export class AnaglyphGamepadCamera extends GamepadCamera {
  45909. /**
  45910. * Creates a new AnaglyphGamepadCamera
  45911. * @param name defines camera name
  45912. * @param position defines initial position
  45913. * @param interaxialDistance defines distance between each color axis
  45914. * @param scene defines the hosting scene
  45915. */
  45916. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45917. /**
  45918. * Gets camera class name
  45919. * @returns AnaglyphGamepadCamera
  45920. */
  45921. getClassName(): string;
  45922. }
  45923. }
  45924. declare module BABYLON {
  45925. /**
  45926. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  45927. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45928. */
  45929. export class AnaglyphUniversalCamera extends UniversalCamera {
  45930. /**
  45931. * Creates a new AnaglyphUniversalCamera
  45932. * @param name defines camera name
  45933. * @param position defines initial position
  45934. * @param interaxialDistance defines distance between each color axis
  45935. * @param scene defines the hosting scene
  45936. */
  45937. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45938. /**
  45939. * Gets camera class name
  45940. * @returns AnaglyphUniversalCamera
  45941. */
  45942. getClassName(): string;
  45943. }
  45944. }
  45945. declare module BABYLON {
  45946. /**
  45947. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  45948. * @see https://doc.babylonjs.com/features/cameras
  45949. */
  45950. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  45951. /**
  45952. * Creates a new StereoscopicArcRotateCamera
  45953. * @param name defines camera name
  45954. * @param alpha defines alpha angle (in radians)
  45955. * @param beta defines beta angle (in radians)
  45956. * @param radius defines radius
  45957. * @param target defines camera target
  45958. * @param interaxialDistance defines distance between each color axis
  45959. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45960. * @param scene defines the hosting scene
  45961. */
  45962. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45963. /**
  45964. * Gets camera class name
  45965. * @returns StereoscopicArcRotateCamera
  45966. */
  45967. getClassName(): string;
  45968. }
  45969. }
  45970. declare module BABYLON {
  45971. /**
  45972. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  45973. * @see https://doc.babylonjs.com/features/cameras
  45974. */
  45975. export class StereoscopicFreeCamera extends FreeCamera {
  45976. /**
  45977. * Creates a new StereoscopicFreeCamera
  45978. * @param name defines camera name
  45979. * @param position defines initial position
  45980. * @param interaxialDistance defines distance between each color axis
  45981. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45982. * @param scene defines the hosting scene
  45983. */
  45984. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45985. /**
  45986. * Gets camera class name
  45987. * @returns StereoscopicFreeCamera
  45988. */
  45989. getClassName(): string;
  45990. }
  45991. }
  45992. declare module BABYLON {
  45993. /**
  45994. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  45995. * @see https://doc.babylonjs.com/features/cameras
  45996. */
  45997. export class StereoscopicGamepadCamera extends GamepadCamera {
  45998. /**
  45999. * Creates a new StereoscopicGamepadCamera
  46000. * @param name defines camera name
  46001. * @param position defines initial position
  46002. * @param interaxialDistance defines distance between each color axis
  46003. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46004. * @param scene defines the hosting scene
  46005. */
  46006. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46007. /**
  46008. * Gets camera class name
  46009. * @returns StereoscopicGamepadCamera
  46010. */
  46011. getClassName(): string;
  46012. }
  46013. }
  46014. declare module BABYLON {
  46015. /**
  46016. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  46017. * @see https://doc.babylonjs.com/features/cameras
  46018. */
  46019. export class StereoscopicUniversalCamera extends UniversalCamera {
  46020. /**
  46021. * Creates a new StereoscopicUniversalCamera
  46022. * @param name defines camera name
  46023. * @param position defines initial position
  46024. * @param interaxialDistance defines distance between each color axis
  46025. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46026. * @param scene defines the hosting scene
  46027. */
  46028. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46029. /**
  46030. * Gets camera class name
  46031. * @returns StereoscopicUniversalCamera
  46032. */
  46033. getClassName(): string;
  46034. }
  46035. }
  46036. declare module BABYLON {
  46037. /**
  46038. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  46039. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46040. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46041. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46042. */
  46043. export class VirtualJoysticksCamera extends FreeCamera {
  46044. /**
  46045. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  46046. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46047. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46048. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46049. * @param name Define the name of the camera in the scene
  46050. * @param position Define the start position of the camera in the scene
  46051. * @param scene Define the scene the camera belongs to
  46052. */
  46053. constructor(name: string, position: Vector3, scene: Scene);
  46054. /**
  46055. * Gets the current object class name.
  46056. * @return the class name
  46057. */
  46058. getClassName(): string;
  46059. }
  46060. }
  46061. declare module BABYLON {
  46062. /**
  46063. * This represents all the required metrics to create a VR camera.
  46064. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  46065. */
  46066. export class VRCameraMetrics {
  46067. /**
  46068. * Define the horizontal resolution off the screen.
  46069. */
  46070. hResolution: number;
  46071. /**
  46072. * Define the vertical resolution off the screen.
  46073. */
  46074. vResolution: number;
  46075. /**
  46076. * Define the horizontal screen size.
  46077. */
  46078. hScreenSize: number;
  46079. /**
  46080. * Define the vertical screen size.
  46081. */
  46082. vScreenSize: number;
  46083. /**
  46084. * Define the vertical screen center position.
  46085. */
  46086. vScreenCenter: number;
  46087. /**
  46088. * Define the distance of the eyes to the screen.
  46089. */
  46090. eyeToScreenDistance: number;
  46091. /**
  46092. * Define the distance between both lenses
  46093. */
  46094. lensSeparationDistance: number;
  46095. /**
  46096. * Define the distance between both viewer's eyes.
  46097. */
  46098. interpupillaryDistance: number;
  46099. /**
  46100. * Define the distortion factor of the VR postprocess.
  46101. * Please, touch with care.
  46102. */
  46103. distortionK: number[];
  46104. /**
  46105. * Define the chromatic aberration correction factors for the VR post process.
  46106. */
  46107. chromaAbCorrection: number[];
  46108. /**
  46109. * Define the scale factor of the post process.
  46110. * The smaller the better but the slower.
  46111. */
  46112. postProcessScaleFactor: number;
  46113. /**
  46114. * Define an offset for the lens center.
  46115. */
  46116. lensCenterOffset: number;
  46117. /**
  46118. * Define if the current vr camera should compensate the distortion of the lense or not.
  46119. */
  46120. compensateDistortion: boolean;
  46121. /**
  46122. * Defines if multiview should be enabled when rendering (Default: false)
  46123. */
  46124. multiviewEnabled: boolean;
  46125. /**
  46126. * Gets the rendering aspect ratio based on the provided resolutions.
  46127. */
  46128. get aspectRatio(): number;
  46129. /**
  46130. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  46131. */
  46132. get aspectRatioFov(): number;
  46133. /**
  46134. * @hidden
  46135. */
  46136. get leftHMatrix(): Matrix;
  46137. /**
  46138. * @hidden
  46139. */
  46140. get rightHMatrix(): Matrix;
  46141. /**
  46142. * @hidden
  46143. */
  46144. get leftPreViewMatrix(): Matrix;
  46145. /**
  46146. * @hidden
  46147. */
  46148. get rightPreViewMatrix(): Matrix;
  46149. /**
  46150. * Get the default VRMetrics based on the most generic setup.
  46151. * @returns the default vr metrics
  46152. */
  46153. static GetDefault(): VRCameraMetrics;
  46154. }
  46155. }
  46156. declare module BABYLON {
  46157. /** @hidden */
  46158. export var vrDistortionCorrectionPixelShader: {
  46159. name: string;
  46160. shader: string;
  46161. };
  46162. }
  46163. declare module BABYLON {
  46164. /**
  46165. * VRDistortionCorrectionPostProcess used for mobile VR
  46166. */
  46167. export class VRDistortionCorrectionPostProcess extends PostProcess {
  46168. private _isRightEye;
  46169. private _distortionFactors;
  46170. private _postProcessScaleFactor;
  46171. private _lensCenterOffset;
  46172. private _scaleIn;
  46173. private _scaleFactor;
  46174. private _lensCenter;
  46175. /**
  46176. * Initializes the VRDistortionCorrectionPostProcess
  46177. * @param name The name of the effect.
  46178. * @param camera The camera to apply the render pass to.
  46179. * @param isRightEye If this is for the right eye distortion
  46180. * @param vrMetrics All the required metrics for the VR camera
  46181. */
  46182. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  46183. }
  46184. }
  46185. declare module BABYLON {
  46186. /**
  46187. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  46188. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46189. */
  46190. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  46191. /**
  46192. * Creates a new VRDeviceOrientationArcRotateCamera
  46193. * @param name defines camera name
  46194. * @param alpha defines the camera rotation along the logitudinal axis
  46195. * @param beta defines the camera rotation along the latitudinal axis
  46196. * @param radius defines the camera distance from its target
  46197. * @param target defines the camera target
  46198. * @param scene defines the scene the camera belongs to
  46199. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46200. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46201. */
  46202. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46203. /**
  46204. * Gets camera class name
  46205. * @returns VRDeviceOrientationArcRotateCamera
  46206. */
  46207. getClassName(): string;
  46208. }
  46209. }
  46210. declare module BABYLON {
  46211. /**
  46212. * Camera used to simulate VR rendering (based on FreeCamera)
  46213. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46214. */
  46215. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  46216. /**
  46217. * Creates a new VRDeviceOrientationFreeCamera
  46218. * @param name defines camera name
  46219. * @param position defines the start position of the camera
  46220. * @param scene defines the scene the camera belongs to
  46221. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46222. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46223. */
  46224. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46225. /**
  46226. * Gets camera class name
  46227. * @returns VRDeviceOrientationFreeCamera
  46228. */
  46229. getClassName(): string;
  46230. }
  46231. }
  46232. declare module BABYLON {
  46233. /**
  46234. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  46235. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46236. */
  46237. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  46238. /**
  46239. * Creates a new VRDeviceOrientationGamepadCamera
  46240. * @param name defines camera name
  46241. * @param position defines the start position of the camera
  46242. * @param scene defines the scene the camera belongs to
  46243. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46244. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46245. */
  46246. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46247. /**
  46248. * Gets camera class name
  46249. * @returns VRDeviceOrientationGamepadCamera
  46250. */
  46251. getClassName(): string;
  46252. }
  46253. }
  46254. declare module BABYLON {
  46255. /**
  46256. * A class extending Texture allowing drawing on a texture
  46257. * @see https://doc.babylonjs.com/how_to/dynamictexture
  46258. */
  46259. export class DynamicTexture extends Texture {
  46260. private _generateMipMaps;
  46261. private _canvas;
  46262. private _context;
  46263. /**
  46264. * Creates a DynamicTexture
  46265. * @param name defines the name of the texture
  46266. * @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
  46267. * @param scene defines the scene where you want the texture
  46268. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46269. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  46270. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  46271. */
  46272. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46273. /**
  46274. * Get the current class name of the texture useful for serialization or dynamic coding.
  46275. * @returns "DynamicTexture"
  46276. */
  46277. getClassName(): string;
  46278. /**
  46279. * Gets the current state of canRescale
  46280. */
  46281. get canRescale(): boolean;
  46282. private _recreate;
  46283. /**
  46284. * Scales the texture
  46285. * @param ratio the scale factor to apply to both width and height
  46286. */
  46287. scale(ratio: number): void;
  46288. /**
  46289. * Resizes the texture
  46290. * @param width the new width
  46291. * @param height the new height
  46292. */
  46293. scaleTo(width: number, height: number): void;
  46294. /**
  46295. * Gets the context of the canvas used by the texture
  46296. * @returns the canvas context of the dynamic texture
  46297. */
  46298. getContext(): CanvasRenderingContext2D;
  46299. /**
  46300. * Clears the texture
  46301. */
  46302. clear(): void;
  46303. /**
  46304. * Updates the texture
  46305. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46306. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46307. */
  46308. update(invertY?: boolean, premulAlpha?: boolean): void;
  46309. /**
  46310. * Draws text onto the texture
  46311. * @param text defines the text to be drawn
  46312. * @param x defines the placement of the text from the left
  46313. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46314. * @param font defines the font to be used with font-style, font-size, font-name
  46315. * @param color defines the color used for the text
  46316. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46317. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46318. * @param update defines whether texture is immediately update (default is true)
  46319. */
  46320. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  46321. /**
  46322. * Clones the texture
  46323. * @returns the clone of the texture.
  46324. */
  46325. clone(): DynamicTexture;
  46326. /**
  46327. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  46328. * @returns a serialized dynamic texture object
  46329. */
  46330. serialize(): any;
  46331. private _IsCanvasElement;
  46332. /** @hidden */
  46333. _rebuild(): void;
  46334. }
  46335. }
  46336. declare module BABYLON {
  46337. /**
  46338. * Class containing static functions to help procedurally build meshes
  46339. */
  46340. export class GroundBuilder {
  46341. /**
  46342. * Creates a ground mesh
  46343. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  46344. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  46345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46346. * @param name defines the name of the mesh
  46347. * @param options defines the options used to create the mesh
  46348. * @param scene defines the hosting scene
  46349. * @returns the ground mesh
  46350. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  46351. */
  46352. static CreateGround(name: string, options: {
  46353. width?: number;
  46354. height?: number;
  46355. subdivisions?: number;
  46356. subdivisionsX?: number;
  46357. subdivisionsY?: number;
  46358. updatable?: boolean;
  46359. }, scene: any): Mesh;
  46360. /**
  46361. * Creates a tiled ground mesh
  46362. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  46363. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  46364. * * 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
  46365. * * 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
  46366. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46367. * @param name defines the name of the mesh
  46368. * @param options defines the options used to create the mesh
  46369. * @param scene defines the hosting scene
  46370. * @returns the tiled ground mesh
  46371. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  46372. */
  46373. static CreateTiledGround(name: string, options: {
  46374. xmin: number;
  46375. zmin: number;
  46376. xmax: number;
  46377. zmax: number;
  46378. subdivisions?: {
  46379. w: number;
  46380. h: number;
  46381. };
  46382. precision?: {
  46383. w: number;
  46384. h: number;
  46385. };
  46386. updatable?: boolean;
  46387. }, scene?: Nullable<Scene>): Mesh;
  46388. /**
  46389. * Creates a ground mesh from a height map
  46390. * * The parameter `url` sets the URL of the height map image resource.
  46391. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  46392. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  46393. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  46394. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  46395. * * 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.
  46396. * * 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).
  46397. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  46398. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46399. * @param name defines the name of the mesh
  46400. * @param url defines the url to the height map
  46401. * @param options defines the options used to create the mesh
  46402. * @param scene defines the hosting scene
  46403. * @returns the ground mesh
  46404. * @see https://doc.babylonjs.com/babylon101/height_map
  46405. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  46406. */
  46407. static CreateGroundFromHeightMap(name: string, url: string, options: {
  46408. width?: number;
  46409. height?: number;
  46410. subdivisions?: number;
  46411. minHeight?: number;
  46412. maxHeight?: number;
  46413. colorFilter?: Color3;
  46414. alphaFilter?: number;
  46415. updatable?: boolean;
  46416. onReady?: (mesh: GroundMesh) => void;
  46417. }, scene?: Nullable<Scene>): GroundMesh;
  46418. }
  46419. }
  46420. declare module BABYLON {
  46421. /**
  46422. * Class containing static functions to help procedurally build meshes
  46423. */
  46424. export class TorusBuilder {
  46425. /**
  46426. * Creates a torus mesh
  46427. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  46428. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  46429. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  46430. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46431. * * 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
  46432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46433. * @param name defines the name of the mesh
  46434. * @param options defines the options used to create the mesh
  46435. * @param scene defines the hosting scene
  46436. * @returns the torus mesh
  46437. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  46438. */
  46439. static CreateTorus(name: string, options: {
  46440. diameter?: number;
  46441. thickness?: number;
  46442. tessellation?: number;
  46443. updatable?: boolean;
  46444. sideOrientation?: number;
  46445. frontUVs?: Vector4;
  46446. backUVs?: Vector4;
  46447. }, scene: any): Mesh;
  46448. }
  46449. }
  46450. declare module BABYLON {
  46451. /**
  46452. * Class containing static functions to help procedurally build meshes
  46453. */
  46454. export class CylinderBuilder {
  46455. /**
  46456. * Creates a cylinder or a cone mesh
  46457. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  46458. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  46459. * * 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.
  46460. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  46461. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  46462. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  46463. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  46464. * * 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).
  46465. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  46466. * * 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).
  46467. * * 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
  46468. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  46469. * * 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
  46470. * * 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.
  46471. * * If `enclose` is false, a ring surface is one element.
  46472. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  46473. * * 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
  46474. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46475. * * 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
  46476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46477. * @param name defines the name of the mesh
  46478. * @param options defines the options used to create the mesh
  46479. * @param scene defines the hosting scene
  46480. * @returns the cylinder mesh
  46481. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  46482. */
  46483. static CreateCylinder(name: string, options: {
  46484. height?: number;
  46485. diameterTop?: number;
  46486. diameterBottom?: number;
  46487. diameter?: number;
  46488. tessellation?: number;
  46489. subdivisions?: number;
  46490. arc?: number;
  46491. faceColors?: Color4[];
  46492. faceUV?: Vector4[];
  46493. updatable?: boolean;
  46494. hasRings?: boolean;
  46495. enclose?: boolean;
  46496. cap?: number;
  46497. sideOrientation?: number;
  46498. frontUVs?: Vector4;
  46499. backUVs?: Vector4;
  46500. }, scene: any): Mesh;
  46501. }
  46502. }
  46503. declare module BABYLON {
  46504. /**
  46505. * States of the webXR experience
  46506. */
  46507. export enum WebXRState {
  46508. /**
  46509. * Transitioning to being in XR mode
  46510. */
  46511. ENTERING_XR = 0,
  46512. /**
  46513. * Transitioning to non XR mode
  46514. */
  46515. EXITING_XR = 1,
  46516. /**
  46517. * In XR mode and presenting
  46518. */
  46519. IN_XR = 2,
  46520. /**
  46521. * Not entered XR mode
  46522. */
  46523. NOT_IN_XR = 3
  46524. }
  46525. /**
  46526. * Abstraction of the XR render target
  46527. */
  46528. export interface WebXRRenderTarget extends IDisposable {
  46529. /**
  46530. * xrpresent context of the canvas which can be used to display/mirror xr content
  46531. */
  46532. canvasContext: WebGLRenderingContext;
  46533. /**
  46534. * xr layer for the canvas
  46535. */
  46536. xrLayer: Nullable<XRWebGLLayer>;
  46537. /**
  46538. * Initializes the xr layer for the session
  46539. * @param xrSession xr session
  46540. * @returns a promise that will resolve once the XR Layer has been created
  46541. */
  46542. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46543. }
  46544. }
  46545. declare module BABYLON {
  46546. /**
  46547. * COnfiguration object for WebXR output canvas
  46548. */
  46549. export class WebXRManagedOutputCanvasOptions {
  46550. /**
  46551. * An optional canvas in case you wish to create it yourself and provide it here.
  46552. * If not provided, a new canvas will be created
  46553. */
  46554. canvasElement?: HTMLCanvasElement;
  46555. /**
  46556. * Options for this XR Layer output
  46557. */
  46558. canvasOptions?: XRWebGLLayerOptions;
  46559. /**
  46560. * CSS styling for a newly created canvas (if not provided)
  46561. */
  46562. newCanvasCssStyle?: string;
  46563. /**
  46564. * Get the default values of the configuration object
  46565. * @returns default values of this configuration object
  46566. */
  46567. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  46568. }
  46569. /**
  46570. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  46571. */
  46572. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  46573. private _options;
  46574. private _canvas;
  46575. private _engine;
  46576. private _originalCanvasSize;
  46577. /**
  46578. * Rendering context of the canvas which can be used to display/mirror xr content
  46579. */
  46580. canvasContext: WebGLRenderingContext;
  46581. /**
  46582. * xr layer for the canvas
  46583. */
  46584. xrLayer: Nullable<XRWebGLLayer>;
  46585. /**
  46586. * Obseervers registered here will be triggered when the xr layer was initialized
  46587. */
  46588. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  46589. /**
  46590. * Initializes the canvas to be added/removed upon entering/exiting xr
  46591. * @param _xrSessionManager The XR Session manager
  46592. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  46593. */
  46594. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  46595. /**
  46596. * Disposes of the object
  46597. */
  46598. dispose(): void;
  46599. /**
  46600. * Initializes the xr layer for the session
  46601. * @param xrSession xr session
  46602. * @returns a promise that will resolve once the XR Layer has been created
  46603. */
  46604. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46605. private _addCanvas;
  46606. private _removeCanvas;
  46607. private _setCanvasSize;
  46608. private _setManagedOutputCanvas;
  46609. }
  46610. }
  46611. declare module BABYLON {
  46612. /**
  46613. * Manages an XRSession to work with Babylon's engine
  46614. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  46615. */
  46616. export class WebXRSessionManager implements IDisposable {
  46617. /** The scene which the session should be created for */
  46618. scene: Scene;
  46619. private _referenceSpace;
  46620. private _rttProvider;
  46621. private _sessionEnded;
  46622. private _xrNavigator;
  46623. private baseLayer;
  46624. /**
  46625. * The base reference space from which the session started. good if you want to reset your
  46626. * reference space
  46627. */
  46628. baseReferenceSpace: XRReferenceSpace;
  46629. /**
  46630. * Current XR frame
  46631. */
  46632. currentFrame: Nullable<XRFrame>;
  46633. /** WebXR timestamp updated every frame */
  46634. currentTimestamp: number;
  46635. /**
  46636. * Used just in case of a failure to initialize an immersive session.
  46637. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  46638. */
  46639. defaultHeightCompensation: number;
  46640. /**
  46641. * Fires every time a new xrFrame arrives which can be used to update the camera
  46642. */
  46643. onXRFrameObservable: Observable<XRFrame>;
  46644. /**
  46645. * Fires when the reference space changed
  46646. */
  46647. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  46648. /**
  46649. * Fires when the xr session is ended either by the device or manually done
  46650. */
  46651. onXRSessionEnded: Observable<any>;
  46652. /**
  46653. * Fires when the xr session is ended either by the device or manually done
  46654. */
  46655. onXRSessionInit: Observable<XRSession>;
  46656. /**
  46657. * Underlying xr session
  46658. */
  46659. session: XRSession;
  46660. /**
  46661. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  46662. * or get the offset the player is currently at.
  46663. */
  46664. viewerReferenceSpace: XRReferenceSpace;
  46665. /**
  46666. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  46667. * @param scene The scene which the session should be created for
  46668. */
  46669. constructor(
  46670. /** The scene which the session should be created for */
  46671. scene: Scene);
  46672. /**
  46673. * The current reference space used in this session. This reference space can constantly change!
  46674. * It is mainly used to offset the camera's position.
  46675. */
  46676. get referenceSpace(): XRReferenceSpace;
  46677. /**
  46678. * Set a new reference space and triggers the observable
  46679. */
  46680. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  46681. /**
  46682. * Disposes of the session manager
  46683. */
  46684. dispose(): void;
  46685. /**
  46686. * Stops the xrSession and restores the render loop
  46687. * @returns Promise which resolves after it exits XR
  46688. */
  46689. exitXRAsync(): Promise<void>;
  46690. /**
  46691. * Gets the correct render target texture to be rendered this frame for this eye
  46692. * @param eye the eye for which to get the render target
  46693. * @returns the render target for the specified eye
  46694. */
  46695. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  46696. /**
  46697. * Creates a WebXRRenderTarget object for the XR session
  46698. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  46699. * @param options optional options to provide when creating a new render target
  46700. * @returns a WebXR render target to which the session can render
  46701. */
  46702. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  46703. /**
  46704. * Initializes the manager
  46705. * After initialization enterXR can be called to start an XR session
  46706. * @returns Promise which resolves after it is initialized
  46707. */
  46708. initializeAsync(): Promise<void>;
  46709. /**
  46710. * Initializes an xr session
  46711. * @param xrSessionMode mode to initialize
  46712. * @param xrSessionInit defines optional and required values to pass to the session builder
  46713. * @returns a promise which will resolve once the session has been initialized
  46714. */
  46715. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  46716. /**
  46717. * Checks if a session would be supported for the creation options specified
  46718. * @param sessionMode session mode to check if supported eg. immersive-vr
  46719. * @returns A Promise that resolves to true if supported and false if not
  46720. */
  46721. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46722. /**
  46723. * Resets the reference space to the one started the session
  46724. */
  46725. resetReferenceSpace(): void;
  46726. /**
  46727. * Starts rendering to the xr layer
  46728. */
  46729. runXRRenderLoop(): void;
  46730. /**
  46731. * Sets the reference space on the xr session
  46732. * @param referenceSpaceType space to set
  46733. * @returns a promise that will resolve once the reference space has been set
  46734. */
  46735. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  46736. /**
  46737. * Updates the render state of the session
  46738. * @param state state to set
  46739. * @returns a promise that resolves once the render state has been updated
  46740. */
  46741. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  46742. /**
  46743. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  46744. * @param sessionMode defines the session to test
  46745. * @returns a promise with boolean as final value
  46746. */
  46747. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46748. private _createRenderTargetTexture;
  46749. }
  46750. }
  46751. declare module BABYLON {
  46752. /**
  46753. * WebXR Camera which holds the views for the xrSession
  46754. * @see https://doc.babylonjs.com/how_to/webxr_camera
  46755. */
  46756. export class WebXRCamera extends FreeCamera {
  46757. private _xrSessionManager;
  46758. private _firstFrame;
  46759. private _referenceQuaternion;
  46760. private _referencedPosition;
  46761. private _xrInvPositionCache;
  46762. private _xrInvQuaternionCache;
  46763. /**
  46764. * Should position compensation execute on first frame.
  46765. * This is used when copying the position from a native (non XR) camera
  46766. */
  46767. compensateOnFirstFrame: boolean;
  46768. /**
  46769. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  46770. * @param name the name of the camera
  46771. * @param scene the scene to add the camera to
  46772. * @param _xrSessionManager a constructed xr session manager
  46773. */
  46774. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  46775. /**
  46776. * Return the user's height, unrelated to the current ground.
  46777. * This will be the y position of this camera, when ground level is 0.
  46778. */
  46779. get realWorldHeight(): number;
  46780. /** @hidden */
  46781. _updateForDualEyeDebugging(): void;
  46782. /**
  46783. * Sets this camera's transformation based on a non-vr camera
  46784. * @param otherCamera the non-vr camera to copy the transformation from
  46785. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  46786. */
  46787. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  46788. /**
  46789. * Gets the current instance class name ("WebXRCamera").
  46790. * @returns the class name
  46791. */
  46792. getClassName(): string;
  46793. private _rotate180;
  46794. private _updateFromXRSession;
  46795. private _updateNumberOfRigCameras;
  46796. private _updateReferenceSpace;
  46797. private _updateReferenceSpaceOffset;
  46798. }
  46799. }
  46800. declare module BABYLON {
  46801. /**
  46802. * Defining the interface required for a (webxr) feature
  46803. */
  46804. export interface IWebXRFeature extends IDisposable {
  46805. /**
  46806. * Is this feature attached
  46807. */
  46808. attached: boolean;
  46809. /**
  46810. * Should auto-attach be disabled?
  46811. */
  46812. disableAutoAttach: boolean;
  46813. /**
  46814. * Attach the feature to the session
  46815. * Will usually be called by the features manager
  46816. *
  46817. * @param force should attachment be forced (even when already attached)
  46818. * @returns true if successful.
  46819. */
  46820. attach(force?: boolean): boolean;
  46821. /**
  46822. * Detach the feature from the session
  46823. * Will usually be called by the features manager
  46824. *
  46825. * @returns true if successful.
  46826. */
  46827. detach(): boolean;
  46828. }
  46829. /**
  46830. * A list of the currently available features without referencing them
  46831. */
  46832. export class WebXRFeatureName {
  46833. /**
  46834. * The name of the anchor system feature
  46835. */
  46836. static ANCHOR_SYSTEM: string;
  46837. /**
  46838. * The name of the background remover feature
  46839. */
  46840. static BACKGROUND_REMOVER: string;
  46841. /**
  46842. * The name of the hit test feature
  46843. */
  46844. static HIT_TEST: string;
  46845. /**
  46846. * physics impostors for xr controllers feature
  46847. */
  46848. static PHYSICS_CONTROLLERS: string;
  46849. /**
  46850. * The name of the plane detection feature
  46851. */
  46852. static PLANE_DETECTION: string;
  46853. /**
  46854. * The name of the pointer selection feature
  46855. */
  46856. static POINTER_SELECTION: string;
  46857. /**
  46858. * The name of the teleportation feature
  46859. */
  46860. static TELEPORTATION: string;
  46861. }
  46862. /**
  46863. * Defining the constructor of a feature. Used to register the modules.
  46864. */
  46865. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  46866. /**
  46867. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  46868. * It is mainly used in AR sessions.
  46869. *
  46870. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  46871. */
  46872. export class WebXRFeaturesManager implements IDisposable {
  46873. private _xrSessionManager;
  46874. private static readonly _AvailableFeatures;
  46875. private _features;
  46876. /**
  46877. * constructs a new features manages.
  46878. *
  46879. * @param _xrSessionManager an instance of WebXRSessionManager
  46880. */
  46881. constructor(_xrSessionManager: WebXRSessionManager);
  46882. /**
  46883. * Used to register a module. After calling this function a developer can use this feature in the scene.
  46884. * Mainly used internally.
  46885. *
  46886. * @param featureName the name of the feature to register
  46887. * @param constructorFunction the function used to construct the module
  46888. * @param version the (babylon) version of the module
  46889. * @param stable is that a stable version of this module
  46890. */
  46891. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  46892. /**
  46893. * Returns a constructor of a specific feature.
  46894. *
  46895. * @param featureName the name of the feature to construct
  46896. * @param version the version of the feature to load
  46897. * @param xrSessionManager the xrSessionManager. Used to construct the module
  46898. * @param options optional options provided to the module.
  46899. * @returns a function that, when called, will return a new instance of this feature
  46900. */
  46901. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  46902. /**
  46903. * Can be used to return the list of features currently registered
  46904. *
  46905. * @returns an Array of available features
  46906. */
  46907. static GetAvailableFeatures(): string[];
  46908. /**
  46909. * Gets the versions available for a specific feature
  46910. * @param featureName the name of the feature
  46911. * @returns an array with the available versions
  46912. */
  46913. static GetAvailableVersions(featureName: string): string[];
  46914. /**
  46915. * Return the latest unstable version of this feature
  46916. * @param featureName the name of the feature to search
  46917. * @returns the version number. if not found will return -1
  46918. */
  46919. static GetLatestVersionOfFeature(featureName: string): number;
  46920. /**
  46921. * Return the latest stable version of this feature
  46922. * @param featureName the name of the feature to search
  46923. * @returns the version number. if not found will return -1
  46924. */
  46925. static GetStableVersionOfFeature(featureName: string): number;
  46926. /**
  46927. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  46928. * Can be used during a session to start a feature
  46929. * @param featureName the name of feature to attach
  46930. */
  46931. attachFeature(featureName: string): void;
  46932. /**
  46933. * Can be used inside a session or when the session ends to detach a specific feature
  46934. * @param featureName the name of the feature to detach
  46935. */
  46936. detachFeature(featureName: string): void;
  46937. /**
  46938. * Used to disable an already-enabled feature
  46939. * The feature will be disposed and will be recreated once enabled.
  46940. * @param featureName the feature to disable
  46941. * @returns true if disable was successful
  46942. */
  46943. disableFeature(featureName: string | {
  46944. Name: string;
  46945. }): boolean;
  46946. /**
  46947. * dispose this features manager
  46948. */
  46949. dispose(): void;
  46950. /**
  46951. * 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.
  46952. * 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.
  46953. *
  46954. * @param featureName the name of the feature to load or the class of the feature
  46955. * @param version optional version to load. if not provided the latest version will be enabled
  46956. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  46957. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  46958. * @returns a new constructed feature or throws an error if feature not found.
  46959. */
  46960. enableFeature(featureName: string | {
  46961. Name: string;
  46962. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  46963. /**
  46964. * get the implementation of an enabled feature.
  46965. * @param featureName the name of the feature to load
  46966. * @returns the feature class, if found
  46967. */
  46968. getEnabledFeature(featureName: string): IWebXRFeature;
  46969. /**
  46970. * Get the list of enabled features
  46971. * @returns an array of enabled features
  46972. */
  46973. getEnabledFeatures(): string[];
  46974. }
  46975. }
  46976. declare module BABYLON {
  46977. /**
  46978. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  46979. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  46980. */
  46981. export class WebXRExperienceHelper implements IDisposable {
  46982. private scene;
  46983. private _nonVRCamera;
  46984. private _originalSceneAutoClear;
  46985. private _supported;
  46986. /**
  46987. * Camera used to render xr content
  46988. */
  46989. camera: WebXRCamera;
  46990. /** A features manager for this xr session */
  46991. featuresManager: WebXRFeaturesManager;
  46992. /**
  46993. * Observers registered here will be triggered after the camera's initial transformation is set
  46994. * This can be used to set a different ground level or an extra rotation.
  46995. *
  46996. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  46997. * to the position set after this observable is done executing.
  46998. */
  46999. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  47000. /**
  47001. * Fires when the state of the experience helper has changed
  47002. */
  47003. onStateChangedObservable: Observable<WebXRState>;
  47004. /** Session manager used to keep track of xr session */
  47005. sessionManager: WebXRSessionManager;
  47006. /**
  47007. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  47008. */
  47009. state: WebXRState;
  47010. /**
  47011. * Creates a WebXRExperienceHelper
  47012. * @param scene The scene the helper should be created in
  47013. */
  47014. private constructor();
  47015. /**
  47016. * Creates the experience helper
  47017. * @param scene the scene to attach the experience helper to
  47018. * @returns a promise for the experience helper
  47019. */
  47020. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  47021. /**
  47022. * Disposes of the experience helper
  47023. */
  47024. dispose(): void;
  47025. /**
  47026. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  47027. * @param sessionMode options for the XR session
  47028. * @param referenceSpaceType frame of reference of the XR session
  47029. * @param renderTarget the output canvas that will be used to enter XR mode
  47030. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  47031. * @returns promise that resolves after xr mode has entered
  47032. */
  47033. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  47034. /**
  47035. * Exits XR mode and returns the scene to its original state
  47036. * @returns promise that resolves after xr mode has exited
  47037. */
  47038. exitXRAsync(): Promise<void>;
  47039. private _nonXRToXRCamera;
  47040. private _setState;
  47041. }
  47042. }
  47043. declare module BABYLON {
  47044. /**
  47045. * X-Y values for axes in WebXR
  47046. */
  47047. export interface IWebXRMotionControllerAxesValue {
  47048. /**
  47049. * The value of the x axis
  47050. */
  47051. x: number;
  47052. /**
  47053. * The value of the y-axis
  47054. */
  47055. y: number;
  47056. }
  47057. /**
  47058. * changed / previous values for the values of this component
  47059. */
  47060. export interface IWebXRMotionControllerComponentChangesValues<T> {
  47061. /**
  47062. * current (this frame) value
  47063. */
  47064. current: T;
  47065. /**
  47066. * previous (last change) value
  47067. */
  47068. previous: T;
  47069. }
  47070. /**
  47071. * Represents changes in the component between current frame and last values recorded
  47072. */
  47073. export interface IWebXRMotionControllerComponentChanges {
  47074. /**
  47075. * will be populated with previous and current values if axes changed
  47076. */
  47077. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  47078. /**
  47079. * will be populated with previous and current values if pressed changed
  47080. */
  47081. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47082. /**
  47083. * will be populated with previous and current values if touched changed
  47084. */
  47085. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47086. /**
  47087. * will be populated with previous and current values if value changed
  47088. */
  47089. value?: IWebXRMotionControllerComponentChangesValues<number>;
  47090. }
  47091. /**
  47092. * This class represents a single component (for example button or thumbstick) of a motion controller
  47093. */
  47094. export class WebXRControllerComponent implements IDisposable {
  47095. /**
  47096. * the id of this component
  47097. */
  47098. id: string;
  47099. /**
  47100. * the type of the component
  47101. */
  47102. type: MotionControllerComponentType;
  47103. private _buttonIndex;
  47104. private _axesIndices;
  47105. private _axes;
  47106. private _changes;
  47107. private _currentValue;
  47108. private _hasChanges;
  47109. private _pressed;
  47110. private _touched;
  47111. /**
  47112. * button component type
  47113. */
  47114. static BUTTON_TYPE: MotionControllerComponentType;
  47115. /**
  47116. * squeeze component type
  47117. */
  47118. static SQUEEZE_TYPE: MotionControllerComponentType;
  47119. /**
  47120. * Thumbstick component type
  47121. */
  47122. static THUMBSTICK_TYPE: MotionControllerComponentType;
  47123. /**
  47124. * Touchpad component type
  47125. */
  47126. static TOUCHPAD_TYPE: MotionControllerComponentType;
  47127. /**
  47128. * trigger component type
  47129. */
  47130. static TRIGGER_TYPE: MotionControllerComponentType;
  47131. /**
  47132. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  47133. * the axes data changes
  47134. */
  47135. onAxisValueChangedObservable: Observable<{
  47136. x: number;
  47137. y: number;
  47138. }>;
  47139. /**
  47140. * Observers registered here will be triggered when the state of a button changes
  47141. * State change is either pressed / touched / value
  47142. */
  47143. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  47144. /**
  47145. * Creates a new component for a motion controller.
  47146. * It is created by the motion controller itself
  47147. *
  47148. * @param id the id of this component
  47149. * @param type the type of the component
  47150. * @param _buttonIndex index in the buttons array of the gamepad
  47151. * @param _axesIndices indices of the values in the axes array of the gamepad
  47152. */
  47153. constructor(
  47154. /**
  47155. * the id of this component
  47156. */
  47157. id: string,
  47158. /**
  47159. * the type of the component
  47160. */
  47161. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  47162. /**
  47163. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  47164. */
  47165. get axes(): IWebXRMotionControllerAxesValue;
  47166. /**
  47167. * Get the changes. Elements will be populated only if they changed with their previous and current value
  47168. */
  47169. get changes(): IWebXRMotionControllerComponentChanges;
  47170. /**
  47171. * Return whether or not the component changed the last frame
  47172. */
  47173. get hasChanges(): boolean;
  47174. /**
  47175. * is the button currently pressed
  47176. */
  47177. get pressed(): boolean;
  47178. /**
  47179. * is the button currently touched
  47180. */
  47181. get touched(): boolean;
  47182. /**
  47183. * Get the current value of this component
  47184. */
  47185. get value(): number;
  47186. /**
  47187. * Dispose this component
  47188. */
  47189. dispose(): void;
  47190. /**
  47191. * Are there axes correlating to this component
  47192. * @return true is axes data is available
  47193. */
  47194. isAxes(): boolean;
  47195. /**
  47196. * Is this component a button (hence - pressable)
  47197. * @returns true if can be pressed
  47198. */
  47199. isButton(): boolean;
  47200. /**
  47201. * update this component using the gamepad object it is in. Called on every frame
  47202. * @param nativeController the native gamepad controller object
  47203. */
  47204. update(nativeController: IMinimalMotionControllerObject): void;
  47205. }
  47206. }
  47207. declare module BABYLON {
  47208. /**
  47209. * Interface used to represent data loading progression
  47210. */
  47211. export interface ISceneLoaderProgressEvent {
  47212. /**
  47213. * Defines if data length to load can be evaluated
  47214. */
  47215. readonly lengthComputable: boolean;
  47216. /**
  47217. * Defines the loaded data length
  47218. */
  47219. readonly loaded: number;
  47220. /**
  47221. * Defines the data length to load
  47222. */
  47223. readonly total: number;
  47224. }
  47225. /**
  47226. * Interface used by SceneLoader plugins to define supported file extensions
  47227. */
  47228. export interface ISceneLoaderPluginExtensions {
  47229. /**
  47230. * Defines the list of supported extensions
  47231. */
  47232. [extension: string]: {
  47233. isBinary: boolean;
  47234. };
  47235. }
  47236. /**
  47237. * Interface used by SceneLoader plugin factory
  47238. */
  47239. export interface ISceneLoaderPluginFactory {
  47240. /**
  47241. * Defines the name of the factory
  47242. */
  47243. name: string;
  47244. /**
  47245. * Function called to create a new plugin
  47246. * @return the new plugin
  47247. */
  47248. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  47249. /**
  47250. * The callback that returns true if the data can be directly loaded.
  47251. * @param data string containing the file data
  47252. * @returns if the data can be loaded directly
  47253. */
  47254. canDirectLoad?(data: string): boolean;
  47255. }
  47256. /**
  47257. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  47258. */
  47259. export interface ISceneLoaderPluginBase {
  47260. /**
  47261. * The friendly name of this plugin.
  47262. */
  47263. name: string;
  47264. /**
  47265. * The file extensions supported by this plugin.
  47266. */
  47267. extensions: string | ISceneLoaderPluginExtensions;
  47268. /**
  47269. * The callback called when loading from a url.
  47270. * @param scene scene loading this url
  47271. * @param url url to load
  47272. * @param onSuccess callback called when the file successfully loads
  47273. * @param onProgress callback called while file is loading (if the server supports this mode)
  47274. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  47275. * @param onError callback called when the file fails to load
  47276. * @returns a file request object
  47277. */
  47278. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47279. /**
  47280. * The callback called when loading from a file object.
  47281. * @param scene scene loading this file
  47282. * @param file defines the file to load
  47283. * @param onSuccess defines the callback to call when data is loaded
  47284. * @param onProgress defines the callback to call during loading process
  47285. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  47286. * @param onError defines the callback to call when an error occurs
  47287. * @returns a file request object
  47288. */
  47289. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47290. /**
  47291. * The callback that returns true if the data can be directly loaded.
  47292. * @param data string containing the file data
  47293. * @returns if the data can be loaded directly
  47294. */
  47295. canDirectLoad?(data: string): boolean;
  47296. /**
  47297. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  47298. * @param scene scene loading this data
  47299. * @param data string containing the data
  47300. * @returns data to pass to the plugin
  47301. */
  47302. directLoad?(scene: Scene, data: string): any;
  47303. /**
  47304. * The callback that allows custom handling of the root url based on the response url.
  47305. * @param rootUrl the original root url
  47306. * @param responseURL the response url if available
  47307. * @returns the new root url
  47308. */
  47309. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  47310. }
  47311. /**
  47312. * Interface used to define a SceneLoader plugin
  47313. */
  47314. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  47315. /**
  47316. * Import meshes into a scene.
  47317. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47318. * @param scene The scene to import into
  47319. * @param data The data to import
  47320. * @param rootUrl The root url for scene and resources
  47321. * @param meshes The meshes array to import into
  47322. * @param particleSystems The particle systems array to import into
  47323. * @param skeletons The skeletons array to import into
  47324. * @param onError The callback when import fails
  47325. * @returns True if successful or false otherwise
  47326. */
  47327. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  47328. /**
  47329. * Load into a scene.
  47330. * @param scene The scene to load into
  47331. * @param data The data to import
  47332. * @param rootUrl The root url for scene and resources
  47333. * @param onError The callback when import fails
  47334. * @returns True if successful or false otherwise
  47335. */
  47336. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  47337. /**
  47338. * Load into an asset container.
  47339. * @param scene The scene to load into
  47340. * @param data The data to import
  47341. * @param rootUrl The root url for scene and resources
  47342. * @param onError The callback when import fails
  47343. * @returns The loaded asset container
  47344. */
  47345. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  47346. }
  47347. /**
  47348. * Interface used to define an async SceneLoader plugin
  47349. */
  47350. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  47351. /**
  47352. * Import meshes into a scene.
  47353. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47354. * @param scene The scene to import into
  47355. * @param data The data to import
  47356. * @param rootUrl The root url for scene and resources
  47357. * @param onProgress The callback when the load progresses
  47358. * @param fileName Defines the name of the file to load
  47359. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  47360. */
  47361. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  47362. meshes: AbstractMesh[];
  47363. particleSystems: IParticleSystem[];
  47364. skeletons: Skeleton[];
  47365. animationGroups: AnimationGroup[];
  47366. }>;
  47367. /**
  47368. * Load into a scene.
  47369. * @param scene The scene to load into
  47370. * @param data The data to import
  47371. * @param rootUrl The root url for scene and resources
  47372. * @param onProgress The callback when the load progresses
  47373. * @param fileName Defines the name of the file to load
  47374. * @returns Nothing
  47375. */
  47376. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  47377. /**
  47378. * Load into an asset container.
  47379. * @param scene The scene to load into
  47380. * @param data The data to import
  47381. * @param rootUrl The root url for scene and resources
  47382. * @param onProgress The callback when the load progresses
  47383. * @param fileName Defines the name of the file to load
  47384. * @returns The loaded asset container
  47385. */
  47386. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  47387. }
  47388. /**
  47389. * Mode that determines how to handle old animation groups before loading new ones.
  47390. */
  47391. export enum SceneLoaderAnimationGroupLoadingMode {
  47392. /**
  47393. * Reset all old animations to initial state then dispose them.
  47394. */
  47395. Clean = 0,
  47396. /**
  47397. * Stop all old animations.
  47398. */
  47399. Stop = 1,
  47400. /**
  47401. * Restart old animations from first frame.
  47402. */
  47403. Sync = 2,
  47404. /**
  47405. * Old animations remains untouched.
  47406. */
  47407. NoSync = 3
  47408. }
  47409. /**
  47410. * Class used to load scene from various file formats using registered plugins
  47411. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  47412. */
  47413. export class SceneLoader {
  47414. /**
  47415. * No logging while loading
  47416. */
  47417. static readonly NO_LOGGING: number;
  47418. /**
  47419. * Minimal logging while loading
  47420. */
  47421. static readonly MINIMAL_LOGGING: number;
  47422. /**
  47423. * Summary logging while loading
  47424. */
  47425. static readonly SUMMARY_LOGGING: number;
  47426. /**
  47427. * Detailled logging while loading
  47428. */
  47429. static readonly DETAILED_LOGGING: number;
  47430. /**
  47431. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  47432. */
  47433. static get ForceFullSceneLoadingForIncremental(): boolean;
  47434. static set ForceFullSceneLoadingForIncremental(value: boolean);
  47435. /**
  47436. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  47437. */
  47438. static get ShowLoadingScreen(): boolean;
  47439. static set ShowLoadingScreen(value: boolean);
  47440. /**
  47441. * Defines the current logging level (while loading the scene)
  47442. * @ignorenaming
  47443. */
  47444. static get loggingLevel(): number;
  47445. static set loggingLevel(value: number);
  47446. /**
  47447. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  47448. */
  47449. static get CleanBoneMatrixWeights(): boolean;
  47450. static set CleanBoneMatrixWeights(value: boolean);
  47451. /**
  47452. * Event raised when a plugin is used to load a scene
  47453. */
  47454. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  47455. private static _registeredPlugins;
  47456. private static _showingLoadingScreen;
  47457. private static _getDefaultPlugin;
  47458. private static _getPluginForExtension;
  47459. private static _getPluginForDirectLoad;
  47460. private static _getPluginForFilename;
  47461. private static _getDirectLoad;
  47462. private static _loadData;
  47463. private static _getFileInfo;
  47464. /**
  47465. * Gets a plugin that can load the given extension
  47466. * @param extension defines the extension to load
  47467. * @returns a plugin or null if none works
  47468. */
  47469. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47470. /**
  47471. * Gets a boolean indicating that the given extension can be loaded
  47472. * @param extension defines the extension to load
  47473. * @returns true if the extension is supported
  47474. */
  47475. static IsPluginForExtensionAvailable(extension: string): boolean;
  47476. /**
  47477. * Adds a new plugin to the list of registered plugins
  47478. * @param plugin defines the plugin to add
  47479. */
  47480. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  47481. /**
  47482. * Import meshes into a scene
  47483. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47484. * @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)
  47485. * @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)
  47486. * @param scene the instance of BABYLON.Scene to append to
  47487. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  47488. * @param onProgress a callback with a progress event for each file being loaded
  47489. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47490. * @param pluginExtension the extension used to determine the plugin
  47491. * @returns The loaded plugin
  47492. */
  47493. 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>;
  47494. /**
  47495. * Import meshes into a scene
  47496. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47497. * @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)
  47498. * @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)
  47499. * @param scene the instance of BABYLON.Scene to append to
  47500. * @param onProgress a callback with a progress event for each file being loaded
  47501. * @param pluginExtension the extension used to determine the plugin
  47502. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  47503. */
  47504. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  47505. meshes: AbstractMesh[];
  47506. particleSystems: IParticleSystem[];
  47507. skeletons: Skeleton[];
  47508. animationGroups: AnimationGroup[];
  47509. }>;
  47510. /**
  47511. * Load a scene
  47512. * @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)
  47513. * @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)
  47514. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47515. * @param onSuccess a callback with the scene when import succeeds
  47516. * @param onProgress a callback with a progress event for each file being loaded
  47517. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47518. * @param pluginExtension the extension used to determine the plugin
  47519. * @returns The loaded plugin
  47520. */
  47521. 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>;
  47522. /**
  47523. * Load a scene
  47524. * @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)
  47525. * @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)
  47526. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47527. * @param onProgress a callback with a progress event for each file being loaded
  47528. * @param pluginExtension the extension used to determine the plugin
  47529. * @returns The loaded scene
  47530. */
  47531. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47532. /**
  47533. * Append a scene
  47534. * @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)
  47535. * @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)
  47536. * @param scene is the instance of BABYLON.Scene to append to
  47537. * @param onSuccess a callback with the scene when import succeeds
  47538. * @param onProgress a callback with a progress event for each file being loaded
  47539. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47540. * @param pluginExtension the extension used to determine the plugin
  47541. * @returns The loaded plugin
  47542. */
  47543. 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>;
  47544. /**
  47545. * Append a scene
  47546. * @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)
  47547. * @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)
  47548. * @param scene is the instance of BABYLON.Scene to append to
  47549. * @param onProgress a callback with a progress event for each file being loaded
  47550. * @param pluginExtension the extension used to determine the plugin
  47551. * @returns The given scene
  47552. */
  47553. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47554. /**
  47555. * Load a scene into an asset container
  47556. * @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)
  47557. * @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)
  47558. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47559. * @param onSuccess a callback with the scene when import succeeds
  47560. * @param onProgress a callback with a progress event for each file being loaded
  47561. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47562. * @param pluginExtension the extension used to determine the plugin
  47563. * @returns The loaded plugin
  47564. */
  47565. 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>;
  47566. /**
  47567. * Load a scene into an asset container
  47568. * @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)
  47569. * @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)
  47570. * @param scene is the instance of Scene to append to
  47571. * @param onProgress a callback with a progress event for each file being loaded
  47572. * @param pluginExtension the extension used to determine the plugin
  47573. * @returns The loaded asset container
  47574. */
  47575. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  47576. /**
  47577. * Import animations from a file into a scene
  47578. * @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)
  47579. * @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)
  47580. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47581. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47582. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47583. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47584. * @param onSuccess a callback with the scene when import succeeds
  47585. * @param onProgress a callback with a progress event for each file being loaded
  47586. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47587. * @param pluginExtension the extension used to determine the plugin
  47588. */
  47589. 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;
  47590. /**
  47591. * Import animations from a file into a scene
  47592. * @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)
  47593. * @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)
  47594. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47595. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47596. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47597. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47598. * @param onSuccess a callback with the scene when import succeeds
  47599. * @param onProgress a callback with a progress event for each file being loaded
  47600. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47601. * @param pluginExtension the extension used to determine the plugin
  47602. * @returns the updated scene with imported animations
  47603. */
  47604. 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>;
  47605. }
  47606. }
  47607. declare module BABYLON {
  47608. /**
  47609. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  47610. */
  47611. export type MotionControllerHandedness = "none" | "left" | "right";
  47612. /**
  47613. * The type of components available in motion controllers.
  47614. * This is not the name of the component.
  47615. */
  47616. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  47617. /**
  47618. * The state of a controller component
  47619. */
  47620. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  47621. /**
  47622. * The schema of motion controller layout.
  47623. * No object will be initialized using this interface
  47624. * This is used just to define the profile.
  47625. */
  47626. export interface IMotionControllerLayout {
  47627. /**
  47628. * Path to load the assets. Usually relative to the base path
  47629. */
  47630. assetPath: string;
  47631. /**
  47632. * Available components (unsorted)
  47633. */
  47634. components: {
  47635. /**
  47636. * A map of component Ids
  47637. */
  47638. [componentId: string]: {
  47639. /**
  47640. * The type of input the component outputs
  47641. */
  47642. type: MotionControllerComponentType;
  47643. /**
  47644. * The indices of this component in the gamepad object
  47645. */
  47646. gamepadIndices: {
  47647. /**
  47648. * Index of button
  47649. */
  47650. button?: number;
  47651. /**
  47652. * If available, index of x-axis
  47653. */
  47654. xAxis?: number;
  47655. /**
  47656. * If available, index of y-axis
  47657. */
  47658. yAxis?: number;
  47659. };
  47660. /**
  47661. * The mesh's root node name
  47662. */
  47663. rootNodeName: string;
  47664. /**
  47665. * Animation definitions for this model
  47666. */
  47667. visualResponses: {
  47668. [stateKey: string]: {
  47669. /**
  47670. * What property will be animated
  47671. */
  47672. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  47673. /**
  47674. * What states influence this visual response
  47675. */
  47676. states: MotionControllerComponentStateType[];
  47677. /**
  47678. * Type of animation - movement or visibility
  47679. */
  47680. valueNodeProperty: "transform" | "visibility";
  47681. /**
  47682. * Base node name to move. Its position will be calculated according to the min and max nodes
  47683. */
  47684. valueNodeName?: string;
  47685. /**
  47686. * Minimum movement node
  47687. */
  47688. minNodeName?: string;
  47689. /**
  47690. * Max movement node
  47691. */
  47692. maxNodeName?: string;
  47693. };
  47694. };
  47695. /**
  47696. * If touch enabled, what is the name of node to display user feedback
  47697. */
  47698. touchPointNodeName?: string;
  47699. };
  47700. };
  47701. /**
  47702. * Is it xr standard mapping or not
  47703. */
  47704. gamepadMapping: "" | "xr-standard";
  47705. /**
  47706. * Base root node of this entire model
  47707. */
  47708. rootNodeName: string;
  47709. /**
  47710. * Defines the main button component id
  47711. */
  47712. selectComponentId: string;
  47713. }
  47714. /**
  47715. * A definition for the layout map in the input profile
  47716. */
  47717. export interface IMotionControllerLayoutMap {
  47718. /**
  47719. * Layouts with handedness type as a key
  47720. */
  47721. [handedness: string]: IMotionControllerLayout;
  47722. }
  47723. /**
  47724. * The XR Input profile schema
  47725. * Profiles can be found here:
  47726. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  47727. */
  47728. export interface IMotionControllerProfile {
  47729. /**
  47730. * fallback profiles for this profileId
  47731. */
  47732. fallbackProfileIds: string[];
  47733. /**
  47734. * The layout map, with handedness as key
  47735. */
  47736. layouts: IMotionControllerLayoutMap;
  47737. /**
  47738. * The id of this profile
  47739. * correlates to the profile(s) in the xrInput.profiles array
  47740. */
  47741. profileId: string;
  47742. }
  47743. /**
  47744. * A helper-interface for the 3 meshes needed for controller button animation
  47745. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  47746. */
  47747. export interface IMotionControllerButtonMeshMap {
  47748. /**
  47749. * the mesh that defines the pressed value mesh position.
  47750. * This is used to find the max-position of this button
  47751. */
  47752. pressedMesh: AbstractMesh;
  47753. /**
  47754. * the mesh that defines the unpressed value mesh position.
  47755. * This is used to find the min (or initial) position of this button
  47756. */
  47757. unpressedMesh: AbstractMesh;
  47758. /**
  47759. * The mesh that will be changed when value changes
  47760. */
  47761. valueMesh: AbstractMesh;
  47762. }
  47763. /**
  47764. * A helper-interface for the 3 meshes needed for controller axis animation.
  47765. * This will be expanded when touchpad animations are fully supported
  47766. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  47767. */
  47768. export interface IMotionControllerMeshMap {
  47769. /**
  47770. * the mesh that defines the maximum value mesh position.
  47771. */
  47772. maxMesh?: AbstractMesh;
  47773. /**
  47774. * the mesh that defines the minimum value mesh position.
  47775. */
  47776. minMesh?: AbstractMesh;
  47777. /**
  47778. * The mesh that will be changed when axis value changes
  47779. */
  47780. valueMesh: AbstractMesh;
  47781. }
  47782. /**
  47783. * The elements needed for change-detection of the gamepad objects in motion controllers
  47784. */
  47785. export interface IMinimalMotionControllerObject {
  47786. /**
  47787. * Available axes of this controller
  47788. */
  47789. axes: number[];
  47790. /**
  47791. * An array of available buttons
  47792. */
  47793. buttons: Array<{
  47794. /**
  47795. * Value of the button/trigger
  47796. */
  47797. value: number;
  47798. /**
  47799. * If the button/trigger is currently touched
  47800. */
  47801. touched: boolean;
  47802. /**
  47803. * If the button/trigger is currently pressed
  47804. */
  47805. pressed: boolean;
  47806. }>;
  47807. /**
  47808. * EXPERIMENTAL haptic support.
  47809. */
  47810. hapticActuators?: Array<{
  47811. pulse: (value: number, duration: number) => Promise<boolean>;
  47812. }>;
  47813. }
  47814. /**
  47815. * An Abstract Motion controller
  47816. * This class receives an xrInput and a profile layout and uses those to initialize the components
  47817. * Each component has an observable to check for changes in value and state
  47818. */
  47819. export abstract class WebXRAbstractMotionController implements IDisposable {
  47820. protected scene: Scene;
  47821. protected layout: IMotionControllerLayout;
  47822. /**
  47823. * The gamepad object correlating to this controller
  47824. */
  47825. gamepadObject: IMinimalMotionControllerObject;
  47826. /**
  47827. * handedness (left/right/none) of this controller
  47828. */
  47829. handedness: MotionControllerHandedness;
  47830. private _initComponent;
  47831. private _modelReady;
  47832. /**
  47833. * A map of components (WebXRControllerComponent) in this motion controller
  47834. * Components have a ComponentType and can also have both button and axis definitions
  47835. */
  47836. readonly components: {
  47837. [id: string]: WebXRControllerComponent;
  47838. };
  47839. /**
  47840. * Disable the model's animation. Can be set at any time.
  47841. */
  47842. disableAnimation: boolean;
  47843. /**
  47844. * Observers registered here will be triggered when the model of this controller is done loading
  47845. */
  47846. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  47847. /**
  47848. * The profile id of this motion controller
  47849. */
  47850. abstract profileId: string;
  47851. /**
  47852. * The root mesh of the model. It is null if the model was not yet initialized
  47853. */
  47854. rootMesh: Nullable<AbstractMesh>;
  47855. /**
  47856. * constructs a new abstract motion controller
  47857. * @param scene the scene to which the model of the controller will be added
  47858. * @param layout The profile layout to load
  47859. * @param gamepadObject The gamepad object correlating to this controller
  47860. * @param handedness handedness (left/right/none) of this controller
  47861. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  47862. */
  47863. constructor(scene: Scene, layout: IMotionControllerLayout,
  47864. /**
  47865. * The gamepad object correlating to this controller
  47866. */
  47867. gamepadObject: IMinimalMotionControllerObject,
  47868. /**
  47869. * handedness (left/right/none) of this controller
  47870. */
  47871. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  47872. /**
  47873. * Dispose this controller, the model mesh and all its components
  47874. */
  47875. dispose(): void;
  47876. /**
  47877. * Returns all components of specific type
  47878. * @param type the type to search for
  47879. * @return an array of components with this type
  47880. */
  47881. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  47882. /**
  47883. * get a component based an its component id as defined in layout.components
  47884. * @param id the id of the component
  47885. * @returns the component correlates to the id or undefined if not found
  47886. */
  47887. getComponent(id: string): WebXRControllerComponent;
  47888. /**
  47889. * Get the list of components available in this motion controller
  47890. * @returns an array of strings correlating to available components
  47891. */
  47892. getComponentIds(): string[];
  47893. /**
  47894. * Get the first component of specific type
  47895. * @param type type of component to find
  47896. * @return a controller component or null if not found
  47897. */
  47898. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  47899. /**
  47900. * Get the main (Select) component of this controller as defined in the layout
  47901. * @returns the main component of this controller
  47902. */
  47903. getMainComponent(): WebXRControllerComponent;
  47904. /**
  47905. * Loads the model correlating to this controller
  47906. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  47907. * @returns A promise fulfilled with the result of the model loading
  47908. */
  47909. loadModel(): Promise<boolean>;
  47910. /**
  47911. * Update this model using the current XRFrame
  47912. * @param xrFrame the current xr frame to use and update the model
  47913. */
  47914. updateFromXRFrame(xrFrame: XRFrame): void;
  47915. /**
  47916. * Backwards compatibility due to a deeply-integrated typo
  47917. */
  47918. get handness(): XREye;
  47919. /**
  47920. * Pulse (vibrate) this controller
  47921. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  47922. * Consecutive calls to this function will cancel the last pulse call
  47923. *
  47924. * @param value the strength of the pulse in 0.0...1.0 range
  47925. * @param duration Duration of the pulse in milliseconds
  47926. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  47927. * @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
  47928. */
  47929. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  47930. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  47931. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  47932. /**
  47933. * Moves the axis on the controller mesh based on its current state
  47934. * @param axis the index of the axis
  47935. * @param axisValue the value of the axis which determines the meshes new position
  47936. * @hidden
  47937. */
  47938. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  47939. /**
  47940. * Update the model itself with the current frame data
  47941. * @param xrFrame the frame to use for updating the model mesh
  47942. */
  47943. protected updateModel(xrFrame: XRFrame): void;
  47944. /**
  47945. * Get the filename and path for this controller's model
  47946. * @returns a map of filename and path
  47947. */
  47948. protected abstract _getFilenameAndPath(): {
  47949. filename: string;
  47950. path: string;
  47951. };
  47952. /**
  47953. * This function is called before the mesh is loaded. It checks for loading constraints.
  47954. * For example, this function can check if the GLB loader is available
  47955. * If this function returns false, the generic controller will be loaded instead
  47956. * @returns Is the client ready to load the mesh
  47957. */
  47958. protected abstract _getModelLoadingConstraints(): boolean;
  47959. /**
  47960. * This function will be called after the model was successfully loaded and can be used
  47961. * for mesh transformations before it is available for the user
  47962. * @param meshes the loaded meshes
  47963. */
  47964. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  47965. /**
  47966. * Set the root mesh for this controller. Important for the WebXR controller class
  47967. * @param meshes the loaded meshes
  47968. */
  47969. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  47970. /**
  47971. * A function executed each frame that updates the mesh (if needed)
  47972. * @param xrFrame the current xrFrame
  47973. */
  47974. protected abstract _updateModel(xrFrame: XRFrame): void;
  47975. private _getGenericFilenameAndPath;
  47976. private _getGenericParentMesh;
  47977. }
  47978. }
  47979. declare module BABYLON {
  47980. /**
  47981. * A generic trigger-only motion controller for WebXR
  47982. */
  47983. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  47984. /**
  47985. * Static version of the profile id of this controller
  47986. */
  47987. static ProfileId: string;
  47988. profileId: string;
  47989. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  47990. protected _getFilenameAndPath(): {
  47991. filename: string;
  47992. path: string;
  47993. };
  47994. protected _getModelLoadingConstraints(): boolean;
  47995. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  47996. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47997. protected _updateModel(): void;
  47998. }
  47999. }
  48000. declare module BABYLON {
  48001. /**
  48002. * Class containing static functions to help procedurally build meshes
  48003. */
  48004. export class SphereBuilder {
  48005. /**
  48006. * Creates a sphere mesh
  48007. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  48008. * * 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`)
  48009. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  48010. * * 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
  48011. * * 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)
  48012. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48013. * * 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
  48014. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48015. * @param name defines the name of the mesh
  48016. * @param options defines the options used to create the mesh
  48017. * @param scene defines the hosting scene
  48018. * @returns the sphere mesh
  48019. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  48020. */
  48021. static CreateSphere(name: string, options: {
  48022. segments?: number;
  48023. diameter?: number;
  48024. diameterX?: number;
  48025. diameterY?: number;
  48026. diameterZ?: number;
  48027. arc?: number;
  48028. slice?: number;
  48029. sideOrientation?: number;
  48030. frontUVs?: Vector4;
  48031. backUVs?: Vector4;
  48032. updatable?: boolean;
  48033. }, scene?: Nullable<Scene>): Mesh;
  48034. }
  48035. }
  48036. declare module BABYLON {
  48037. /**
  48038. * A profiled motion controller has its profile loaded from an online repository.
  48039. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  48040. */
  48041. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  48042. private _repositoryUrl;
  48043. private _buttonMeshMapping;
  48044. private _touchDots;
  48045. /**
  48046. * The profile ID of this controller. Will be populated when the controller initializes.
  48047. */
  48048. profileId: string;
  48049. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  48050. dispose(): void;
  48051. protected _getFilenameAndPath(): {
  48052. filename: string;
  48053. path: string;
  48054. };
  48055. protected _getModelLoadingConstraints(): boolean;
  48056. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  48057. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48058. protected _updateModel(_xrFrame: XRFrame): void;
  48059. }
  48060. }
  48061. declare module BABYLON {
  48062. /**
  48063. * A construction function type to create a new controller based on an xrInput object
  48064. */
  48065. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  48066. /**
  48067. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  48068. *
  48069. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  48070. * it should be replaced with auto-loaded controllers.
  48071. *
  48072. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  48073. */
  48074. export class WebXRMotionControllerManager {
  48075. private static _AvailableControllers;
  48076. private static _Fallbacks;
  48077. private static _ProfileLoadingPromises;
  48078. private static _ProfilesList;
  48079. /**
  48080. * The base URL of the online controller repository. Can be changed at any time.
  48081. */
  48082. static BaseRepositoryUrl: string;
  48083. /**
  48084. * Which repository gets priority - local or online
  48085. */
  48086. static PrioritizeOnlineRepository: boolean;
  48087. /**
  48088. * Use the online repository, or use only locally-defined controllers
  48089. */
  48090. static UseOnlineRepository: boolean;
  48091. /**
  48092. * Clear the cache used for profile loading and reload when requested again
  48093. */
  48094. static ClearProfilesCache(): void;
  48095. /**
  48096. * Register the default fallbacks.
  48097. * This function is called automatically when this file is imported.
  48098. */
  48099. static DefaultFallbacks(): void;
  48100. /**
  48101. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  48102. * @param profileId the profile to which a fallback needs to be found
  48103. * @return an array with corresponding fallback profiles
  48104. */
  48105. static FindFallbackWithProfileId(profileId: string): string[];
  48106. /**
  48107. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  48108. * The order of search:
  48109. *
  48110. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  48111. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  48112. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  48113. * 4) return the generic trigger controller if none were found
  48114. *
  48115. * @param xrInput the xrInput to which a new controller is initialized
  48116. * @param scene the scene to which the model will be added
  48117. * @param forceProfile force a certain profile for this controller
  48118. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  48119. */
  48120. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  48121. /**
  48122. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  48123. *
  48124. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  48125. *
  48126. * @param type the profile type to register
  48127. * @param constructFunction the function to be called when loading this profile
  48128. */
  48129. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  48130. /**
  48131. * Register a fallback to a specific profile.
  48132. * @param profileId the profileId that will receive the fallbacks
  48133. * @param fallbacks A list of fallback profiles
  48134. */
  48135. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  48136. /**
  48137. * Will update the list of profiles available in the repository
  48138. * @return a promise that resolves to a map of profiles available online
  48139. */
  48140. static UpdateProfilesList(): Promise<{
  48141. [profile: string]: string;
  48142. }>;
  48143. private static _LoadProfileFromRepository;
  48144. private static _LoadProfilesFromAvailableControllers;
  48145. }
  48146. }
  48147. declare module BABYLON {
  48148. /**
  48149. * Configuration options for the WebXR controller creation
  48150. */
  48151. export interface IWebXRControllerOptions {
  48152. /**
  48153. * Should the controller mesh be animated when a user interacts with it
  48154. * The pressed buttons / thumbstick and touchpad animations will be disabled
  48155. */
  48156. disableMotionControllerAnimation?: boolean;
  48157. /**
  48158. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  48159. */
  48160. doNotLoadControllerMesh?: boolean;
  48161. /**
  48162. * Force a specific controller type for this controller.
  48163. * This can be used when creating your own profile or when testing different controllers
  48164. */
  48165. forceControllerProfile?: string;
  48166. /**
  48167. * Defines a rendering group ID for meshes that will be loaded.
  48168. * This is for the default controllers only.
  48169. */
  48170. renderingGroupId?: number;
  48171. }
  48172. /**
  48173. * Represents an XR controller
  48174. */
  48175. export class WebXRInputSource {
  48176. private _scene;
  48177. /** The underlying input source for the controller */
  48178. inputSource: XRInputSource;
  48179. private _options;
  48180. private _tmpVector;
  48181. private _uniqueId;
  48182. /**
  48183. * 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
  48184. */
  48185. grip?: AbstractMesh;
  48186. /**
  48187. * If available, this is the gamepad object related to this controller.
  48188. * Using this object it is possible to get click events and trackpad changes of the
  48189. * webxr controller that is currently being used.
  48190. */
  48191. motionController?: WebXRAbstractMotionController;
  48192. /**
  48193. * Event that fires when the controller is removed/disposed.
  48194. * The object provided as event data is this controller, after associated assets were disposed.
  48195. * uniqueId is still available.
  48196. */
  48197. onDisposeObservable: Observable<WebXRInputSource>;
  48198. /**
  48199. * Will be triggered when the mesh associated with the motion controller is done loading.
  48200. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  48201. * A shortened version of controller -> motion controller -> on mesh loaded.
  48202. */
  48203. onMeshLoadedObservable: Observable<AbstractMesh>;
  48204. /**
  48205. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  48206. */
  48207. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  48208. /**
  48209. * Pointer which can be used to select objects or attach a visible laser to
  48210. */
  48211. pointer: AbstractMesh;
  48212. /**
  48213. * Creates the input source object
  48214. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  48215. * @param _scene the scene which the controller should be associated to
  48216. * @param inputSource the underlying input source for the controller
  48217. * @param _options options for this controller creation
  48218. */
  48219. constructor(_scene: Scene,
  48220. /** The underlying input source for the controller */
  48221. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  48222. /**
  48223. * Get this controllers unique id
  48224. */
  48225. get uniqueId(): string;
  48226. /**
  48227. * Disposes of the object
  48228. */
  48229. dispose(): void;
  48230. /**
  48231. * Gets a world space ray coming from the pointer or grip
  48232. * @param result the resulting ray
  48233. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  48234. */
  48235. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  48236. /**
  48237. * Updates the controller pose based on the given XRFrame
  48238. * @param xrFrame xr frame to update the pose with
  48239. * @param referenceSpace reference space to use
  48240. */
  48241. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  48242. }
  48243. }
  48244. declare module BABYLON {
  48245. /**
  48246. * The schema for initialization options of the XR Input class
  48247. */
  48248. export interface IWebXRInputOptions {
  48249. /**
  48250. * If set to true no model will be automatically loaded
  48251. */
  48252. doNotLoadControllerMeshes?: boolean;
  48253. /**
  48254. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  48255. * If not found, the xr input profile data will be used.
  48256. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  48257. */
  48258. forceInputProfile?: string;
  48259. /**
  48260. * Do not send a request to the controller repository to load the profile.
  48261. *
  48262. * Instead, use the controllers available in babylon itself.
  48263. */
  48264. disableOnlineControllerRepository?: boolean;
  48265. /**
  48266. * A custom URL for the controllers repository
  48267. */
  48268. customControllersRepositoryURL?: string;
  48269. /**
  48270. * Should the controller model's components not move according to the user input
  48271. */
  48272. disableControllerAnimation?: boolean;
  48273. /**
  48274. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  48275. */
  48276. controllerOptions?: IWebXRControllerOptions;
  48277. }
  48278. /**
  48279. * XR input used to track XR inputs such as controllers/rays
  48280. */
  48281. export class WebXRInput implements IDisposable {
  48282. /**
  48283. * the xr session manager for this session
  48284. */
  48285. xrSessionManager: WebXRSessionManager;
  48286. /**
  48287. * the WebXR camera for this session. Mainly used for teleportation
  48288. */
  48289. xrCamera: WebXRCamera;
  48290. private readonly options;
  48291. /**
  48292. * XR controllers being tracked
  48293. */
  48294. controllers: Array<WebXRInputSource>;
  48295. private _frameObserver;
  48296. private _sessionEndedObserver;
  48297. private _sessionInitObserver;
  48298. /**
  48299. * Event when a controller has been connected/added
  48300. */
  48301. onControllerAddedObservable: Observable<WebXRInputSource>;
  48302. /**
  48303. * Event when a controller has been removed/disconnected
  48304. */
  48305. onControllerRemovedObservable: Observable<WebXRInputSource>;
  48306. /**
  48307. * Initializes the WebXRInput
  48308. * @param xrSessionManager the xr session manager for this session
  48309. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  48310. * @param options = initialization options for this xr input
  48311. */
  48312. constructor(
  48313. /**
  48314. * the xr session manager for this session
  48315. */
  48316. xrSessionManager: WebXRSessionManager,
  48317. /**
  48318. * the WebXR camera for this session. Mainly used for teleportation
  48319. */
  48320. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  48321. private _onInputSourcesChange;
  48322. private _addAndRemoveControllers;
  48323. /**
  48324. * Disposes of the object
  48325. */
  48326. dispose(): void;
  48327. }
  48328. }
  48329. declare module BABYLON {
  48330. /**
  48331. * This is the base class for all WebXR features.
  48332. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  48333. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  48334. */
  48335. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  48336. protected _xrSessionManager: WebXRSessionManager;
  48337. private _attached;
  48338. private _removeOnDetach;
  48339. /**
  48340. * Should auto-attach be disabled?
  48341. */
  48342. disableAutoAttach: boolean;
  48343. /**
  48344. * Construct a new (abstract) WebXR feature
  48345. * @param _xrSessionManager the xr session manager for this feature
  48346. */
  48347. constructor(_xrSessionManager: WebXRSessionManager);
  48348. /**
  48349. * Is this feature attached
  48350. */
  48351. get attached(): boolean;
  48352. /**
  48353. * attach this feature
  48354. *
  48355. * @param force should attachment be forced (even when already attached)
  48356. * @returns true if successful, false is failed or already attached
  48357. */
  48358. attach(force?: boolean): boolean;
  48359. /**
  48360. * detach this feature.
  48361. *
  48362. * @returns true if successful, false if failed or already detached
  48363. */
  48364. detach(): boolean;
  48365. /**
  48366. * Dispose this feature and all of the resources attached
  48367. */
  48368. dispose(): void;
  48369. /**
  48370. * This is used to register callbacks that will automatically be removed when detach is called.
  48371. * @param observable the observable to which the observer will be attached
  48372. * @param callback the callback to register
  48373. */
  48374. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  48375. /**
  48376. * Code in this function will be executed on each xrFrame received from the browser.
  48377. * This function will not execute after the feature is detached.
  48378. * @param _xrFrame the current frame
  48379. */
  48380. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  48381. }
  48382. }
  48383. declare module BABYLON {
  48384. /**
  48385. * Renders a layer on top of an existing scene
  48386. */
  48387. export class UtilityLayerRenderer implements IDisposable {
  48388. /** the original scene that will be rendered on top of */
  48389. originalScene: Scene;
  48390. private _pointerCaptures;
  48391. private _lastPointerEvents;
  48392. private static _DefaultUtilityLayer;
  48393. private static _DefaultKeepDepthUtilityLayer;
  48394. private _sharedGizmoLight;
  48395. private _renderCamera;
  48396. /**
  48397. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  48398. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  48399. * @returns the camera that is used when rendering the utility layer
  48400. */
  48401. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  48402. /**
  48403. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  48404. * @param cam the camera that should be used when rendering the utility layer
  48405. */
  48406. setRenderCamera(cam: Nullable<Camera>): void;
  48407. /**
  48408. * @hidden
  48409. * Light which used by gizmos to get light shading
  48410. */
  48411. _getSharedGizmoLight(): HemisphericLight;
  48412. /**
  48413. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  48414. */
  48415. pickUtilitySceneFirst: boolean;
  48416. /**
  48417. * 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)
  48418. */
  48419. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  48420. /**
  48421. * 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)
  48422. */
  48423. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  48424. /**
  48425. * The scene that is rendered on top of the original scene
  48426. */
  48427. utilityLayerScene: Scene;
  48428. /**
  48429. * If the utility layer should automatically be rendered on top of existing scene
  48430. */
  48431. shouldRender: boolean;
  48432. /**
  48433. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  48434. */
  48435. onlyCheckPointerDownEvents: boolean;
  48436. /**
  48437. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  48438. */
  48439. processAllEvents: boolean;
  48440. /**
  48441. * Observable raised when the pointer move from the utility layer scene to the main scene
  48442. */
  48443. onPointerOutObservable: Observable<number>;
  48444. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  48445. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  48446. private _afterRenderObserver;
  48447. private _sceneDisposeObserver;
  48448. private _originalPointerObserver;
  48449. /**
  48450. * Instantiates a UtilityLayerRenderer
  48451. * @param originalScene the original scene that will be rendered on top of
  48452. * @param handleEvents boolean indicating if the utility layer should handle events
  48453. */
  48454. constructor(
  48455. /** the original scene that will be rendered on top of */
  48456. originalScene: Scene, handleEvents?: boolean);
  48457. private _notifyObservers;
  48458. /**
  48459. * Renders the utility layers scene on top of the original scene
  48460. */
  48461. render(): void;
  48462. /**
  48463. * Disposes of the renderer
  48464. */
  48465. dispose(): void;
  48466. private _updateCamera;
  48467. }
  48468. }
  48469. declare module BABYLON {
  48470. /**
  48471. * Options interface for the pointer selection module
  48472. */
  48473. export interface IWebXRControllerPointerSelectionOptions {
  48474. /**
  48475. * if provided, this scene will be used to render meshes.
  48476. */
  48477. customUtilityLayerScene?: Scene;
  48478. /**
  48479. * 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)
  48480. * If not disabled, the last picked point will be used to execute a pointer up event
  48481. * If disabled, pointer up event will be triggered right after the pointer down event.
  48482. * Used in screen and gaze target ray mode only
  48483. */
  48484. disablePointerUpOnTouchOut: boolean;
  48485. /**
  48486. * For gaze mode (time to select instead of press)
  48487. */
  48488. forceGazeMode: boolean;
  48489. /**
  48490. * 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
  48491. * to start a new countdown to the pointer down event.
  48492. * Defaults to 1.
  48493. */
  48494. gazeModePointerMovedFactor?: number;
  48495. /**
  48496. * Different button type to use instead of the main component
  48497. */
  48498. overrideButtonId?: string;
  48499. /**
  48500. * use this rendering group id for the meshes (optional)
  48501. */
  48502. renderingGroupId?: number;
  48503. /**
  48504. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  48505. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  48506. * 3000 means 3 seconds between pointing at something and selecting it
  48507. */
  48508. timeToSelect?: number;
  48509. /**
  48510. * Should meshes created here be added to a utility layer or the main scene
  48511. */
  48512. useUtilityLayer?: boolean;
  48513. /**
  48514. * the xr input to use with this pointer selection
  48515. */
  48516. xrInput: WebXRInput;
  48517. }
  48518. /**
  48519. * A module that will enable pointer selection for motion controllers of XR Input Sources
  48520. */
  48521. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  48522. private readonly _options;
  48523. private static _idCounter;
  48524. private _attachController;
  48525. private _controllers;
  48526. private _scene;
  48527. private _tmpVectorForPickCompare;
  48528. /**
  48529. * The module's name
  48530. */
  48531. static readonly Name: string;
  48532. /**
  48533. * The (Babylon) version of this module.
  48534. * This is an integer representing the implementation version.
  48535. * This number does not correspond to the WebXR specs version
  48536. */
  48537. static readonly Version: number;
  48538. /**
  48539. * Disable lighting on the laser pointer (so it will always be visible)
  48540. */
  48541. disablePointerLighting: boolean;
  48542. /**
  48543. * Disable lighting on the selection mesh (so it will always be visible)
  48544. */
  48545. disableSelectionMeshLighting: boolean;
  48546. /**
  48547. * Should the laser pointer be displayed
  48548. */
  48549. displayLaserPointer: boolean;
  48550. /**
  48551. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  48552. */
  48553. displaySelectionMesh: boolean;
  48554. /**
  48555. * This color will be set to the laser pointer when selection is triggered
  48556. */
  48557. laserPointerPickedColor: Color3;
  48558. /**
  48559. * Default color of the laser pointer
  48560. */
  48561. laserPointerDefaultColor: Color3;
  48562. /**
  48563. * default color of the selection ring
  48564. */
  48565. selectionMeshDefaultColor: Color3;
  48566. /**
  48567. * This color will be applied to the selection ring when selection is triggered
  48568. */
  48569. selectionMeshPickedColor: Color3;
  48570. /**
  48571. * Optional filter to be used for ray selection. This predicate shares behavior with
  48572. * scene.pointerMovePredicate which takes priority if it is also assigned.
  48573. */
  48574. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48575. /**
  48576. * constructs a new background remover module
  48577. * @param _xrSessionManager the session manager for this module
  48578. * @param _options read-only options to be used in this module
  48579. */
  48580. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  48581. /**
  48582. * attach this feature
  48583. * Will usually be called by the features manager
  48584. *
  48585. * @returns true if successful.
  48586. */
  48587. attach(): boolean;
  48588. /**
  48589. * detach this feature.
  48590. * Will usually be called by the features manager
  48591. *
  48592. * @returns true if successful.
  48593. */
  48594. detach(): boolean;
  48595. /**
  48596. * Will get the mesh under a specific pointer.
  48597. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  48598. * @param controllerId the controllerId to check
  48599. * @returns The mesh under pointer or null if no mesh is under the pointer
  48600. */
  48601. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  48602. /**
  48603. * Get the xr controller that correlates to the pointer id in the pointer event
  48604. *
  48605. * @param id the pointer id to search for
  48606. * @returns the controller that correlates to this id or null if not found
  48607. */
  48608. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  48609. protected _onXRFrame(_xrFrame: XRFrame): void;
  48610. private _attachGazeMode;
  48611. private _attachScreenRayMode;
  48612. private _attachTrackedPointerRayMode;
  48613. private _convertNormalToDirectionOfRay;
  48614. private _detachController;
  48615. private _generateNewMeshPair;
  48616. private _pickingMoved;
  48617. private _updatePointerDistance;
  48618. /** @hidden */
  48619. get lasterPointerDefaultColor(): Color3;
  48620. }
  48621. }
  48622. declare module BABYLON {
  48623. /**
  48624. * Button which can be used to enter a different mode of XR
  48625. */
  48626. export class WebXREnterExitUIButton {
  48627. /** button element */
  48628. element: HTMLElement;
  48629. /** XR initialization options for the button */
  48630. sessionMode: XRSessionMode;
  48631. /** Reference space type */
  48632. referenceSpaceType: XRReferenceSpaceType;
  48633. /**
  48634. * Creates a WebXREnterExitUIButton
  48635. * @param element button element
  48636. * @param sessionMode XR initialization session mode
  48637. * @param referenceSpaceType the type of reference space to be used
  48638. */
  48639. constructor(
  48640. /** button element */
  48641. element: HTMLElement,
  48642. /** XR initialization options for the button */
  48643. sessionMode: XRSessionMode,
  48644. /** Reference space type */
  48645. referenceSpaceType: XRReferenceSpaceType);
  48646. /**
  48647. * Extendable function which can be used to update the button's visuals when the state changes
  48648. * @param activeButton the current active button in the UI
  48649. */
  48650. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  48651. }
  48652. /**
  48653. * Options to create the webXR UI
  48654. */
  48655. export class WebXREnterExitUIOptions {
  48656. /**
  48657. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  48658. */
  48659. customButtons?: Array<WebXREnterExitUIButton>;
  48660. /**
  48661. * A reference space type to use when creating the default button.
  48662. * Default is local-floor
  48663. */
  48664. referenceSpaceType?: XRReferenceSpaceType;
  48665. /**
  48666. * Context to enter xr with
  48667. */
  48668. renderTarget?: Nullable<WebXRRenderTarget>;
  48669. /**
  48670. * A session mode to use when creating the default button.
  48671. * Default is immersive-vr
  48672. */
  48673. sessionMode?: XRSessionMode;
  48674. /**
  48675. * A list of optional features to init the session with
  48676. */
  48677. optionalFeatures?: string[];
  48678. /**
  48679. * A list of optional features to init the session with
  48680. */
  48681. requiredFeatures?: string[];
  48682. }
  48683. /**
  48684. * UI to allow the user to enter/exit XR mode
  48685. */
  48686. export class WebXREnterExitUI implements IDisposable {
  48687. private scene;
  48688. /** version of the options passed to this UI */
  48689. options: WebXREnterExitUIOptions;
  48690. private _activeButton;
  48691. private _buttons;
  48692. private _overlay;
  48693. /**
  48694. * Fired every time the active button is changed.
  48695. *
  48696. * When xr is entered via a button that launches xr that button will be the callback parameter
  48697. *
  48698. * When exiting xr the callback parameter will be null)
  48699. */
  48700. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  48701. /**
  48702. *
  48703. * @param scene babylon scene object to use
  48704. * @param options (read-only) version of the options passed to this UI
  48705. */
  48706. private constructor();
  48707. /**
  48708. * Creates UI to allow the user to enter/exit XR mode
  48709. * @param scene the scene to add the ui to
  48710. * @param helper the xr experience helper to enter/exit xr with
  48711. * @param options options to configure the UI
  48712. * @returns the created ui
  48713. */
  48714. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  48715. /**
  48716. * Disposes of the XR UI component
  48717. */
  48718. dispose(): void;
  48719. private _updateButtons;
  48720. }
  48721. }
  48722. declare module BABYLON {
  48723. /**
  48724. * Class containing static functions to help procedurally build meshes
  48725. */
  48726. export class LinesBuilder {
  48727. /**
  48728. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  48729. * * 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
  48730. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  48731. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  48732. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  48733. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  48734. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  48735. * * 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
  48736. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  48737. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48738. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  48739. * @param name defines the name of the new line system
  48740. * @param options defines the options used to create the line system
  48741. * @param scene defines the hosting scene
  48742. * @returns a new line system mesh
  48743. */
  48744. static CreateLineSystem(name: string, options: {
  48745. lines: Vector3[][];
  48746. updatable?: boolean;
  48747. instance?: Nullable<LinesMesh>;
  48748. colors?: Nullable<Color4[][]>;
  48749. useVertexAlpha?: boolean;
  48750. }, scene: Nullable<Scene>): LinesMesh;
  48751. /**
  48752. * Creates a line mesh
  48753. * 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
  48754. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48755. * * The parameter `points` is an array successive Vector3
  48756. * * 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
  48757. * * The optional parameter `colors` is an array of successive Color4, one per line point
  48758. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  48759. * * When updating an instance, remember that only point positions can change, not the number of points
  48760. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48761. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  48762. * @param name defines the name of the new line system
  48763. * @param options defines the options used to create the line system
  48764. * @param scene defines the hosting scene
  48765. * @returns a new line mesh
  48766. */
  48767. static CreateLines(name: string, options: {
  48768. points: Vector3[];
  48769. updatable?: boolean;
  48770. instance?: Nullable<LinesMesh>;
  48771. colors?: Color4[];
  48772. useVertexAlpha?: boolean;
  48773. }, scene?: Nullable<Scene>): LinesMesh;
  48774. /**
  48775. * Creates a dashed line mesh
  48776. * * 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
  48777. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48778. * * The parameter `points` is an array successive Vector3
  48779. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  48780. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  48781. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  48782. * * 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
  48783. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  48784. * * When updating an instance, remember that only point positions can change, not the number of points
  48785. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48786. * @param name defines the name of the mesh
  48787. * @param options defines the options used to create the mesh
  48788. * @param scene defines the hosting scene
  48789. * @returns the dashed line mesh
  48790. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  48791. */
  48792. static CreateDashedLines(name: string, options: {
  48793. points: Vector3[];
  48794. dashSize?: number;
  48795. gapSize?: number;
  48796. dashNb?: number;
  48797. updatable?: boolean;
  48798. instance?: LinesMesh;
  48799. useVertexAlpha?: boolean;
  48800. }, scene?: Nullable<Scene>): LinesMesh;
  48801. }
  48802. }
  48803. declare module BABYLON {
  48804. /**
  48805. * Construction options for a timer
  48806. */
  48807. export interface ITimerOptions<T> {
  48808. /**
  48809. * Time-to-end
  48810. */
  48811. timeout: number;
  48812. /**
  48813. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  48814. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  48815. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  48816. */
  48817. contextObservable: Observable<T>;
  48818. /**
  48819. * Optional parameters when adding an observer to the observable
  48820. */
  48821. observableParameters?: {
  48822. mask?: number;
  48823. insertFirst?: boolean;
  48824. scope?: any;
  48825. };
  48826. /**
  48827. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  48828. */
  48829. breakCondition?: (data?: ITimerData<T>) => boolean;
  48830. /**
  48831. * Will be triggered when the time condition has met
  48832. */
  48833. onEnded?: (data: ITimerData<any>) => void;
  48834. /**
  48835. * Will be triggered when the break condition has met (prematurely ended)
  48836. */
  48837. onAborted?: (data: ITimerData<any>) => void;
  48838. /**
  48839. * Optional function to execute on each tick (or count)
  48840. */
  48841. onTick?: (data: ITimerData<any>) => void;
  48842. }
  48843. /**
  48844. * An interface defining the data sent by the timer
  48845. */
  48846. export interface ITimerData<T> {
  48847. /**
  48848. * When did it start
  48849. */
  48850. startTime: number;
  48851. /**
  48852. * Time now
  48853. */
  48854. currentTime: number;
  48855. /**
  48856. * Time passed since started
  48857. */
  48858. deltaTime: number;
  48859. /**
  48860. * How much is completed, in [0.0...1.0].
  48861. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  48862. */
  48863. completeRate: number;
  48864. /**
  48865. * What the registered observable sent in the last count
  48866. */
  48867. payload: T;
  48868. }
  48869. /**
  48870. * The current state of the timer
  48871. */
  48872. export enum TimerState {
  48873. /**
  48874. * Timer initialized, not yet started
  48875. */
  48876. INIT = 0,
  48877. /**
  48878. * Timer started and counting
  48879. */
  48880. STARTED = 1,
  48881. /**
  48882. * Timer ended (whether aborted or time reached)
  48883. */
  48884. ENDED = 2
  48885. }
  48886. /**
  48887. * A simple version of the timer. Will take options and start the timer immediately after calling it
  48888. *
  48889. * @param options options with which to initialize this timer
  48890. */
  48891. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  48892. /**
  48893. * An advanced implementation of a timer class
  48894. */
  48895. export class AdvancedTimer<T = any> implements IDisposable {
  48896. /**
  48897. * Will notify each time the timer calculates the remaining time
  48898. */
  48899. onEachCountObservable: Observable<ITimerData<T>>;
  48900. /**
  48901. * Will trigger when the timer was aborted due to the break condition
  48902. */
  48903. onTimerAbortedObservable: Observable<ITimerData<T>>;
  48904. /**
  48905. * Will trigger when the timer ended successfully
  48906. */
  48907. onTimerEndedObservable: Observable<ITimerData<T>>;
  48908. /**
  48909. * Will trigger when the timer state has changed
  48910. */
  48911. onStateChangedObservable: Observable<TimerState>;
  48912. private _observer;
  48913. private _contextObservable;
  48914. private _observableParameters;
  48915. private _startTime;
  48916. private _timer;
  48917. private _state;
  48918. private _breakCondition;
  48919. private _timeToEnd;
  48920. private _breakOnNextTick;
  48921. /**
  48922. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  48923. * @param options construction options for this advanced timer
  48924. */
  48925. constructor(options: ITimerOptions<T>);
  48926. /**
  48927. * set a breaking condition for this timer. Default is to never break during count
  48928. * @param predicate the new break condition. Returns true to break, false otherwise
  48929. */
  48930. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  48931. /**
  48932. * Reset ALL associated observables in this advanced timer
  48933. */
  48934. clearObservables(): void;
  48935. /**
  48936. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  48937. *
  48938. * @param timeToEnd how much time to measure until timer ended
  48939. */
  48940. start(timeToEnd?: number): void;
  48941. /**
  48942. * Will force a stop on the next tick.
  48943. */
  48944. stop(): void;
  48945. /**
  48946. * Dispose this timer, clearing all resources
  48947. */
  48948. dispose(): void;
  48949. private _setState;
  48950. private _tick;
  48951. private _stop;
  48952. }
  48953. }
  48954. declare module BABYLON {
  48955. /**
  48956. * The options container for the teleportation module
  48957. */
  48958. export interface IWebXRTeleportationOptions {
  48959. /**
  48960. * if provided, this scene will be used to render meshes.
  48961. */
  48962. customUtilityLayerScene?: Scene;
  48963. /**
  48964. * Values to configure the default target mesh
  48965. */
  48966. defaultTargetMeshOptions?: {
  48967. /**
  48968. * Fill color of the teleportation area
  48969. */
  48970. teleportationFillColor?: string;
  48971. /**
  48972. * Border color for the teleportation area
  48973. */
  48974. teleportationBorderColor?: string;
  48975. /**
  48976. * Disable the mesh's animation sequence
  48977. */
  48978. disableAnimation?: boolean;
  48979. /**
  48980. * Disable lighting on the material or the ring and arrow
  48981. */
  48982. disableLighting?: boolean;
  48983. /**
  48984. * Override the default material of the torus and arrow
  48985. */
  48986. torusArrowMaterial?: Material;
  48987. };
  48988. /**
  48989. * A list of meshes to use as floor meshes.
  48990. * Meshes can be added and removed after initializing the feature using the
  48991. * addFloorMesh and removeFloorMesh functions
  48992. * If empty, rotation will still work
  48993. */
  48994. floorMeshes?: AbstractMesh[];
  48995. /**
  48996. * use this rendering group id for the meshes (optional)
  48997. */
  48998. renderingGroupId?: number;
  48999. /**
  49000. * Should teleportation move only to snap points
  49001. */
  49002. snapPointsOnly?: boolean;
  49003. /**
  49004. * An array of points to which the teleportation will snap to.
  49005. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  49006. */
  49007. snapPositions?: Vector3[];
  49008. /**
  49009. * How close should the teleportation ray be in order to snap to position.
  49010. * Default to 0.8 units (meters)
  49011. */
  49012. snapToPositionRadius?: number;
  49013. /**
  49014. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  49015. * If you want to support rotation, make sure your mesh has a direction indicator.
  49016. *
  49017. * When left untouched, the default mesh will be initialized.
  49018. */
  49019. teleportationTargetMesh?: AbstractMesh;
  49020. /**
  49021. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  49022. */
  49023. timeToTeleport?: number;
  49024. /**
  49025. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  49026. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  49027. */
  49028. useMainComponentOnly?: boolean;
  49029. /**
  49030. * Should meshes created here be added to a utility layer or the main scene
  49031. */
  49032. useUtilityLayer?: boolean;
  49033. /**
  49034. * Babylon XR Input class for controller
  49035. */
  49036. xrInput: WebXRInput;
  49037. }
  49038. /**
  49039. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  49040. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  49041. * the input of the attached controllers.
  49042. */
  49043. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  49044. private _options;
  49045. private _controllers;
  49046. private _currentTeleportationControllerId;
  49047. private _floorMeshes;
  49048. private _quadraticBezierCurve;
  49049. private _selectionFeature;
  49050. private _snapToPositions;
  49051. private _snappedToPoint;
  49052. private _teleportationRingMaterial?;
  49053. private _tmpRay;
  49054. private _tmpVector;
  49055. /**
  49056. * The module's name
  49057. */
  49058. static readonly Name: string;
  49059. /**
  49060. * The (Babylon) version of this module.
  49061. * This is an integer representing the implementation version.
  49062. * This number does not correspond to the webxr specs version
  49063. */
  49064. static readonly Version: number;
  49065. /**
  49066. * Is movement backwards enabled
  49067. */
  49068. backwardsMovementEnabled: boolean;
  49069. /**
  49070. * Distance to travel when moving backwards
  49071. */
  49072. backwardsTeleportationDistance: number;
  49073. /**
  49074. * The distance from the user to the inspection point in the direction of the controller
  49075. * A higher number will allow the user to move further
  49076. * defaults to 5 (meters, in xr units)
  49077. */
  49078. parabolicCheckRadius: number;
  49079. /**
  49080. * Should the module support parabolic ray on top of direct ray
  49081. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  49082. * Very helpful when moving between floors / different heights
  49083. */
  49084. parabolicRayEnabled: boolean;
  49085. /**
  49086. * How much rotation should be applied when rotating right and left
  49087. */
  49088. rotationAngle: number;
  49089. /**
  49090. * Is rotation enabled when moving forward?
  49091. * Disabling this feature will prevent the user from deciding the direction when teleporting
  49092. */
  49093. rotationEnabled: boolean;
  49094. /**
  49095. * constructs a new anchor system
  49096. * @param _xrSessionManager an instance of WebXRSessionManager
  49097. * @param _options configuration object for this feature
  49098. */
  49099. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  49100. /**
  49101. * Get the snapPointsOnly flag
  49102. */
  49103. get snapPointsOnly(): boolean;
  49104. /**
  49105. * Sets the snapPointsOnly flag
  49106. * @param snapToPoints should teleportation be exclusively to snap points
  49107. */
  49108. set snapPointsOnly(snapToPoints: boolean);
  49109. /**
  49110. * Add a new mesh to the floor meshes array
  49111. * @param mesh the mesh to use as floor mesh
  49112. */
  49113. addFloorMesh(mesh: AbstractMesh): void;
  49114. /**
  49115. * Add a new snap-to point to fix teleportation to this position
  49116. * @param newSnapPoint The new Snap-To point
  49117. */
  49118. addSnapPoint(newSnapPoint: Vector3): void;
  49119. attach(): boolean;
  49120. detach(): boolean;
  49121. dispose(): void;
  49122. /**
  49123. * Remove a mesh from the floor meshes array
  49124. * @param mesh the mesh to remove
  49125. */
  49126. removeFloorMesh(mesh: AbstractMesh): void;
  49127. /**
  49128. * Remove a mesh from the floor meshes array using its name
  49129. * @param name the mesh name to remove
  49130. */
  49131. removeFloorMeshByName(name: string): void;
  49132. /**
  49133. * 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
  49134. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  49135. * @returns was the point found and removed or not
  49136. */
  49137. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  49138. /**
  49139. * This function sets a selection feature that will be disabled when
  49140. * the forward ray is shown and will be reattached when hidden.
  49141. * This is used to remove the selection rays when moving.
  49142. * @param selectionFeature the feature to disable when forward movement is enabled
  49143. */
  49144. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  49145. protected _onXRFrame(_xrFrame: XRFrame): void;
  49146. private _attachController;
  49147. private _createDefaultTargetMesh;
  49148. private _detachController;
  49149. private _findClosestSnapPointWithRadius;
  49150. private _setTargetMeshPosition;
  49151. private _setTargetMeshVisibility;
  49152. private _showParabolicPath;
  49153. private _teleportForward;
  49154. }
  49155. }
  49156. declare module BABYLON {
  49157. /**
  49158. * Options for the default xr helper
  49159. */
  49160. export class WebXRDefaultExperienceOptions {
  49161. /**
  49162. * Enable or disable default UI to enter XR
  49163. */
  49164. disableDefaultUI?: boolean;
  49165. /**
  49166. * Should teleportation not initialize. defaults to false.
  49167. */
  49168. disableTeleportation?: boolean;
  49169. /**
  49170. * Floor meshes that will be used for teleport
  49171. */
  49172. floorMeshes?: Array<AbstractMesh>;
  49173. /**
  49174. * If set to true, the first frame will not be used to reset position
  49175. * The first frame is mainly used when copying transformation from the old camera
  49176. * Mainly used in AR
  49177. */
  49178. ignoreNativeCameraTransformation?: boolean;
  49179. /**
  49180. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  49181. */
  49182. inputOptions?: IWebXRInputOptions;
  49183. /**
  49184. * optional configuration for the output canvas
  49185. */
  49186. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  49187. /**
  49188. * optional UI options. This can be used among other to change session mode and reference space type
  49189. */
  49190. uiOptions?: WebXREnterExitUIOptions;
  49191. /**
  49192. * When loading teleportation and pointer select, use stable versions instead of latest.
  49193. */
  49194. useStablePlugins?: boolean;
  49195. /**
  49196. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  49197. */
  49198. renderingGroupId?: number;
  49199. /**
  49200. * A list of optional features to init the session with
  49201. * If set to true, all features we support will be added
  49202. */
  49203. optionalFeatures?: boolean | string[];
  49204. }
  49205. /**
  49206. * Default experience which provides a similar setup to the previous webVRExperience
  49207. */
  49208. export class WebXRDefaultExperience {
  49209. /**
  49210. * Base experience
  49211. */
  49212. baseExperience: WebXRExperienceHelper;
  49213. /**
  49214. * Enables ui for entering/exiting xr
  49215. */
  49216. enterExitUI: WebXREnterExitUI;
  49217. /**
  49218. * Input experience extension
  49219. */
  49220. input: WebXRInput;
  49221. /**
  49222. * Enables laser pointer and selection
  49223. */
  49224. pointerSelection: WebXRControllerPointerSelection;
  49225. /**
  49226. * Default target xr should render to
  49227. */
  49228. renderTarget: WebXRRenderTarget;
  49229. /**
  49230. * Enables teleportation
  49231. */
  49232. teleportation: WebXRMotionControllerTeleportation;
  49233. private constructor();
  49234. /**
  49235. * Creates the default xr experience
  49236. * @param scene scene
  49237. * @param options options for basic configuration
  49238. * @returns resulting WebXRDefaultExperience
  49239. */
  49240. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49241. /**
  49242. * DIsposes of the experience helper
  49243. */
  49244. dispose(): void;
  49245. }
  49246. }
  49247. declare module BABYLON {
  49248. /**
  49249. * Options to modify the vr teleportation behavior.
  49250. */
  49251. export interface VRTeleportationOptions {
  49252. /**
  49253. * The name of the mesh which should be used as the teleportation floor. (default: null)
  49254. */
  49255. floorMeshName?: string;
  49256. /**
  49257. * A list of meshes to be used as the teleportation floor. (default: empty)
  49258. */
  49259. floorMeshes?: Mesh[];
  49260. /**
  49261. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  49262. */
  49263. teleportationMode?: number;
  49264. /**
  49265. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  49266. */
  49267. teleportationTime?: number;
  49268. /**
  49269. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  49270. */
  49271. teleportationSpeed?: number;
  49272. /**
  49273. * The easing function used in the animation or null for Linear. (default CircleEase)
  49274. */
  49275. easingFunction?: EasingFunction;
  49276. }
  49277. /**
  49278. * Options to modify the vr experience helper's behavior.
  49279. */
  49280. export interface VRExperienceHelperOptions extends WebVROptions {
  49281. /**
  49282. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  49283. */
  49284. createDeviceOrientationCamera?: boolean;
  49285. /**
  49286. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  49287. */
  49288. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  49289. /**
  49290. * Uses the main button on the controller to toggle the laser casted. (default: true)
  49291. */
  49292. laserToggle?: boolean;
  49293. /**
  49294. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  49295. */
  49296. floorMeshes?: Mesh[];
  49297. /**
  49298. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  49299. */
  49300. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  49301. /**
  49302. * Defines if WebXR should be used instead of WebVR (if available)
  49303. */
  49304. useXR?: boolean;
  49305. }
  49306. /**
  49307. * Event containing information after VR has been entered
  49308. */
  49309. export class OnAfterEnteringVRObservableEvent {
  49310. /**
  49311. * If entering vr was successful
  49312. */
  49313. success: boolean;
  49314. }
  49315. /**
  49316. * Helps to quickly add VR support to an existing scene.
  49317. * See https://doc.babylonjs.com/how_to/webvr_helper
  49318. */
  49319. export class VRExperienceHelper {
  49320. /** Options to modify the vr experience helper's behavior. */
  49321. webVROptions: VRExperienceHelperOptions;
  49322. private _scene;
  49323. private _position;
  49324. private _btnVR;
  49325. private _btnVRDisplayed;
  49326. private _webVRsupported;
  49327. private _webVRready;
  49328. private _webVRrequesting;
  49329. private _webVRpresenting;
  49330. private _hasEnteredVR;
  49331. private _fullscreenVRpresenting;
  49332. private _inputElement;
  49333. private _webVRCamera;
  49334. private _vrDeviceOrientationCamera;
  49335. private _deviceOrientationCamera;
  49336. private _existingCamera;
  49337. private _onKeyDown;
  49338. private _onVrDisplayPresentChange;
  49339. private _onVRDisplayChanged;
  49340. private _onVRRequestPresentStart;
  49341. private _onVRRequestPresentComplete;
  49342. /**
  49343. * 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)
  49344. */
  49345. enableGazeEvenWhenNoPointerLock: boolean;
  49346. /**
  49347. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  49348. */
  49349. exitVROnDoubleTap: boolean;
  49350. /**
  49351. * Observable raised right before entering VR.
  49352. */
  49353. onEnteringVRObservable: Observable<VRExperienceHelper>;
  49354. /**
  49355. * Observable raised when entering VR has completed.
  49356. */
  49357. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  49358. /**
  49359. * Observable raised when exiting VR.
  49360. */
  49361. onExitingVRObservable: Observable<VRExperienceHelper>;
  49362. /**
  49363. * Observable raised when controller mesh is loaded.
  49364. */
  49365. onControllerMeshLoadedObservable: Observable<WebVRController>;
  49366. /** Return this.onEnteringVRObservable
  49367. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  49368. */
  49369. get onEnteringVR(): Observable<VRExperienceHelper>;
  49370. /** Return this.onExitingVRObservable
  49371. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  49372. */
  49373. get onExitingVR(): Observable<VRExperienceHelper>;
  49374. /** Return this.onControllerMeshLoadedObservable
  49375. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  49376. */
  49377. get onControllerMeshLoaded(): Observable<WebVRController>;
  49378. private _rayLength;
  49379. private _useCustomVRButton;
  49380. private _teleportationRequested;
  49381. private _teleportActive;
  49382. private _floorMeshName;
  49383. private _floorMeshesCollection;
  49384. private _teleportationMode;
  49385. private _teleportationTime;
  49386. private _teleportationSpeed;
  49387. private _teleportationEasing;
  49388. private _rotationAllowed;
  49389. private _teleportBackwardsVector;
  49390. private _teleportationTarget;
  49391. private _isDefaultTeleportationTarget;
  49392. private _postProcessMove;
  49393. private _teleportationFillColor;
  49394. private _teleportationBorderColor;
  49395. private _rotationAngle;
  49396. private _haloCenter;
  49397. private _cameraGazer;
  49398. private _padSensibilityUp;
  49399. private _padSensibilityDown;
  49400. private _leftController;
  49401. private _rightController;
  49402. private _gazeColor;
  49403. private _laserColor;
  49404. private _pickedLaserColor;
  49405. private _pickedGazeColor;
  49406. /**
  49407. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  49408. */
  49409. onNewMeshSelected: Observable<AbstractMesh>;
  49410. /**
  49411. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  49412. * This observable will provide the mesh and the controller used to select the mesh
  49413. */
  49414. onMeshSelectedWithController: Observable<{
  49415. mesh: AbstractMesh;
  49416. controller: WebVRController;
  49417. }>;
  49418. /**
  49419. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  49420. */
  49421. onNewMeshPicked: Observable<PickingInfo>;
  49422. private _circleEase;
  49423. /**
  49424. * Observable raised before camera teleportation
  49425. */
  49426. onBeforeCameraTeleport: Observable<Vector3>;
  49427. /**
  49428. * Observable raised after camera teleportation
  49429. */
  49430. onAfterCameraTeleport: Observable<Vector3>;
  49431. /**
  49432. * Observable raised when current selected mesh gets unselected
  49433. */
  49434. onSelectedMeshUnselected: Observable<AbstractMesh>;
  49435. private _raySelectionPredicate;
  49436. /**
  49437. * To be optionaly changed by user to define custom ray selection
  49438. */
  49439. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49440. /**
  49441. * To be optionaly changed by user to define custom selection logic (after ray selection)
  49442. */
  49443. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49444. /**
  49445. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  49446. */
  49447. teleportationEnabled: boolean;
  49448. private _defaultHeight;
  49449. private _teleportationInitialized;
  49450. private _interactionsEnabled;
  49451. private _interactionsRequested;
  49452. private _displayGaze;
  49453. private _displayLaserPointer;
  49454. /**
  49455. * The mesh used to display where the user is going to teleport.
  49456. */
  49457. get teleportationTarget(): Mesh;
  49458. /**
  49459. * Sets the mesh to be used to display where the user is going to teleport.
  49460. */
  49461. set teleportationTarget(value: Mesh);
  49462. /**
  49463. * 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
  49464. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  49465. * See https://doc.babylonjs.com/resources/baking_transformations
  49466. */
  49467. get gazeTrackerMesh(): Mesh;
  49468. set gazeTrackerMesh(value: Mesh);
  49469. /**
  49470. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  49471. */
  49472. updateGazeTrackerScale: boolean;
  49473. /**
  49474. * If the gaze trackers color should be updated when selecting meshes
  49475. */
  49476. updateGazeTrackerColor: boolean;
  49477. /**
  49478. * If the controller laser color should be updated when selecting meshes
  49479. */
  49480. updateControllerLaserColor: boolean;
  49481. /**
  49482. * The gaze tracking mesh corresponding to the left controller
  49483. */
  49484. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  49485. /**
  49486. * The gaze tracking mesh corresponding to the right controller
  49487. */
  49488. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  49489. /**
  49490. * If the ray of the gaze should be displayed.
  49491. */
  49492. get displayGaze(): boolean;
  49493. /**
  49494. * Sets if the ray of the gaze should be displayed.
  49495. */
  49496. set displayGaze(value: boolean);
  49497. /**
  49498. * If the ray of the LaserPointer should be displayed.
  49499. */
  49500. get displayLaserPointer(): boolean;
  49501. /**
  49502. * Sets if the ray of the LaserPointer should be displayed.
  49503. */
  49504. set displayLaserPointer(value: boolean);
  49505. /**
  49506. * The deviceOrientationCamera used as the camera when not in VR.
  49507. */
  49508. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  49509. /**
  49510. * Based on the current WebVR support, returns the current VR camera used.
  49511. */
  49512. get currentVRCamera(): Nullable<Camera>;
  49513. /**
  49514. * The webVRCamera which is used when in VR.
  49515. */
  49516. get webVRCamera(): WebVRFreeCamera;
  49517. /**
  49518. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  49519. */
  49520. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  49521. /**
  49522. * The html button that is used to trigger entering into VR.
  49523. */
  49524. get vrButton(): Nullable<HTMLButtonElement>;
  49525. private get _teleportationRequestInitiated();
  49526. /**
  49527. * Defines whether or not Pointer lock should be requested when switching to
  49528. * full screen.
  49529. */
  49530. requestPointerLockOnFullScreen: boolean;
  49531. /**
  49532. * If asking to force XR, this will be populated with the default xr experience
  49533. */
  49534. xr: WebXRDefaultExperience;
  49535. /**
  49536. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  49537. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  49538. */
  49539. xrTestDone: boolean;
  49540. /**
  49541. * Instantiates a VRExperienceHelper.
  49542. * Helps to quickly add VR support to an existing scene.
  49543. * @param scene The scene the VRExperienceHelper belongs to.
  49544. * @param webVROptions Options to modify the vr experience helper's behavior.
  49545. */
  49546. constructor(scene: Scene,
  49547. /** Options to modify the vr experience helper's behavior. */
  49548. webVROptions?: VRExperienceHelperOptions);
  49549. private completeVRInit;
  49550. private _onDefaultMeshLoaded;
  49551. private _onResize;
  49552. private _onFullscreenChange;
  49553. /**
  49554. * Gets a value indicating if we are currently in VR mode.
  49555. */
  49556. get isInVRMode(): boolean;
  49557. private onVrDisplayPresentChange;
  49558. private onVRDisplayChanged;
  49559. private moveButtonToBottomRight;
  49560. private displayVRButton;
  49561. private updateButtonVisibility;
  49562. private _cachedAngularSensibility;
  49563. /**
  49564. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  49565. * Otherwise, will use the fullscreen API.
  49566. */
  49567. enterVR(): void;
  49568. /**
  49569. * Attempt to exit VR, or fullscreen.
  49570. */
  49571. exitVR(): void;
  49572. /**
  49573. * The position of the vr experience helper.
  49574. */
  49575. get position(): Vector3;
  49576. /**
  49577. * Sets the position of the vr experience helper.
  49578. */
  49579. set position(value: Vector3);
  49580. /**
  49581. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  49582. */
  49583. enableInteractions(): void;
  49584. private get _noControllerIsActive();
  49585. private beforeRender;
  49586. private _isTeleportationFloor;
  49587. /**
  49588. * Adds a floor mesh to be used for teleportation.
  49589. * @param floorMesh the mesh to be used for teleportation.
  49590. */
  49591. addFloorMesh(floorMesh: Mesh): void;
  49592. /**
  49593. * Removes a floor mesh from being used for teleportation.
  49594. * @param floorMesh the mesh to be removed.
  49595. */
  49596. removeFloorMesh(floorMesh: Mesh): void;
  49597. /**
  49598. * Enables interactions and teleportation using the VR controllers and gaze.
  49599. * @param vrTeleportationOptions options to modify teleportation behavior.
  49600. */
  49601. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  49602. private _onNewGamepadConnected;
  49603. private _tryEnableInteractionOnController;
  49604. private _onNewGamepadDisconnected;
  49605. private _enableInteractionOnController;
  49606. private _checkTeleportWithRay;
  49607. private _checkRotate;
  49608. private _checkTeleportBackwards;
  49609. private _enableTeleportationOnController;
  49610. private _createTeleportationCircles;
  49611. private _displayTeleportationTarget;
  49612. private _hideTeleportationTarget;
  49613. private _rotateCamera;
  49614. private _moveTeleportationSelectorTo;
  49615. private _workingVector;
  49616. private _workingQuaternion;
  49617. private _workingMatrix;
  49618. /**
  49619. * Time Constant Teleportation Mode
  49620. */
  49621. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  49622. /**
  49623. * Speed Constant Teleportation Mode
  49624. */
  49625. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  49626. /**
  49627. * Teleports the users feet to the desired location
  49628. * @param location The location where the user's feet should be placed
  49629. */
  49630. teleportCamera(location: Vector3): void;
  49631. private _convertNormalToDirectionOfRay;
  49632. private _castRayAndSelectObject;
  49633. private _notifySelectedMeshUnselected;
  49634. /**
  49635. * Permanently set new colors for the laser pointer
  49636. * @param color the new laser color
  49637. * @param pickedColor the new laser color when picked mesh detected
  49638. */
  49639. setLaserColor(color: Color3, pickedColor?: Color3): void;
  49640. /**
  49641. * Set lighting enabled / disabled on the laser pointer of both controllers
  49642. * @param enabled should the lighting be enabled on the laser pointer
  49643. */
  49644. setLaserLightingState(enabled?: boolean): void;
  49645. /**
  49646. * Permanently set new colors for the gaze pointer
  49647. * @param color the new gaze color
  49648. * @param pickedColor the new gaze color when picked mesh detected
  49649. */
  49650. setGazeColor(color: Color3, pickedColor?: Color3): void;
  49651. /**
  49652. * Sets the color of the laser ray from the vr controllers.
  49653. * @param color new color for the ray.
  49654. */
  49655. changeLaserColor(color: Color3): void;
  49656. /**
  49657. * Sets the color of the ray from the vr headsets gaze.
  49658. * @param color new color for the ray.
  49659. */
  49660. changeGazeColor(color: Color3): void;
  49661. /**
  49662. * Exits VR and disposes of the vr experience helper
  49663. */
  49664. dispose(): void;
  49665. /**
  49666. * Gets the name of the VRExperienceHelper class
  49667. * @returns "VRExperienceHelper"
  49668. */
  49669. getClassName(): string;
  49670. }
  49671. }
  49672. declare module BABYLON {
  49673. /**
  49674. * Contains an array of blocks representing the octree
  49675. */
  49676. export interface IOctreeContainer<T> {
  49677. /**
  49678. * Blocks within the octree
  49679. */
  49680. blocks: Array<OctreeBlock<T>>;
  49681. }
  49682. /**
  49683. * Class used to store a cell in an octree
  49684. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49685. */
  49686. export class OctreeBlock<T> {
  49687. /**
  49688. * Gets the content of the current block
  49689. */
  49690. entries: T[];
  49691. /**
  49692. * Gets the list of block children
  49693. */
  49694. blocks: Array<OctreeBlock<T>>;
  49695. private _depth;
  49696. private _maxDepth;
  49697. private _capacity;
  49698. private _minPoint;
  49699. private _maxPoint;
  49700. private _boundingVectors;
  49701. private _creationFunc;
  49702. /**
  49703. * Creates a new block
  49704. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  49705. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  49706. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49707. * @param depth defines the current depth of this block in the octree
  49708. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  49709. * @param creationFunc defines a callback to call when an element is added to the block
  49710. */
  49711. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  49712. /**
  49713. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49714. */
  49715. get capacity(): number;
  49716. /**
  49717. * Gets the minimum vector (in world space) of the block's bounding box
  49718. */
  49719. get minPoint(): Vector3;
  49720. /**
  49721. * Gets the maximum vector (in world space) of the block's bounding box
  49722. */
  49723. get maxPoint(): Vector3;
  49724. /**
  49725. * Add a new element to this block
  49726. * @param entry defines the element to add
  49727. */
  49728. addEntry(entry: T): void;
  49729. /**
  49730. * Remove an element from this block
  49731. * @param entry defines the element to remove
  49732. */
  49733. removeEntry(entry: T): void;
  49734. /**
  49735. * Add an array of elements to this block
  49736. * @param entries defines the array of elements to add
  49737. */
  49738. addEntries(entries: T[]): void;
  49739. /**
  49740. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  49741. * @param frustumPlanes defines the frustum planes to test
  49742. * @param selection defines the array to store current content if selection is positive
  49743. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49744. */
  49745. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  49746. /**
  49747. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  49748. * @param sphereCenter defines the bounding sphere center
  49749. * @param sphereRadius defines the bounding sphere radius
  49750. * @param selection defines the array to store current content if selection is positive
  49751. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49752. */
  49753. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  49754. /**
  49755. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  49756. * @param ray defines the ray to test with
  49757. * @param selection defines the array to store current content if selection is positive
  49758. */
  49759. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  49760. /**
  49761. * Subdivide the content into child blocks (this block will then be empty)
  49762. */
  49763. createInnerBlocks(): void;
  49764. /**
  49765. * @hidden
  49766. */
  49767. 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;
  49768. }
  49769. }
  49770. declare module BABYLON {
  49771. /**
  49772. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  49773. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49774. */
  49775. export class Octree<T> {
  49776. /** 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.) */
  49777. maxDepth: number;
  49778. /**
  49779. * Blocks within the octree containing objects
  49780. */
  49781. blocks: Array<OctreeBlock<T>>;
  49782. /**
  49783. * Content stored in the octree
  49784. */
  49785. dynamicContent: T[];
  49786. private _maxBlockCapacity;
  49787. private _selectionContent;
  49788. private _creationFunc;
  49789. /**
  49790. * Creates a octree
  49791. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49792. * @param creationFunc function to be used to instatiate the octree
  49793. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  49794. * @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.)
  49795. */
  49796. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  49797. /** 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.) */
  49798. maxDepth?: number);
  49799. /**
  49800. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  49801. * @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);
  49802. * @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);
  49803. * @param entries meshes to be added to the octree blocks
  49804. */
  49805. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  49806. /**
  49807. * Adds a mesh to the octree
  49808. * @param entry Mesh to add to the octree
  49809. */
  49810. addMesh(entry: T): void;
  49811. /**
  49812. * Remove an element from the octree
  49813. * @param entry defines the element to remove
  49814. */
  49815. removeMesh(entry: T): void;
  49816. /**
  49817. * Selects an array of meshes within the frustum
  49818. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  49819. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  49820. * @returns array of meshes within the frustum
  49821. */
  49822. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  49823. /**
  49824. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  49825. * @param sphereCenter defines the bounding sphere center
  49826. * @param sphereRadius defines the bounding sphere radius
  49827. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49828. * @returns an array of objects that intersect the sphere
  49829. */
  49830. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  49831. /**
  49832. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  49833. * @param ray defines the ray to test with
  49834. * @returns array of intersected objects
  49835. */
  49836. intersectsRay(ray: Ray): SmartArray<T>;
  49837. /**
  49838. * Adds a mesh into the octree block if it intersects the block
  49839. */
  49840. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  49841. /**
  49842. * Adds a submesh into the octree block if it intersects the block
  49843. */
  49844. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  49845. }
  49846. }
  49847. declare module BABYLON {
  49848. interface Scene {
  49849. /**
  49850. * @hidden
  49851. * Backing Filed
  49852. */
  49853. _selectionOctree: Octree<AbstractMesh>;
  49854. /**
  49855. * Gets the octree used to boost mesh selection (picking)
  49856. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49857. */
  49858. selectionOctree: Octree<AbstractMesh>;
  49859. /**
  49860. * Creates or updates the octree used to boost selection (picking)
  49861. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49862. * @param maxCapacity defines the maximum capacity per leaf
  49863. * @param maxDepth defines the maximum depth of the octree
  49864. * @returns an octree of AbstractMesh
  49865. */
  49866. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  49867. }
  49868. interface AbstractMesh {
  49869. /**
  49870. * @hidden
  49871. * Backing Field
  49872. */
  49873. _submeshesOctree: Octree<SubMesh>;
  49874. /**
  49875. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  49876. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  49877. * @param maxCapacity defines the maximum size of each block (64 by default)
  49878. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  49879. * @returns the new octree
  49880. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  49881. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49882. */
  49883. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  49884. }
  49885. /**
  49886. * Defines the octree scene component responsible to manage any octrees
  49887. * in a given scene.
  49888. */
  49889. export class OctreeSceneComponent {
  49890. /**
  49891. * The component name help to identify the component in the list of scene components.
  49892. */
  49893. readonly name: string;
  49894. /**
  49895. * The scene the component belongs to.
  49896. */
  49897. scene: Scene;
  49898. /**
  49899. * Indicates if the meshes have been checked to make sure they are isEnabled()
  49900. */
  49901. readonly checksIsEnabled: boolean;
  49902. /**
  49903. * Creates a new instance of the component for the given scene
  49904. * @param scene Defines the scene to register the component in
  49905. */
  49906. constructor(scene: Scene);
  49907. /**
  49908. * Registers the component in a given scene
  49909. */
  49910. register(): void;
  49911. /**
  49912. * Return the list of active meshes
  49913. * @returns the list of active meshes
  49914. */
  49915. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  49916. /**
  49917. * Return the list of active sub meshes
  49918. * @param mesh The mesh to get the candidates sub meshes from
  49919. * @returns the list of active sub meshes
  49920. */
  49921. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  49922. private _tempRay;
  49923. /**
  49924. * Return the list of sub meshes intersecting with a given local ray
  49925. * @param mesh defines the mesh to find the submesh for
  49926. * @param localRay defines the ray in local space
  49927. * @returns the list of intersecting sub meshes
  49928. */
  49929. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  49930. /**
  49931. * Return the list of sub meshes colliding with a collider
  49932. * @param mesh defines the mesh to find the submesh for
  49933. * @param collider defines the collider to evaluate the collision against
  49934. * @returns the list of colliding sub meshes
  49935. */
  49936. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  49937. /**
  49938. * Rebuilds the elements related to this component in case of
  49939. * context lost for instance.
  49940. */
  49941. rebuild(): void;
  49942. /**
  49943. * Disposes the component and the associated ressources.
  49944. */
  49945. dispose(): void;
  49946. }
  49947. }
  49948. declare module BABYLON {
  49949. /**
  49950. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  49951. */
  49952. export class Gizmo implements IDisposable {
  49953. /** The utility layer the gizmo will be added to */
  49954. gizmoLayer: UtilityLayerRenderer;
  49955. /**
  49956. * The root mesh of the gizmo
  49957. */
  49958. _rootMesh: Mesh;
  49959. private _attachedMesh;
  49960. private _attachedNode;
  49961. /**
  49962. * Ratio for the scale of the gizmo (Default: 1)
  49963. */
  49964. scaleRatio: number;
  49965. /**
  49966. * If a custom mesh has been set (Default: false)
  49967. */
  49968. protected _customMeshSet: boolean;
  49969. /**
  49970. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  49971. * * When set, interactions will be enabled
  49972. */
  49973. get attachedMesh(): Nullable<AbstractMesh>;
  49974. set attachedMesh(value: Nullable<AbstractMesh>);
  49975. /**
  49976. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  49977. * * When set, interactions will be enabled
  49978. */
  49979. get attachedNode(): Nullable<Node>;
  49980. set attachedNode(value: Nullable<Node>);
  49981. /**
  49982. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  49983. * @param mesh The mesh to replace the default mesh of the gizmo
  49984. */
  49985. setCustomMesh(mesh: Mesh): void;
  49986. /**
  49987. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  49988. */
  49989. updateGizmoRotationToMatchAttachedMesh: boolean;
  49990. /**
  49991. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  49992. */
  49993. updateGizmoPositionToMatchAttachedMesh: boolean;
  49994. /**
  49995. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  49996. */
  49997. updateScale: boolean;
  49998. protected _interactionsEnabled: boolean;
  49999. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50000. private _beforeRenderObserver;
  50001. private _tempVector;
  50002. /**
  50003. * Creates a gizmo
  50004. * @param gizmoLayer The utility layer the gizmo will be added to
  50005. */
  50006. constructor(
  50007. /** The utility layer the gizmo will be added to */
  50008. gizmoLayer?: UtilityLayerRenderer);
  50009. /**
  50010. * Updates the gizmo to match the attached mesh's position/rotation
  50011. */
  50012. protected _update(): void;
  50013. /**
  50014. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  50015. * @param value Node, TransformNode or mesh
  50016. */
  50017. protected _matrixChanged(): void;
  50018. /**
  50019. * Disposes of the gizmo
  50020. */
  50021. dispose(): void;
  50022. }
  50023. }
  50024. declare module BABYLON {
  50025. /**
  50026. * Single plane drag gizmo
  50027. */
  50028. export class PlaneDragGizmo extends Gizmo {
  50029. /**
  50030. * Drag behavior responsible for the gizmos dragging interactions
  50031. */
  50032. dragBehavior: PointerDragBehavior;
  50033. private _pointerObserver;
  50034. /**
  50035. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50036. */
  50037. snapDistance: number;
  50038. /**
  50039. * Event that fires each time the gizmo snaps to a new location.
  50040. * * snapDistance is the the change in distance
  50041. */
  50042. onSnapObservable: Observable<{
  50043. snapDistance: number;
  50044. }>;
  50045. private _plane;
  50046. private _coloredMaterial;
  50047. private _hoverMaterial;
  50048. private _isEnabled;
  50049. private _parent;
  50050. /** @hidden */
  50051. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  50052. /** @hidden */
  50053. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50054. /**
  50055. * Creates a PlaneDragGizmo
  50056. * @param gizmoLayer The utility layer the gizmo will be added to
  50057. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  50058. * @param color The color of the gizmo
  50059. */
  50060. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  50061. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50062. /**
  50063. * If the gizmo is enabled
  50064. */
  50065. set isEnabled(value: boolean);
  50066. get isEnabled(): boolean;
  50067. /**
  50068. * Disposes of the gizmo
  50069. */
  50070. dispose(): void;
  50071. }
  50072. }
  50073. declare module BABYLON {
  50074. /**
  50075. * Gizmo that enables dragging a mesh along 3 axis
  50076. */
  50077. export class PositionGizmo extends Gizmo {
  50078. /**
  50079. * Internal gizmo used for interactions on the x axis
  50080. */
  50081. xGizmo: AxisDragGizmo;
  50082. /**
  50083. * Internal gizmo used for interactions on the y axis
  50084. */
  50085. yGizmo: AxisDragGizmo;
  50086. /**
  50087. * Internal gizmo used for interactions on the z axis
  50088. */
  50089. zGizmo: AxisDragGizmo;
  50090. /**
  50091. * Internal gizmo used for interactions on the yz plane
  50092. */
  50093. xPlaneGizmo: PlaneDragGizmo;
  50094. /**
  50095. * Internal gizmo used for interactions on the xz plane
  50096. */
  50097. yPlaneGizmo: PlaneDragGizmo;
  50098. /**
  50099. * Internal gizmo used for interactions on the xy plane
  50100. */
  50101. zPlaneGizmo: PlaneDragGizmo;
  50102. /**
  50103. * private variables
  50104. */
  50105. private _meshAttached;
  50106. private _nodeAttached;
  50107. private _updateGizmoRotationToMatchAttachedMesh;
  50108. private _snapDistance;
  50109. private _scaleRatio;
  50110. /** Fires an event when any of it's sub gizmos are dragged */
  50111. onDragStartObservable: Observable<unknown>;
  50112. /** Fires an event when any of it's sub gizmos are released from dragging */
  50113. onDragEndObservable: Observable<unknown>;
  50114. /**
  50115. * If set to true, planar drag is enabled
  50116. */
  50117. private _planarGizmoEnabled;
  50118. get attachedMesh(): Nullable<AbstractMesh>;
  50119. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50120. get attachedNode(): Nullable<Node>;
  50121. set attachedNode(node: Nullable<Node>);
  50122. /**
  50123. * Creates a PositionGizmo
  50124. * @param gizmoLayer The utility layer the gizmo will be added to
  50125. @param thickness display gizmo axis thickness
  50126. */
  50127. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  50128. /**
  50129. * If the planar drag gizmo is enabled
  50130. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  50131. */
  50132. set planarGizmoEnabled(value: boolean);
  50133. get planarGizmoEnabled(): boolean;
  50134. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50135. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50136. /**
  50137. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50138. */
  50139. set snapDistance(value: number);
  50140. get snapDistance(): number;
  50141. /**
  50142. * Ratio for the scale of the gizmo (Default: 1)
  50143. */
  50144. set scaleRatio(value: number);
  50145. get scaleRatio(): number;
  50146. /**
  50147. * Disposes of the gizmo
  50148. */
  50149. dispose(): void;
  50150. /**
  50151. * CustomMeshes are not supported by this gizmo
  50152. * @param mesh The mesh to replace the default mesh of the gizmo
  50153. */
  50154. setCustomMesh(mesh: Mesh): void;
  50155. }
  50156. }
  50157. declare module BABYLON {
  50158. /**
  50159. * Single axis drag gizmo
  50160. */
  50161. export class AxisDragGizmo extends Gizmo {
  50162. /**
  50163. * Drag behavior responsible for the gizmos dragging interactions
  50164. */
  50165. dragBehavior: PointerDragBehavior;
  50166. private _pointerObserver;
  50167. /**
  50168. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50169. */
  50170. snapDistance: number;
  50171. /**
  50172. * Event that fires each time the gizmo snaps to a new location.
  50173. * * snapDistance is the the change in distance
  50174. */
  50175. onSnapObservable: Observable<{
  50176. snapDistance: number;
  50177. }>;
  50178. private _isEnabled;
  50179. private _parent;
  50180. private _arrow;
  50181. private _coloredMaterial;
  50182. private _hoverMaterial;
  50183. /** @hidden */
  50184. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  50185. /** @hidden */
  50186. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50187. /**
  50188. * Creates an AxisDragGizmo
  50189. * @param gizmoLayer The utility layer the gizmo will be added to
  50190. * @param dragAxis The axis which the gizmo will be able to drag on
  50191. * @param color The color of the gizmo
  50192. * @param thickness display gizmo axis thickness
  50193. */
  50194. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  50195. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50196. /**
  50197. * If the gizmo is enabled
  50198. */
  50199. set isEnabled(value: boolean);
  50200. get isEnabled(): boolean;
  50201. /**
  50202. * Disposes of the gizmo
  50203. */
  50204. dispose(): void;
  50205. }
  50206. }
  50207. declare module BABYLON.Debug {
  50208. /**
  50209. * The Axes viewer will show 3 axes in a specific point in space
  50210. */
  50211. export class AxesViewer {
  50212. private _xAxis;
  50213. private _yAxis;
  50214. private _zAxis;
  50215. private _scaleLinesFactor;
  50216. private _instanced;
  50217. /**
  50218. * Gets the hosting scene
  50219. */
  50220. scene: Scene;
  50221. /**
  50222. * Gets or sets a number used to scale line length
  50223. */
  50224. scaleLines: number;
  50225. /** Gets the node hierarchy used to render x-axis */
  50226. get xAxis(): TransformNode;
  50227. /** Gets the node hierarchy used to render y-axis */
  50228. get yAxis(): TransformNode;
  50229. /** Gets the node hierarchy used to render z-axis */
  50230. get zAxis(): TransformNode;
  50231. /**
  50232. * Creates a new AxesViewer
  50233. * @param scene defines the hosting scene
  50234. * @param scaleLines defines a number used to scale line length (1 by default)
  50235. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  50236. * @param xAxis defines the node hierarchy used to render the x-axis
  50237. * @param yAxis defines the node hierarchy used to render the y-axis
  50238. * @param zAxis defines the node hierarchy used to render the z-axis
  50239. */
  50240. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  50241. /**
  50242. * Force the viewer to update
  50243. * @param position defines the position of the viewer
  50244. * @param xaxis defines the x axis of the viewer
  50245. * @param yaxis defines the y axis of the viewer
  50246. * @param zaxis defines the z axis of the viewer
  50247. */
  50248. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  50249. /**
  50250. * Creates an instance of this axes viewer.
  50251. * @returns a new axes viewer with instanced meshes
  50252. */
  50253. createInstance(): AxesViewer;
  50254. /** Releases resources */
  50255. dispose(): void;
  50256. private static _SetRenderingGroupId;
  50257. }
  50258. }
  50259. declare module BABYLON.Debug {
  50260. /**
  50261. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  50262. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  50263. */
  50264. export class BoneAxesViewer extends AxesViewer {
  50265. /**
  50266. * Gets or sets the target mesh where to display the axes viewer
  50267. */
  50268. mesh: Nullable<Mesh>;
  50269. /**
  50270. * Gets or sets the target bone where to display the axes viewer
  50271. */
  50272. bone: Nullable<Bone>;
  50273. /** Gets current position */
  50274. pos: Vector3;
  50275. /** Gets direction of X axis */
  50276. xaxis: Vector3;
  50277. /** Gets direction of Y axis */
  50278. yaxis: Vector3;
  50279. /** Gets direction of Z axis */
  50280. zaxis: Vector3;
  50281. /**
  50282. * Creates a new BoneAxesViewer
  50283. * @param scene defines the hosting scene
  50284. * @param bone defines the target bone
  50285. * @param mesh defines the target mesh
  50286. * @param scaleLines defines a scaling factor for line length (1 by default)
  50287. */
  50288. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  50289. /**
  50290. * Force the viewer to update
  50291. */
  50292. update(): void;
  50293. /** Releases resources */
  50294. dispose(): void;
  50295. }
  50296. }
  50297. declare module BABYLON {
  50298. /**
  50299. * Interface used to define scene explorer extensibility option
  50300. */
  50301. export interface IExplorerExtensibilityOption {
  50302. /**
  50303. * Define the option label
  50304. */
  50305. label: string;
  50306. /**
  50307. * Defines the action to execute on click
  50308. */
  50309. action: (entity: any) => void;
  50310. }
  50311. /**
  50312. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  50313. */
  50314. export interface IExplorerExtensibilityGroup {
  50315. /**
  50316. * Defines a predicate to test if a given type mut be extended
  50317. */
  50318. predicate: (entity: any) => boolean;
  50319. /**
  50320. * Gets the list of options added to a type
  50321. */
  50322. entries: IExplorerExtensibilityOption[];
  50323. }
  50324. /**
  50325. * Interface used to define the options to use to create the Inspector
  50326. */
  50327. export interface IInspectorOptions {
  50328. /**
  50329. * Display in overlay mode (default: false)
  50330. */
  50331. overlay?: boolean;
  50332. /**
  50333. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  50334. */
  50335. globalRoot?: HTMLElement;
  50336. /**
  50337. * Display the Scene explorer
  50338. */
  50339. showExplorer?: boolean;
  50340. /**
  50341. * Display the property inspector
  50342. */
  50343. showInspector?: boolean;
  50344. /**
  50345. * Display in embed mode (both panes on the right)
  50346. */
  50347. embedMode?: boolean;
  50348. /**
  50349. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  50350. */
  50351. handleResize?: boolean;
  50352. /**
  50353. * Allow the panes to popup (default: true)
  50354. */
  50355. enablePopup?: boolean;
  50356. /**
  50357. * Allow the panes to be closed by users (default: true)
  50358. */
  50359. enableClose?: boolean;
  50360. /**
  50361. * Optional list of extensibility entries
  50362. */
  50363. explorerExtensibility?: IExplorerExtensibilityGroup[];
  50364. /**
  50365. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  50366. */
  50367. inspectorURL?: string;
  50368. /**
  50369. * Optional initial tab (default to DebugLayerTab.Properties)
  50370. */
  50371. initialTab?: DebugLayerTab;
  50372. }
  50373. interface Scene {
  50374. /**
  50375. * @hidden
  50376. * Backing field
  50377. */
  50378. _debugLayer: DebugLayer;
  50379. /**
  50380. * Gets the debug layer (aka Inspector) associated with the scene
  50381. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50382. */
  50383. debugLayer: DebugLayer;
  50384. }
  50385. /**
  50386. * Enum of inspector action tab
  50387. */
  50388. export enum DebugLayerTab {
  50389. /**
  50390. * Properties tag (default)
  50391. */
  50392. Properties = 0,
  50393. /**
  50394. * Debug tab
  50395. */
  50396. Debug = 1,
  50397. /**
  50398. * Statistics tab
  50399. */
  50400. Statistics = 2,
  50401. /**
  50402. * Tools tab
  50403. */
  50404. Tools = 3,
  50405. /**
  50406. * Settings tab
  50407. */
  50408. Settings = 4
  50409. }
  50410. /**
  50411. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50412. * what is happening in your scene
  50413. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50414. */
  50415. export class DebugLayer {
  50416. /**
  50417. * Define the url to get the inspector script from.
  50418. * By default it uses the babylonjs CDN.
  50419. * @ignoreNaming
  50420. */
  50421. static InspectorURL: string;
  50422. private _scene;
  50423. private BJSINSPECTOR;
  50424. private _onPropertyChangedObservable?;
  50425. /**
  50426. * Observable triggered when a property is changed through the inspector.
  50427. */
  50428. get onPropertyChangedObservable(): any;
  50429. /**
  50430. * Instantiates a new debug layer.
  50431. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50432. * what is happening in your scene
  50433. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50434. * @param scene Defines the scene to inspect
  50435. */
  50436. constructor(scene: Scene);
  50437. /** Creates the inspector window. */
  50438. private _createInspector;
  50439. /**
  50440. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  50441. * @param entity defines the entity to select
  50442. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  50443. */
  50444. select(entity: any, lineContainerTitles?: string | string[]): void;
  50445. /** Get the inspector from bundle or global */
  50446. private _getGlobalInspector;
  50447. /**
  50448. * Get if the inspector is visible or not.
  50449. * @returns true if visible otherwise, false
  50450. */
  50451. isVisible(): boolean;
  50452. /**
  50453. * Hide the inspector and close its window.
  50454. */
  50455. hide(): void;
  50456. /**
  50457. * Update the scene in the inspector
  50458. */
  50459. setAsActiveScene(): void;
  50460. /**
  50461. * Launch the debugLayer.
  50462. * @param config Define the configuration of the inspector
  50463. * @return a promise fulfilled when the debug layer is visible
  50464. */
  50465. show(config?: IInspectorOptions): Promise<DebugLayer>;
  50466. }
  50467. }
  50468. declare module BABYLON {
  50469. /**
  50470. * Class containing static functions to help procedurally build meshes
  50471. */
  50472. export class BoxBuilder {
  50473. /**
  50474. * Creates a box mesh
  50475. * * The parameter `size` sets the size (float) of each box side (default 1)
  50476. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50477. * * 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)
  50478. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50479. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50480. * * 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
  50481. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50482. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50483. * @param name defines the name of the mesh
  50484. * @param options defines the options used to create the mesh
  50485. * @param scene defines the hosting scene
  50486. * @returns the box mesh
  50487. */
  50488. static CreateBox(name: string, options: {
  50489. size?: number;
  50490. width?: number;
  50491. height?: number;
  50492. depth?: number;
  50493. faceUV?: Vector4[];
  50494. faceColors?: Color4[];
  50495. sideOrientation?: number;
  50496. frontUVs?: Vector4;
  50497. backUVs?: Vector4;
  50498. wrap?: boolean;
  50499. topBaseAt?: number;
  50500. bottomBaseAt?: number;
  50501. updatable?: boolean;
  50502. }, scene?: Nullable<Scene>): Mesh;
  50503. }
  50504. }
  50505. declare module BABYLON.Debug {
  50506. /**
  50507. * Used to show the physics impostor around the specific mesh
  50508. */
  50509. export class PhysicsViewer {
  50510. /** @hidden */
  50511. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  50512. /** @hidden */
  50513. protected _meshes: Array<Nullable<AbstractMesh>>;
  50514. /** @hidden */
  50515. protected _scene: Nullable<Scene>;
  50516. /** @hidden */
  50517. protected _numMeshes: number;
  50518. /** @hidden */
  50519. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  50520. private _renderFunction;
  50521. private _utilityLayer;
  50522. private _debugBoxMesh;
  50523. private _debugSphereMesh;
  50524. private _debugCylinderMesh;
  50525. private _debugMaterial;
  50526. private _debugMeshMeshes;
  50527. /**
  50528. * Creates a new PhysicsViewer
  50529. * @param scene defines the hosting scene
  50530. */
  50531. constructor(scene: Scene);
  50532. /** @hidden */
  50533. protected _updateDebugMeshes(): void;
  50534. /**
  50535. * Renders a specified physic impostor
  50536. * @param impostor defines the impostor to render
  50537. * @param targetMesh defines the mesh represented by the impostor
  50538. * @returns the new debug mesh used to render the impostor
  50539. */
  50540. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  50541. /**
  50542. * Hides a specified physic impostor
  50543. * @param impostor defines the impostor to hide
  50544. */
  50545. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  50546. private _getDebugMaterial;
  50547. private _getDebugBoxMesh;
  50548. private _getDebugSphereMesh;
  50549. private _getDebugCylinderMesh;
  50550. private _getDebugMeshMesh;
  50551. private _getDebugMesh;
  50552. /** Releases all resources */
  50553. dispose(): void;
  50554. }
  50555. }
  50556. declare module BABYLON {
  50557. /**
  50558. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50559. * in order to better appreciate the issue one might have.
  50560. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50561. */
  50562. export class RayHelper {
  50563. /**
  50564. * Defines the ray we are currently tryin to visualize.
  50565. */
  50566. ray: Nullable<Ray>;
  50567. private _renderPoints;
  50568. private _renderLine;
  50569. private _renderFunction;
  50570. private _scene;
  50571. private _updateToMeshFunction;
  50572. private _attachedToMesh;
  50573. private _meshSpaceDirection;
  50574. private _meshSpaceOrigin;
  50575. /**
  50576. * Helper function to create a colored helper in a scene in one line.
  50577. * @param ray Defines the ray we are currently tryin to visualize
  50578. * @param scene Defines the scene the ray is used in
  50579. * @param color Defines the color we want to see the ray in
  50580. * @returns The newly created ray helper.
  50581. */
  50582. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  50583. /**
  50584. * Instantiate a new ray helper.
  50585. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50586. * in order to better appreciate the issue one might have.
  50587. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50588. * @param ray Defines the ray we are currently tryin to visualize
  50589. */
  50590. constructor(ray: Ray);
  50591. /**
  50592. * Shows the ray we are willing to debug.
  50593. * @param scene Defines the scene the ray needs to be rendered in
  50594. * @param color Defines the color the ray needs to be rendered in
  50595. */
  50596. show(scene: Scene, color?: Color3): void;
  50597. /**
  50598. * Hides the ray we are debugging.
  50599. */
  50600. hide(): void;
  50601. private _render;
  50602. /**
  50603. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  50604. * @param mesh Defines the mesh we want the helper attached to
  50605. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  50606. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  50607. * @param length Defines the length of the ray
  50608. */
  50609. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  50610. /**
  50611. * Detach the ray helper from the mesh it has previously been attached to.
  50612. */
  50613. detachFromMesh(): void;
  50614. private _updateToMesh;
  50615. /**
  50616. * Dispose the helper and release its associated resources.
  50617. */
  50618. dispose(): void;
  50619. }
  50620. }
  50621. declare module BABYLON.Debug {
  50622. /**
  50623. * Class used to render a debug view of a given skeleton
  50624. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  50625. */
  50626. export class SkeletonViewer {
  50627. /** defines the skeleton to render */
  50628. skeleton: Skeleton;
  50629. /** defines the mesh attached to the skeleton */
  50630. mesh: AbstractMesh;
  50631. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  50632. autoUpdateBonesMatrices: boolean;
  50633. /** defines the rendering group id to use with the viewer */
  50634. renderingGroupId: number;
  50635. /** Gets or sets the color used to render the skeleton */
  50636. color: Color3;
  50637. private _scene;
  50638. private _debugLines;
  50639. private _debugMesh;
  50640. private _isEnabled;
  50641. private _renderFunction;
  50642. private _utilityLayer;
  50643. /**
  50644. * Returns the mesh used to render the bones
  50645. */
  50646. get debugMesh(): Nullable<LinesMesh>;
  50647. /**
  50648. * Creates a new SkeletonViewer
  50649. * @param skeleton defines the skeleton to render
  50650. * @param mesh defines the mesh attached to the skeleton
  50651. * @param scene defines the hosting scene
  50652. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  50653. * @param renderingGroupId defines the rendering group id to use with the viewer
  50654. */
  50655. constructor(
  50656. /** defines the skeleton to render */
  50657. skeleton: Skeleton,
  50658. /** defines the mesh attached to the skeleton */
  50659. mesh: AbstractMesh, scene: Scene,
  50660. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  50661. autoUpdateBonesMatrices?: boolean,
  50662. /** defines the rendering group id to use with the viewer */
  50663. renderingGroupId?: number);
  50664. /** Gets or sets a boolean indicating if the viewer is enabled */
  50665. set isEnabled(value: boolean);
  50666. get isEnabled(): boolean;
  50667. private _getBonePosition;
  50668. private _getLinesForBonesWithLength;
  50669. private _getLinesForBonesNoLength;
  50670. /** Update the viewer to sync with current skeleton state */
  50671. update(): void;
  50672. /** Release associated resources */
  50673. dispose(): void;
  50674. }
  50675. }
  50676. declare module BABYLON {
  50677. /**
  50678. * Enum for Device Types
  50679. */
  50680. export enum DeviceType {
  50681. /** Generic */
  50682. Generic = 0,
  50683. /** Keyboard */
  50684. Keyboard = 1,
  50685. /** Mouse */
  50686. Mouse = 2,
  50687. /** Touch Pointers */
  50688. Touch = 3,
  50689. /** PS4 Dual Shock */
  50690. DualShock = 4,
  50691. /** Xbox */
  50692. Xbox = 5,
  50693. /** Switch Controller */
  50694. Switch = 6
  50695. }
  50696. /**
  50697. * Enum for All Pointers (Touch/Mouse)
  50698. */
  50699. export enum PointerInput {
  50700. /** Horizontal Axis */
  50701. Horizontal = 0,
  50702. /** Vertical Axis */
  50703. Vertical = 1,
  50704. /** Left Click or Touch */
  50705. LeftClick = 2,
  50706. /** Middle Click */
  50707. MiddleClick = 3,
  50708. /** Right Click */
  50709. RightClick = 4,
  50710. /** Browser Back */
  50711. BrowserBack = 5,
  50712. /** Browser Forward */
  50713. BrowserForward = 6
  50714. }
  50715. /**
  50716. * Enum for Dual Shock Gamepad
  50717. */
  50718. export enum DualShockInput {
  50719. /** Cross */
  50720. Cross = 0,
  50721. /** Circle */
  50722. Circle = 1,
  50723. /** Square */
  50724. Square = 2,
  50725. /** Triangle */
  50726. Triangle = 3,
  50727. /** L1 */
  50728. L1 = 4,
  50729. /** R1 */
  50730. R1 = 5,
  50731. /** L2 */
  50732. L2 = 6,
  50733. /** R2 */
  50734. R2 = 7,
  50735. /** Share */
  50736. Share = 8,
  50737. /** Options */
  50738. Options = 9,
  50739. /** L3 */
  50740. L3 = 10,
  50741. /** R3 */
  50742. R3 = 11,
  50743. /** DPadUp */
  50744. DPadUp = 12,
  50745. /** DPadDown */
  50746. DPadDown = 13,
  50747. /** DPadLeft */
  50748. DPadLeft = 14,
  50749. /** DRight */
  50750. DPadRight = 15,
  50751. /** Home */
  50752. Home = 16,
  50753. /** TouchPad */
  50754. TouchPad = 17,
  50755. /** LStickXAxis */
  50756. LStickXAxis = 18,
  50757. /** LStickYAxis */
  50758. LStickYAxis = 19,
  50759. /** RStickXAxis */
  50760. RStickXAxis = 20,
  50761. /** RStickYAxis */
  50762. RStickYAxis = 21
  50763. }
  50764. /**
  50765. * Enum for Xbox Gamepad
  50766. */
  50767. export enum XboxInput {
  50768. /** A */
  50769. A = 0,
  50770. /** B */
  50771. B = 1,
  50772. /** X */
  50773. X = 2,
  50774. /** Y */
  50775. Y = 3,
  50776. /** LB */
  50777. LB = 4,
  50778. /** RB */
  50779. RB = 5,
  50780. /** LT */
  50781. LT = 6,
  50782. /** RT */
  50783. RT = 7,
  50784. /** Back */
  50785. Back = 8,
  50786. /** Start */
  50787. Start = 9,
  50788. /** LS */
  50789. LS = 10,
  50790. /** RS */
  50791. RS = 11,
  50792. /** DPadUp */
  50793. DPadUp = 12,
  50794. /** DPadDown */
  50795. DPadDown = 13,
  50796. /** DPadLeft */
  50797. DPadLeft = 14,
  50798. /** DRight */
  50799. DPadRight = 15,
  50800. /** Home */
  50801. Home = 16,
  50802. /** LStickXAxis */
  50803. LStickXAxis = 17,
  50804. /** LStickYAxis */
  50805. LStickYAxis = 18,
  50806. /** RStickXAxis */
  50807. RStickXAxis = 19,
  50808. /** RStickYAxis */
  50809. RStickYAxis = 20
  50810. }
  50811. /**
  50812. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  50813. */
  50814. export enum SwitchInput {
  50815. /** B */
  50816. B = 0,
  50817. /** A */
  50818. A = 1,
  50819. /** Y */
  50820. Y = 2,
  50821. /** X */
  50822. X = 3,
  50823. /** L */
  50824. L = 4,
  50825. /** R */
  50826. R = 5,
  50827. /** ZL */
  50828. ZL = 6,
  50829. /** ZR */
  50830. ZR = 7,
  50831. /** Minus */
  50832. Minus = 8,
  50833. /** Plus */
  50834. Plus = 9,
  50835. /** LS */
  50836. LS = 10,
  50837. /** RS */
  50838. RS = 11,
  50839. /** DPadUp */
  50840. DPadUp = 12,
  50841. /** DPadDown */
  50842. DPadDown = 13,
  50843. /** DPadLeft */
  50844. DPadLeft = 14,
  50845. /** DRight */
  50846. DPadRight = 15,
  50847. /** Home */
  50848. Home = 16,
  50849. /** Capture */
  50850. Capture = 17,
  50851. /** LStickXAxis */
  50852. LStickXAxis = 18,
  50853. /** LStickYAxis */
  50854. LStickYAxis = 19,
  50855. /** RStickXAxis */
  50856. RStickXAxis = 20,
  50857. /** RStickYAxis */
  50858. RStickYAxis = 21
  50859. }
  50860. }
  50861. declare module BABYLON {
  50862. /**
  50863. * This class will take all inputs from Keyboard, Pointer, and
  50864. * any Gamepads and provide a polling system that all devices
  50865. * will use. This class assumes that there will only be one
  50866. * pointer device and one keyboard.
  50867. */
  50868. export class DeviceInputSystem implements IDisposable {
  50869. /**
  50870. * Callback to be triggered when a device is connected
  50871. */
  50872. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  50873. /**
  50874. * Callback to be triggered when a device is disconnected
  50875. */
  50876. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  50877. /**
  50878. * Callback to be triggered when event driven input is updated
  50879. */
  50880. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  50881. private _inputs;
  50882. private _gamepads;
  50883. private _keyboardActive;
  50884. private _pointerActive;
  50885. private _elementToAttachTo;
  50886. private _keyboardDownEvent;
  50887. private _keyboardUpEvent;
  50888. private _pointerMoveEvent;
  50889. private _pointerDownEvent;
  50890. private _pointerUpEvent;
  50891. private _gamepadConnectedEvent;
  50892. private _gamepadDisconnectedEvent;
  50893. private static _MAX_KEYCODES;
  50894. private static _MAX_POINTER_INPUTS;
  50895. private constructor();
  50896. /**
  50897. * Creates a new DeviceInputSystem instance
  50898. * @param engine Engine to pull input element from
  50899. * @returns The new instance
  50900. */
  50901. static Create(engine: Engine): DeviceInputSystem;
  50902. /**
  50903. * Checks for current device input value, given an id and input index
  50904. * @param deviceName Id of connected device
  50905. * @param inputIndex Index of device input
  50906. * @returns Current value of input
  50907. */
  50908. /**
  50909. * Checks for current device input value, given an id and input index
  50910. * @param deviceType Enum specifiying device type
  50911. * @param deviceSlot "Slot" or index that device is referenced in
  50912. * @param inputIndex Id of input to be checked
  50913. * @returns Current value of input
  50914. */
  50915. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  50916. /**
  50917. * Dispose of all the eventlisteners
  50918. */
  50919. dispose(): void;
  50920. /**
  50921. * Add device and inputs to device array
  50922. * @param deviceType Enum specifiying device type
  50923. * @param deviceSlot "Slot" or index that device is referenced in
  50924. * @param numberOfInputs Number of input entries to create for given device
  50925. */
  50926. private _registerDevice;
  50927. /**
  50928. * Given a specific device name, remove that device from the device map
  50929. * @param deviceType Enum specifiying device type
  50930. * @param deviceSlot "Slot" or index that device is referenced in
  50931. */
  50932. private _unregisterDevice;
  50933. /**
  50934. * Handle all actions that come from keyboard interaction
  50935. */
  50936. private _handleKeyActions;
  50937. /**
  50938. * Handle all actions that come from pointer interaction
  50939. */
  50940. private _handlePointerActions;
  50941. /**
  50942. * Handle all actions that come from gamepad interaction
  50943. */
  50944. private _handleGamepadActions;
  50945. /**
  50946. * Update all non-event based devices with each frame
  50947. * @param deviceType Enum specifiying device type
  50948. * @param deviceSlot "Slot" or index that device is referenced in
  50949. * @param inputIndex Id of input to be checked
  50950. */
  50951. private _updateDevice;
  50952. /**
  50953. * Gets DeviceType from the device name
  50954. * @param deviceName Name of Device from DeviceInputSystem
  50955. * @returns DeviceType enum value
  50956. */
  50957. private _getGamepadDeviceType;
  50958. }
  50959. }
  50960. declare module BABYLON {
  50961. /**
  50962. * Type to handle enforcement of inputs
  50963. */
  50964. 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;
  50965. }
  50966. declare module BABYLON {
  50967. /**
  50968. * Class that handles all input for a specific device
  50969. */
  50970. export class DeviceSource<T extends DeviceType> {
  50971. /** Type of device */
  50972. readonly deviceType: DeviceType;
  50973. /** "Slot" or index that device is referenced in */
  50974. readonly deviceSlot: number;
  50975. /**
  50976. * Observable to handle device input changes per device
  50977. */
  50978. readonly onInputChangedObservable: Observable<{
  50979. inputIndex: DeviceInput<T>;
  50980. previousState: Nullable<number>;
  50981. currentState: Nullable<number>;
  50982. }>;
  50983. private readonly _deviceInputSystem;
  50984. /**
  50985. * Default Constructor
  50986. * @param deviceInputSystem Reference to DeviceInputSystem
  50987. * @param deviceType Type of device
  50988. * @param deviceSlot "Slot" or index that device is referenced in
  50989. */
  50990. constructor(deviceInputSystem: DeviceInputSystem,
  50991. /** Type of device */
  50992. deviceType: DeviceType,
  50993. /** "Slot" or index that device is referenced in */
  50994. deviceSlot?: number);
  50995. /**
  50996. * Get input for specific input
  50997. * @param inputIndex index of specific input on device
  50998. * @returns Input value from DeviceInputSystem
  50999. */
  51000. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  51001. }
  51002. /**
  51003. * Class to keep track of devices
  51004. */
  51005. export class DeviceSourceManager implements IDisposable {
  51006. /**
  51007. * Observable to be triggered when before a device is connected
  51008. */
  51009. readonly onBeforeDeviceConnectedObservable: Observable<{
  51010. deviceType: DeviceType;
  51011. deviceSlot: number;
  51012. }>;
  51013. /**
  51014. * Observable to be triggered when before a device is disconnected
  51015. */
  51016. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  51017. deviceType: DeviceType;
  51018. deviceSlot: number;
  51019. }>;
  51020. /**
  51021. * Observable to be triggered when after a device is connected
  51022. */
  51023. readonly onAfterDeviceConnectedObservable: Observable<{
  51024. deviceType: DeviceType;
  51025. deviceSlot: number;
  51026. }>;
  51027. /**
  51028. * Observable to be triggered when after a device is disconnected
  51029. */
  51030. readonly onAfterDeviceDisconnectedObservable: Observable<{
  51031. deviceType: DeviceType;
  51032. deviceSlot: number;
  51033. }>;
  51034. private readonly _devices;
  51035. private readonly _firstDevice;
  51036. private readonly _deviceInputSystem;
  51037. /**
  51038. * Default Constructor
  51039. * @param engine engine to pull input element from
  51040. */
  51041. constructor(engine: Engine);
  51042. /**
  51043. * Gets a DeviceSource, given a type and slot
  51044. * @param deviceType Enum specifying device type
  51045. * @param deviceSlot "Slot" or index that device is referenced in
  51046. * @returns DeviceSource object
  51047. */
  51048. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  51049. /**
  51050. * Gets an array of DeviceSource objects for a given device type
  51051. * @param deviceType Enum specifying device type
  51052. * @returns Array of DeviceSource objects
  51053. */
  51054. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  51055. /**
  51056. * Dispose of DeviceInputSystem and other parts
  51057. */
  51058. dispose(): void;
  51059. /**
  51060. * Function to add device name to device list
  51061. * @param deviceType Enum specifying device type
  51062. * @param deviceSlot "Slot" or index that device is referenced in
  51063. */
  51064. private _addDevice;
  51065. /**
  51066. * Function to remove device name to device list
  51067. * @param deviceType Enum specifying device type
  51068. * @param deviceSlot "Slot" or index that device is referenced in
  51069. */
  51070. private _removeDevice;
  51071. /**
  51072. * Updates array storing first connected device of each type
  51073. * @param type Type of Device
  51074. */
  51075. private _updateFirstDevices;
  51076. }
  51077. }
  51078. declare module BABYLON {
  51079. /**
  51080. * Options to create the null engine
  51081. */
  51082. export class NullEngineOptions {
  51083. /**
  51084. * Render width (Default: 512)
  51085. */
  51086. renderWidth: number;
  51087. /**
  51088. * Render height (Default: 256)
  51089. */
  51090. renderHeight: number;
  51091. /**
  51092. * Texture size (Default: 512)
  51093. */
  51094. textureSize: number;
  51095. /**
  51096. * If delta time between frames should be constant
  51097. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51098. */
  51099. deterministicLockstep: boolean;
  51100. /**
  51101. * Maximum about of steps between frames (Default: 4)
  51102. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51103. */
  51104. lockstepMaxSteps: number;
  51105. /**
  51106. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  51107. */
  51108. useHighPrecisionMatrix?: boolean;
  51109. }
  51110. /**
  51111. * The null engine class provides support for headless version of babylon.js.
  51112. * This can be used in server side scenario or for testing purposes
  51113. */
  51114. export class NullEngine extends Engine {
  51115. private _options;
  51116. /**
  51117. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  51118. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51119. * @returns true if engine is in deterministic lock step mode
  51120. */
  51121. isDeterministicLockStep(): boolean;
  51122. /**
  51123. * Gets the max steps when engine is running in deterministic lock step
  51124. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51125. * @returns the max steps
  51126. */
  51127. getLockstepMaxSteps(): number;
  51128. /**
  51129. * Gets the current hardware scaling level.
  51130. * By default the hardware scaling level is computed from the window device ratio.
  51131. * 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.
  51132. * @returns a number indicating the current hardware scaling level
  51133. */
  51134. getHardwareScalingLevel(): number;
  51135. constructor(options?: NullEngineOptions);
  51136. /**
  51137. * Creates a vertex buffer
  51138. * @param vertices the data for the vertex buffer
  51139. * @returns the new WebGL static buffer
  51140. */
  51141. createVertexBuffer(vertices: FloatArray): DataBuffer;
  51142. /**
  51143. * Creates a new index buffer
  51144. * @param indices defines the content of the index buffer
  51145. * @param updatable defines if the index buffer must be updatable
  51146. * @returns a new webGL buffer
  51147. */
  51148. createIndexBuffer(indices: IndicesArray): DataBuffer;
  51149. /**
  51150. * Clear the current render buffer or the current render target (if any is set up)
  51151. * @param color defines the color to use
  51152. * @param backBuffer defines if the back buffer must be cleared
  51153. * @param depth defines if the depth buffer must be cleared
  51154. * @param stencil defines if the stencil buffer must be cleared
  51155. */
  51156. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51157. /**
  51158. * Gets the current render width
  51159. * @param useScreen defines if screen size must be used (or the current render target if any)
  51160. * @returns a number defining the current render width
  51161. */
  51162. getRenderWidth(useScreen?: boolean): number;
  51163. /**
  51164. * Gets the current render height
  51165. * @param useScreen defines if screen size must be used (or the current render target if any)
  51166. * @returns a number defining the current render height
  51167. */
  51168. getRenderHeight(useScreen?: boolean): number;
  51169. /**
  51170. * Set the WebGL's viewport
  51171. * @param viewport defines the viewport element to be used
  51172. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  51173. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  51174. */
  51175. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  51176. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  51177. /**
  51178. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  51179. * @param pipelineContext defines the pipeline context to use
  51180. * @param uniformsNames defines the list of uniform names
  51181. * @returns an array of webGL uniform locations
  51182. */
  51183. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  51184. /**
  51185. * Gets the lsit of active attributes for a given webGL program
  51186. * @param pipelineContext defines the pipeline context to use
  51187. * @param attributesNames defines the list of attribute names to get
  51188. * @returns an array of indices indicating the offset of each attribute
  51189. */
  51190. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51191. /**
  51192. * Binds an effect to the webGL context
  51193. * @param effect defines the effect to bind
  51194. */
  51195. bindSamplers(effect: Effect): void;
  51196. /**
  51197. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  51198. * @param effect defines the effect to activate
  51199. */
  51200. enableEffect(effect: Effect): void;
  51201. /**
  51202. * Set various states to the webGL context
  51203. * @param culling defines backface culling state
  51204. * @param zOffset defines the value to apply to zOffset (0 by default)
  51205. * @param force defines if states must be applied even if cache is up to date
  51206. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  51207. */
  51208. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51209. /**
  51210. * Set the value of an uniform to an array of int32
  51211. * @param uniform defines the webGL uniform location where to store the value
  51212. * @param array defines the array of int32 to store
  51213. */
  51214. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51215. /**
  51216. * Set the value of an uniform to an array of int32 (stored as vec2)
  51217. * @param uniform defines the webGL uniform location where to store the value
  51218. * @param array defines the array of int32 to store
  51219. */
  51220. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51221. /**
  51222. * Set the value of an uniform to an array of int32 (stored as vec3)
  51223. * @param uniform defines the webGL uniform location where to store the value
  51224. * @param array defines the array of int32 to store
  51225. */
  51226. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51227. /**
  51228. * Set the value of an uniform to an array of int32 (stored as vec4)
  51229. * @param uniform defines the webGL uniform location where to store the value
  51230. * @param array defines the array of int32 to store
  51231. */
  51232. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51233. /**
  51234. * Set the value of an uniform to an array of float32
  51235. * @param uniform defines the webGL uniform location where to store the value
  51236. * @param array defines the array of float32 to store
  51237. */
  51238. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51239. /**
  51240. * Set the value of an uniform to an array of float32 (stored as vec2)
  51241. * @param uniform defines the webGL uniform location where to store the value
  51242. * @param array defines the array of float32 to store
  51243. */
  51244. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51245. /**
  51246. * Set the value of an uniform to an array of float32 (stored as vec3)
  51247. * @param uniform defines the webGL uniform location where to store the value
  51248. * @param array defines the array of float32 to store
  51249. */
  51250. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51251. /**
  51252. * Set the value of an uniform to an array of float32 (stored as vec4)
  51253. * @param uniform defines the webGL uniform location where to store the value
  51254. * @param array defines the array of float32 to store
  51255. */
  51256. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51257. /**
  51258. * Set the value of an uniform to an array of number
  51259. * @param uniform defines the webGL uniform location where to store the value
  51260. * @param array defines the array of number to store
  51261. */
  51262. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51263. /**
  51264. * Set the value of an uniform to an array of number (stored as vec2)
  51265. * @param uniform defines the webGL uniform location where to store the value
  51266. * @param array defines the array of number to store
  51267. */
  51268. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51269. /**
  51270. * Set the value of an uniform to an array of number (stored as vec3)
  51271. * @param uniform defines the webGL uniform location where to store the value
  51272. * @param array defines the array of number to store
  51273. */
  51274. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51275. /**
  51276. * Set the value of an uniform to an array of number (stored as vec4)
  51277. * @param uniform defines the webGL uniform location where to store the value
  51278. * @param array defines the array of number to store
  51279. */
  51280. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51281. /**
  51282. * Set the value of an uniform to an array of float32 (stored as matrices)
  51283. * @param uniform defines the webGL uniform location where to store the value
  51284. * @param matrices defines the array of float32 to store
  51285. */
  51286. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  51287. /**
  51288. * Set the value of an uniform to a matrix (3x3)
  51289. * @param uniform defines the webGL uniform location where to store the value
  51290. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  51291. */
  51292. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51293. /**
  51294. * Set the value of an uniform to a matrix (2x2)
  51295. * @param uniform defines the webGL uniform location where to store the value
  51296. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  51297. */
  51298. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51299. /**
  51300. * Set the value of an uniform to a number (float)
  51301. * @param uniform defines the webGL uniform location where to store the value
  51302. * @param value defines the float number to store
  51303. */
  51304. setFloat(uniform: WebGLUniformLocation, value: number): void;
  51305. /**
  51306. * Set the value of an uniform to a vec2
  51307. * @param uniform defines the webGL uniform location where to store the value
  51308. * @param x defines the 1st component of the value
  51309. * @param y defines the 2nd component of the value
  51310. */
  51311. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  51312. /**
  51313. * Set the value of an uniform to a vec3
  51314. * @param uniform defines the webGL uniform location where to store the value
  51315. * @param x defines the 1st component of the value
  51316. * @param y defines the 2nd component of the value
  51317. * @param z defines the 3rd component of the value
  51318. */
  51319. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  51320. /**
  51321. * Set the value of an uniform to a boolean
  51322. * @param uniform defines the webGL uniform location where to store the value
  51323. * @param bool defines the boolean to store
  51324. */
  51325. setBool(uniform: WebGLUniformLocation, bool: number): void;
  51326. /**
  51327. * Set the value of an uniform to a vec4
  51328. * @param uniform defines the webGL uniform location where to store the value
  51329. * @param x defines the 1st component of the value
  51330. * @param y defines the 2nd component of the value
  51331. * @param z defines the 3rd component of the value
  51332. * @param w defines the 4th component of the value
  51333. */
  51334. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  51335. /**
  51336. * Sets the current alpha mode
  51337. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  51338. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  51339. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51340. */
  51341. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  51342. /**
  51343. * Bind webGl buffers directly to the webGL context
  51344. * @param vertexBuffers defines the vertex buffer to bind
  51345. * @param indexBuffer defines the index buffer to bind
  51346. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  51347. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  51348. * @param effect defines the effect associated with the vertex buffer
  51349. */
  51350. bindBuffers(vertexBuffers: {
  51351. [key: string]: VertexBuffer;
  51352. }, indexBuffer: DataBuffer, effect: Effect): void;
  51353. /**
  51354. * Force the entire cache to be cleared
  51355. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  51356. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  51357. */
  51358. wipeCaches(bruteForce?: boolean): void;
  51359. /**
  51360. * Send a draw order
  51361. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  51362. * @param indexStart defines the starting index
  51363. * @param indexCount defines the number of index to draw
  51364. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51365. */
  51366. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  51367. /**
  51368. * Draw a list of indexed primitives
  51369. * @param fillMode defines the primitive to use
  51370. * @param indexStart defines the starting index
  51371. * @param indexCount defines the number of index to draw
  51372. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51373. */
  51374. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  51375. /**
  51376. * Draw a list of unindexed primitives
  51377. * @param fillMode defines the primitive to use
  51378. * @param verticesStart defines the index of first vertex to draw
  51379. * @param verticesCount defines the count of vertices to draw
  51380. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51381. */
  51382. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  51383. /** @hidden */
  51384. _createTexture(): WebGLTexture;
  51385. /** @hidden */
  51386. _releaseTexture(texture: InternalTexture): void;
  51387. /**
  51388. * Usually called from Texture.ts.
  51389. * Passed information to create a WebGLTexture
  51390. * @param urlArg defines a value which contains one of the following:
  51391. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  51392. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  51393. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  51394. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  51395. * @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)
  51396. * @param scene needed for loading to the correct scene
  51397. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  51398. * @param onLoad optional callback to be called upon successful completion
  51399. * @param onError optional callback to be called upon failure
  51400. * @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
  51401. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  51402. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  51403. * @param forcedExtension defines the extension to use to pick the right loader
  51404. * @param mimeType defines an optional mime type
  51405. * @returns a InternalTexture for assignment back into BABYLON.Texture
  51406. */
  51407. 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;
  51408. /**
  51409. * Creates a new render target texture
  51410. * @param size defines the size of the texture
  51411. * @param options defines the options used to create the texture
  51412. * @returns a new render target texture stored in an InternalTexture
  51413. */
  51414. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  51415. /**
  51416. * Update the sampling mode of a given texture
  51417. * @param samplingMode defines the required sampling mode
  51418. * @param texture defines the texture to update
  51419. */
  51420. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  51421. /**
  51422. * Binds the frame buffer to the specified texture.
  51423. * @param texture The texture to render to or null for the default canvas
  51424. * @param faceIndex The face of the texture to render to in case of cube texture
  51425. * @param requiredWidth The width of the target to render to
  51426. * @param requiredHeight The height of the target to render to
  51427. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  51428. * @param lodLevel defines le lod level to bind to the frame buffer
  51429. */
  51430. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  51431. /**
  51432. * Unbind the current render target texture from the webGL context
  51433. * @param texture defines the render target texture to unbind
  51434. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  51435. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  51436. */
  51437. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  51438. /**
  51439. * Creates a dynamic vertex buffer
  51440. * @param vertices the data for the dynamic vertex buffer
  51441. * @returns the new WebGL dynamic buffer
  51442. */
  51443. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  51444. /**
  51445. * Update the content of a dynamic texture
  51446. * @param texture defines the texture to update
  51447. * @param canvas defines the canvas containing the source
  51448. * @param invertY defines if data must be stored with Y axis inverted
  51449. * @param premulAlpha defines if alpha is stored as premultiplied
  51450. * @param format defines the format of the data
  51451. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  51452. */
  51453. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  51454. /**
  51455. * Gets a boolean indicating if all created effects are ready
  51456. * @returns true if all effects are ready
  51457. */
  51458. areAllEffectsReady(): boolean;
  51459. /**
  51460. * @hidden
  51461. * Get the current error code of the webGL context
  51462. * @returns the error code
  51463. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  51464. */
  51465. getError(): number;
  51466. /** @hidden */
  51467. _getUnpackAlignement(): number;
  51468. /** @hidden */
  51469. _unpackFlipY(value: boolean): void;
  51470. /**
  51471. * Update a dynamic index buffer
  51472. * @param indexBuffer defines the target index buffer
  51473. * @param indices defines the data to update
  51474. * @param offset defines the offset in the target index buffer where update should start
  51475. */
  51476. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  51477. /**
  51478. * Updates a dynamic vertex buffer.
  51479. * @param vertexBuffer the vertex buffer to update
  51480. * @param vertices the data used to update the vertex buffer
  51481. * @param byteOffset the byte offset of the data (optional)
  51482. * @param byteLength the byte length of the data (optional)
  51483. */
  51484. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  51485. /** @hidden */
  51486. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  51487. /** @hidden */
  51488. _bindTexture(channel: number, texture: InternalTexture): void;
  51489. protected _deleteBuffer(buffer: WebGLBuffer): void;
  51490. /**
  51491. * 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
  51492. */
  51493. releaseEffects(): void;
  51494. displayLoadingUI(): void;
  51495. hideLoadingUI(): void;
  51496. /** @hidden */
  51497. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51498. /** @hidden */
  51499. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51500. /** @hidden */
  51501. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51502. /** @hidden */
  51503. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  51504. }
  51505. }
  51506. declare module BABYLON {
  51507. /**
  51508. * @hidden
  51509. **/
  51510. export class _TimeToken {
  51511. _startTimeQuery: Nullable<WebGLQuery>;
  51512. _endTimeQuery: Nullable<WebGLQuery>;
  51513. _timeElapsedQuery: Nullable<WebGLQuery>;
  51514. _timeElapsedQueryEnded: boolean;
  51515. }
  51516. }
  51517. declare module BABYLON {
  51518. /** @hidden */
  51519. export class _OcclusionDataStorage {
  51520. /** @hidden */
  51521. occlusionInternalRetryCounter: number;
  51522. /** @hidden */
  51523. isOcclusionQueryInProgress: boolean;
  51524. /** @hidden */
  51525. isOccluded: boolean;
  51526. /** @hidden */
  51527. occlusionRetryCount: number;
  51528. /** @hidden */
  51529. occlusionType: number;
  51530. /** @hidden */
  51531. occlusionQueryAlgorithmType: number;
  51532. }
  51533. interface Engine {
  51534. /**
  51535. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  51536. * @return the new query
  51537. */
  51538. createQuery(): WebGLQuery;
  51539. /**
  51540. * Delete and release a webGL query
  51541. * @param query defines the query to delete
  51542. * @return the current engine
  51543. */
  51544. deleteQuery(query: WebGLQuery): Engine;
  51545. /**
  51546. * Check if a given query has resolved and got its value
  51547. * @param query defines the query to check
  51548. * @returns true if the query got its value
  51549. */
  51550. isQueryResultAvailable(query: WebGLQuery): boolean;
  51551. /**
  51552. * Gets the value of a given query
  51553. * @param query defines the query to check
  51554. * @returns the value of the query
  51555. */
  51556. getQueryResult(query: WebGLQuery): number;
  51557. /**
  51558. * Initiates an occlusion query
  51559. * @param algorithmType defines the algorithm to use
  51560. * @param query defines the query to use
  51561. * @returns the current engine
  51562. * @see https://doc.babylonjs.com/features/occlusionquery
  51563. */
  51564. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  51565. /**
  51566. * Ends an occlusion query
  51567. * @see https://doc.babylonjs.com/features/occlusionquery
  51568. * @param algorithmType defines the algorithm to use
  51569. * @returns the current engine
  51570. */
  51571. endOcclusionQuery(algorithmType: number): Engine;
  51572. /**
  51573. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  51574. * Please note that only one query can be issued at a time
  51575. * @returns a time token used to track the time span
  51576. */
  51577. startTimeQuery(): Nullable<_TimeToken>;
  51578. /**
  51579. * Ends a time query
  51580. * @param token defines the token used to measure the time span
  51581. * @returns the time spent (in ns)
  51582. */
  51583. endTimeQuery(token: _TimeToken): int;
  51584. /** @hidden */
  51585. _currentNonTimestampToken: Nullable<_TimeToken>;
  51586. /** @hidden */
  51587. _createTimeQuery(): WebGLQuery;
  51588. /** @hidden */
  51589. _deleteTimeQuery(query: WebGLQuery): void;
  51590. /** @hidden */
  51591. _getGlAlgorithmType(algorithmType: number): number;
  51592. /** @hidden */
  51593. _getTimeQueryResult(query: WebGLQuery): any;
  51594. /** @hidden */
  51595. _getTimeQueryAvailability(query: WebGLQuery): any;
  51596. }
  51597. interface AbstractMesh {
  51598. /**
  51599. * Backing filed
  51600. * @hidden
  51601. */
  51602. __occlusionDataStorage: _OcclusionDataStorage;
  51603. /**
  51604. * Access property
  51605. * @hidden
  51606. */
  51607. _occlusionDataStorage: _OcclusionDataStorage;
  51608. /**
  51609. * 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.
  51610. * The default value is -1 which means don't break the query and wait till the result
  51611. * @see https://doc.babylonjs.com/features/occlusionquery
  51612. */
  51613. occlusionRetryCount: number;
  51614. /**
  51615. * 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:
  51616. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  51617. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  51618. * * 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.
  51619. * @see https://doc.babylonjs.com/features/occlusionquery
  51620. */
  51621. occlusionType: number;
  51622. /**
  51623. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  51624. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  51625. * * 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.
  51626. * @see https://doc.babylonjs.com/features/occlusionquery
  51627. */
  51628. occlusionQueryAlgorithmType: number;
  51629. /**
  51630. * 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
  51631. * @see https://doc.babylonjs.com/features/occlusionquery
  51632. */
  51633. isOccluded: boolean;
  51634. /**
  51635. * Flag to check the progress status of the query
  51636. * @see https://doc.babylonjs.com/features/occlusionquery
  51637. */
  51638. isOcclusionQueryInProgress: boolean;
  51639. }
  51640. }
  51641. declare module BABYLON {
  51642. /** @hidden */
  51643. export var _forceTransformFeedbackToBundle: boolean;
  51644. interface Engine {
  51645. /**
  51646. * Creates a webGL transform feedback object
  51647. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  51648. * @returns the webGL transform feedback object
  51649. */
  51650. createTransformFeedback(): WebGLTransformFeedback;
  51651. /**
  51652. * Delete a webGL transform feedback object
  51653. * @param value defines the webGL transform feedback object to delete
  51654. */
  51655. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  51656. /**
  51657. * Bind a webGL transform feedback object to the webgl context
  51658. * @param value defines the webGL transform feedback object to bind
  51659. */
  51660. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  51661. /**
  51662. * Begins a transform feedback operation
  51663. * @param usePoints defines if points or triangles must be used
  51664. */
  51665. beginTransformFeedback(usePoints: boolean): void;
  51666. /**
  51667. * Ends a transform feedback operation
  51668. */
  51669. endTransformFeedback(): void;
  51670. /**
  51671. * Specify the varyings to use with transform feedback
  51672. * @param program defines the associated webGL program
  51673. * @param value defines the list of strings representing the varying names
  51674. */
  51675. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  51676. /**
  51677. * Bind a webGL buffer for a transform feedback operation
  51678. * @param value defines the webGL buffer to bind
  51679. */
  51680. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  51681. }
  51682. }
  51683. declare module BABYLON {
  51684. /**
  51685. * Class used to define an additional view for the engine
  51686. * @see https://doc.babylonjs.com/how_to/multi_canvases
  51687. */
  51688. export class EngineView {
  51689. /** Defines the canvas where to render the view */
  51690. target: HTMLCanvasElement;
  51691. /** Defines an optional camera used to render the view (will use active camera else) */
  51692. camera?: Camera;
  51693. }
  51694. interface Engine {
  51695. /**
  51696. * Gets or sets the HTML element to use for attaching events
  51697. */
  51698. inputElement: Nullable<HTMLElement>;
  51699. /**
  51700. * Gets the current engine view
  51701. * @see https://doc.babylonjs.com/how_to/multi_canvases
  51702. */
  51703. activeView: Nullable<EngineView>;
  51704. /** Gets or sets the list of views */
  51705. views: EngineView[];
  51706. /**
  51707. * Register a new child canvas
  51708. * @param canvas defines the canvas to register
  51709. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  51710. * @returns the associated view
  51711. */
  51712. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  51713. /**
  51714. * Remove a registered child canvas
  51715. * @param canvas defines the canvas to remove
  51716. * @returns the current engine
  51717. */
  51718. unRegisterView(canvas: HTMLCanvasElement): Engine;
  51719. }
  51720. }
  51721. declare module BABYLON {
  51722. interface Engine {
  51723. /** @hidden */
  51724. _excludedCompressedTextures: string[];
  51725. /** @hidden */
  51726. _textureFormatInUse: string;
  51727. /**
  51728. * Gets the list of texture formats supported
  51729. */
  51730. readonly texturesSupported: Array<string>;
  51731. /**
  51732. * Gets the texture format in use
  51733. */
  51734. readonly textureFormatInUse: Nullable<string>;
  51735. /**
  51736. * Set the compressed texture extensions or file names to skip.
  51737. *
  51738. * @param skippedFiles defines the list of those texture files you want to skip
  51739. * Example: [".dds", ".env", "myfile.png"]
  51740. */
  51741. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  51742. /**
  51743. * Set the compressed texture format to use, based on the formats you have, and the formats
  51744. * supported by the hardware / browser.
  51745. *
  51746. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  51747. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  51748. * to API arguments needed to compressed textures. This puts the burden on the container
  51749. * generator to house the arcane code for determining these for current & future formats.
  51750. *
  51751. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51752. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51753. *
  51754. * Note: The result of this call is not taken into account when a texture is base64.
  51755. *
  51756. * @param formatsAvailable defines the list of those format families you have created
  51757. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  51758. *
  51759. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  51760. * @returns The extension selected.
  51761. */
  51762. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  51763. }
  51764. }
  51765. declare module BABYLON {
  51766. /**
  51767. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  51768. */
  51769. export interface CubeMapInfo {
  51770. /**
  51771. * The pixel array for the front face.
  51772. * This is stored in format, left to right, up to down format.
  51773. */
  51774. front: Nullable<ArrayBufferView>;
  51775. /**
  51776. * The pixel array for the back face.
  51777. * This is stored in format, left to right, up to down format.
  51778. */
  51779. back: Nullable<ArrayBufferView>;
  51780. /**
  51781. * The pixel array for the left face.
  51782. * This is stored in format, left to right, up to down format.
  51783. */
  51784. left: Nullable<ArrayBufferView>;
  51785. /**
  51786. * The pixel array for the right face.
  51787. * This is stored in format, left to right, up to down format.
  51788. */
  51789. right: Nullable<ArrayBufferView>;
  51790. /**
  51791. * The pixel array for the up face.
  51792. * This is stored in format, left to right, up to down format.
  51793. */
  51794. up: Nullable<ArrayBufferView>;
  51795. /**
  51796. * The pixel array for the down face.
  51797. * This is stored in format, left to right, up to down format.
  51798. */
  51799. down: Nullable<ArrayBufferView>;
  51800. /**
  51801. * The size of the cubemap stored.
  51802. *
  51803. * Each faces will be size * size pixels.
  51804. */
  51805. size: number;
  51806. /**
  51807. * The format of the texture.
  51808. *
  51809. * RGBA, RGB.
  51810. */
  51811. format: number;
  51812. /**
  51813. * The type of the texture data.
  51814. *
  51815. * UNSIGNED_INT, FLOAT.
  51816. */
  51817. type: number;
  51818. /**
  51819. * Specifies whether the texture is in gamma space.
  51820. */
  51821. gammaSpace: boolean;
  51822. }
  51823. /**
  51824. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  51825. */
  51826. export class PanoramaToCubeMapTools {
  51827. private static FACE_LEFT;
  51828. private static FACE_RIGHT;
  51829. private static FACE_FRONT;
  51830. private static FACE_BACK;
  51831. private static FACE_DOWN;
  51832. private static FACE_UP;
  51833. /**
  51834. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  51835. *
  51836. * @param float32Array The source data.
  51837. * @param inputWidth The width of the input panorama.
  51838. * @param inputHeight The height of the input panorama.
  51839. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  51840. * @return The cubemap data
  51841. */
  51842. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  51843. private static CreateCubemapTexture;
  51844. private static CalcProjectionSpherical;
  51845. }
  51846. }
  51847. declare module BABYLON {
  51848. /**
  51849. * Helper class dealing with the extraction of spherical polynomial dataArray
  51850. * from a cube map.
  51851. */
  51852. export class CubeMapToSphericalPolynomialTools {
  51853. private static FileFaces;
  51854. /**
  51855. * Converts a texture to the according Spherical Polynomial data.
  51856. * This extracts the first 3 orders only as they are the only one used in the lighting.
  51857. *
  51858. * @param texture The texture to extract the information from.
  51859. * @return The Spherical Polynomial data.
  51860. */
  51861. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  51862. /**
  51863. * Converts a cubemap to the according Spherical Polynomial data.
  51864. * This extracts the first 3 orders only as they are the only one used in the lighting.
  51865. *
  51866. * @param cubeInfo The Cube map to extract the information from.
  51867. * @return The Spherical Polynomial data.
  51868. */
  51869. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  51870. }
  51871. }
  51872. declare module BABYLON {
  51873. interface BaseTexture {
  51874. /**
  51875. * Get the polynomial representation of the texture data.
  51876. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  51877. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  51878. */
  51879. sphericalPolynomial: Nullable<SphericalPolynomial>;
  51880. }
  51881. }
  51882. declare module BABYLON {
  51883. /** @hidden */
  51884. export var rgbdEncodePixelShader: {
  51885. name: string;
  51886. shader: string;
  51887. };
  51888. }
  51889. declare module BABYLON {
  51890. /** @hidden */
  51891. export var rgbdDecodePixelShader: {
  51892. name: string;
  51893. shader: string;
  51894. };
  51895. }
  51896. declare module BABYLON {
  51897. /**
  51898. * Raw texture data and descriptor sufficient for WebGL texture upload
  51899. */
  51900. export interface EnvironmentTextureInfo {
  51901. /**
  51902. * Version of the environment map
  51903. */
  51904. version: number;
  51905. /**
  51906. * Width of image
  51907. */
  51908. width: number;
  51909. /**
  51910. * Irradiance information stored in the file.
  51911. */
  51912. irradiance: any;
  51913. /**
  51914. * Specular information stored in the file.
  51915. */
  51916. specular: any;
  51917. }
  51918. /**
  51919. * Defines One Image in the file. It requires only the position in the file
  51920. * as well as the length.
  51921. */
  51922. interface BufferImageData {
  51923. /**
  51924. * Length of the image data.
  51925. */
  51926. length: number;
  51927. /**
  51928. * Position of the data from the null terminator delimiting the end of the JSON.
  51929. */
  51930. position: number;
  51931. }
  51932. /**
  51933. * Defines the specular data enclosed in the file.
  51934. * This corresponds to the version 1 of the data.
  51935. */
  51936. export interface EnvironmentTextureSpecularInfoV1 {
  51937. /**
  51938. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  51939. */
  51940. specularDataPosition?: number;
  51941. /**
  51942. * This contains all the images data needed to reconstruct the cubemap.
  51943. */
  51944. mipmaps: Array<BufferImageData>;
  51945. /**
  51946. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  51947. */
  51948. lodGenerationScale: number;
  51949. }
  51950. /**
  51951. * Sets of helpers addressing the serialization and deserialization of environment texture
  51952. * stored in a BabylonJS env file.
  51953. * Those files are usually stored as .env files.
  51954. */
  51955. export class EnvironmentTextureTools {
  51956. /**
  51957. * Magic number identifying the env file.
  51958. */
  51959. private static _MagicBytes;
  51960. /**
  51961. * Gets the environment info from an env file.
  51962. * @param data The array buffer containing the .env bytes.
  51963. * @returns the environment file info (the json header) if successfully parsed.
  51964. */
  51965. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  51966. /**
  51967. * Creates an environment texture from a loaded cube texture.
  51968. * @param texture defines the cube texture to convert in env file
  51969. * @return a promise containing the environment data if succesfull.
  51970. */
  51971. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  51972. /**
  51973. * Creates a JSON representation of the spherical data.
  51974. * @param texture defines the texture containing the polynomials
  51975. * @return the JSON representation of the spherical info
  51976. */
  51977. private static _CreateEnvTextureIrradiance;
  51978. /**
  51979. * Creates the ArrayBufferViews used for initializing environment texture image data.
  51980. * @param data the image data
  51981. * @param info parameters that determine what views will be created for accessing the underlying buffer
  51982. * @return the views described by info providing access to the underlying buffer
  51983. */
  51984. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  51985. /**
  51986. * Uploads the texture info contained in the env file to the GPU.
  51987. * @param texture defines the internal texture to upload to
  51988. * @param data defines the data to load
  51989. * @param info defines the texture info retrieved through the GetEnvInfo method
  51990. * @returns a promise
  51991. */
  51992. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  51993. private static _OnImageReadyAsync;
  51994. /**
  51995. * Uploads the levels of image data to the GPU.
  51996. * @param texture defines the internal texture to upload to
  51997. * @param imageData defines the array buffer views of image data [mipmap][face]
  51998. * @returns a promise
  51999. */
  52000. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  52001. /**
  52002. * Uploads spherical polynomials information to the texture.
  52003. * @param texture defines the texture we are trying to upload the information to
  52004. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  52005. */
  52006. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  52007. /** @hidden */
  52008. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52009. }
  52010. }
  52011. declare module BABYLON {
  52012. /**
  52013. * Class used to inline functions in shader code
  52014. */
  52015. export class ShaderCodeInliner {
  52016. private static readonly _RegexpFindFunctionNameAndType;
  52017. private _sourceCode;
  52018. private _functionDescr;
  52019. private _numMaxIterations;
  52020. /** Gets or sets the token used to mark the functions to inline */
  52021. inlineToken: string;
  52022. /** Gets or sets the debug mode */
  52023. debug: boolean;
  52024. /** Gets the code after the inlining process */
  52025. get code(): string;
  52026. /**
  52027. * Initializes the inliner
  52028. * @param sourceCode shader code source to inline
  52029. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  52030. */
  52031. constructor(sourceCode: string, numMaxIterations?: number);
  52032. /**
  52033. * Start the processing of the shader code
  52034. */
  52035. processCode(): void;
  52036. private _collectFunctions;
  52037. private _processInlining;
  52038. private _extractBetweenMarkers;
  52039. private _skipWhitespaces;
  52040. private _removeComments;
  52041. private _replaceFunctionCallsByCode;
  52042. private _findBackward;
  52043. private _escapeRegExp;
  52044. private _replaceNames;
  52045. }
  52046. }
  52047. declare module BABYLON {
  52048. /**
  52049. * Container for accessors for natively-stored mesh data buffers.
  52050. */
  52051. class NativeDataBuffer extends DataBuffer {
  52052. /**
  52053. * Accessor value used to identify/retrieve a natively-stored index buffer.
  52054. */
  52055. nativeIndexBuffer?: any;
  52056. /**
  52057. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  52058. */
  52059. nativeVertexBuffer?: any;
  52060. }
  52061. /** @hidden */
  52062. class NativeTexture extends InternalTexture {
  52063. getInternalTexture(): InternalTexture;
  52064. getViewCount(): number;
  52065. }
  52066. /** @hidden */
  52067. export class NativeEngine extends Engine {
  52068. private readonly _native;
  52069. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  52070. private readonly INVALID_HANDLE;
  52071. getHardwareScalingLevel(): number;
  52072. constructor();
  52073. dispose(): void;
  52074. /**
  52075. * Can be used to override the current requestAnimationFrame requester.
  52076. * @hidden
  52077. */
  52078. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  52079. /**
  52080. * Override default engine behavior.
  52081. * @param color
  52082. * @param backBuffer
  52083. * @param depth
  52084. * @param stencil
  52085. */
  52086. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  52087. /**
  52088. * Gets host document
  52089. * @returns the host document object
  52090. */
  52091. getHostDocument(): Nullable<Document>;
  52092. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52093. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  52094. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  52095. recordVertexArrayObject(vertexBuffers: {
  52096. [key: string]: VertexBuffer;
  52097. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  52098. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52099. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52100. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52101. /**
  52102. * Draw a list of indexed primitives
  52103. * @param fillMode defines the primitive to use
  52104. * @param indexStart defines the starting index
  52105. * @param indexCount defines the number of index to draw
  52106. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52107. */
  52108. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52109. /**
  52110. * Draw a list of unindexed primitives
  52111. * @param fillMode defines the primitive to use
  52112. * @param verticesStart defines the index of first vertex to draw
  52113. * @param verticesCount defines the count of vertices to draw
  52114. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52115. */
  52116. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52117. createPipelineContext(): IPipelineContext;
  52118. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  52119. /** @hidden */
  52120. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  52121. /** @hidden */
  52122. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  52123. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52124. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52125. protected _setProgram(program: WebGLProgram): void;
  52126. _releaseEffect(effect: Effect): void;
  52127. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  52128. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  52129. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  52130. bindSamplers(effect: Effect): void;
  52131. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  52132. getRenderWidth(useScreen?: boolean): number;
  52133. getRenderHeight(useScreen?: boolean): number;
  52134. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  52135. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52136. /**
  52137. * Set the z offset to apply to current rendering
  52138. * @param value defines the offset to apply
  52139. */
  52140. setZOffset(value: number): void;
  52141. /**
  52142. * Gets the current value of the zOffset
  52143. * @returns the current zOffset state
  52144. */
  52145. getZOffset(): number;
  52146. /**
  52147. * Enable or disable depth buffering
  52148. * @param enable defines the state to set
  52149. */
  52150. setDepthBuffer(enable: boolean): void;
  52151. /**
  52152. * Gets a boolean indicating if depth writing is enabled
  52153. * @returns the current depth writing state
  52154. */
  52155. getDepthWrite(): boolean;
  52156. /**
  52157. * Enable or disable depth writing
  52158. * @param enable defines the state to set
  52159. */
  52160. setDepthWrite(enable: boolean): void;
  52161. /**
  52162. * Enable or disable color writing
  52163. * @param enable defines the state to set
  52164. */
  52165. setColorWrite(enable: boolean): void;
  52166. /**
  52167. * Gets a boolean indicating if color writing is enabled
  52168. * @returns the current color writing state
  52169. */
  52170. getColorWrite(): boolean;
  52171. /**
  52172. * Sets alpha constants used by some alpha blending modes
  52173. * @param r defines the red component
  52174. * @param g defines the green component
  52175. * @param b defines the blue component
  52176. * @param a defines the alpha component
  52177. */
  52178. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  52179. /**
  52180. * Sets the current alpha mode
  52181. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  52182. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52183. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52184. */
  52185. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52186. /**
  52187. * Gets the current alpha mode
  52188. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52189. * @returns the current alpha mode
  52190. */
  52191. getAlphaMode(): number;
  52192. setInt(uniform: WebGLUniformLocation, int: number): void;
  52193. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  52194. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  52195. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  52196. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  52197. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  52198. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  52199. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  52200. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  52201. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  52202. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  52203. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  52204. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  52205. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  52206. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52207. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52208. setFloat(uniform: WebGLUniformLocation, value: number): void;
  52209. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  52210. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  52211. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  52212. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  52213. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  52214. wipeCaches(bruteForce?: boolean): void;
  52215. _createTexture(): WebGLTexture;
  52216. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  52217. /**
  52218. * Usually called from Texture.ts.
  52219. * Passed information to create a WebGLTexture
  52220. * @param url defines a value which contains one of the following:
  52221. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52222. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52223. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52224. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52225. * @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)
  52226. * @param scene needed for loading to the correct scene
  52227. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52228. * @param onLoad optional callback to be called upon successful completion
  52229. * @param onError optional callback to be called upon failure
  52230. * @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
  52231. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52232. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52233. * @param forcedExtension defines the extension to use to pick the right loader
  52234. * @param mimeType defines an optional mime type
  52235. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52236. */
  52237. 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;
  52238. /**
  52239. * Creates a cube texture
  52240. * @param rootUrl defines the url where the files to load is located
  52241. * @param scene defines the current scene
  52242. * @param files defines the list of files to load (1 per face)
  52243. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  52244. * @param onLoad defines an optional callback raised when the texture is loaded
  52245. * @param onError defines an optional callback raised if there is an issue to load the texture
  52246. * @param format defines the format of the data
  52247. * @param forcedExtension defines the extension to use to pick the right loader
  52248. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  52249. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52250. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52251. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  52252. * @returns the cube texture as an InternalTexture
  52253. */
  52254. 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;
  52255. private _getSamplingFilter;
  52256. private static _GetNativeTextureFormat;
  52257. createRenderTargetTexture(size: number | {
  52258. width: number;
  52259. height: number;
  52260. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  52261. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52262. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52263. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52264. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  52265. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  52266. /**
  52267. * Updates a dynamic vertex buffer.
  52268. * @param vertexBuffer the vertex buffer to update
  52269. * @param data the data used to update the vertex buffer
  52270. * @param byteOffset the byte offset of the data (optional)
  52271. * @param byteLength the byte length of the data (optional)
  52272. */
  52273. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  52274. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  52275. private _updateAnisotropicLevel;
  52276. private _getAddressMode;
  52277. /** @hidden */
  52278. _bindTexture(channel: number, texture: InternalTexture): void;
  52279. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  52280. releaseEffects(): void;
  52281. /** @hidden */
  52282. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52283. /** @hidden */
  52284. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52285. /** @hidden */
  52286. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52287. /** @hidden */
  52288. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52289. }
  52290. }
  52291. declare module BABYLON {
  52292. /**
  52293. * Gather the list of clipboard event types as constants.
  52294. */
  52295. export class ClipboardEventTypes {
  52296. /**
  52297. * The clipboard event is fired when a copy command is active (pressed).
  52298. */
  52299. static readonly COPY: number;
  52300. /**
  52301. * The clipboard event is fired when a cut command is active (pressed).
  52302. */
  52303. static readonly CUT: number;
  52304. /**
  52305. * The clipboard event is fired when a paste command is active (pressed).
  52306. */
  52307. static readonly PASTE: number;
  52308. }
  52309. /**
  52310. * This class is used to store clipboard related info for the onClipboardObservable event.
  52311. */
  52312. export class ClipboardInfo {
  52313. /**
  52314. * Defines the type of event (BABYLON.ClipboardEventTypes)
  52315. */
  52316. type: number;
  52317. /**
  52318. * Defines the related dom event
  52319. */
  52320. event: ClipboardEvent;
  52321. /**
  52322. *Creates an instance of ClipboardInfo.
  52323. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  52324. * @param event Defines the related dom event
  52325. */
  52326. constructor(
  52327. /**
  52328. * Defines the type of event (BABYLON.ClipboardEventTypes)
  52329. */
  52330. type: number,
  52331. /**
  52332. * Defines the related dom event
  52333. */
  52334. event: ClipboardEvent);
  52335. /**
  52336. * Get the clipboard event's type from the keycode.
  52337. * @param keyCode Defines the keyCode for the current keyboard event.
  52338. * @return {number}
  52339. */
  52340. static GetTypeFromCharacter(keyCode: number): number;
  52341. }
  52342. }
  52343. declare module BABYLON {
  52344. /**
  52345. * Google Daydream controller
  52346. */
  52347. export class DaydreamController extends WebVRController {
  52348. /**
  52349. * Base Url for the controller model.
  52350. */
  52351. static MODEL_BASE_URL: string;
  52352. /**
  52353. * File name for the controller model.
  52354. */
  52355. static MODEL_FILENAME: string;
  52356. /**
  52357. * Gamepad Id prefix used to identify Daydream Controller.
  52358. */
  52359. static readonly GAMEPAD_ID_PREFIX: string;
  52360. /**
  52361. * Creates a new DaydreamController from a gamepad
  52362. * @param vrGamepad the gamepad that the controller should be created from
  52363. */
  52364. constructor(vrGamepad: any);
  52365. /**
  52366. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52367. * @param scene scene in which to add meshes
  52368. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52369. */
  52370. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52371. /**
  52372. * Called once for each button that changed state since the last frame
  52373. * @param buttonIdx Which button index changed
  52374. * @param state New state of the button
  52375. * @param changes Which properties on the state changed since last frame
  52376. */
  52377. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52378. }
  52379. }
  52380. declare module BABYLON {
  52381. /**
  52382. * Gear VR Controller
  52383. */
  52384. export class GearVRController extends WebVRController {
  52385. /**
  52386. * Base Url for the controller model.
  52387. */
  52388. static MODEL_BASE_URL: string;
  52389. /**
  52390. * File name for the controller model.
  52391. */
  52392. static MODEL_FILENAME: string;
  52393. /**
  52394. * Gamepad Id prefix used to identify this controller.
  52395. */
  52396. static readonly GAMEPAD_ID_PREFIX: string;
  52397. private readonly _buttonIndexToObservableNameMap;
  52398. /**
  52399. * Creates a new GearVRController from a gamepad
  52400. * @param vrGamepad the gamepad that the controller should be created from
  52401. */
  52402. constructor(vrGamepad: any);
  52403. /**
  52404. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52405. * @param scene scene in which to add meshes
  52406. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52407. */
  52408. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52409. /**
  52410. * Called once for each button that changed state since the last frame
  52411. * @param buttonIdx Which button index changed
  52412. * @param state New state of the button
  52413. * @param changes Which properties on the state changed since last frame
  52414. */
  52415. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52416. }
  52417. }
  52418. declare module BABYLON {
  52419. /**
  52420. * Generic Controller
  52421. */
  52422. export class GenericController extends WebVRController {
  52423. /**
  52424. * Base Url for the controller model.
  52425. */
  52426. static readonly MODEL_BASE_URL: string;
  52427. /**
  52428. * File name for the controller model.
  52429. */
  52430. static readonly MODEL_FILENAME: string;
  52431. /**
  52432. * Creates a new GenericController from a gamepad
  52433. * @param vrGamepad the gamepad that the controller should be created from
  52434. */
  52435. constructor(vrGamepad: any);
  52436. /**
  52437. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52438. * @param scene scene in which to add meshes
  52439. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52440. */
  52441. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52442. /**
  52443. * Called once for each button that changed state since the last frame
  52444. * @param buttonIdx Which button index changed
  52445. * @param state New state of the button
  52446. * @param changes Which properties on the state changed since last frame
  52447. */
  52448. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52449. }
  52450. }
  52451. declare module BABYLON {
  52452. /**
  52453. * Oculus Touch Controller
  52454. */
  52455. export class OculusTouchController extends WebVRController {
  52456. /**
  52457. * Base Url for the controller model.
  52458. */
  52459. static MODEL_BASE_URL: string;
  52460. /**
  52461. * File name for the left controller model.
  52462. */
  52463. static MODEL_LEFT_FILENAME: string;
  52464. /**
  52465. * File name for the right controller model.
  52466. */
  52467. static MODEL_RIGHT_FILENAME: string;
  52468. /**
  52469. * Base Url for the Quest controller model.
  52470. */
  52471. static QUEST_MODEL_BASE_URL: string;
  52472. /**
  52473. * @hidden
  52474. * If the controllers are running on a device that needs the updated Quest controller models
  52475. */
  52476. static _IsQuest: boolean;
  52477. /**
  52478. * Fired when the secondary trigger on this controller is modified
  52479. */
  52480. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  52481. /**
  52482. * Fired when the thumb rest on this controller is modified
  52483. */
  52484. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  52485. /**
  52486. * Creates a new OculusTouchController from a gamepad
  52487. * @param vrGamepad the gamepad that the controller should be created from
  52488. */
  52489. constructor(vrGamepad: any);
  52490. /**
  52491. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52492. * @param scene scene in which to add meshes
  52493. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52494. */
  52495. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52496. /**
  52497. * Fired when the A button on this controller is modified
  52498. */
  52499. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52500. /**
  52501. * Fired when the B button on this controller is modified
  52502. */
  52503. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52504. /**
  52505. * Fired when the X button on this controller is modified
  52506. */
  52507. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52508. /**
  52509. * Fired when the Y button on this controller is modified
  52510. */
  52511. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52512. /**
  52513. * Called once for each button that changed state since the last frame
  52514. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  52515. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  52516. * 2) secondary trigger (same)
  52517. * 3) A (right) X (left), touch, pressed = value
  52518. * 4) B / Y
  52519. * 5) thumb rest
  52520. * @param buttonIdx Which button index changed
  52521. * @param state New state of the button
  52522. * @param changes Which properties on the state changed since last frame
  52523. */
  52524. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52525. }
  52526. }
  52527. declare module BABYLON {
  52528. /**
  52529. * Vive Controller
  52530. */
  52531. export class ViveController extends WebVRController {
  52532. /**
  52533. * Base Url for the controller model.
  52534. */
  52535. static MODEL_BASE_URL: string;
  52536. /**
  52537. * File name for the controller model.
  52538. */
  52539. static MODEL_FILENAME: string;
  52540. /**
  52541. * Creates a new ViveController from a gamepad
  52542. * @param vrGamepad the gamepad that the controller should be created from
  52543. */
  52544. constructor(vrGamepad: any);
  52545. /**
  52546. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52547. * @param scene scene in which to add meshes
  52548. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52549. */
  52550. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52551. /**
  52552. * Fired when the left button on this controller is modified
  52553. */
  52554. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52555. /**
  52556. * Fired when the right button on this controller is modified
  52557. */
  52558. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52559. /**
  52560. * Fired when the menu button on this controller is modified
  52561. */
  52562. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52563. /**
  52564. * Called once for each button that changed state since the last frame
  52565. * Vive mapping:
  52566. * 0: touchpad
  52567. * 1: trigger
  52568. * 2: left AND right buttons
  52569. * 3: menu button
  52570. * @param buttonIdx Which button index changed
  52571. * @param state New state of the button
  52572. * @param changes Which properties on the state changed since last frame
  52573. */
  52574. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52575. }
  52576. }
  52577. declare module BABYLON {
  52578. /**
  52579. * Defines the WindowsMotionController object that the state of the windows motion controller
  52580. */
  52581. export class WindowsMotionController extends WebVRController {
  52582. /**
  52583. * The base url used to load the left and right controller models
  52584. */
  52585. static MODEL_BASE_URL: string;
  52586. /**
  52587. * The name of the left controller model file
  52588. */
  52589. static MODEL_LEFT_FILENAME: string;
  52590. /**
  52591. * The name of the right controller model file
  52592. */
  52593. static MODEL_RIGHT_FILENAME: string;
  52594. /**
  52595. * The controller name prefix for this controller type
  52596. */
  52597. static readonly GAMEPAD_ID_PREFIX: string;
  52598. /**
  52599. * The controller id pattern for this controller type
  52600. */
  52601. private static readonly GAMEPAD_ID_PATTERN;
  52602. private _loadedMeshInfo;
  52603. protected readonly _mapping: {
  52604. buttons: string[];
  52605. buttonMeshNames: {
  52606. trigger: string;
  52607. menu: string;
  52608. grip: string;
  52609. thumbstick: string;
  52610. trackpad: string;
  52611. };
  52612. buttonObservableNames: {
  52613. trigger: string;
  52614. menu: string;
  52615. grip: string;
  52616. thumbstick: string;
  52617. trackpad: string;
  52618. };
  52619. axisMeshNames: string[];
  52620. pointingPoseMeshName: string;
  52621. };
  52622. /**
  52623. * Fired when the trackpad on this controller is clicked
  52624. */
  52625. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  52626. /**
  52627. * Fired when the trackpad on this controller is modified
  52628. */
  52629. onTrackpadValuesChangedObservable: Observable<StickValues>;
  52630. /**
  52631. * The current x and y values of this controller's trackpad
  52632. */
  52633. trackpad: StickValues;
  52634. /**
  52635. * Creates a new WindowsMotionController from a gamepad
  52636. * @param vrGamepad the gamepad that the controller should be created from
  52637. */
  52638. constructor(vrGamepad: any);
  52639. /**
  52640. * Fired when the trigger on this controller is modified
  52641. */
  52642. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52643. /**
  52644. * Fired when the menu button on this controller is modified
  52645. */
  52646. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52647. /**
  52648. * Fired when the grip button on this controller is modified
  52649. */
  52650. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52651. /**
  52652. * Fired when the thumbstick button on this controller is modified
  52653. */
  52654. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52655. /**
  52656. * Fired when the touchpad button on this controller is modified
  52657. */
  52658. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52659. /**
  52660. * Fired when the touchpad values on this controller are modified
  52661. */
  52662. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  52663. protected _updateTrackpad(): void;
  52664. /**
  52665. * Called once per frame by the engine.
  52666. */
  52667. update(): void;
  52668. /**
  52669. * Called once for each button that changed state since the last frame
  52670. * @param buttonIdx Which button index changed
  52671. * @param state New state of the button
  52672. * @param changes Which properties on the state changed since last frame
  52673. */
  52674. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52675. /**
  52676. * Moves the buttons on the controller mesh based on their current state
  52677. * @param buttonName the name of the button to move
  52678. * @param buttonValue the value of the button which determines the buttons new position
  52679. */
  52680. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  52681. /**
  52682. * Moves the axis on the controller mesh based on its current state
  52683. * @param axis the index of the axis
  52684. * @param axisValue the value of the axis which determines the meshes new position
  52685. * @hidden
  52686. */
  52687. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  52688. /**
  52689. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52690. * @param scene scene in which to add meshes
  52691. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52692. */
  52693. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  52694. /**
  52695. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  52696. * can be transformed by button presses and axes values, based on this._mapping.
  52697. *
  52698. * @param scene scene in which the meshes exist
  52699. * @param meshes list of meshes that make up the controller model to process
  52700. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  52701. */
  52702. private processModel;
  52703. private createMeshInfo;
  52704. /**
  52705. * Gets the ray of the controller in the direction the controller is pointing
  52706. * @param length the length the resulting ray should be
  52707. * @returns a ray in the direction the controller is pointing
  52708. */
  52709. getForwardRay(length?: number): Ray;
  52710. /**
  52711. * Disposes of the controller
  52712. */
  52713. dispose(): void;
  52714. }
  52715. /**
  52716. * This class represents a new windows motion controller in XR.
  52717. */
  52718. export class XRWindowsMotionController extends WindowsMotionController {
  52719. /**
  52720. * Changing the original WIndowsMotionController mapping to fir the new mapping
  52721. */
  52722. protected readonly _mapping: {
  52723. buttons: string[];
  52724. buttonMeshNames: {
  52725. trigger: string;
  52726. menu: string;
  52727. grip: string;
  52728. thumbstick: string;
  52729. trackpad: string;
  52730. };
  52731. buttonObservableNames: {
  52732. trigger: string;
  52733. menu: string;
  52734. grip: string;
  52735. thumbstick: string;
  52736. trackpad: string;
  52737. };
  52738. axisMeshNames: string[];
  52739. pointingPoseMeshName: string;
  52740. };
  52741. /**
  52742. * Construct a new XR-Based windows motion controller
  52743. *
  52744. * @param gamepadInfo the gamepad object from the browser
  52745. */
  52746. constructor(gamepadInfo: any);
  52747. /**
  52748. * holds the thumbstick values (X,Y)
  52749. */
  52750. thumbstickValues: StickValues;
  52751. /**
  52752. * Fired when the thumbstick on this controller is clicked
  52753. */
  52754. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  52755. /**
  52756. * Fired when the thumbstick on this controller is modified
  52757. */
  52758. onThumbstickValuesChangedObservable: Observable<StickValues>;
  52759. /**
  52760. * Fired when the touchpad button on this controller is modified
  52761. */
  52762. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  52763. /**
  52764. * Fired when the touchpad values on this controller are modified
  52765. */
  52766. onTrackpadValuesChangedObservable: Observable<StickValues>;
  52767. /**
  52768. * Fired when the thumbstick button on this controller is modified
  52769. * here to prevent breaking changes
  52770. */
  52771. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52772. /**
  52773. * updating the thumbstick(!) and not the trackpad.
  52774. * This is named this way due to the difference between WebVR and XR and to avoid
  52775. * changing the parent class.
  52776. */
  52777. protected _updateTrackpad(): void;
  52778. /**
  52779. * Disposes the class with joy
  52780. */
  52781. dispose(): void;
  52782. }
  52783. }
  52784. declare module BABYLON {
  52785. /**
  52786. * Class containing static functions to help procedurally build meshes
  52787. */
  52788. export class PolyhedronBuilder {
  52789. /**
  52790. * Creates a polyhedron mesh
  52791. * * 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
  52792. * * The parameter `size` (positive float, default 1) sets the polygon size
  52793. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  52794. * * 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`
  52795. * * 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
  52796. * * 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)`)
  52797. * * 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
  52798. * * 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
  52799. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52800. * * 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
  52801. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52802. * @param name defines the name of the mesh
  52803. * @param options defines the options used to create the mesh
  52804. * @param scene defines the hosting scene
  52805. * @returns the polyhedron mesh
  52806. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  52807. */
  52808. static CreatePolyhedron(name: string, options: {
  52809. type?: number;
  52810. size?: number;
  52811. sizeX?: number;
  52812. sizeY?: number;
  52813. sizeZ?: number;
  52814. custom?: any;
  52815. faceUV?: Vector4[];
  52816. faceColors?: Color4[];
  52817. flat?: boolean;
  52818. updatable?: boolean;
  52819. sideOrientation?: number;
  52820. frontUVs?: Vector4;
  52821. backUVs?: Vector4;
  52822. }, scene?: Nullable<Scene>): Mesh;
  52823. }
  52824. }
  52825. declare module BABYLON {
  52826. /**
  52827. * Gizmo that enables scaling a mesh along 3 axis
  52828. */
  52829. export class ScaleGizmo extends Gizmo {
  52830. /**
  52831. * Internal gizmo used for interactions on the x axis
  52832. */
  52833. xGizmo: AxisScaleGizmo;
  52834. /**
  52835. * Internal gizmo used for interactions on the y axis
  52836. */
  52837. yGizmo: AxisScaleGizmo;
  52838. /**
  52839. * Internal gizmo used for interactions on the z axis
  52840. */
  52841. zGizmo: AxisScaleGizmo;
  52842. /**
  52843. * Internal gizmo used to scale all axis equally
  52844. */
  52845. uniformScaleGizmo: AxisScaleGizmo;
  52846. private _meshAttached;
  52847. private _nodeAttached;
  52848. private _updateGizmoRotationToMatchAttachedMesh;
  52849. private _snapDistance;
  52850. private _scaleRatio;
  52851. private _uniformScalingMesh;
  52852. private _octahedron;
  52853. private _sensitivity;
  52854. /** Fires an event when any of it's sub gizmos are dragged */
  52855. onDragStartObservable: Observable<unknown>;
  52856. /** Fires an event when any of it's sub gizmos are released from dragging */
  52857. onDragEndObservable: Observable<unknown>;
  52858. get attachedMesh(): Nullable<AbstractMesh>;
  52859. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52860. get attachedNode(): Nullable<Node>;
  52861. set attachedNode(node: Nullable<Node>);
  52862. /**
  52863. * Creates a ScaleGizmo
  52864. * @param gizmoLayer The utility layer the gizmo will be added to
  52865. * @param thickness display gizmo axis thickness
  52866. */
  52867. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  52868. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52869. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52870. /**
  52871. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52872. */
  52873. set snapDistance(value: number);
  52874. get snapDistance(): number;
  52875. /**
  52876. * Ratio for the scale of the gizmo (Default: 1)
  52877. */
  52878. set scaleRatio(value: number);
  52879. get scaleRatio(): number;
  52880. /**
  52881. * Sensitivity factor for dragging (Default: 1)
  52882. */
  52883. set sensitivity(value: number);
  52884. get sensitivity(): number;
  52885. /**
  52886. * Disposes of the gizmo
  52887. */
  52888. dispose(): void;
  52889. }
  52890. }
  52891. declare module BABYLON {
  52892. /**
  52893. * Single axis scale gizmo
  52894. */
  52895. export class AxisScaleGizmo extends Gizmo {
  52896. /**
  52897. * Drag behavior responsible for the gizmos dragging interactions
  52898. */
  52899. dragBehavior: PointerDragBehavior;
  52900. private _pointerObserver;
  52901. /**
  52902. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52903. */
  52904. snapDistance: number;
  52905. /**
  52906. * Event that fires each time the gizmo snaps to a new location.
  52907. * * snapDistance is the the change in distance
  52908. */
  52909. onSnapObservable: Observable<{
  52910. snapDistance: number;
  52911. }>;
  52912. /**
  52913. * If the scaling operation should be done on all axis (default: false)
  52914. */
  52915. uniformScaling: boolean;
  52916. /**
  52917. * Custom sensitivity value for the drag strength
  52918. */
  52919. sensitivity: number;
  52920. private _isEnabled;
  52921. private _parent;
  52922. private _arrow;
  52923. private _coloredMaterial;
  52924. private _hoverMaterial;
  52925. /**
  52926. * Creates an AxisScaleGizmo
  52927. * @param gizmoLayer The utility layer the gizmo will be added to
  52928. * @param dragAxis The axis which the gizmo will be able to scale on
  52929. * @param color The color of the gizmo
  52930. * @param thickness display gizmo axis thickness
  52931. */
  52932. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  52933. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52934. /**
  52935. * If the gizmo is enabled
  52936. */
  52937. set isEnabled(value: boolean);
  52938. get isEnabled(): boolean;
  52939. /**
  52940. * Disposes of the gizmo
  52941. */
  52942. dispose(): void;
  52943. /**
  52944. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52945. * @param mesh The mesh to replace the default mesh of the gizmo
  52946. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  52947. */
  52948. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  52949. }
  52950. }
  52951. declare module BABYLON {
  52952. /**
  52953. * Bounding box gizmo
  52954. */
  52955. export class BoundingBoxGizmo extends Gizmo {
  52956. private _lineBoundingBox;
  52957. private _rotateSpheresParent;
  52958. private _scaleBoxesParent;
  52959. private _boundingDimensions;
  52960. private _renderObserver;
  52961. private _pointerObserver;
  52962. private _scaleDragSpeed;
  52963. private _tmpQuaternion;
  52964. private _tmpVector;
  52965. private _tmpRotationMatrix;
  52966. /**
  52967. * 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)
  52968. */
  52969. ignoreChildren: boolean;
  52970. /**
  52971. * 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)
  52972. */
  52973. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  52974. /**
  52975. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  52976. */
  52977. rotationSphereSize: number;
  52978. /**
  52979. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  52980. */
  52981. scaleBoxSize: number;
  52982. /**
  52983. * 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)
  52984. */
  52985. fixedDragMeshScreenSize: boolean;
  52986. /**
  52987. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  52988. */
  52989. fixedDragMeshScreenSizeDistanceFactor: number;
  52990. /**
  52991. * Fired when a rotation sphere or scale box is dragged
  52992. */
  52993. onDragStartObservable: Observable<{}>;
  52994. /**
  52995. * Fired when a scale box is dragged
  52996. */
  52997. onScaleBoxDragObservable: Observable<{}>;
  52998. /**
  52999. * Fired when a scale box drag is ended
  53000. */
  53001. onScaleBoxDragEndObservable: Observable<{}>;
  53002. /**
  53003. * Fired when a rotation sphere is dragged
  53004. */
  53005. onRotationSphereDragObservable: Observable<{}>;
  53006. /**
  53007. * Fired when a rotation sphere drag is ended
  53008. */
  53009. onRotationSphereDragEndObservable: Observable<{}>;
  53010. /**
  53011. * 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)
  53012. */
  53013. scalePivot: Nullable<Vector3>;
  53014. /**
  53015. * Mesh used as a pivot to rotate the attached node
  53016. */
  53017. private _anchorMesh;
  53018. private _existingMeshScale;
  53019. private _dragMesh;
  53020. private pointerDragBehavior;
  53021. private coloredMaterial;
  53022. private hoverColoredMaterial;
  53023. /**
  53024. * Sets the color of the bounding box gizmo
  53025. * @param color the color to set
  53026. */
  53027. setColor(color: Color3): void;
  53028. /**
  53029. * Creates an BoundingBoxGizmo
  53030. * @param gizmoLayer The utility layer the gizmo will be added to
  53031. * @param color The color of the gizmo
  53032. */
  53033. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  53034. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  53035. private _selectNode;
  53036. /**
  53037. * Updates the bounding box information for the Gizmo
  53038. */
  53039. updateBoundingBox(): void;
  53040. private _updateRotationSpheres;
  53041. private _updateScaleBoxes;
  53042. /**
  53043. * Enables rotation on the specified axis and disables rotation on the others
  53044. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  53045. */
  53046. setEnabledRotationAxis(axis: string): void;
  53047. /**
  53048. * Enables/disables scaling
  53049. * @param enable if scaling should be enabled
  53050. * @param homogeneousScaling defines if scaling should only be homogeneous
  53051. */
  53052. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  53053. private _updateDummy;
  53054. /**
  53055. * Enables a pointer drag behavior on the bounding box of the gizmo
  53056. */
  53057. enableDragBehavior(): void;
  53058. /**
  53059. * Disposes of the gizmo
  53060. */
  53061. dispose(): void;
  53062. /**
  53063. * 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)
  53064. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  53065. * @returns the bounding box mesh with the passed in mesh as a child
  53066. */
  53067. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  53068. /**
  53069. * CustomMeshes are not supported by this gizmo
  53070. * @param mesh The mesh to replace the default mesh of the gizmo
  53071. */
  53072. setCustomMesh(mesh: Mesh): void;
  53073. }
  53074. }
  53075. declare module BABYLON {
  53076. /**
  53077. * Single plane rotation gizmo
  53078. */
  53079. export class PlaneRotationGizmo extends Gizmo {
  53080. /**
  53081. * Drag behavior responsible for the gizmos dragging interactions
  53082. */
  53083. dragBehavior: PointerDragBehavior;
  53084. private _pointerObserver;
  53085. /**
  53086. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  53087. */
  53088. snapDistance: number;
  53089. /**
  53090. * Event that fires each time the gizmo snaps to a new location.
  53091. * * snapDistance is the the change in distance
  53092. */
  53093. onSnapObservable: Observable<{
  53094. snapDistance: number;
  53095. }>;
  53096. private _isEnabled;
  53097. private _parent;
  53098. /**
  53099. * Creates a PlaneRotationGizmo
  53100. * @param gizmoLayer The utility layer the gizmo will be added to
  53101. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  53102. * @param color The color of the gizmo
  53103. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53104. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53105. * @param thickness display gizmo axis thickness
  53106. */
  53107. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  53108. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53109. /**
  53110. * If the gizmo is enabled
  53111. */
  53112. set isEnabled(value: boolean);
  53113. get isEnabled(): boolean;
  53114. /**
  53115. * Disposes of the gizmo
  53116. */
  53117. dispose(): void;
  53118. }
  53119. }
  53120. declare module BABYLON {
  53121. /**
  53122. * Gizmo that enables rotating a mesh along 3 axis
  53123. */
  53124. export class RotationGizmo extends Gizmo {
  53125. /**
  53126. * Internal gizmo used for interactions on the x axis
  53127. */
  53128. xGizmo: PlaneRotationGizmo;
  53129. /**
  53130. * Internal gizmo used for interactions on the y axis
  53131. */
  53132. yGizmo: PlaneRotationGizmo;
  53133. /**
  53134. * Internal gizmo used for interactions on the z axis
  53135. */
  53136. zGizmo: PlaneRotationGizmo;
  53137. /** Fires an event when any of it's sub gizmos are dragged */
  53138. onDragStartObservable: Observable<unknown>;
  53139. /** Fires an event when any of it's sub gizmos are released from dragging */
  53140. onDragEndObservable: Observable<unknown>;
  53141. private _meshAttached;
  53142. private _nodeAttached;
  53143. get attachedMesh(): Nullable<AbstractMesh>;
  53144. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53145. get attachedNode(): Nullable<Node>;
  53146. set attachedNode(node: Nullable<Node>);
  53147. /**
  53148. * Creates a RotationGizmo
  53149. * @param gizmoLayer The utility layer the gizmo will be added to
  53150. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53151. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53152. * @param thickness display gizmo axis thickness
  53153. */
  53154. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  53155. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53156. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53157. /**
  53158. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53159. */
  53160. set snapDistance(value: number);
  53161. get snapDistance(): number;
  53162. /**
  53163. * Ratio for the scale of the gizmo (Default: 1)
  53164. */
  53165. set scaleRatio(value: number);
  53166. get scaleRatio(): number;
  53167. /**
  53168. * Disposes of the gizmo
  53169. */
  53170. dispose(): void;
  53171. /**
  53172. * CustomMeshes are not supported by this gizmo
  53173. * @param mesh The mesh to replace the default mesh of the gizmo
  53174. */
  53175. setCustomMesh(mesh: Mesh): void;
  53176. }
  53177. }
  53178. declare module BABYLON {
  53179. /**
  53180. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  53181. */
  53182. export class GizmoManager implements IDisposable {
  53183. private scene;
  53184. /**
  53185. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  53186. */
  53187. gizmos: {
  53188. positionGizmo: Nullable<PositionGizmo>;
  53189. rotationGizmo: Nullable<RotationGizmo>;
  53190. scaleGizmo: Nullable<ScaleGizmo>;
  53191. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  53192. };
  53193. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  53194. clearGizmoOnEmptyPointerEvent: boolean;
  53195. /** Fires an event when the manager is attached to a mesh */
  53196. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  53197. private _gizmosEnabled;
  53198. private _pointerObserver;
  53199. private _attachedMesh;
  53200. private _boundingBoxColor;
  53201. private _defaultUtilityLayer;
  53202. private _defaultKeepDepthUtilityLayer;
  53203. private _thickness;
  53204. /**
  53205. * When bounding box gizmo is enabled, this can be used to track drag/end events
  53206. */
  53207. boundingBoxDragBehavior: SixDofDragBehavior;
  53208. /**
  53209. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  53210. */
  53211. attachableMeshes: Nullable<Array<AbstractMesh>>;
  53212. /**
  53213. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  53214. */
  53215. usePointerToAttachGizmos: boolean;
  53216. /**
  53217. * Utility layer that the bounding box gizmo belongs to
  53218. */
  53219. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  53220. /**
  53221. * Utility layer that all gizmos besides bounding box belong to
  53222. */
  53223. get utilityLayer(): UtilityLayerRenderer;
  53224. /**
  53225. * Instatiates a gizmo manager
  53226. * @param scene the scene to overlay the gizmos on top of
  53227. * @param thickness display gizmo axis thickness
  53228. */
  53229. constructor(scene: Scene, thickness?: number);
  53230. /**
  53231. * Attaches a set of gizmos to the specified mesh
  53232. * @param mesh The mesh the gizmo's should be attached to
  53233. */
  53234. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53235. /**
  53236. * If the position gizmo is enabled
  53237. */
  53238. set positionGizmoEnabled(value: boolean);
  53239. get positionGizmoEnabled(): boolean;
  53240. /**
  53241. * If the rotation gizmo is enabled
  53242. */
  53243. set rotationGizmoEnabled(value: boolean);
  53244. get rotationGizmoEnabled(): boolean;
  53245. /**
  53246. * If the scale gizmo is enabled
  53247. */
  53248. set scaleGizmoEnabled(value: boolean);
  53249. get scaleGizmoEnabled(): boolean;
  53250. /**
  53251. * If the boundingBox gizmo is enabled
  53252. */
  53253. set boundingBoxGizmoEnabled(value: boolean);
  53254. get boundingBoxGizmoEnabled(): boolean;
  53255. /**
  53256. * Disposes of the gizmo manager
  53257. */
  53258. dispose(): void;
  53259. }
  53260. }
  53261. declare module BABYLON {
  53262. /**
  53263. * A directional light is defined by a direction (what a surprise!).
  53264. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  53265. * 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.
  53266. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53267. */
  53268. export class DirectionalLight extends ShadowLight {
  53269. private _shadowFrustumSize;
  53270. /**
  53271. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  53272. */
  53273. get shadowFrustumSize(): number;
  53274. /**
  53275. * Specifies a fix frustum size for the shadow generation.
  53276. */
  53277. set shadowFrustumSize(value: number);
  53278. private _shadowOrthoScale;
  53279. /**
  53280. * Gets the shadow projection scale against the optimal computed one.
  53281. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  53282. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  53283. */
  53284. get shadowOrthoScale(): number;
  53285. /**
  53286. * Sets the shadow projection scale against the optimal computed one.
  53287. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  53288. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  53289. */
  53290. set shadowOrthoScale(value: number);
  53291. /**
  53292. * Automatically compute the projection matrix to best fit (including all the casters)
  53293. * on each frame.
  53294. */
  53295. autoUpdateExtends: boolean;
  53296. /**
  53297. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  53298. * on each frame. autoUpdateExtends must be set to true for this to work
  53299. */
  53300. autoCalcShadowZBounds: boolean;
  53301. private _orthoLeft;
  53302. private _orthoRight;
  53303. private _orthoTop;
  53304. private _orthoBottom;
  53305. /**
  53306. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  53307. * The directional light is emitted from everywhere in the given direction.
  53308. * It can cast shadows.
  53309. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53310. * @param name The friendly name of the light
  53311. * @param direction The direction of the light
  53312. * @param scene The scene the light belongs to
  53313. */
  53314. constructor(name: string, direction: Vector3, scene: Scene);
  53315. /**
  53316. * Returns the string "DirectionalLight".
  53317. * @return The class name
  53318. */
  53319. getClassName(): string;
  53320. /**
  53321. * Returns the integer 1.
  53322. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53323. */
  53324. getTypeID(): number;
  53325. /**
  53326. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  53327. * Returns the DirectionalLight Shadow projection matrix.
  53328. */
  53329. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53330. /**
  53331. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  53332. * Returns the DirectionalLight Shadow projection matrix.
  53333. */
  53334. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  53335. /**
  53336. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  53337. * Returns the DirectionalLight Shadow projection matrix.
  53338. */
  53339. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53340. protected _buildUniformLayout(): void;
  53341. /**
  53342. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  53343. * @param effect The effect to update
  53344. * @param lightIndex The index of the light in the effect to update
  53345. * @returns The directional light
  53346. */
  53347. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  53348. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  53349. /**
  53350. * Gets the minZ used for shadow according to both the scene and the light.
  53351. *
  53352. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  53353. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  53354. * @param activeCamera The camera we are returning the min for
  53355. * @returns the depth min z
  53356. */
  53357. getDepthMinZ(activeCamera: Camera): number;
  53358. /**
  53359. * Gets the maxZ used for shadow according to both the scene and the light.
  53360. *
  53361. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  53362. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  53363. * @param activeCamera The camera we are returning the max for
  53364. * @returns the depth max z
  53365. */
  53366. getDepthMaxZ(activeCamera: Camera): number;
  53367. /**
  53368. * Prepares the list of defines specific to the light type.
  53369. * @param defines the list of defines
  53370. * @param lightIndex defines the index of the light for the effect
  53371. */
  53372. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53373. }
  53374. }
  53375. declare module BABYLON {
  53376. /**
  53377. * Class containing static functions to help procedurally build meshes
  53378. */
  53379. export class HemisphereBuilder {
  53380. /**
  53381. * Creates a hemisphere mesh
  53382. * @param name defines the name of the mesh
  53383. * @param options defines the options used to create the mesh
  53384. * @param scene defines the hosting scene
  53385. * @returns the hemisphere mesh
  53386. */
  53387. static CreateHemisphere(name: string, options: {
  53388. segments?: number;
  53389. diameter?: number;
  53390. sideOrientation?: number;
  53391. }, scene: any): Mesh;
  53392. }
  53393. }
  53394. declare module BABYLON {
  53395. /**
  53396. * A spot light is defined by a position, a direction, an angle, and an exponent.
  53397. * These values define a cone of light starting from the position, emitting toward the direction.
  53398. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  53399. * and the exponent defines the speed of the decay of the light with distance (reach).
  53400. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53401. */
  53402. export class SpotLight extends ShadowLight {
  53403. private _angle;
  53404. private _innerAngle;
  53405. private _cosHalfAngle;
  53406. private _lightAngleScale;
  53407. private _lightAngleOffset;
  53408. /**
  53409. * Gets the cone angle of the spot light in Radians.
  53410. */
  53411. get angle(): number;
  53412. /**
  53413. * Sets the cone angle of the spot light in Radians.
  53414. */
  53415. set angle(value: number);
  53416. /**
  53417. * Only used in gltf falloff mode, this defines the angle where
  53418. * the directional falloff will start before cutting at angle which could be seen
  53419. * as outer angle.
  53420. */
  53421. get innerAngle(): number;
  53422. /**
  53423. * Only used in gltf falloff mode, this defines the angle where
  53424. * the directional falloff will start before cutting at angle which could be seen
  53425. * as outer angle.
  53426. */
  53427. set innerAngle(value: number);
  53428. private _shadowAngleScale;
  53429. /**
  53430. * Allows scaling the angle of the light for shadow generation only.
  53431. */
  53432. get shadowAngleScale(): number;
  53433. /**
  53434. * Allows scaling the angle of the light for shadow generation only.
  53435. */
  53436. set shadowAngleScale(value: number);
  53437. /**
  53438. * The light decay speed with the distance from the emission spot.
  53439. */
  53440. exponent: number;
  53441. private _projectionTextureMatrix;
  53442. /**
  53443. * Allows reading the projecton texture
  53444. */
  53445. get projectionTextureMatrix(): Matrix;
  53446. protected _projectionTextureLightNear: number;
  53447. /**
  53448. * Gets the near clip of the Spotlight for texture projection.
  53449. */
  53450. get projectionTextureLightNear(): number;
  53451. /**
  53452. * Sets the near clip of the Spotlight for texture projection.
  53453. */
  53454. set projectionTextureLightNear(value: number);
  53455. protected _projectionTextureLightFar: number;
  53456. /**
  53457. * Gets the far clip of the Spotlight for texture projection.
  53458. */
  53459. get projectionTextureLightFar(): number;
  53460. /**
  53461. * Sets the far clip of the Spotlight for texture projection.
  53462. */
  53463. set projectionTextureLightFar(value: number);
  53464. protected _projectionTextureUpDirection: Vector3;
  53465. /**
  53466. * Gets the Up vector of the Spotlight for texture projection.
  53467. */
  53468. get projectionTextureUpDirection(): Vector3;
  53469. /**
  53470. * Sets the Up vector of the Spotlight for texture projection.
  53471. */
  53472. set projectionTextureUpDirection(value: Vector3);
  53473. private _projectionTexture;
  53474. /**
  53475. * Gets the projection texture of the light.
  53476. */
  53477. get projectionTexture(): Nullable<BaseTexture>;
  53478. /**
  53479. * Sets the projection texture of the light.
  53480. */
  53481. set projectionTexture(value: Nullable<BaseTexture>);
  53482. private _projectionTextureViewLightDirty;
  53483. private _projectionTextureProjectionLightDirty;
  53484. private _projectionTextureDirty;
  53485. private _projectionTextureViewTargetVector;
  53486. private _projectionTextureViewLightMatrix;
  53487. private _projectionTextureProjectionLightMatrix;
  53488. private _projectionTextureScalingMatrix;
  53489. /**
  53490. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  53491. * It can cast shadows.
  53492. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53493. * @param name The light friendly name
  53494. * @param position The position of the spot light in the scene
  53495. * @param direction The direction of the light in the scene
  53496. * @param angle The cone angle of the light in Radians
  53497. * @param exponent The light decay speed with the distance from the emission spot
  53498. * @param scene The scene the lights belongs to
  53499. */
  53500. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  53501. /**
  53502. * Returns the string "SpotLight".
  53503. * @returns the class name
  53504. */
  53505. getClassName(): string;
  53506. /**
  53507. * Returns the integer 2.
  53508. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53509. */
  53510. getTypeID(): number;
  53511. /**
  53512. * Overrides the direction setter to recompute the projection texture view light Matrix.
  53513. */
  53514. protected _setDirection(value: Vector3): void;
  53515. /**
  53516. * Overrides the position setter to recompute the projection texture view light Matrix.
  53517. */
  53518. protected _setPosition(value: Vector3): void;
  53519. /**
  53520. * 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.
  53521. * Returns the SpotLight.
  53522. */
  53523. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53524. protected _computeProjectionTextureViewLightMatrix(): void;
  53525. protected _computeProjectionTextureProjectionLightMatrix(): void;
  53526. /**
  53527. * Main function for light texture projection matrix computing.
  53528. */
  53529. protected _computeProjectionTextureMatrix(): void;
  53530. protected _buildUniformLayout(): void;
  53531. private _computeAngleValues;
  53532. /**
  53533. * Sets the passed Effect "effect" with the Light textures.
  53534. * @param effect The effect to update
  53535. * @param lightIndex The index of the light in the effect to update
  53536. * @returns The light
  53537. */
  53538. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  53539. /**
  53540. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  53541. * @param effect The effect to update
  53542. * @param lightIndex The index of the light in the effect to update
  53543. * @returns The spot light
  53544. */
  53545. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  53546. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  53547. /**
  53548. * Disposes the light and the associated resources.
  53549. */
  53550. dispose(): void;
  53551. /**
  53552. * Prepares the list of defines specific to the light type.
  53553. * @param defines the list of defines
  53554. * @param lightIndex defines the index of the light for the effect
  53555. */
  53556. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53557. }
  53558. }
  53559. declare module BABYLON {
  53560. /**
  53561. * Gizmo that enables viewing a light
  53562. */
  53563. export class LightGizmo extends Gizmo {
  53564. private _lightMesh;
  53565. private _material;
  53566. private _cachedPosition;
  53567. private _cachedForward;
  53568. private _attachedMeshParent;
  53569. /**
  53570. * Creates a LightGizmo
  53571. * @param gizmoLayer The utility layer the gizmo will be added to
  53572. */
  53573. constructor(gizmoLayer?: UtilityLayerRenderer);
  53574. private _light;
  53575. /**
  53576. * The light that the gizmo is attached to
  53577. */
  53578. set light(light: Nullable<Light>);
  53579. get light(): Nullable<Light>;
  53580. /**
  53581. * Gets the material used to render the light gizmo
  53582. */
  53583. get material(): StandardMaterial;
  53584. /**
  53585. * @hidden
  53586. * Updates the gizmo to match the attached mesh's position/rotation
  53587. */
  53588. protected _update(): void;
  53589. private static _Scale;
  53590. /**
  53591. * Creates the lines for a light mesh
  53592. */
  53593. private static _CreateLightLines;
  53594. /**
  53595. * Disposes of the light gizmo
  53596. */
  53597. dispose(): void;
  53598. private static _CreateHemisphericLightMesh;
  53599. private static _CreatePointLightMesh;
  53600. private static _CreateSpotLightMesh;
  53601. private static _CreateDirectionalLightMesh;
  53602. }
  53603. }
  53604. declare module BABYLON {
  53605. /** @hidden */
  53606. export var backgroundFragmentDeclaration: {
  53607. name: string;
  53608. shader: string;
  53609. };
  53610. }
  53611. declare module BABYLON {
  53612. /** @hidden */
  53613. export var backgroundUboDeclaration: {
  53614. name: string;
  53615. shader: string;
  53616. };
  53617. }
  53618. declare module BABYLON {
  53619. /** @hidden */
  53620. export var backgroundPixelShader: {
  53621. name: string;
  53622. shader: string;
  53623. };
  53624. }
  53625. declare module BABYLON {
  53626. /** @hidden */
  53627. export var backgroundVertexDeclaration: {
  53628. name: string;
  53629. shader: string;
  53630. };
  53631. }
  53632. declare module BABYLON {
  53633. /** @hidden */
  53634. export var backgroundVertexShader: {
  53635. name: string;
  53636. shader: string;
  53637. };
  53638. }
  53639. declare module BABYLON {
  53640. /**
  53641. * Background material used to create an efficient environement around your scene.
  53642. */
  53643. export class BackgroundMaterial extends PushMaterial {
  53644. /**
  53645. * Standard reflectance value at parallel view angle.
  53646. */
  53647. static StandardReflectance0: number;
  53648. /**
  53649. * Standard reflectance value at grazing angle.
  53650. */
  53651. static StandardReflectance90: number;
  53652. protected _primaryColor: Color3;
  53653. /**
  53654. * Key light Color (multiply against the environement texture)
  53655. */
  53656. primaryColor: Color3;
  53657. protected __perceptualColor: Nullable<Color3>;
  53658. /**
  53659. * Experimental Internal Use Only.
  53660. *
  53661. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  53662. * This acts as a helper to set the primary color to a more "human friendly" value.
  53663. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  53664. * output color as close as possible from the chosen value.
  53665. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  53666. * part of lighting setup.)
  53667. */
  53668. get _perceptualColor(): Nullable<Color3>;
  53669. set _perceptualColor(value: Nullable<Color3>);
  53670. protected _primaryColorShadowLevel: float;
  53671. /**
  53672. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  53673. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  53674. */
  53675. get primaryColorShadowLevel(): float;
  53676. set primaryColorShadowLevel(value: float);
  53677. protected _primaryColorHighlightLevel: float;
  53678. /**
  53679. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  53680. * The primary color is used at the level chosen to define what the white area would look.
  53681. */
  53682. get primaryColorHighlightLevel(): float;
  53683. set primaryColorHighlightLevel(value: float);
  53684. protected _reflectionTexture: Nullable<BaseTexture>;
  53685. /**
  53686. * Reflection Texture used in the material.
  53687. * Should be author in a specific way for the best result (refer to the documentation).
  53688. */
  53689. reflectionTexture: Nullable<BaseTexture>;
  53690. protected _reflectionBlur: float;
  53691. /**
  53692. * Reflection Texture level of blur.
  53693. *
  53694. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  53695. * texture twice.
  53696. */
  53697. reflectionBlur: float;
  53698. protected _diffuseTexture: Nullable<BaseTexture>;
  53699. /**
  53700. * Diffuse Texture used in the material.
  53701. * Should be author in a specific way for the best result (refer to the documentation).
  53702. */
  53703. diffuseTexture: Nullable<BaseTexture>;
  53704. protected _shadowLights: Nullable<IShadowLight[]>;
  53705. /**
  53706. * Specify the list of lights casting shadow on the material.
  53707. * All scene shadow lights will be included if null.
  53708. */
  53709. shadowLights: Nullable<IShadowLight[]>;
  53710. protected _shadowLevel: float;
  53711. /**
  53712. * Helps adjusting the shadow to a softer level if required.
  53713. * 0 means black shadows and 1 means no shadows.
  53714. */
  53715. shadowLevel: float;
  53716. protected _sceneCenter: Vector3;
  53717. /**
  53718. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  53719. * It is usually zero but might be interesting to modify according to your setup.
  53720. */
  53721. sceneCenter: Vector3;
  53722. protected _opacityFresnel: boolean;
  53723. /**
  53724. * This helps specifying that the material is falling off to the sky box at grazing angle.
  53725. * This helps ensuring a nice transition when the camera goes under the ground.
  53726. */
  53727. opacityFresnel: boolean;
  53728. protected _reflectionFresnel: boolean;
  53729. /**
  53730. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  53731. * This helps adding a mirror texture on the ground.
  53732. */
  53733. reflectionFresnel: boolean;
  53734. protected _reflectionFalloffDistance: number;
  53735. /**
  53736. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  53737. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  53738. */
  53739. reflectionFalloffDistance: number;
  53740. protected _reflectionAmount: number;
  53741. /**
  53742. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  53743. */
  53744. reflectionAmount: number;
  53745. protected _reflectionReflectance0: number;
  53746. /**
  53747. * This specifies the weight of the reflection at grazing angle.
  53748. */
  53749. reflectionReflectance0: number;
  53750. protected _reflectionReflectance90: number;
  53751. /**
  53752. * This specifies the weight of the reflection at a perpendicular point of view.
  53753. */
  53754. reflectionReflectance90: number;
  53755. /**
  53756. * Sets the reflection reflectance fresnel values according to the default standard
  53757. * empirically know to work well :-)
  53758. */
  53759. set reflectionStandardFresnelWeight(value: number);
  53760. protected _useRGBColor: boolean;
  53761. /**
  53762. * Helps to directly use the maps channels instead of their level.
  53763. */
  53764. useRGBColor: boolean;
  53765. protected _enableNoise: boolean;
  53766. /**
  53767. * This helps reducing the banding effect that could occur on the background.
  53768. */
  53769. enableNoise: boolean;
  53770. /**
  53771. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53772. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  53773. * Recommended to be keep at 1.0 except for special cases.
  53774. */
  53775. get fovMultiplier(): number;
  53776. set fovMultiplier(value: number);
  53777. private _fovMultiplier;
  53778. /**
  53779. * Enable the FOV adjustment feature controlled by fovMultiplier.
  53780. */
  53781. useEquirectangularFOV: boolean;
  53782. private _maxSimultaneousLights;
  53783. /**
  53784. * Number of Simultaneous lights allowed on the material.
  53785. */
  53786. maxSimultaneousLights: int;
  53787. private _shadowOnly;
  53788. /**
  53789. * Make the material only render shadows
  53790. */
  53791. shadowOnly: boolean;
  53792. /**
  53793. * Default configuration related to image processing available in the Background Material.
  53794. */
  53795. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53796. /**
  53797. * Keep track of the image processing observer to allow dispose and replace.
  53798. */
  53799. private _imageProcessingObserver;
  53800. /**
  53801. * Attaches a new image processing configuration to the PBR Material.
  53802. * @param configuration (if null the scene configuration will be use)
  53803. */
  53804. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53805. /**
  53806. * Gets the image processing configuration used either in this material.
  53807. */
  53808. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  53809. /**
  53810. * Sets the Default image processing configuration used either in the this material.
  53811. *
  53812. * If sets to null, the scene one is in use.
  53813. */
  53814. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  53815. /**
  53816. * Gets wether the color curves effect is enabled.
  53817. */
  53818. get cameraColorCurvesEnabled(): boolean;
  53819. /**
  53820. * Sets wether the color curves effect is enabled.
  53821. */
  53822. set cameraColorCurvesEnabled(value: boolean);
  53823. /**
  53824. * Gets wether the color grading effect is enabled.
  53825. */
  53826. get cameraColorGradingEnabled(): boolean;
  53827. /**
  53828. * Gets wether the color grading effect is enabled.
  53829. */
  53830. set cameraColorGradingEnabled(value: boolean);
  53831. /**
  53832. * Gets wether tonemapping is enabled or not.
  53833. */
  53834. get cameraToneMappingEnabled(): boolean;
  53835. /**
  53836. * Sets wether tonemapping is enabled or not
  53837. */
  53838. set cameraToneMappingEnabled(value: boolean);
  53839. /**
  53840. * The camera exposure used on this material.
  53841. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53842. * This corresponds to a photographic exposure.
  53843. */
  53844. get cameraExposure(): float;
  53845. /**
  53846. * The camera exposure used on this material.
  53847. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53848. * This corresponds to a photographic exposure.
  53849. */
  53850. set cameraExposure(value: float);
  53851. /**
  53852. * Gets The camera contrast used on this material.
  53853. */
  53854. get cameraContrast(): float;
  53855. /**
  53856. * Sets The camera contrast used on this material.
  53857. */
  53858. set cameraContrast(value: float);
  53859. /**
  53860. * Gets the Color Grading 2D Lookup Texture.
  53861. */
  53862. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  53863. /**
  53864. * Sets the Color Grading 2D Lookup Texture.
  53865. */
  53866. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  53867. /**
  53868. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53869. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53870. * 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;
  53871. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53872. */
  53873. get cameraColorCurves(): Nullable<ColorCurves>;
  53874. /**
  53875. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53876. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53877. * 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;
  53878. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53879. */
  53880. set cameraColorCurves(value: Nullable<ColorCurves>);
  53881. /**
  53882. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  53883. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  53884. */
  53885. switchToBGR: boolean;
  53886. private _renderTargets;
  53887. private _reflectionControls;
  53888. private _white;
  53889. private _primaryShadowColor;
  53890. private _primaryHighlightColor;
  53891. /**
  53892. * Instantiates a Background Material in the given scene
  53893. * @param name The friendly name of the material
  53894. * @param scene The scene to add the material to
  53895. */
  53896. constructor(name: string, scene: Scene);
  53897. /**
  53898. * Gets a boolean indicating that current material needs to register RTT
  53899. */
  53900. get hasRenderTargetTextures(): boolean;
  53901. /**
  53902. * The entire material has been created in order to prevent overdraw.
  53903. * @returns false
  53904. */
  53905. needAlphaTesting(): boolean;
  53906. /**
  53907. * The entire material has been created in order to prevent overdraw.
  53908. * @returns true if blending is enable
  53909. */
  53910. needAlphaBlending(): boolean;
  53911. /**
  53912. * Checks wether the material is ready to be rendered for a given mesh.
  53913. * @param mesh The mesh to render
  53914. * @param subMesh The submesh to check against
  53915. * @param useInstances Specify wether or not the material is used with instances
  53916. * @returns true if all the dependencies are ready (Textures, Effects...)
  53917. */
  53918. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53919. /**
  53920. * Compute the primary color according to the chosen perceptual color.
  53921. */
  53922. private _computePrimaryColorFromPerceptualColor;
  53923. /**
  53924. * Compute the highlights and shadow colors according to their chosen levels.
  53925. */
  53926. private _computePrimaryColors;
  53927. /**
  53928. * Build the uniform buffer used in the material.
  53929. */
  53930. buildUniformLayout(): void;
  53931. /**
  53932. * Unbind the material.
  53933. */
  53934. unbind(): void;
  53935. /**
  53936. * Bind only the world matrix to the material.
  53937. * @param world The world matrix to bind.
  53938. */
  53939. bindOnlyWorldMatrix(world: Matrix): void;
  53940. /**
  53941. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  53942. * @param world The world matrix to bind.
  53943. * @param subMesh The submesh to bind for.
  53944. */
  53945. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53946. /**
  53947. * Checks to see if a texture is used in the material.
  53948. * @param texture - Base texture to use.
  53949. * @returns - Boolean specifying if a texture is used in the material.
  53950. */
  53951. hasTexture(texture: BaseTexture): boolean;
  53952. /**
  53953. * Dispose the material.
  53954. * @param forceDisposeEffect Force disposal of the associated effect.
  53955. * @param forceDisposeTextures Force disposal of the associated textures.
  53956. */
  53957. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53958. /**
  53959. * Clones the material.
  53960. * @param name The cloned name.
  53961. * @returns The cloned material.
  53962. */
  53963. clone(name: string): BackgroundMaterial;
  53964. /**
  53965. * Serializes the current material to its JSON representation.
  53966. * @returns The JSON representation.
  53967. */
  53968. serialize(): any;
  53969. /**
  53970. * Gets the class name of the material
  53971. * @returns "BackgroundMaterial"
  53972. */
  53973. getClassName(): string;
  53974. /**
  53975. * Parse a JSON input to create back a background material.
  53976. * @param source The JSON data to parse
  53977. * @param scene The scene to create the parsed material in
  53978. * @param rootUrl The root url of the assets the material depends upon
  53979. * @returns the instantiated BackgroundMaterial.
  53980. */
  53981. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  53982. }
  53983. }
  53984. declare module BABYLON {
  53985. /**
  53986. * Represents the different options available during the creation of
  53987. * a Environment helper.
  53988. *
  53989. * This can control the default ground, skybox and image processing setup of your scene.
  53990. */
  53991. export interface IEnvironmentHelperOptions {
  53992. /**
  53993. * Specifies whether or not to create a ground.
  53994. * True by default.
  53995. */
  53996. createGround: boolean;
  53997. /**
  53998. * Specifies the ground size.
  53999. * 15 by default.
  54000. */
  54001. groundSize: number;
  54002. /**
  54003. * The texture used on the ground for the main color.
  54004. * Comes from the BabylonJS CDN by default.
  54005. *
  54006. * Remarks: Can be either a texture or a url.
  54007. */
  54008. groundTexture: string | BaseTexture;
  54009. /**
  54010. * The color mixed in the ground texture by default.
  54011. * BabylonJS clearColor by default.
  54012. */
  54013. groundColor: Color3;
  54014. /**
  54015. * Specifies the ground opacity.
  54016. * 1 by default.
  54017. */
  54018. groundOpacity: number;
  54019. /**
  54020. * Enables the ground to receive shadows.
  54021. * True by default.
  54022. */
  54023. enableGroundShadow: boolean;
  54024. /**
  54025. * Helps preventing the shadow to be fully black on the ground.
  54026. * 0.5 by default.
  54027. */
  54028. groundShadowLevel: number;
  54029. /**
  54030. * Creates a mirror texture attach to the ground.
  54031. * false by default.
  54032. */
  54033. enableGroundMirror: boolean;
  54034. /**
  54035. * Specifies the ground mirror size ratio.
  54036. * 0.3 by default as the default kernel is 64.
  54037. */
  54038. groundMirrorSizeRatio: number;
  54039. /**
  54040. * Specifies the ground mirror blur kernel size.
  54041. * 64 by default.
  54042. */
  54043. groundMirrorBlurKernel: number;
  54044. /**
  54045. * Specifies the ground mirror visibility amount.
  54046. * 1 by default
  54047. */
  54048. groundMirrorAmount: number;
  54049. /**
  54050. * Specifies the ground mirror reflectance weight.
  54051. * This uses the standard weight of the background material to setup the fresnel effect
  54052. * of the mirror.
  54053. * 1 by default.
  54054. */
  54055. groundMirrorFresnelWeight: number;
  54056. /**
  54057. * Specifies the ground mirror Falloff distance.
  54058. * This can helps reducing the size of the reflection.
  54059. * 0 by Default.
  54060. */
  54061. groundMirrorFallOffDistance: number;
  54062. /**
  54063. * Specifies the ground mirror texture type.
  54064. * Unsigned Int by Default.
  54065. */
  54066. groundMirrorTextureType: number;
  54067. /**
  54068. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  54069. * the shown objects.
  54070. */
  54071. groundYBias: number;
  54072. /**
  54073. * Specifies whether or not to create a skybox.
  54074. * True by default.
  54075. */
  54076. createSkybox: boolean;
  54077. /**
  54078. * Specifies the skybox size.
  54079. * 20 by default.
  54080. */
  54081. skyboxSize: number;
  54082. /**
  54083. * The texture used on the skybox for the main color.
  54084. * Comes from the BabylonJS CDN by default.
  54085. *
  54086. * Remarks: Can be either a texture or a url.
  54087. */
  54088. skyboxTexture: string | BaseTexture;
  54089. /**
  54090. * The color mixed in the skybox texture by default.
  54091. * BabylonJS clearColor by default.
  54092. */
  54093. skyboxColor: Color3;
  54094. /**
  54095. * The background rotation around the Y axis of the scene.
  54096. * This helps aligning the key lights of your scene with the background.
  54097. * 0 by default.
  54098. */
  54099. backgroundYRotation: number;
  54100. /**
  54101. * Compute automatically the size of the elements to best fit with the scene.
  54102. */
  54103. sizeAuto: boolean;
  54104. /**
  54105. * Default position of the rootMesh if autoSize is not true.
  54106. */
  54107. rootPosition: Vector3;
  54108. /**
  54109. * Sets up the image processing in the scene.
  54110. * true by default.
  54111. */
  54112. setupImageProcessing: boolean;
  54113. /**
  54114. * The texture used as your environment texture in the scene.
  54115. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  54116. *
  54117. * Remarks: Can be either a texture or a url.
  54118. */
  54119. environmentTexture: string | BaseTexture;
  54120. /**
  54121. * The value of the exposure to apply to the scene.
  54122. * 0.6 by default if setupImageProcessing is true.
  54123. */
  54124. cameraExposure: number;
  54125. /**
  54126. * The value of the contrast to apply to the scene.
  54127. * 1.6 by default if setupImageProcessing is true.
  54128. */
  54129. cameraContrast: number;
  54130. /**
  54131. * Specifies whether or not tonemapping should be enabled in the scene.
  54132. * true by default if setupImageProcessing is true.
  54133. */
  54134. toneMappingEnabled: boolean;
  54135. }
  54136. /**
  54137. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  54138. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  54139. * It also helps with the default setup of your imageProcessing configuration.
  54140. */
  54141. export class EnvironmentHelper {
  54142. /**
  54143. * Default ground texture URL.
  54144. */
  54145. private static _groundTextureCDNUrl;
  54146. /**
  54147. * Default skybox texture URL.
  54148. */
  54149. private static _skyboxTextureCDNUrl;
  54150. /**
  54151. * Default environment texture URL.
  54152. */
  54153. private static _environmentTextureCDNUrl;
  54154. /**
  54155. * Creates the default options for the helper.
  54156. */
  54157. private static _getDefaultOptions;
  54158. private _rootMesh;
  54159. /**
  54160. * Gets the root mesh created by the helper.
  54161. */
  54162. get rootMesh(): Mesh;
  54163. private _skybox;
  54164. /**
  54165. * Gets the skybox created by the helper.
  54166. */
  54167. get skybox(): Nullable<Mesh>;
  54168. private _skyboxTexture;
  54169. /**
  54170. * Gets the skybox texture created by the helper.
  54171. */
  54172. get skyboxTexture(): Nullable<BaseTexture>;
  54173. private _skyboxMaterial;
  54174. /**
  54175. * Gets the skybox material created by the helper.
  54176. */
  54177. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  54178. private _ground;
  54179. /**
  54180. * Gets the ground mesh created by the helper.
  54181. */
  54182. get ground(): Nullable<Mesh>;
  54183. private _groundTexture;
  54184. /**
  54185. * Gets the ground texture created by the helper.
  54186. */
  54187. get groundTexture(): Nullable<BaseTexture>;
  54188. private _groundMirror;
  54189. /**
  54190. * Gets the ground mirror created by the helper.
  54191. */
  54192. get groundMirror(): Nullable<MirrorTexture>;
  54193. /**
  54194. * Gets the ground mirror render list to helps pushing the meshes
  54195. * you wish in the ground reflection.
  54196. */
  54197. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  54198. private _groundMaterial;
  54199. /**
  54200. * Gets the ground material created by the helper.
  54201. */
  54202. get groundMaterial(): Nullable<BackgroundMaterial>;
  54203. /**
  54204. * Stores the creation options.
  54205. */
  54206. private readonly _scene;
  54207. private _options;
  54208. /**
  54209. * This observable will be notified with any error during the creation of the environment,
  54210. * mainly texture creation errors.
  54211. */
  54212. onErrorObservable: Observable<{
  54213. message?: string;
  54214. exception?: any;
  54215. }>;
  54216. /**
  54217. * constructor
  54218. * @param options Defines the options we want to customize the helper
  54219. * @param scene The scene to add the material to
  54220. */
  54221. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  54222. /**
  54223. * Updates the background according to the new options
  54224. * @param options
  54225. */
  54226. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  54227. /**
  54228. * Sets the primary color of all the available elements.
  54229. * @param color the main color to affect to the ground and the background
  54230. */
  54231. setMainColor(color: Color3): void;
  54232. /**
  54233. * Setup the image processing according to the specified options.
  54234. */
  54235. private _setupImageProcessing;
  54236. /**
  54237. * Setup the environment texture according to the specified options.
  54238. */
  54239. private _setupEnvironmentTexture;
  54240. /**
  54241. * Setup the background according to the specified options.
  54242. */
  54243. private _setupBackground;
  54244. /**
  54245. * Get the scene sizes according to the setup.
  54246. */
  54247. private _getSceneSize;
  54248. /**
  54249. * Setup the ground according to the specified options.
  54250. */
  54251. private _setupGround;
  54252. /**
  54253. * Setup the ground material according to the specified options.
  54254. */
  54255. private _setupGroundMaterial;
  54256. /**
  54257. * Setup the ground diffuse texture according to the specified options.
  54258. */
  54259. private _setupGroundDiffuseTexture;
  54260. /**
  54261. * Setup the ground mirror texture according to the specified options.
  54262. */
  54263. private _setupGroundMirrorTexture;
  54264. /**
  54265. * Setup the ground to receive the mirror texture.
  54266. */
  54267. private _setupMirrorInGroundMaterial;
  54268. /**
  54269. * Setup the skybox according to the specified options.
  54270. */
  54271. private _setupSkybox;
  54272. /**
  54273. * Setup the skybox material according to the specified options.
  54274. */
  54275. private _setupSkyboxMaterial;
  54276. /**
  54277. * Setup the skybox reflection texture according to the specified options.
  54278. */
  54279. private _setupSkyboxReflectionTexture;
  54280. private _errorHandler;
  54281. /**
  54282. * Dispose all the elements created by the Helper.
  54283. */
  54284. dispose(): void;
  54285. }
  54286. }
  54287. declare module BABYLON {
  54288. /**
  54289. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  54290. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  54291. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  54292. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54293. */
  54294. export class PhotoDome extends TransformNode {
  54295. /**
  54296. * Define the image as a Monoscopic panoramic 360 image.
  54297. */
  54298. static readonly MODE_MONOSCOPIC: number;
  54299. /**
  54300. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  54301. */
  54302. static readonly MODE_TOPBOTTOM: number;
  54303. /**
  54304. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  54305. */
  54306. static readonly MODE_SIDEBYSIDE: number;
  54307. private _useDirectMapping;
  54308. /**
  54309. * The texture being displayed on the sphere
  54310. */
  54311. protected _photoTexture: Texture;
  54312. /**
  54313. * Gets or sets the texture being displayed on the sphere
  54314. */
  54315. get photoTexture(): Texture;
  54316. set photoTexture(value: Texture);
  54317. /**
  54318. * Observable raised when an error occured while loading the 360 image
  54319. */
  54320. onLoadErrorObservable: Observable<string>;
  54321. /**
  54322. * The skybox material
  54323. */
  54324. protected _material: BackgroundMaterial;
  54325. /**
  54326. * The surface used for the skybox
  54327. */
  54328. protected _mesh: Mesh;
  54329. /**
  54330. * Gets the mesh used for the skybox.
  54331. */
  54332. get mesh(): Mesh;
  54333. /**
  54334. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54335. * Also see the options.resolution property.
  54336. */
  54337. get fovMultiplier(): number;
  54338. set fovMultiplier(value: number);
  54339. private _imageMode;
  54340. /**
  54341. * Gets or set the current video mode for the video. It can be:
  54342. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  54343. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  54344. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  54345. */
  54346. get imageMode(): number;
  54347. set imageMode(value: number);
  54348. /**
  54349. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  54350. * @param name Element's name, child elements will append suffixes for their own names.
  54351. * @param urlsOfPhoto defines the url of the photo to display
  54352. * @param options defines an object containing optional or exposed sub element properties
  54353. * @param onError defines a callback called when an error occured while loading the texture
  54354. */
  54355. constructor(name: string, urlOfPhoto: string, options: {
  54356. resolution?: number;
  54357. size?: number;
  54358. useDirectMapping?: boolean;
  54359. faceForward?: boolean;
  54360. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  54361. private _onBeforeCameraRenderObserver;
  54362. private _changeImageMode;
  54363. /**
  54364. * Releases resources associated with this node.
  54365. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54366. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54367. */
  54368. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  54369. }
  54370. }
  54371. declare module BABYLON {
  54372. /**
  54373. * Class used to host RGBD texture specific utilities
  54374. */
  54375. export class RGBDTextureTools {
  54376. /**
  54377. * Expand the RGBD Texture from RGBD to Half Float if possible.
  54378. * @param texture the texture to expand.
  54379. */
  54380. static ExpandRGBDTexture(texture: Texture): void;
  54381. }
  54382. }
  54383. declare module BABYLON {
  54384. /**
  54385. * Class used to host texture specific utilities
  54386. */
  54387. export class BRDFTextureTools {
  54388. /**
  54389. * Prevents texture cache collision
  54390. */
  54391. private static _instanceNumber;
  54392. /**
  54393. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  54394. * @param scene defines the hosting scene
  54395. * @returns the environment BRDF texture
  54396. */
  54397. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  54398. private static _environmentBRDFBase64Texture;
  54399. }
  54400. }
  54401. declare module BABYLON {
  54402. /**
  54403. * @hidden
  54404. */
  54405. export interface IMaterialClearCoatDefines {
  54406. CLEARCOAT: boolean;
  54407. CLEARCOAT_DEFAULTIOR: boolean;
  54408. CLEARCOAT_TEXTURE: boolean;
  54409. CLEARCOAT_TEXTUREDIRECTUV: number;
  54410. CLEARCOAT_BUMP: boolean;
  54411. CLEARCOAT_BUMPDIRECTUV: number;
  54412. CLEARCOAT_TINT: boolean;
  54413. CLEARCOAT_TINT_TEXTURE: boolean;
  54414. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  54415. /** @hidden */
  54416. _areTexturesDirty: boolean;
  54417. }
  54418. /**
  54419. * Define the code related to the clear coat parameters of the pbr material.
  54420. */
  54421. export class PBRClearCoatConfiguration {
  54422. /**
  54423. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  54424. * The default fits with a polyurethane material.
  54425. */
  54426. private static readonly _DefaultIndexOfRefraction;
  54427. private _isEnabled;
  54428. /**
  54429. * Defines if the clear coat is enabled in the material.
  54430. */
  54431. isEnabled: boolean;
  54432. /**
  54433. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  54434. */
  54435. intensity: number;
  54436. /**
  54437. * Defines the clear coat layer roughness.
  54438. */
  54439. roughness: number;
  54440. private _indexOfRefraction;
  54441. /**
  54442. * Defines the index of refraction of the clear coat.
  54443. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  54444. * The default fits with a polyurethane material.
  54445. * Changing the default value is more performance intensive.
  54446. */
  54447. indexOfRefraction: number;
  54448. private _texture;
  54449. /**
  54450. * Stores the clear coat values in a texture.
  54451. */
  54452. texture: Nullable<BaseTexture>;
  54453. private _bumpTexture;
  54454. /**
  54455. * Define the clear coat specific bump texture.
  54456. */
  54457. bumpTexture: Nullable<BaseTexture>;
  54458. private _isTintEnabled;
  54459. /**
  54460. * Defines if the clear coat tint is enabled in the material.
  54461. */
  54462. isTintEnabled: boolean;
  54463. /**
  54464. * Defines the clear coat tint of the material.
  54465. * This is only use if tint is enabled
  54466. */
  54467. tintColor: Color3;
  54468. /**
  54469. * Defines the distance at which the tint color should be found in the
  54470. * clear coat media.
  54471. * This is only use if tint is enabled
  54472. */
  54473. tintColorAtDistance: number;
  54474. /**
  54475. * Defines the clear coat layer thickness.
  54476. * This is only use if tint is enabled
  54477. */
  54478. tintThickness: number;
  54479. private _tintTexture;
  54480. /**
  54481. * Stores the clear tint values in a texture.
  54482. * rgb is tint
  54483. * a is a thickness factor
  54484. */
  54485. tintTexture: Nullable<BaseTexture>;
  54486. /** @hidden */
  54487. private _internalMarkAllSubMeshesAsTexturesDirty;
  54488. /** @hidden */
  54489. _markAllSubMeshesAsTexturesDirty(): void;
  54490. /**
  54491. * Instantiate a new istance of clear coat configuration.
  54492. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54493. */
  54494. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54495. /**
  54496. * Gets wehter the submesh is ready to be used or not.
  54497. * @param defines the list of "defines" to update.
  54498. * @param scene defines the scene the material belongs to.
  54499. * @param engine defines the engine the material belongs to.
  54500. * @param disableBumpMap defines wether the material disables bump or not.
  54501. * @returns - boolean indicating that the submesh is ready or not.
  54502. */
  54503. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  54504. /**
  54505. * Checks to see if a texture is used in the material.
  54506. * @param defines the list of "defines" to update.
  54507. * @param scene defines the scene to the material belongs to.
  54508. */
  54509. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  54510. /**
  54511. * Binds the material data.
  54512. * @param uniformBuffer defines the Uniform buffer to fill in.
  54513. * @param scene defines the scene the material belongs to.
  54514. * @param engine defines the engine the material belongs to.
  54515. * @param disableBumpMap defines wether the material disables bump or not.
  54516. * @param isFrozen defines wether the material is frozen or not.
  54517. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  54518. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  54519. */
  54520. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  54521. /**
  54522. * Checks to see if a texture is used in the material.
  54523. * @param texture - Base texture to use.
  54524. * @returns - Boolean specifying if a texture is used in the material.
  54525. */
  54526. hasTexture(texture: BaseTexture): boolean;
  54527. /**
  54528. * Returns an array of the actively used textures.
  54529. * @param activeTextures Array of BaseTextures
  54530. */
  54531. getActiveTextures(activeTextures: BaseTexture[]): void;
  54532. /**
  54533. * Returns the animatable textures.
  54534. * @param animatables Array of animatable textures.
  54535. */
  54536. getAnimatables(animatables: IAnimatable[]): void;
  54537. /**
  54538. * Disposes the resources of the material.
  54539. * @param forceDisposeTextures - Forces the disposal of all textures.
  54540. */
  54541. dispose(forceDisposeTextures?: boolean): void;
  54542. /**
  54543. * Get the current class name of the texture useful for serialization or dynamic coding.
  54544. * @returns "PBRClearCoatConfiguration"
  54545. */
  54546. getClassName(): string;
  54547. /**
  54548. * Add fallbacks to the effect fallbacks list.
  54549. * @param defines defines the Base texture to use.
  54550. * @param fallbacks defines the current fallback list.
  54551. * @param currentRank defines the current fallback rank.
  54552. * @returns the new fallback rank.
  54553. */
  54554. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54555. /**
  54556. * Add the required uniforms to the current list.
  54557. * @param uniforms defines the current uniform list.
  54558. */
  54559. static AddUniforms(uniforms: string[]): void;
  54560. /**
  54561. * Add the required samplers to the current list.
  54562. * @param samplers defines the current sampler list.
  54563. */
  54564. static AddSamplers(samplers: string[]): void;
  54565. /**
  54566. * Add the required uniforms to the current buffer.
  54567. * @param uniformBuffer defines the current uniform buffer.
  54568. */
  54569. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54570. /**
  54571. * Makes a duplicate of the current configuration into another one.
  54572. * @param clearCoatConfiguration define the config where to copy the info
  54573. */
  54574. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  54575. /**
  54576. * Serializes this clear coat configuration.
  54577. * @returns - An object with the serialized config.
  54578. */
  54579. serialize(): any;
  54580. /**
  54581. * Parses a anisotropy Configuration from a serialized object.
  54582. * @param source - Serialized object.
  54583. * @param scene Defines the scene we are parsing for
  54584. * @param rootUrl Defines the rootUrl to load from
  54585. */
  54586. parse(source: any, scene: Scene, rootUrl: string): void;
  54587. }
  54588. }
  54589. declare module BABYLON {
  54590. /**
  54591. * @hidden
  54592. */
  54593. export interface IMaterialAnisotropicDefines {
  54594. ANISOTROPIC: boolean;
  54595. ANISOTROPIC_TEXTURE: boolean;
  54596. ANISOTROPIC_TEXTUREDIRECTUV: number;
  54597. MAINUV1: boolean;
  54598. _areTexturesDirty: boolean;
  54599. _needUVs: boolean;
  54600. }
  54601. /**
  54602. * Define the code related to the anisotropic parameters of the pbr material.
  54603. */
  54604. export class PBRAnisotropicConfiguration {
  54605. private _isEnabled;
  54606. /**
  54607. * Defines if the anisotropy is enabled in the material.
  54608. */
  54609. isEnabled: boolean;
  54610. /**
  54611. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  54612. */
  54613. intensity: number;
  54614. /**
  54615. * Defines if the effect is along the tangents, bitangents or in between.
  54616. * By default, the effect is "strectching" the highlights along the tangents.
  54617. */
  54618. direction: Vector2;
  54619. private _texture;
  54620. /**
  54621. * Stores the anisotropy values in a texture.
  54622. * rg is direction (like normal from -1 to 1)
  54623. * b is a intensity
  54624. */
  54625. texture: Nullable<BaseTexture>;
  54626. /** @hidden */
  54627. private _internalMarkAllSubMeshesAsTexturesDirty;
  54628. /** @hidden */
  54629. _markAllSubMeshesAsTexturesDirty(): void;
  54630. /**
  54631. * Instantiate a new istance of anisotropy configuration.
  54632. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54633. */
  54634. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54635. /**
  54636. * Specifies that the submesh is ready to be used.
  54637. * @param defines the list of "defines" to update.
  54638. * @param scene defines the scene the material belongs to.
  54639. * @returns - boolean indicating that the submesh is ready or not.
  54640. */
  54641. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  54642. /**
  54643. * Checks to see if a texture is used in the material.
  54644. * @param defines the list of "defines" to update.
  54645. * @param mesh the mesh we are preparing the defines for.
  54646. * @param scene defines the scene the material belongs to.
  54647. */
  54648. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  54649. /**
  54650. * Binds the material data.
  54651. * @param uniformBuffer defines the Uniform buffer to fill in.
  54652. * @param scene defines the scene the material belongs to.
  54653. * @param isFrozen defines wether the material is frozen or not.
  54654. */
  54655. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  54656. /**
  54657. * Checks to see if a texture is used in the material.
  54658. * @param texture - Base texture to use.
  54659. * @returns - Boolean specifying if a texture is used in the material.
  54660. */
  54661. hasTexture(texture: BaseTexture): boolean;
  54662. /**
  54663. * Returns an array of the actively used textures.
  54664. * @param activeTextures Array of BaseTextures
  54665. */
  54666. getActiveTextures(activeTextures: BaseTexture[]): void;
  54667. /**
  54668. * Returns the animatable textures.
  54669. * @param animatables Array of animatable textures.
  54670. */
  54671. getAnimatables(animatables: IAnimatable[]): void;
  54672. /**
  54673. * Disposes the resources of the material.
  54674. * @param forceDisposeTextures - Forces the disposal of all textures.
  54675. */
  54676. dispose(forceDisposeTextures?: boolean): void;
  54677. /**
  54678. * Get the current class name of the texture useful for serialization or dynamic coding.
  54679. * @returns "PBRAnisotropicConfiguration"
  54680. */
  54681. getClassName(): string;
  54682. /**
  54683. * Add fallbacks to the effect fallbacks list.
  54684. * @param defines defines the Base texture to use.
  54685. * @param fallbacks defines the current fallback list.
  54686. * @param currentRank defines the current fallback rank.
  54687. * @returns the new fallback rank.
  54688. */
  54689. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54690. /**
  54691. * Add the required uniforms to the current list.
  54692. * @param uniforms defines the current uniform list.
  54693. */
  54694. static AddUniforms(uniforms: string[]): void;
  54695. /**
  54696. * Add the required uniforms to the current buffer.
  54697. * @param uniformBuffer defines the current uniform buffer.
  54698. */
  54699. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54700. /**
  54701. * Add the required samplers to the current list.
  54702. * @param samplers defines the current sampler list.
  54703. */
  54704. static AddSamplers(samplers: string[]): void;
  54705. /**
  54706. * Makes a duplicate of the current configuration into another one.
  54707. * @param anisotropicConfiguration define the config where to copy the info
  54708. */
  54709. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  54710. /**
  54711. * Serializes this anisotropy configuration.
  54712. * @returns - An object with the serialized config.
  54713. */
  54714. serialize(): any;
  54715. /**
  54716. * Parses a anisotropy Configuration from a serialized object.
  54717. * @param source - Serialized object.
  54718. * @param scene Defines the scene we are parsing for
  54719. * @param rootUrl Defines the rootUrl to load from
  54720. */
  54721. parse(source: any, scene: Scene, rootUrl: string): void;
  54722. }
  54723. }
  54724. declare module BABYLON {
  54725. /**
  54726. * @hidden
  54727. */
  54728. export interface IMaterialBRDFDefines {
  54729. BRDF_V_HEIGHT_CORRELATED: boolean;
  54730. MS_BRDF_ENERGY_CONSERVATION: boolean;
  54731. SPHERICAL_HARMONICS: boolean;
  54732. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  54733. /** @hidden */
  54734. _areMiscDirty: boolean;
  54735. }
  54736. /**
  54737. * Define the code related to the BRDF parameters of the pbr material.
  54738. */
  54739. export class PBRBRDFConfiguration {
  54740. /**
  54741. * Default value used for the energy conservation.
  54742. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54743. */
  54744. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  54745. /**
  54746. * Default value used for the Smith Visibility Height Correlated mode.
  54747. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54748. */
  54749. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  54750. /**
  54751. * Default value used for the IBL diffuse part.
  54752. * This can help switching back to the polynomials mode globally which is a tiny bit
  54753. * less GPU intensive at the drawback of a lower quality.
  54754. */
  54755. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  54756. /**
  54757. * Default value used for activating energy conservation for the specular workflow.
  54758. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54759. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54760. */
  54761. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  54762. private _useEnergyConservation;
  54763. /**
  54764. * Defines if the material uses energy conservation.
  54765. */
  54766. useEnergyConservation: boolean;
  54767. private _useSmithVisibilityHeightCorrelated;
  54768. /**
  54769. * LEGACY Mode set to false
  54770. * Defines if the material uses height smith correlated visibility term.
  54771. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  54772. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  54773. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  54774. * Not relying on height correlated will also disable energy conservation.
  54775. */
  54776. useSmithVisibilityHeightCorrelated: boolean;
  54777. private _useSphericalHarmonics;
  54778. /**
  54779. * LEGACY Mode set to false
  54780. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  54781. * diffuse part of the IBL.
  54782. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  54783. * to the ground truth.
  54784. */
  54785. useSphericalHarmonics: boolean;
  54786. private _useSpecularGlossinessInputEnergyConservation;
  54787. /**
  54788. * Defines if the material uses energy conservation, when the specular workflow is active.
  54789. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54790. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54791. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  54792. */
  54793. useSpecularGlossinessInputEnergyConservation: boolean;
  54794. /** @hidden */
  54795. private _internalMarkAllSubMeshesAsMiscDirty;
  54796. /** @hidden */
  54797. _markAllSubMeshesAsMiscDirty(): void;
  54798. /**
  54799. * Instantiate a new istance of clear coat configuration.
  54800. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  54801. */
  54802. constructor(markAllSubMeshesAsMiscDirty: () => void);
  54803. /**
  54804. * Checks to see if a texture is used in the material.
  54805. * @param defines the list of "defines" to update.
  54806. */
  54807. prepareDefines(defines: IMaterialBRDFDefines): void;
  54808. /**
  54809. * Get the current class name of the texture useful for serialization or dynamic coding.
  54810. * @returns "PBRClearCoatConfiguration"
  54811. */
  54812. getClassName(): string;
  54813. /**
  54814. * Makes a duplicate of the current configuration into another one.
  54815. * @param brdfConfiguration define the config where to copy the info
  54816. */
  54817. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  54818. /**
  54819. * Serializes this BRDF configuration.
  54820. * @returns - An object with the serialized config.
  54821. */
  54822. serialize(): any;
  54823. /**
  54824. * Parses a anisotropy Configuration from a serialized object.
  54825. * @param source - Serialized object.
  54826. * @param scene Defines the scene we are parsing for
  54827. * @param rootUrl Defines the rootUrl to load from
  54828. */
  54829. parse(source: any, scene: Scene, rootUrl: string): void;
  54830. }
  54831. }
  54832. declare module BABYLON {
  54833. /**
  54834. * @hidden
  54835. */
  54836. export interface IMaterialSheenDefines {
  54837. SHEEN: boolean;
  54838. SHEEN_TEXTURE: boolean;
  54839. SHEEN_TEXTUREDIRECTUV: number;
  54840. SHEEN_LINKWITHALBEDO: boolean;
  54841. SHEEN_ROUGHNESS: boolean;
  54842. SHEEN_ALBEDOSCALING: boolean;
  54843. /** @hidden */
  54844. _areTexturesDirty: boolean;
  54845. }
  54846. /**
  54847. * Define the code related to the Sheen parameters of the pbr material.
  54848. */
  54849. export class PBRSheenConfiguration {
  54850. private _isEnabled;
  54851. /**
  54852. * Defines if the material uses sheen.
  54853. */
  54854. isEnabled: boolean;
  54855. private _linkSheenWithAlbedo;
  54856. /**
  54857. * Defines if the sheen is linked to the sheen color.
  54858. */
  54859. linkSheenWithAlbedo: boolean;
  54860. /**
  54861. * Defines the sheen intensity.
  54862. */
  54863. intensity: number;
  54864. /**
  54865. * Defines the sheen color.
  54866. */
  54867. color: Color3;
  54868. private _texture;
  54869. /**
  54870. * Stores the sheen tint values in a texture.
  54871. * rgb is tint
  54872. * a is a intensity or roughness if roughness has been defined
  54873. */
  54874. texture: Nullable<BaseTexture>;
  54875. private _roughness;
  54876. /**
  54877. * Defines the sheen roughness.
  54878. * It is not taken into account if linkSheenWithAlbedo is true.
  54879. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  54880. */
  54881. roughness: Nullable<number>;
  54882. private _albedoScaling;
  54883. /**
  54884. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  54885. * It allows the strength of the sheen effect to not depend on the base color of the material,
  54886. * making it easier to setup and tweak the effect
  54887. */
  54888. albedoScaling: boolean;
  54889. /** @hidden */
  54890. private _internalMarkAllSubMeshesAsTexturesDirty;
  54891. /** @hidden */
  54892. _markAllSubMeshesAsTexturesDirty(): void;
  54893. /**
  54894. * Instantiate a new istance of clear coat configuration.
  54895. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54896. */
  54897. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54898. /**
  54899. * Specifies that the submesh is ready to be used.
  54900. * @param defines the list of "defines" to update.
  54901. * @param scene defines the scene the material belongs to.
  54902. * @returns - boolean indicating that the submesh is ready or not.
  54903. */
  54904. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  54905. /**
  54906. * Checks to see if a texture is used in the material.
  54907. * @param defines the list of "defines" to update.
  54908. * @param scene defines the scene the material belongs to.
  54909. */
  54910. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  54911. /**
  54912. * Binds the material data.
  54913. * @param uniformBuffer defines the Uniform buffer to fill in.
  54914. * @param scene defines the scene the material belongs to.
  54915. * @param isFrozen defines wether the material is frozen or not.
  54916. */
  54917. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  54918. /**
  54919. * Checks to see if a texture is used in the material.
  54920. * @param texture - Base texture to use.
  54921. * @returns - Boolean specifying if a texture is used in the material.
  54922. */
  54923. hasTexture(texture: BaseTexture): boolean;
  54924. /**
  54925. * Returns an array of the actively used textures.
  54926. * @param activeTextures Array of BaseTextures
  54927. */
  54928. getActiveTextures(activeTextures: BaseTexture[]): void;
  54929. /**
  54930. * Returns the animatable textures.
  54931. * @param animatables Array of animatable textures.
  54932. */
  54933. getAnimatables(animatables: IAnimatable[]): void;
  54934. /**
  54935. * Disposes the resources of the material.
  54936. * @param forceDisposeTextures - Forces the disposal of all textures.
  54937. */
  54938. dispose(forceDisposeTextures?: boolean): void;
  54939. /**
  54940. * Get the current class name of the texture useful for serialization or dynamic coding.
  54941. * @returns "PBRSheenConfiguration"
  54942. */
  54943. getClassName(): string;
  54944. /**
  54945. * Add fallbacks to the effect fallbacks list.
  54946. * @param defines defines the Base texture to use.
  54947. * @param fallbacks defines the current fallback list.
  54948. * @param currentRank defines the current fallback rank.
  54949. * @returns the new fallback rank.
  54950. */
  54951. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54952. /**
  54953. * Add the required uniforms to the current list.
  54954. * @param uniforms defines the current uniform list.
  54955. */
  54956. static AddUniforms(uniforms: string[]): void;
  54957. /**
  54958. * Add the required uniforms to the current buffer.
  54959. * @param uniformBuffer defines the current uniform buffer.
  54960. */
  54961. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54962. /**
  54963. * Add the required samplers to the current list.
  54964. * @param samplers defines the current sampler list.
  54965. */
  54966. static AddSamplers(samplers: string[]): void;
  54967. /**
  54968. * Makes a duplicate of the current configuration into another one.
  54969. * @param sheenConfiguration define the config where to copy the info
  54970. */
  54971. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  54972. /**
  54973. * Serializes this BRDF configuration.
  54974. * @returns - An object with the serialized config.
  54975. */
  54976. serialize(): any;
  54977. /**
  54978. * Parses a anisotropy Configuration from a serialized object.
  54979. * @param source - Serialized object.
  54980. * @param scene Defines the scene we are parsing for
  54981. * @param rootUrl Defines the rootUrl to load from
  54982. */
  54983. parse(source: any, scene: Scene, rootUrl: string): void;
  54984. }
  54985. }
  54986. declare module BABYLON {
  54987. /**
  54988. * @hidden
  54989. */
  54990. export interface IMaterialSubSurfaceDefines {
  54991. SUBSURFACE: boolean;
  54992. SS_REFRACTION: boolean;
  54993. SS_TRANSLUCENCY: boolean;
  54994. SS_SCATTERING: boolean;
  54995. SS_THICKNESSANDMASK_TEXTURE: boolean;
  54996. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  54997. SS_REFRACTIONMAP_3D: boolean;
  54998. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  54999. SS_LODINREFRACTIONALPHA: boolean;
  55000. SS_GAMMAREFRACTION: boolean;
  55001. SS_RGBDREFRACTION: boolean;
  55002. SS_LINEARSPECULARREFRACTION: boolean;
  55003. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  55004. SS_ALBEDOFORREFRACTIONTINT: boolean;
  55005. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  55006. /** @hidden */
  55007. _areTexturesDirty: boolean;
  55008. }
  55009. /**
  55010. * Define the code related to the sub surface parameters of the pbr material.
  55011. */
  55012. export class PBRSubSurfaceConfiguration {
  55013. private _isRefractionEnabled;
  55014. /**
  55015. * Defines if the refraction is enabled in the material.
  55016. */
  55017. isRefractionEnabled: boolean;
  55018. private _isTranslucencyEnabled;
  55019. /**
  55020. * Defines if the translucency is enabled in the material.
  55021. */
  55022. isTranslucencyEnabled: boolean;
  55023. private _isScatteringEnabled;
  55024. /**
  55025. * Defines if the sub surface scattering is enabled in the material.
  55026. */
  55027. isScatteringEnabled: boolean;
  55028. private _scatteringDiffusionProfileIndex;
  55029. /**
  55030. * Diffusion profile for subsurface scattering.
  55031. * Useful for better scattering in the skins or foliages.
  55032. */
  55033. get scatteringDiffusionProfile(): Nullable<Color3>;
  55034. set scatteringDiffusionProfile(c: Nullable<Color3>);
  55035. /**
  55036. * Defines the refraction intensity of the material.
  55037. * The refraction when enabled replaces the Diffuse part of the material.
  55038. * The intensity helps transitionning between diffuse and refraction.
  55039. */
  55040. refractionIntensity: number;
  55041. /**
  55042. * Defines the translucency intensity of the material.
  55043. * When translucency has been enabled, this defines how much of the "translucency"
  55044. * is addded to the diffuse part of the material.
  55045. */
  55046. translucencyIntensity: number;
  55047. /**
  55048. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  55049. */
  55050. useAlbedoToTintRefraction: boolean;
  55051. private _thicknessTexture;
  55052. /**
  55053. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  55054. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  55055. * 0 would mean minimumThickness
  55056. * 1 would mean maximumThickness
  55057. * The other channels might be use as a mask to vary the different effects intensity.
  55058. */
  55059. thicknessTexture: Nullable<BaseTexture>;
  55060. private _refractionTexture;
  55061. /**
  55062. * Defines the texture to use for refraction.
  55063. */
  55064. refractionTexture: Nullable<BaseTexture>;
  55065. private _indexOfRefraction;
  55066. /**
  55067. * Index of refraction of the material base layer.
  55068. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55069. *
  55070. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  55071. *
  55072. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  55073. */
  55074. indexOfRefraction: number;
  55075. private _volumeIndexOfRefraction;
  55076. /**
  55077. * Index of refraction of the material's volume.
  55078. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55079. *
  55080. * This ONLY impacts refraction. If not provided or given a non-valid value,
  55081. * the volume will use the same IOR as the surface.
  55082. */
  55083. get volumeIndexOfRefraction(): number;
  55084. set volumeIndexOfRefraction(value: number);
  55085. private _invertRefractionY;
  55086. /**
  55087. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55088. */
  55089. invertRefractionY: boolean;
  55090. private _linkRefractionWithTransparency;
  55091. /**
  55092. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55093. * Materials half opaque for instance using refraction could benefit from this control.
  55094. */
  55095. linkRefractionWithTransparency: boolean;
  55096. /**
  55097. * Defines the minimum thickness stored in the thickness map.
  55098. * If no thickness map is defined, this value will be used to simulate thickness.
  55099. */
  55100. minimumThickness: number;
  55101. /**
  55102. * Defines the maximum thickness stored in the thickness map.
  55103. */
  55104. maximumThickness: number;
  55105. /**
  55106. * Defines the volume tint of the material.
  55107. * This is used for both translucency and scattering.
  55108. */
  55109. tintColor: Color3;
  55110. /**
  55111. * Defines the distance at which the tint color should be found in the media.
  55112. * This is used for refraction only.
  55113. */
  55114. tintColorAtDistance: number;
  55115. /**
  55116. * Defines how far each channel transmit through the media.
  55117. * It is defined as a color to simplify it selection.
  55118. */
  55119. diffusionDistance: Color3;
  55120. private _useMaskFromThicknessTexture;
  55121. /**
  55122. * Stores the intensity of the different subsurface effects in the thickness texture.
  55123. * * the green channel is the translucency intensity.
  55124. * * the blue channel is the scattering intensity.
  55125. * * the alpha channel is the refraction intensity.
  55126. */
  55127. useMaskFromThicknessTexture: boolean;
  55128. private _scene;
  55129. /** @hidden */
  55130. private _internalMarkAllSubMeshesAsTexturesDirty;
  55131. private _internalMarkScenePrePassDirty;
  55132. /** @hidden */
  55133. _markAllSubMeshesAsTexturesDirty(): void;
  55134. /** @hidden */
  55135. _markScenePrePassDirty(): void;
  55136. /**
  55137. * Instantiate a new istance of sub surface configuration.
  55138. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55139. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  55140. * @param scene The scene
  55141. */
  55142. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  55143. /**
  55144. * Gets wehter the submesh is ready to be used or not.
  55145. * @param defines the list of "defines" to update.
  55146. * @param scene defines the scene the material belongs to.
  55147. * @returns - boolean indicating that the submesh is ready or not.
  55148. */
  55149. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  55150. /**
  55151. * Checks to see if a texture is used in the material.
  55152. * @param defines the list of "defines" to update.
  55153. * @param scene defines the scene to the material belongs to.
  55154. */
  55155. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  55156. /**
  55157. * Binds the material data.
  55158. * @param uniformBuffer defines the Uniform buffer to fill in.
  55159. * @param scene defines the scene the material belongs to.
  55160. * @param engine defines the engine the material belongs to.
  55161. * @param isFrozen defines whether the material is frozen or not.
  55162. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  55163. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  55164. */
  55165. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  55166. /**
  55167. * Unbinds the material from the mesh.
  55168. * @param activeEffect defines the effect that should be unbound from.
  55169. * @returns true if unbound, otherwise false
  55170. */
  55171. unbind(activeEffect: Effect): boolean;
  55172. /**
  55173. * Returns the texture used for refraction or null if none is used.
  55174. * @param scene defines the scene the material belongs to.
  55175. * @returns - Refraction texture if present. If no refraction texture and refraction
  55176. * is linked with transparency, returns environment texture. Otherwise, returns null.
  55177. */
  55178. private _getRefractionTexture;
  55179. /**
  55180. * Returns true if alpha blending should be disabled.
  55181. */
  55182. get disableAlphaBlending(): boolean;
  55183. /**
  55184. * Fills the list of render target textures.
  55185. * @param renderTargets the list of render targets to update
  55186. */
  55187. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  55188. /**
  55189. * Checks to see if a texture is used in the material.
  55190. * @param texture - Base texture to use.
  55191. * @returns - Boolean specifying if a texture is used in the material.
  55192. */
  55193. hasTexture(texture: BaseTexture): boolean;
  55194. /**
  55195. * Gets a boolean indicating that current material needs to register RTT
  55196. * @returns true if this uses a render target otherwise false.
  55197. */
  55198. hasRenderTargetTextures(): boolean;
  55199. /**
  55200. * Returns an array of the actively used textures.
  55201. * @param activeTextures Array of BaseTextures
  55202. */
  55203. getActiveTextures(activeTextures: BaseTexture[]): void;
  55204. /**
  55205. * Returns the animatable textures.
  55206. * @param animatables Array of animatable textures.
  55207. */
  55208. getAnimatables(animatables: IAnimatable[]): void;
  55209. /**
  55210. * Disposes the resources of the material.
  55211. * @param forceDisposeTextures - Forces the disposal of all textures.
  55212. */
  55213. dispose(forceDisposeTextures?: boolean): void;
  55214. /**
  55215. * Get the current class name of the texture useful for serialization or dynamic coding.
  55216. * @returns "PBRSubSurfaceConfiguration"
  55217. */
  55218. getClassName(): string;
  55219. /**
  55220. * Add fallbacks to the effect fallbacks list.
  55221. * @param defines defines the Base texture to use.
  55222. * @param fallbacks defines the current fallback list.
  55223. * @param currentRank defines the current fallback rank.
  55224. * @returns the new fallback rank.
  55225. */
  55226. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55227. /**
  55228. * Add the required uniforms to the current list.
  55229. * @param uniforms defines the current uniform list.
  55230. */
  55231. static AddUniforms(uniforms: string[]): void;
  55232. /**
  55233. * Add the required samplers to the current list.
  55234. * @param samplers defines the current sampler list.
  55235. */
  55236. static AddSamplers(samplers: string[]): void;
  55237. /**
  55238. * Add the required uniforms to the current buffer.
  55239. * @param uniformBuffer defines the current uniform buffer.
  55240. */
  55241. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55242. /**
  55243. * Makes a duplicate of the current configuration into another one.
  55244. * @param configuration define the config where to copy the info
  55245. */
  55246. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  55247. /**
  55248. * Serializes this Sub Surface configuration.
  55249. * @returns - An object with the serialized config.
  55250. */
  55251. serialize(): any;
  55252. /**
  55253. * Parses a anisotropy Configuration from a serialized object.
  55254. * @param source - Serialized object.
  55255. * @param scene Defines the scene we are parsing for
  55256. * @param rootUrl Defines the rootUrl to load from
  55257. */
  55258. parse(source: any, scene: Scene, rootUrl: string): void;
  55259. }
  55260. }
  55261. declare module BABYLON {
  55262. /** @hidden */
  55263. export var pbrFragmentDeclaration: {
  55264. name: string;
  55265. shader: string;
  55266. };
  55267. }
  55268. declare module BABYLON {
  55269. /** @hidden */
  55270. export var pbrUboDeclaration: {
  55271. name: string;
  55272. shader: string;
  55273. };
  55274. }
  55275. declare module BABYLON {
  55276. /** @hidden */
  55277. export var pbrFragmentExtraDeclaration: {
  55278. name: string;
  55279. shader: string;
  55280. };
  55281. }
  55282. declare module BABYLON {
  55283. /** @hidden */
  55284. export var pbrFragmentSamplersDeclaration: {
  55285. name: string;
  55286. shader: string;
  55287. };
  55288. }
  55289. declare module BABYLON {
  55290. /** @hidden */
  55291. export var importanceSampling: {
  55292. name: string;
  55293. shader: string;
  55294. };
  55295. }
  55296. declare module BABYLON {
  55297. /** @hidden */
  55298. export var pbrHelperFunctions: {
  55299. name: string;
  55300. shader: string;
  55301. };
  55302. }
  55303. declare module BABYLON {
  55304. /** @hidden */
  55305. export var harmonicsFunctions: {
  55306. name: string;
  55307. shader: string;
  55308. };
  55309. }
  55310. declare module BABYLON {
  55311. /** @hidden */
  55312. export var pbrDirectLightingSetupFunctions: {
  55313. name: string;
  55314. shader: string;
  55315. };
  55316. }
  55317. declare module BABYLON {
  55318. /** @hidden */
  55319. export var pbrDirectLightingFalloffFunctions: {
  55320. name: string;
  55321. shader: string;
  55322. };
  55323. }
  55324. declare module BABYLON {
  55325. /** @hidden */
  55326. export var pbrBRDFFunctions: {
  55327. name: string;
  55328. shader: string;
  55329. };
  55330. }
  55331. declare module BABYLON {
  55332. /** @hidden */
  55333. export var hdrFilteringFunctions: {
  55334. name: string;
  55335. shader: string;
  55336. };
  55337. }
  55338. declare module BABYLON {
  55339. /** @hidden */
  55340. export var pbrDirectLightingFunctions: {
  55341. name: string;
  55342. shader: string;
  55343. };
  55344. }
  55345. declare module BABYLON {
  55346. /** @hidden */
  55347. export var pbrIBLFunctions: {
  55348. name: string;
  55349. shader: string;
  55350. };
  55351. }
  55352. declare module BABYLON {
  55353. /** @hidden */
  55354. export var pbrBlockAlbedoOpacity: {
  55355. name: string;
  55356. shader: string;
  55357. };
  55358. }
  55359. declare module BABYLON {
  55360. /** @hidden */
  55361. export var pbrBlockReflectivity: {
  55362. name: string;
  55363. shader: string;
  55364. };
  55365. }
  55366. declare module BABYLON {
  55367. /** @hidden */
  55368. export var pbrBlockAmbientOcclusion: {
  55369. name: string;
  55370. shader: string;
  55371. };
  55372. }
  55373. declare module BABYLON {
  55374. /** @hidden */
  55375. export var pbrBlockAlphaFresnel: {
  55376. name: string;
  55377. shader: string;
  55378. };
  55379. }
  55380. declare module BABYLON {
  55381. /** @hidden */
  55382. export var pbrBlockAnisotropic: {
  55383. name: string;
  55384. shader: string;
  55385. };
  55386. }
  55387. declare module BABYLON {
  55388. /** @hidden */
  55389. export var pbrBlockReflection: {
  55390. name: string;
  55391. shader: string;
  55392. };
  55393. }
  55394. declare module BABYLON {
  55395. /** @hidden */
  55396. export var pbrBlockSheen: {
  55397. name: string;
  55398. shader: string;
  55399. };
  55400. }
  55401. declare module BABYLON {
  55402. /** @hidden */
  55403. export var pbrBlockClearcoat: {
  55404. name: string;
  55405. shader: string;
  55406. };
  55407. }
  55408. declare module BABYLON {
  55409. /** @hidden */
  55410. export var pbrBlockSubSurface: {
  55411. name: string;
  55412. shader: string;
  55413. };
  55414. }
  55415. declare module BABYLON {
  55416. /** @hidden */
  55417. export var pbrBlockNormalGeometric: {
  55418. name: string;
  55419. shader: string;
  55420. };
  55421. }
  55422. declare module BABYLON {
  55423. /** @hidden */
  55424. export var pbrBlockNormalFinal: {
  55425. name: string;
  55426. shader: string;
  55427. };
  55428. }
  55429. declare module BABYLON {
  55430. /** @hidden */
  55431. export var pbrBlockLightmapInit: {
  55432. name: string;
  55433. shader: string;
  55434. };
  55435. }
  55436. declare module BABYLON {
  55437. /** @hidden */
  55438. export var pbrBlockGeometryInfo: {
  55439. name: string;
  55440. shader: string;
  55441. };
  55442. }
  55443. declare module BABYLON {
  55444. /** @hidden */
  55445. export var pbrBlockReflectance0: {
  55446. name: string;
  55447. shader: string;
  55448. };
  55449. }
  55450. declare module BABYLON {
  55451. /** @hidden */
  55452. export var pbrBlockReflectance: {
  55453. name: string;
  55454. shader: string;
  55455. };
  55456. }
  55457. declare module BABYLON {
  55458. /** @hidden */
  55459. export var pbrBlockDirectLighting: {
  55460. name: string;
  55461. shader: string;
  55462. };
  55463. }
  55464. declare module BABYLON {
  55465. /** @hidden */
  55466. export var pbrBlockFinalLitComponents: {
  55467. name: string;
  55468. shader: string;
  55469. };
  55470. }
  55471. declare module BABYLON {
  55472. /** @hidden */
  55473. export var pbrBlockFinalUnlitComponents: {
  55474. name: string;
  55475. shader: string;
  55476. };
  55477. }
  55478. declare module BABYLON {
  55479. /** @hidden */
  55480. export var pbrBlockFinalColorComposition: {
  55481. name: string;
  55482. shader: string;
  55483. };
  55484. }
  55485. declare module BABYLON {
  55486. /** @hidden */
  55487. export var pbrBlockImageProcessing: {
  55488. name: string;
  55489. shader: string;
  55490. };
  55491. }
  55492. declare module BABYLON {
  55493. /** @hidden */
  55494. export var pbrDebug: {
  55495. name: string;
  55496. shader: string;
  55497. };
  55498. }
  55499. declare module BABYLON {
  55500. /** @hidden */
  55501. export var pbrPixelShader: {
  55502. name: string;
  55503. shader: string;
  55504. };
  55505. }
  55506. declare module BABYLON {
  55507. /** @hidden */
  55508. export var pbrVertexDeclaration: {
  55509. name: string;
  55510. shader: string;
  55511. };
  55512. }
  55513. declare module BABYLON {
  55514. /** @hidden */
  55515. export var pbrVertexShader: {
  55516. name: string;
  55517. shader: string;
  55518. };
  55519. }
  55520. declare module BABYLON {
  55521. /**
  55522. * Manages the defines for the PBR Material.
  55523. * @hidden
  55524. */
  55525. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  55526. PBR: boolean;
  55527. NUM_SAMPLES: string;
  55528. REALTIME_FILTERING: boolean;
  55529. MAINUV1: boolean;
  55530. MAINUV2: boolean;
  55531. UV1: boolean;
  55532. UV2: boolean;
  55533. ALBEDO: boolean;
  55534. GAMMAALBEDO: boolean;
  55535. ALBEDODIRECTUV: number;
  55536. VERTEXCOLOR: boolean;
  55537. DETAIL: boolean;
  55538. DETAILDIRECTUV: number;
  55539. DETAIL_NORMALBLENDMETHOD: number;
  55540. AMBIENT: boolean;
  55541. AMBIENTDIRECTUV: number;
  55542. AMBIENTINGRAYSCALE: boolean;
  55543. OPACITY: boolean;
  55544. VERTEXALPHA: boolean;
  55545. OPACITYDIRECTUV: number;
  55546. OPACITYRGB: boolean;
  55547. ALPHATEST: boolean;
  55548. DEPTHPREPASS: boolean;
  55549. ALPHABLEND: boolean;
  55550. ALPHAFROMALBEDO: boolean;
  55551. ALPHATESTVALUE: string;
  55552. SPECULAROVERALPHA: boolean;
  55553. RADIANCEOVERALPHA: boolean;
  55554. ALPHAFRESNEL: boolean;
  55555. LINEARALPHAFRESNEL: boolean;
  55556. PREMULTIPLYALPHA: boolean;
  55557. EMISSIVE: boolean;
  55558. EMISSIVEDIRECTUV: number;
  55559. REFLECTIVITY: boolean;
  55560. REFLECTIVITYDIRECTUV: number;
  55561. SPECULARTERM: boolean;
  55562. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  55563. MICROSURFACEAUTOMATIC: boolean;
  55564. LODBASEDMICROSFURACE: boolean;
  55565. MICROSURFACEMAP: boolean;
  55566. MICROSURFACEMAPDIRECTUV: number;
  55567. METALLICWORKFLOW: boolean;
  55568. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  55569. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  55570. METALLNESSSTOREINMETALMAPBLUE: boolean;
  55571. AOSTOREINMETALMAPRED: boolean;
  55572. METALLIC_REFLECTANCE: boolean;
  55573. METALLIC_REFLECTANCEDIRECTUV: number;
  55574. ENVIRONMENTBRDF: boolean;
  55575. ENVIRONMENTBRDF_RGBD: boolean;
  55576. NORMAL: boolean;
  55577. TANGENT: boolean;
  55578. BUMP: boolean;
  55579. BUMPDIRECTUV: number;
  55580. OBJECTSPACE_NORMALMAP: boolean;
  55581. PARALLAX: boolean;
  55582. PARALLAXOCCLUSION: boolean;
  55583. NORMALXYSCALE: boolean;
  55584. LIGHTMAP: boolean;
  55585. LIGHTMAPDIRECTUV: number;
  55586. USELIGHTMAPASSHADOWMAP: boolean;
  55587. GAMMALIGHTMAP: boolean;
  55588. RGBDLIGHTMAP: boolean;
  55589. REFLECTION: boolean;
  55590. REFLECTIONMAP_3D: boolean;
  55591. REFLECTIONMAP_SPHERICAL: boolean;
  55592. REFLECTIONMAP_PLANAR: boolean;
  55593. REFLECTIONMAP_CUBIC: boolean;
  55594. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  55595. REFLECTIONMAP_PROJECTION: boolean;
  55596. REFLECTIONMAP_SKYBOX: boolean;
  55597. REFLECTIONMAP_EXPLICIT: boolean;
  55598. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  55599. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  55600. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  55601. INVERTCUBICMAP: boolean;
  55602. USESPHERICALFROMREFLECTIONMAP: boolean;
  55603. USEIRRADIANCEMAP: boolean;
  55604. SPHERICAL_HARMONICS: boolean;
  55605. USESPHERICALINVERTEX: boolean;
  55606. REFLECTIONMAP_OPPOSITEZ: boolean;
  55607. LODINREFLECTIONALPHA: boolean;
  55608. GAMMAREFLECTION: boolean;
  55609. RGBDREFLECTION: boolean;
  55610. LINEARSPECULARREFLECTION: boolean;
  55611. RADIANCEOCCLUSION: boolean;
  55612. HORIZONOCCLUSION: boolean;
  55613. INSTANCES: boolean;
  55614. THIN_INSTANCES: boolean;
  55615. PREPASS: boolean;
  55616. SCENE_MRT_COUNT: number;
  55617. NUM_BONE_INFLUENCERS: number;
  55618. BonesPerMesh: number;
  55619. BONETEXTURE: boolean;
  55620. NONUNIFORMSCALING: boolean;
  55621. MORPHTARGETS: boolean;
  55622. MORPHTARGETS_NORMAL: boolean;
  55623. MORPHTARGETS_TANGENT: boolean;
  55624. MORPHTARGETS_UV: boolean;
  55625. NUM_MORPH_INFLUENCERS: number;
  55626. IMAGEPROCESSING: boolean;
  55627. VIGNETTE: boolean;
  55628. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55629. VIGNETTEBLENDMODEOPAQUE: boolean;
  55630. TONEMAPPING: boolean;
  55631. TONEMAPPING_ACES: boolean;
  55632. CONTRAST: boolean;
  55633. COLORCURVES: boolean;
  55634. COLORGRADING: boolean;
  55635. COLORGRADING3D: boolean;
  55636. SAMPLER3DGREENDEPTH: boolean;
  55637. SAMPLER3DBGRMAP: boolean;
  55638. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55639. EXPOSURE: boolean;
  55640. MULTIVIEW: boolean;
  55641. USEPHYSICALLIGHTFALLOFF: boolean;
  55642. USEGLTFLIGHTFALLOFF: boolean;
  55643. TWOSIDEDLIGHTING: boolean;
  55644. SHADOWFLOAT: boolean;
  55645. CLIPPLANE: boolean;
  55646. CLIPPLANE2: boolean;
  55647. CLIPPLANE3: boolean;
  55648. CLIPPLANE4: boolean;
  55649. CLIPPLANE5: boolean;
  55650. CLIPPLANE6: boolean;
  55651. POINTSIZE: boolean;
  55652. FOG: boolean;
  55653. LOGARITHMICDEPTH: boolean;
  55654. FORCENORMALFORWARD: boolean;
  55655. SPECULARAA: boolean;
  55656. CLEARCOAT: boolean;
  55657. CLEARCOAT_DEFAULTIOR: boolean;
  55658. CLEARCOAT_TEXTURE: boolean;
  55659. CLEARCOAT_TEXTUREDIRECTUV: number;
  55660. CLEARCOAT_BUMP: boolean;
  55661. CLEARCOAT_BUMPDIRECTUV: number;
  55662. CLEARCOAT_TINT: boolean;
  55663. CLEARCOAT_TINT_TEXTURE: boolean;
  55664. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  55665. ANISOTROPIC: boolean;
  55666. ANISOTROPIC_TEXTURE: boolean;
  55667. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55668. BRDF_V_HEIGHT_CORRELATED: boolean;
  55669. MS_BRDF_ENERGY_CONSERVATION: boolean;
  55670. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  55671. SHEEN: boolean;
  55672. SHEEN_TEXTURE: boolean;
  55673. SHEEN_TEXTUREDIRECTUV: number;
  55674. SHEEN_LINKWITHALBEDO: boolean;
  55675. SHEEN_ROUGHNESS: boolean;
  55676. SHEEN_ALBEDOSCALING: boolean;
  55677. SUBSURFACE: boolean;
  55678. SS_REFRACTION: boolean;
  55679. SS_TRANSLUCENCY: boolean;
  55680. SS_SCATTERING: boolean;
  55681. SS_THICKNESSANDMASK_TEXTURE: boolean;
  55682. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  55683. SS_REFRACTIONMAP_3D: boolean;
  55684. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  55685. SS_LODINREFRACTIONALPHA: boolean;
  55686. SS_GAMMAREFRACTION: boolean;
  55687. SS_RGBDREFRACTION: boolean;
  55688. SS_LINEARSPECULARREFRACTION: boolean;
  55689. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  55690. SS_ALBEDOFORREFRACTIONTINT: boolean;
  55691. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  55692. UNLIT: boolean;
  55693. DEBUGMODE: number;
  55694. /**
  55695. * Initializes the PBR Material defines.
  55696. */
  55697. constructor();
  55698. /**
  55699. * Resets the PBR Material defines.
  55700. */
  55701. reset(): void;
  55702. }
  55703. /**
  55704. * The Physically based material base class of BJS.
  55705. *
  55706. * This offers the main features of a standard PBR material.
  55707. * For more information, please refer to the documentation :
  55708. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55709. */
  55710. export abstract class PBRBaseMaterial extends PushMaterial {
  55711. /**
  55712. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55713. */
  55714. static readonly PBRMATERIAL_OPAQUE: number;
  55715. /**
  55716. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55717. */
  55718. static readonly PBRMATERIAL_ALPHATEST: number;
  55719. /**
  55720. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55721. */
  55722. static readonly PBRMATERIAL_ALPHABLEND: number;
  55723. /**
  55724. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55725. * They are also discarded below the alpha cutoff threshold to improve performances.
  55726. */
  55727. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55728. /**
  55729. * Defines the default value of how much AO map is occluding the analytical lights
  55730. * (point spot...).
  55731. */
  55732. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55733. /**
  55734. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  55735. */
  55736. static readonly LIGHTFALLOFF_PHYSICAL: number;
  55737. /**
  55738. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  55739. * to enhance interoperability with other engines.
  55740. */
  55741. static readonly LIGHTFALLOFF_GLTF: number;
  55742. /**
  55743. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  55744. * to enhance interoperability with other materials.
  55745. */
  55746. static readonly LIGHTFALLOFF_STANDARD: number;
  55747. /**
  55748. * Intensity of the direct lights e.g. the four lights available in your scene.
  55749. * This impacts both the direct diffuse and specular highlights.
  55750. */
  55751. protected _directIntensity: number;
  55752. /**
  55753. * Intensity of the emissive part of the material.
  55754. * This helps controlling the emissive effect without modifying the emissive color.
  55755. */
  55756. protected _emissiveIntensity: number;
  55757. /**
  55758. * Intensity of the environment e.g. how much the environment will light the object
  55759. * either through harmonics for rough material or through the refelction for shiny ones.
  55760. */
  55761. protected _environmentIntensity: number;
  55762. /**
  55763. * This is a special control allowing the reduction of the specular highlights coming from the
  55764. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55765. */
  55766. protected _specularIntensity: number;
  55767. /**
  55768. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  55769. */
  55770. private _lightingInfos;
  55771. /**
  55772. * Debug Control allowing disabling the bump map on this material.
  55773. */
  55774. protected _disableBumpMap: boolean;
  55775. /**
  55776. * AKA Diffuse Texture in standard nomenclature.
  55777. */
  55778. protected _albedoTexture: Nullable<BaseTexture>;
  55779. /**
  55780. * AKA Occlusion Texture in other nomenclature.
  55781. */
  55782. protected _ambientTexture: Nullable<BaseTexture>;
  55783. /**
  55784. * AKA Occlusion Texture Intensity in other nomenclature.
  55785. */
  55786. protected _ambientTextureStrength: number;
  55787. /**
  55788. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55789. * 1 means it completely occludes it
  55790. * 0 mean it has no impact
  55791. */
  55792. protected _ambientTextureImpactOnAnalyticalLights: number;
  55793. /**
  55794. * Stores the alpha values in a texture.
  55795. */
  55796. protected _opacityTexture: Nullable<BaseTexture>;
  55797. /**
  55798. * Stores the reflection values in a texture.
  55799. */
  55800. protected _reflectionTexture: Nullable<BaseTexture>;
  55801. /**
  55802. * Stores the emissive values in a texture.
  55803. */
  55804. protected _emissiveTexture: Nullable<BaseTexture>;
  55805. /**
  55806. * AKA Specular texture in other nomenclature.
  55807. */
  55808. protected _reflectivityTexture: Nullable<BaseTexture>;
  55809. /**
  55810. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55811. */
  55812. protected _metallicTexture: Nullable<BaseTexture>;
  55813. /**
  55814. * Specifies the metallic scalar of the metallic/roughness workflow.
  55815. * Can also be used to scale the metalness values of the metallic texture.
  55816. */
  55817. protected _metallic: Nullable<number>;
  55818. /**
  55819. * Specifies the roughness scalar of the metallic/roughness workflow.
  55820. * Can also be used to scale the roughness values of the metallic texture.
  55821. */
  55822. protected _roughness: Nullable<number>;
  55823. /**
  55824. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55825. * By default the indexOfrefraction is used to compute F0;
  55826. *
  55827. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55828. *
  55829. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55830. * F90 = metallicReflectanceColor;
  55831. */
  55832. protected _metallicF0Factor: number;
  55833. /**
  55834. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55835. * By default the F90 is always 1;
  55836. *
  55837. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55838. *
  55839. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55840. * F90 = metallicReflectanceColor;
  55841. */
  55842. protected _metallicReflectanceColor: Color3;
  55843. /**
  55844. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55845. * This is multiply against the scalar values defined in the material.
  55846. */
  55847. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  55848. /**
  55849. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55850. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55851. */
  55852. protected _microSurfaceTexture: Nullable<BaseTexture>;
  55853. /**
  55854. * Stores surface normal data used to displace a mesh in a texture.
  55855. */
  55856. protected _bumpTexture: Nullable<BaseTexture>;
  55857. /**
  55858. * Stores the pre-calculated light information of a mesh in a texture.
  55859. */
  55860. protected _lightmapTexture: Nullable<BaseTexture>;
  55861. /**
  55862. * The color of a material in ambient lighting.
  55863. */
  55864. protected _ambientColor: Color3;
  55865. /**
  55866. * AKA Diffuse Color in other nomenclature.
  55867. */
  55868. protected _albedoColor: Color3;
  55869. /**
  55870. * AKA Specular Color in other nomenclature.
  55871. */
  55872. protected _reflectivityColor: Color3;
  55873. /**
  55874. * The color applied when light is reflected from a material.
  55875. */
  55876. protected _reflectionColor: Color3;
  55877. /**
  55878. * The color applied when light is emitted from a material.
  55879. */
  55880. protected _emissiveColor: Color3;
  55881. /**
  55882. * AKA Glossiness in other nomenclature.
  55883. */
  55884. protected _microSurface: number;
  55885. /**
  55886. * Specifies that the material will use the light map as a show map.
  55887. */
  55888. protected _useLightmapAsShadowmap: boolean;
  55889. /**
  55890. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  55891. * makes the reflect vector face the model (under horizon).
  55892. */
  55893. protected _useHorizonOcclusion: boolean;
  55894. /**
  55895. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  55896. * too much the area relying on ambient texture to define their ambient occlusion.
  55897. */
  55898. protected _useRadianceOcclusion: boolean;
  55899. /**
  55900. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  55901. */
  55902. protected _useAlphaFromAlbedoTexture: boolean;
  55903. /**
  55904. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  55905. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  55906. */
  55907. protected _useSpecularOverAlpha: boolean;
  55908. /**
  55909. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  55910. */
  55911. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  55912. /**
  55913. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  55914. */
  55915. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  55916. /**
  55917. * Specifies if the metallic texture contains the roughness information in its green channel.
  55918. */
  55919. protected _useRoughnessFromMetallicTextureGreen: boolean;
  55920. /**
  55921. * Specifies if the metallic texture contains the metallness information in its blue channel.
  55922. */
  55923. protected _useMetallnessFromMetallicTextureBlue: boolean;
  55924. /**
  55925. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  55926. */
  55927. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  55928. /**
  55929. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  55930. */
  55931. protected _useAmbientInGrayScale: boolean;
  55932. /**
  55933. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  55934. * The material will try to infer what glossiness each pixel should be.
  55935. */
  55936. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  55937. /**
  55938. * Defines the falloff type used in this material.
  55939. * It by default is Physical.
  55940. */
  55941. protected _lightFalloff: number;
  55942. /**
  55943. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  55944. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  55945. */
  55946. protected _useRadianceOverAlpha: boolean;
  55947. /**
  55948. * Allows using an object space normal map (instead of tangent space).
  55949. */
  55950. protected _useObjectSpaceNormalMap: boolean;
  55951. /**
  55952. * Allows using the bump map in parallax mode.
  55953. */
  55954. protected _useParallax: boolean;
  55955. /**
  55956. * Allows using the bump map in parallax occlusion mode.
  55957. */
  55958. protected _useParallaxOcclusion: boolean;
  55959. /**
  55960. * Controls the scale bias of the parallax mode.
  55961. */
  55962. protected _parallaxScaleBias: number;
  55963. /**
  55964. * If sets to true, disables all the lights affecting the material.
  55965. */
  55966. protected _disableLighting: boolean;
  55967. /**
  55968. * Number of Simultaneous lights allowed on the material.
  55969. */
  55970. protected _maxSimultaneousLights: number;
  55971. /**
  55972. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55973. */
  55974. protected _invertNormalMapX: boolean;
  55975. /**
  55976. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55977. */
  55978. protected _invertNormalMapY: boolean;
  55979. /**
  55980. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55981. */
  55982. protected _twoSidedLighting: boolean;
  55983. /**
  55984. * Defines the alpha limits in alpha test mode.
  55985. */
  55986. protected _alphaCutOff: number;
  55987. /**
  55988. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  55989. */
  55990. protected _forceAlphaTest: boolean;
  55991. /**
  55992. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55993. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  55994. */
  55995. protected _useAlphaFresnel: boolean;
  55996. /**
  55997. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55998. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  55999. */
  56000. protected _useLinearAlphaFresnel: boolean;
  56001. /**
  56002. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  56003. * from cos thetav and roughness:
  56004. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  56005. */
  56006. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  56007. /**
  56008. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  56009. */
  56010. protected _forceIrradianceInFragment: boolean;
  56011. private _realTimeFiltering;
  56012. /**
  56013. * Enables realtime filtering on the texture.
  56014. */
  56015. get realTimeFiltering(): boolean;
  56016. set realTimeFiltering(b: boolean);
  56017. private _realTimeFilteringQuality;
  56018. /**
  56019. * Quality switch for realtime filtering
  56020. */
  56021. get realTimeFilteringQuality(): number;
  56022. set realTimeFilteringQuality(n: number);
  56023. /**
  56024. * Can this material render to several textures at once
  56025. */
  56026. get canRenderToMRT(): boolean;
  56027. /**
  56028. * Force normal to face away from face.
  56029. */
  56030. protected _forceNormalForward: boolean;
  56031. /**
  56032. * Enables specular anti aliasing in the PBR shader.
  56033. * It will both interacts on the Geometry for analytical and IBL lighting.
  56034. * It also prefilter the roughness map based on the bump values.
  56035. */
  56036. protected _enableSpecularAntiAliasing: boolean;
  56037. /**
  56038. * Default configuration related to image processing available in the PBR Material.
  56039. */
  56040. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56041. /**
  56042. * Keep track of the image processing observer to allow dispose and replace.
  56043. */
  56044. private _imageProcessingObserver;
  56045. /**
  56046. * Attaches a new image processing configuration to the PBR Material.
  56047. * @param configuration
  56048. */
  56049. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56050. /**
  56051. * Stores the available render targets.
  56052. */
  56053. private _renderTargets;
  56054. /**
  56055. * Sets the global ambient color for the material used in lighting calculations.
  56056. */
  56057. private _globalAmbientColor;
  56058. /**
  56059. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  56060. */
  56061. private _useLogarithmicDepth;
  56062. /**
  56063. * If set to true, no lighting calculations will be applied.
  56064. */
  56065. private _unlit;
  56066. private _debugMode;
  56067. /**
  56068. * @hidden
  56069. * This is reserved for the inspector.
  56070. * Defines the material debug mode.
  56071. * It helps seeing only some components of the material while troubleshooting.
  56072. */
  56073. debugMode: number;
  56074. /**
  56075. * @hidden
  56076. * This is reserved for the inspector.
  56077. * Specify from where on screen the debug mode should start.
  56078. * The value goes from -1 (full screen) to 1 (not visible)
  56079. * It helps with side by side comparison against the final render
  56080. * This defaults to -1
  56081. */
  56082. private debugLimit;
  56083. /**
  56084. * @hidden
  56085. * This is reserved for the inspector.
  56086. * As the default viewing range might not be enough (if the ambient is really small for instance)
  56087. * You can use the factor to better multiply the final value.
  56088. */
  56089. private debugFactor;
  56090. /**
  56091. * Defines the clear coat layer parameters for the material.
  56092. */
  56093. readonly clearCoat: PBRClearCoatConfiguration;
  56094. /**
  56095. * Defines the anisotropic parameters for the material.
  56096. */
  56097. readonly anisotropy: PBRAnisotropicConfiguration;
  56098. /**
  56099. * Defines the BRDF parameters for the material.
  56100. */
  56101. readonly brdf: PBRBRDFConfiguration;
  56102. /**
  56103. * Defines the Sheen parameters for the material.
  56104. */
  56105. readonly sheen: PBRSheenConfiguration;
  56106. /**
  56107. * Defines the SubSurface parameters for the material.
  56108. */
  56109. readonly subSurface: PBRSubSurfaceConfiguration;
  56110. /**
  56111. * Defines the detail map parameters for the material.
  56112. */
  56113. readonly detailMap: DetailMapConfiguration;
  56114. protected _rebuildInParallel: boolean;
  56115. /**
  56116. * Instantiates a new PBRMaterial instance.
  56117. *
  56118. * @param name The material name
  56119. * @param scene The scene the material will be use in.
  56120. */
  56121. constructor(name: string, scene: Scene);
  56122. /**
  56123. * Gets a boolean indicating that current material needs to register RTT
  56124. */
  56125. get hasRenderTargetTextures(): boolean;
  56126. /**
  56127. * Gets the name of the material class.
  56128. */
  56129. getClassName(): string;
  56130. /**
  56131. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  56132. */
  56133. get useLogarithmicDepth(): boolean;
  56134. /**
  56135. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  56136. */
  56137. set useLogarithmicDepth(value: boolean);
  56138. /**
  56139. * Returns true if alpha blending should be disabled.
  56140. */
  56141. protected get _disableAlphaBlending(): boolean;
  56142. /**
  56143. * Specifies whether or not this material should be rendered in alpha blend mode.
  56144. */
  56145. needAlphaBlending(): boolean;
  56146. /**
  56147. * Specifies whether or not this material should be rendered in alpha test mode.
  56148. */
  56149. needAlphaTesting(): boolean;
  56150. /**
  56151. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  56152. */
  56153. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  56154. /**
  56155. * Gets the texture used for the alpha test.
  56156. */
  56157. getAlphaTestTexture(): Nullable<BaseTexture>;
  56158. /**
  56159. * Specifies that the submesh is ready to be used.
  56160. * @param mesh - BJS mesh.
  56161. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  56162. * @param useInstances - Specifies that instances should be used.
  56163. * @returns - boolean indicating that the submesh is ready or not.
  56164. */
  56165. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56166. /**
  56167. * Specifies if the material uses metallic roughness workflow.
  56168. * @returns boolean specifiying if the material uses metallic roughness workflow.
  56169. */
  56170. isMetallicWorkflow(): boolean;
  56171. private _prepareEffect;
  56172. private _prepareDefines;
  56173. /**
  56174. * Force shader compilation
  56175. */
  56176. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  56177. /**
  56178. * Initializes the uniform buffer layout for the shader.
  56179. */
  56180. buildUniformLayout(): void;
  56181. /**
  56182. * Unbinds the material from the mesh
  56183. */
  56184. unbind(): void;
  56185. /**
  56186. * Binds the submesh data.
  56187. * @param world - The world matrix.
  56188. * @param mesh - The BJS mesh.
  56189. * @param subMesh - A submesh of the BJS mesh.
  56190. */
  56191. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56192. /**
  56193. * Returns the animatable textures.
  56194. * @returns - Array of animatable textures.
  56195. */
  56196. getAnimatables(): IAnimatable[];
  56197. /**
  56198. * Returns the texture used for reflections.
  56199. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  56200. */
  56201. private _getReflectionTexture;
  56202. /**
  56203. * Returns an array of the actively used textures.
  56204. * @returns - Array of BaseTextures
  56205. */
  56206. getActiveTextures(): BaseTexture[];
  56207. /**
  56208. * Checks to see if a texture is used in the material.
  56209. * @param texture - Base texture to use.
  56210. * @returns - Boolean specifying if a texture is used in the material.
  56211. */
  56212. hasTexture(texture: BaseTexture): boolean;
  56213. /**
  56214. * Sets the required values to the prepass renderer.
  56215. * @param prePassRenderer defines the prepass renderer to setup
  56216. */
  56217. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  56218. /**
  56219. * Disposes the resources of the material.
  56220. * @param forceDisposeEffect - Forces the disposal of effects.
  56221. * @param forceDisposeTextures - Forces the disposal of all textures.
  56222. */
  56223. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  56224. }
  56225. }
  56226. declare module BABYLON {
  56227. /**
  56228. * The Physically based material of BJS.
  56229. *
  56230. * This offers the main features of a standard PBR material.
  56231. * For more information, please refer to the documentation :
  56232. * https://doc.babylonjs.com/how_to/physically_based_rendering
  56233. */
  56234. export class PBRMaterial extends PBRBaseMaterial {
  56235. /**
  56236. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  56237. */
  56238. static readonly PBRMATERIAL_OPAQUE: number;
  56239. /**
  56240. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  56241. */
  56242. static readonly PBRMATERIAL_ALPHATEST: number;
  56243. /**
  56244. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56245. */
  56246. static readonly PBRMATERIAL_ALPHABLEND: number;
  56247. /**
  56248. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56249. * They are also discarded below the alpha cutoff threshold to improve performances.
  56250. */
  56251. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  56252. /**
  56253. * Defines the default value of how much AO map is occluding the analytical lights
  56254. * (point spot...).
  56255. */
  56256. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  56257. /**
  56258. * Intensity of the direct lights e.g. the four lights available in your scene.
  56259. * This impacts both the direct diffuse and specular highlights.
  56260. */
  56261. directIntensity: number;
  56262. /**
  56263. * Intensity of the emissive part of the material.
  56264. * This helps controlling the emissive effect without modifying the emissive color.
  56265. */
  56266. emissiveIntensity: number;
  56267. /**
  56268. * Intensity of the environment e.g. how much the environment will light the object
  56269. * either through harmonics for rough material or through the refelction for shiny ones.
  56270. */
  56271. environmentIntensity: number;
  56272. /**
  56273. * This is a special control allowing the reduction of the specular highlights coming from the
  56274. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  56275. */
  56276. specularIntensity: number;
  56277. /**
  56278. * Debug Control allowing disabling the bump map on this material.
  56279. */
  56280. disableBumpMap: boolean;
  56281. /**
  56282. * AKA Diffuse Texture in standard nomenclature.
  56283. */
  56284. albedoTexture: BaseTexture;
  56285. /**
  56286. * AKA Occlusion Texture in other nomenclature.
  56287. */
  56288. ambientTexture: BaseTexture;
  56289. /**
  56290. * AKA Occlusion Texture Intensity in other nomenclature.
  56291. */
  56292. ambientTextureStrength: number;
  56293. /**
  56294. * Defines how much the AO map is occluding the analytical lights (point spot...).
  56295. * 1 means it completely occludes it
  56296. * 0 mean it has no impact
  56297. */
  56298. ambientTextureImpactOnAnalyticalLights: number;
  56299. /**
  56300. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  56301. */
  56302. opacityTexture: BaseTexture;
  56303. /**
  56304. * Stores the reflection values in a texture.
  56305. */
  56306. reflectionTexture: Nullable<BaseTexture>;
  56307. /**
  56308. * Stores the emissive values in a texture.
  56309. */
  56310. emissiveTexture: BaseTexture;
  56311. /**
  56312. * AKA Specular texture in other nomenclature.
  56313. */
  56314. reflectivityTexture: BaseTexture;
  56315. /**
  56316. * Used to switch from specular/glossiness to metallic/roughness workflow.
  56317. */
  56318. metallicTexture: BaseTexture;
  56319. /**
  56320. * Specifies the metallic scalar of the metallic/roughness workflow.
  56321. * Can also be used to scale the metalness values of the metallic texture.
  56322. */
  56323. metallic: Nullable<number>;
  56324. /**
  56325. * Specifies the roughness scalar of the metallic/roughness workflow.
  56326. * Can also be used to scale the roughness values of the metallic texture.
  56327. */
  56328. roughness: Nullable<number>;
  56329. /**
  56330. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  56331. * By default the indexOfrefraction is used to compute F0;
  56332. *
  56333. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  56334. *
  56335. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  56336. * F90 = metallicReflectanceColor;
  56337. */
  56338. metallicF0Factor: number;
  56339. /**
  56340. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  56341. * By default the F90 is always 1;
  56342. *
  56343. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  56344. *
  56345. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  56346. * F90 = metallicReflectanceColor;
  56347. */
  56348. metallicReflectanceColor: Color3;
  56349. /**
  56350. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  56351. * This is multiply against the scalar values defined in the material.
  56352. */
  56353. metallicReflectanceTexture: Nullable<BaseTexture>;
  56354. /**
  56355. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  56356. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  56357. */
  56358. microSurfaceTexture: BaseTexture;
  56359. /**
  56360. * Stores surface normal data used to displace a mesh in a texture.
  56361. */
  56362. bumpTexture: BaseTexture;
  56363. /**
  56364. * Stores the pre-calculated light information of a mesh in a texture.
  56365. */
  56366. lightmapTexture: BaseTexture;
  56367. /**
  56368. * Stores the refracted light information in a texture.
  56369. */
  56370. get refractionTexture(): Nullable<BaseTexture>;
  56371. set refractionTexture(value: Nullable<BaseTexture>);
  56372. /**
  56373. * The color of a material in ambient lighting.
  56374. */
  56375. ambientColor: Color3;
  56376. /**
  56377. * AKA Diffuse Color in other nomenclature.
  56378. */
  56379. albedoColor: Color3;
  56380. /**
  56381. * AKA Specular Color in other nomenclature.
  56382. */
  56383. reflectivityColor: Color3;
  56384. /**
  56385. * The color reflected from the material.
  56386. */
  56387. reflectionColor: Color3;
  56388. /**
  56389. * The color emitted from the material.
  56390. */
  56391. emissiveColor: Color3;
  56392. /**
  56393. * AKA Glossiness in other nomenclature.
  56394. */
  56395. microSurface: number;
  56396. /**
  56397. * Index of refraction of the material base layer.
  56398. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56399. *
  56400. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  56401. *
  56402. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  56403. */
  56404. get indexOfRefraction(): number;
  56405. set indexOfRefraction(value: number);
  56406. /**
  56407. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  56408. */
  56409. get invertRefractionY(): boolean;
  56410. set invertRefractionY(value: boolean);
  56411. /**
  56412. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  56413. * Materials half opaque for instance using refraction could benefit from this control.
  56414. */
  56415. get linkRefractionWithTransparency(): boolean;
  56416. set linkRefractionWithTransparency(value: boolean);
  56417. /**
  56418. * If true, the light map contains occlusion information instead of lighting info.
  56419. */
  56420. useLightmapAsShadowmap: boolean;
  56421. /**
  56422. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  56423. */
  56424. useAlphaFromAlbedoTexture: boolean;
  56425. /**
  56426. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  56427. */
  56428. forceAlphaTest: boolean;
  56429. /**
  56430. * Defines the alpha limits in alpha test mode.
  56431. */
  56432. alphaCutOff: number;
  56433. /**
  56434. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  56435. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  56436. */
  56437. useSpecularOverAlpha: boolean;
  56438. /**
  56439. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  56440. */
  56441. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  56442. /**
  56443. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  56444. */
  56445. useRoughnessFromMetallicTextureAlpha: boolean;
  56446. /**
  56447. * Specifies if the metallic texture contains the roughness information in its green channel.
  56448. */
  56449. useRoughnessFromMetallicTextureGreen: boolean;
  56450. /**
  56451. * Specifies if the metallic texture contains the metallness information in its blue channel.
  56452. */
  56453. useMetallnessFromMetallicTextureBlue: boolean;
  56454. /**
  56455. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  56456. */
  56457. useAmbientOcclusionFromMetallicTextureRed: boolean;
  56458. /**
  56459. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  56460. */
  56461. useAmbientInGrayScale: boolean;
  56462. /**
  56463. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  56464. * The material will try to infer what glossiness each pixel should be.
  56465. */
  56466. useAutoMicroSurfaceFromReflectivityMap: boolean;
  56467. /**
  56468. * BJS is using an harcoded light falloff based on a manually sets up range.
  56469. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  56470. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  56471. */
  56472. get usePhysicalLightFalloff(): boolean;
  56473. /**
  56474. * BJS is using an harcoded light falloff based on a manually sets up range.
  56475. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  56476. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  56477. */
  56478. set usePhysicalLightFalloff(value: boolean);
  56479. /**
  56480. * In order to support the falloff compatibility with gltf, a special mode has been added
  56481. * to reproduce the gltf light falloff.
  56482. */
  56483. get useGLTFLightFalloff(): boolean;
  56484. /**
  56485. * In order to support the falloff compatibility with gltf, a special mode has been added
  56486. * to reproduce the gltf light falloff.
  56487. */
  56488. set useGLTFLightFalloff(value: boolean);
  56489. /**
  56490. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  56491. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  56492. */
  56493. useRadianceOverAlpha: boolean;
  56494. /**
  56495. * Allows using an object space normal map (instead of tangent space).
  56496. */
  56497. useObjectSpaceNormalMap: boolean;
  56498. /**
  56499. * Allows using the bump map in parallax mode.
  56500. */
  56501. useParallax: boolean;
  56502. /**
  56503. * Allows using the bump map in parallax occlusion mode.
  56504. */
  56505. useParallaxOcclusion: boolean;
  56506. /**
  56507. * Controls the scale bias of the parallax mode.
  56508. */
  56509. parallaxScaleBias: number;
  56510. /**
  56511. * If sets to true, disables all the lights affecting the material.
  56512. */
  56513. disableLighting: boolean;
  56514. /**
  56515. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  56516. */
  56517. forceIrradianceInFragment: boolean;
  56518. /**
  56519. * Number of Simultaneous lights allowed on the material.
  56520. */
  56521. maxSimultaneousLights: number;
  56522. /**
  56523. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56524. */
  56525. invertNormalMapX: boolean;
  56526. /**
  56527. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56528. */
  56529. invertNormalMapY: boolean;
  56530. /**
  56531. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56532. */
  56533. twoSidedLighting: boolean;
  56534. /**
  56535. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56536. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  56537. */
  56538. useAlphaFresnel: boolean;
  56539. /**
  56540. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56541. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  56542. */
  56543. useLinearAlphaFresnel: boolean;
  56544. /**
  56545. * Let user defines the brdf lookup texture used for IBL.
  56546. * A default 8bit version is embedded but you could point at :
  56547. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  56548. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  56549. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  56550. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  56551. */
  56552. environmentBRDFTexture: Nullable<BaseTexture>;
  56553. /**
  56554. * Force normal to face away from face.
  56555. */
  56556. forceNormalForward: boolean;
  56557. /**
  56558. * Enables specular anti aliasing in the PBR shader.
  56559. * It will both interacts on the Geometry for analytical and IBL lighting.
  56560. * It also prefilter the roughness map based on the bump values.
  56561. */
  56562. enableSpecularAntiAliasing: boolean;
  56563. /**
  56564. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  56565. * makes the reflect vector face the model (under horizon).
  56566. */
  56567. useHorizonOcclusion: boolean;
  56568. /**
  56569. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  56570. * too much the area relying on ambient texture to define their ambient occlusion.
  56571. */
  56572. useRadianceOcclusion: boolean;
  56573. /**
  56574. * If set to true, no lighting calculations will be applied.
  56575. */
  56576. unlit: boolean;
  56577. /**
  56578. * Gets the image processing configuration used either in this material.
  56579. */
  56580. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  56581. /**
  56582. * Sets the Default image processing configuration used either in the this material.
  56583. *
  56584. * If sets to null, the scene one is in use.
  56585. */
  56586. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  56587. /**
  56588. * Gets wether the color curves effect is enabled.
  56589. */
  56590. get cameraColorCurvesEnabled(): boolean;
  56591. /**
  56592. * Sets wether the color curves effect is enabled.
  56593. */
  56594. set cameraColorCurvesEnabled(value: boolean);
  56595. /**
  56596. * Gets wether the color grading effect is enabled.
  56597. */
  56598. get cameraColorGradingEnabled(): boolean;
  56599. /**
  56600. * Gets wether the color grading effect is enabled.
  56601. */
  56602. set cameraColorGradingEnabled(value: boolean);
  56603. /**
  56604. * Gets wether tonemapping is enabled or not.
  56605. */
  56606. get cameraToneMappingEnabled(): boolean;
  56607. /**
  56608. * Sets wether tonemapping is enabled or not
  56609. */
  56610. set cameraToneMappingEnabled(value: boolean);
  56611. /**
  56612. * The camera exposure used on this material.
  56613. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56614. * This corresponds to a photographic exposure.
  56615. */
  56616. get cameraExposure(): number;
  56617. /**
  56618. * The camera exposure used on this material.
  56619. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56620. * This corresponds to a photographic exposure.
  56621. */
  56622. set cameraExposure(value: number);
  56623. /**
  56624. * Gets The camera contrast used on this material.
  56625. */
  56626. get cameraContrast(): number;
  56627. /**
  56628. * Sets The camera contrast used on this material.
  56629. */
  56630. set cameraContrast(value: number);
  56631. /**
  56632. * Gets the Color Grading 2D Lookup Texture.
  56633. */
  56634. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  56635. /**
  56636. * Sets the Color Grading 2D Lookup Texture.
  56637. */
  56638. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  56639. /**
  56640. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56641. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56642. * 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;
  56643. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56644. */
  56645. get cameraColorCurves(): Nullable<ColorCurves>;
  56646. /**
  56647. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56648. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56649. * 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;
  56650. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56651. */
  56652. set cameraColorCurves(value: Nullable<ColorCurves>);
  56653. /**
  56654. * Instantiates a new PBRMaterial instance.
  56655. *
  56656. * @param name The material name
  56657. * @param scene The scene the material will be use in.
  56658. */
  56659. constructor(name: string, scene: Scene);
  56660. /**
  56661. * Returns the name of this material class.
  56662. */
  56663. getClassName(): string;
  56664. /**
  56665. * Makes a duplicate of the current material.
  56666. * @param name - name to use for the new material.
  56667. */
  56668. clone(name: string): PBRMaterial;
  56669. /**
  56670. * Serializes this PBR Material.
  56671. * @returns - An object with the serialized material.
  56672. */
  56673. serialize(): any;
  56674. /**
  56675. * Parses a PBR Material from a serialized object.
  56676. * @param source - Serialized object.
  56677. * @param scene - BJS scene instance.
  56678. * @param rootUrl - url for the scene object
  56679. * @returns - PBRMaterial
  56680. */
  56681. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  56682. }
  56683. }
  56684. declare module BABYLON {
  56685. /**
  56686. * Direct draw surface info
  56687. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  56688. */
  56689. export interface DDSInfo {
  56690. /**
  56691. * Width of the texture
  56692. */
  56693. width: number;
  56694. /**
  56695. * Width of the texture
  56696. */
  56697. height: number;
  56698. /**
  56699. * Number of Mipmaps for the texture
  56700. * @see https://en.wikipedia.org/wiki/Mipmap
  56701. */
  56702. mipmapCount: number;
  56703. /**
  56704. * If the textures format is a known fourCC format
  56705. * @see https://www.fourcc.org/
  56706. */
  56707. isFourCC: boolean;
  56708. /**
  56709. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  56710. */
  56711. isRGB: boolean;
  56712. /**
  56713. * If the texture is a lumincance format
  56714. */
  56715. isLuminance: boolean;
  56716. /**
  56717. * If this is a cube texture
  56718. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  56719. */
  56720. isCube: boolean;
  56721. /**
  56722. * If the texture is a compressed format eg. FOURCC_DXT1
  56723. */
  56724. isCompressed: boolean;
  56725. /**
  56726. * The dxgiFormat of the texture
  56727. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  56728. */
  56729. dxgiFormat: number;
  56730. /**
  56731. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  56732. */
  56733. textureType: number;
  56734. /**
  56735. * Sphericle polynomial created for the dds texture
  56736. */
  56737. sphericalPolynomial?: SphericalPolynomial;
  56738. }
  56739. /**
  56740. * Class used to provide DDS decompression tools
  56741. */
  56742. export class DDSTools {
  56743. /**
  56744. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  56745. */
  56746. static StoreLODInAlphaChannel: boolean;
  56747. /**
  56748. * Gets DDS information from an array buffer
  56749. * @param data defines the array buffer view to read data from
  56750. * @returns the DDS information
  56751. */
  56752. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  56753. private static _FloatView;
  56754. private static _Int32View;
  56755. private static _ToHalfFloat;
  56756. private static _FromHalfFloat;
  56757. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  56758. private static _GetHalfFloatRGBAArrayBuffer;
  56759. private static _GetFloatRGBAArrayBuffer;
  56760. private static _GetFloatAsUIntRGBAArrayBuffer;
  56761. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  56762. private static _GetRGBAArrayBuffer;
  56763. private static _ExtractLongWordOrder;
  56764. private static _GetRGBArrayBuffer;
  56765. private static _GetLuminanceArrayBuffer;
  56766. /**
  56767. * Uploads DDS Levels to a Babylon Texture
  56768. * @hidden
  56769. */
  56770. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  56771. }
  56772. interface ThinEngine {
  56773. /**
  56774. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  56775. * @param rootUrl defines the url where the file to load is located
  56776. * @param scene defines the current scene
  56777. * @param lodScale defines scale to apply to the mip map selection
  56778. * @param lodOffset defines offset to apply to the mip map selection
  56779. * @param onLoad defines an optional callback raised when the texture is loaded
  56780. * @param onError defines an optional callback raised if there is an issue to load the texture
  56781. * @param format defines the format of the data
  56782. * @param forcedExtension defines the extension to use to pick the right loader
  56783. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  56784. * @returns the cube texture as an InternalTexture
  56785. */
  56786. 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;
  56787. }
  56788. }
  56789. declare module BABYLON {
  56790. /**
  56791. * Implementation of the DDS Texture Loader.
  56792. * @hidden
  56793. */
  56794. export class _DDSTextureLoader implements IInternalTextureLoader {
  56795. /**
  56796. * Defines wether the loader supports cascade loading the different faces.
  56797. */
  56798. readonly supportCascades: boolean;
  56799. /**
  56800. * This returns if the loader support the current file information.
  56801. * @param extension defines the file extension of the file being loaded
  56802. * @returns true if the loader can load the specified file
  56803. */
  56804. canLoad(extension: string): boolean;
  56805. /**
  56806. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56807. * @param data contains the texture data
  56808. * @param texture defines the BabylonJS internal texture
  56809. * @param createPolynomials will be true if polynomials have been requested
  56810. * @param onLoad defines the callback to trigger once the texture is ready
  56811. * @param onError defines the callback to trigger in case of error
  56812. */
  56813. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56814. /**
  56815. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56816. * @param data contains the texture data
  56817. * @param texture defines the BabylonJS internal texture
  56818. * @param callback defines the method to call once ready to upload
  56819. */
  56820. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56821. }
  56822. }
  56823. declare module BABYLON {
  56824. /**
  56825. * Implementation of the ENV Texture Loader.
  56826. * @hidden
  56827. */
  56828. export class _ENVTextureLoader implements IInternalTextureLoader {
  56829. /**
  56830. * Defines wether the loader supports cascade loading the different faces.
  56831. */
  56832. readonly supportCascades: boolean;
  56833. /**
  56834. * This returns if the loader support the current file information.
  56835. * @param extension defines the file extension of the file being loaded
  56836. * @returns true if the loader can load the specified file
  56837. */
  56838. canLoad(extension: string): boolean;
  56839. /**
  56840. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56841. * @param data contains the texture data
  56842. * @param texture defines the BabylonJS internal texture
  56843. * @param createPolynomials will be true if polynomials have been requested
  56844. * @param onLoad defines the callback to trigger once the texture is ready
  56845. * @param onError defines the callback to trigger in case of error
  56846. */
  56847. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56848. /**
  56849. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56850. * @param data contains the texture data
  56851. * @param texture defines the BabylonJS internal texture
  56852. * @param callback defines the method to call once ready to upload
  56853. */
  56854. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56855. }
  56856. }
  56857. declare module BABYLON {
  56858. /**
  56859. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  56860. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  56861. */
  56862. export class KhronosTextureContainer {
  56863. /** contents of the KTX container file */
  56864. data: ArrayBufferView;
  56865. private static HEADER_LEN;
  56866. private static COMPRESSED_2D;
  56867. private static COMPRESSED_3D;
  56868. private static TEX_2D;
  56869. private static TEX_3D;
  56870. /**
  56871. * Gets the openGL type
  56872. */
  56873. glType: number;
  56874. /**
  56875. * Gets the openGL type size
  56876. */
  56877. glTypeSize: number;
  56878. /**
  56879. * Gets the openGL format
  56880. */
  56881. glFormat: number;
  56882. /**
  56883. * Gets the openGL internal format
  56884. */
  56885. glInternalFormat: number;
  56886. /**
  56887. * Gets the base internal format
  56888. */
  56889. glBaseInternalFormat: number;
  56890. /**
  56891. * Gets image width in pixel
  56892. */
  56893. pixelWidth: number;
  56894. /**
  56895. * Gets image height in pixel
  56896. */
  56897. pixelHeight: number;
  56898. /**
  56899. * Gets image depth in pixels
  56900. */
  56901. pixelDepth: number;
  56902. /**
  56903. * Gets the number of array elements
  56904. */
  56905. numberOfArrayElements: number;
  56906. /**
  56907. * Gets the number of faces
  56908. */
  56909. numberOfFaces: number;
  56910. /**
  56911. * Gets the number of mipmap levels
  56912. */
  56913. numberOfMipmapLevels: number;
  56914. /**
  56915. * Gets the bytes of key value data
  56916. */
  56917. bytesOfKeyValueData: number;
  56918. /**
  56919. * Gets the load type
  56920. */
  56921. loadType: number;
  56922. /**
  56923. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  56924. */
  56925. isInvalid: boolean;
  56926. /**
  56927. * Creates a new KhronosTextureContainer
  56928. * @param data contents of the KTX container file
  56929. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  56930. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  56931. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  56932. */
  56933. constructor(
  56934. /** contents of the KTX container file */
  56935. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  56936. /**
  56937. * Uploads KTX content to a Babylon Texture.
  56938. * It is assumed that the texture has already been created & is currently bound
  56939. * @hidden
  56940. */
  56941. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  56942. private _upload2DCompressedLevels;
  56943. /**
  56944. * Checks if the given data starts with a KTX file identifier.
  56945. * @param data the data to check
  56946. * @returns true if the data is a KTX file or false otherwise
  56947. */
  56948. static IsValid(data: ArrayBufferView): boolean;
  56949. }
  56950. }
  56951. declare module BABYLON {
  56952. /**
  56953. * Class for loading KTX2 files
  56954. * !!! Experimental Extension Subject to Changes !!!
  56955. * @hidden
  56956. */
  56957. export class KhronosTextureContainer2 {
  56958. private static _ModulePromise;
  56959. private static _TranscodeFormat;
  56960. constructor(engine: ThinEngine);
  56961. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  56962. private _determineTranscodeFormat;
  56963. /**
  56964. * Checks if the given data starts with a KTX2 file identifier.
  56965. * @param data the data to check
  56966. * @returns true if the data is a KTX2 file or false otherwise
  56967. */
  56968. static IsValid(data: ArrayBufferView): boolean;
  56969. }
  56970. }
  56971. declare module BABYLON {
  56972. /**
  56973. * Implementation of the KTX Texture Loader.
  56974. * @hidden
  56975. */
  56976. export class _KTXTextureLoader implements IInternalTextureLoader {
  56977. /**
  56978. * Defines wether the loader supports cascade loading the different faces.
  56979. */
  56980. readonly supportCascades: boolean;
  56981. /**
  56982. * This returns if the loader support the current file information.
  56983. * @param extension defines the file extension of the file being loaded
  56984. * @param mimeType defines the optional mime type of the file being loaded
  56985. * @returns true if the loader can load the specified file
  56986. */
  56987. canLoad(extension: string, mimeType?: string): boolean;
  56988. /**
  56989. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56990. * @param data contains the texture data
  56991. * @param texture defines the BabylonJS internal texture
  56992. * @param createPolynomials will be true if polynomials have been requested
  56993. * @param onLoad defines the callback to trigger once the texture is ready
  56994. * @param onError defines the callback to trigger in case of error
  56995. */
  56996. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56997. /**
  56998. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56999. * @param data contains the texture data
  57000. * @param texture defines the BabylonJS internal texture
  57001. * @param callback defines the method to call once ready to upload
  57002. */
  57003. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  57004. }
  57005. }
  57006. declare module BABYLON {
  57007. /** @hidden */
  57008. export var _forceSceneHelpersToBundle: boolean;
  57009. interface Scene {
  57010. /**
  57011. * Creates a default light for the scene.
  57012. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  57013. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  57014. */
  57015. createDefaultLight(replace?: boolean): void;
  57016. /**
  57017. * Creates a default camera for the scene.
  57018. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  57019. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  57020. * @param replace has default false, when true replaces the active camera in the scene
  57021. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  57022. */
  57023. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  57024. /**
  57025. * Creates a default camera and a default light.
  57026. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  57027. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  57028. * @param replace has the default false, when true replaces the active camera/light in the scene
  57029. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  57030. */
  57031. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  57032. /**
  57033. * Creates a new sky box
  57034. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  57035. * @param environmentTexture defines the texture to use as environment texture
  57036. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  57037. * @param scale defines the overall scale of the skybox
  57038. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  57039. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  57040. * @returns a new mesh holding the sky box
  57041. */
  57042. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  57043. /**
  57044. * Creates a new environment
  57045. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  57046. * @param options defines the options you can use to configure the environment
  57047. * @returns the new EnvironmentHelper
  57048. */
  57049. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  57050. /**
  57051. * Creates a new VREXperienceHelper
  57052. * @see https://doc.babylonjs.com/how_to/webvr_helper
  57053. * @param webVROptions defines the options used to create the new VREXperienceHelper
  57054. * @returns a new VREXperienceHelper
  57055. */
  57056. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  57057. /**
  57058. * Creates a new WebXRDefaultExperience
  57059. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  57060. * @param options experience options
  57061. * @returns a promise for a new WebXRDefaultExperience
  57062. */
  57063. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  57064. }
  57065. }
  57066. declare module BABYLON {
  57067. /**
  57068. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  57069. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  57070. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  57071. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57072. */
  57073. export class VideoDome extends TransformNode {
  57074. /**
  57075. * Define the video source as a Monoscopic panoramic 360 video.
  57076. */
  57077. static readonly MODE_MONOSCOPIC: number;
  57078. /**
  57079. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  57080. */
  57081. static readonly MODE_TOPBOTTOM: number;
  57082. /**
  57083. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  57084. */
  57085. static readonly MODE_SIDEBYSIDE: number;
  57086. private _halfDome;
  57087. private _useDirectMapping;
  57088. /**
  57089. * The video texture being displayed on the sphere
  57090. */
  57091. protected _videoTexture: VideoTexture;
  57092. /**
  57093. * Gets the video texture being displayed on the sphere
  57094. */
  57095. get videoTexture(): VideoTexture;
  57096. /**
  57097. * The skybox material
  57098. */
  57099. protected _material: BackgroundMaterial;
  57100. /**
  57101. * The surface used for the video dome
  57102. */
  57103. protected _mesh: Mesh;
  57104. /**
  57105. * Gets the mesh used for the video dome.
  57106. */
  57107. get mesh(): Mesh;
  57108. /**
  57109. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  57110. */
  57111. private _halfDomeMask;
  57112. /**
  57113. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57114. * Also see the options.resolution property.
  57115. */
  57116. get fovMultiplier(): number;
  57117. set fovMultiplier(value: number);
  57118. private _videoMode;
  57119. /**
  57120. * Gets or set the current video mode for the video. It can be:
  57121. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  57122. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  57123. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  57124. */
  57125. get videoMode(): number;
  57126. set videoMode(value: number);
  57127. /**
  57128. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  57129. *
  57130. */
  57131. get halfDome(): boolean;
  57132. /**
  57133. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  57134. */
  57135. set halfDome(enabled: boolean);
  57136. /**
  57137. * Oberserver used in Stereoscopic VR Mode.
  57138. */
  57139. private _onBeforeCameraRenderObserver;
  57140. /**
  57141. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  57142. * @param name Element's name, child elements will append suffixes for their own names.
  57143. * @param urlsOrVideo defines the url(s) or the video element to use
  57144. * @param options An object containing optional or exposed sub element properties
  57145. */
  57146. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  57147. resolution?: number;
  57148. clickToPlay?: boolean;
  57149. autoPlay?: boolean;
  57150. loop?: boolean;
  57151. size?: number;
  57152. poster?: string;
  57153. faceForward?: boolean;
  57154. useDirectMapping?: boolean;
  57155. halfDomeMode?: boolean;
  57156. }, scene: Scene);
  57157. private _changeVideoMode;
  57158. /**
  57159. * Releases resources associated with this node.
  57160. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  57161. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  57162. */
  57163. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  57164. }
  57165. }
  57166. declare module BABYLON {
  57167. /**
  57168. * This class can be used to get instrumentation data from a Babylon engine
  57169. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  57170. */
  57171. export class EngineInstrumentation implements IDisposable {
  57172. /**
  57173. * Define the instrumented engine.
  57174. */
  57175. engine: Engine;
  57176. private _captureGPUFrameTime;
  57177. private _gpuFrameTimeToken;
  57178. private _gpuFrameTime;
  57179. private _captureShaderCompilationTime;
  57180. private _shaderCompilationTime;
  57181. private _onBeginFrameObserver;
  57182. private _onEndFrameObserver;
  57183. private _onBeforeShaderCompilationObserver;
  57184. private _onAfterShaderCompilationObserver;
  57185. /**
  57186. * Gets the perf counter used for GPU frame time
  57187. */
  57188. get gpuFrameTimeCounter(): PerfCounter;
  57189. /**
  57190. * Gets the GPU frame time capture status
  57191. */
  57192. get captureGPUFrameTime(): boolean;
  57193. /**
  57194. * Enable or disable the GPU frame time capture
  57195. */
  57196. set captureGPUFrameTime(value: boolean);
  57197. /**
  57198. * Gets the perf counter used for shader compilation time
  57199. */
  57200. get shaderCompilationTimeCounter(): PerfCounter;
  57201. /**
  57202. * Gets the shader compilation time capture status
  57203. */
  57204. get captureShaderCompilationTime(): boolean;
  57205. /**
  57206. * Enable or disable the shader compilation time capture
  57207. */
  57208. set captureShaderCompilationTime(value: boolean);
  57209. /**
  57210. * Instantiates a new engine instrumentation.
  57211. * This class can be used to get instrumentation data from a Babylon engine
  57212. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  57213. * @param engine Defines the engine to instrument
  57214. */
  57215. constructor(
  57216. /**
  57217. * Define the instrumented engine.
  57218. */
  57219. engine: Engine);
  57220. /**
  57221. * Dispose and release associated resources.
  57222. */
  57223. dispose(): void;
  57224. }
  57225. }
  57226. declare module BABYLON {
  57227. /**
  57228. * This class can be used to get instrumentation data from a Babylon engine
  57229. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  57230. */
  57231. export class SceneInstrumentation implements IDisposable {
  57232. /**
  57233. * Defines the scene to instrument
  57234. */
  57235. scene: Scene;
  57236. private _captureActiveMeshesEvaluationTime;
  57237. private _activeMeshesEvaluationTime;
  57238. private _captureRenderTargetsRenderTime;
  57239. private _renderTargetsRenderTime;
  57240. private _captureFrameTime;
  57241. private _frameTime;
  57242. private _captureRenderTime;
  57243. private _renderTime;
  57244. private _captureInterFrameTime;
  57245. private _interFrameTime;
  57246. private _captureParticlesRenderTime;
  57247. private _particlesRenderTime;
  57248. private _captureSpritesRenderTime;
  57249. private _spritesRenderTime;
  57250. private _capturePhysicsTime;
  57251. private _physicsTime;
  57252. private _captureAnimationsTime;
  57253. private _animationsTime;
  57254. private _captureCameraRenderTime;
  57255. private _cameraRenderTime;
  57256. private _onBeforeActiveMeshesEvaluationObserver;
  57257. private _onAfterActiveMeshesEvaluationObserver;
  57258. private _onBeforeRenderTargetsRenderObserver;
  57259. private _onAfterRenderTargetsRenderObserver;
  57260. private _onAfterRenderObserver;
  57261. private _onBeforeDrawPhaseObserver;
  57262. private _onAfterDrawPhaseObserver;
  57263. private _onBeforeAnimationsObserver;
  57264. private _onBeforeParticlesRenderingObserver;
  57265. private _onAfterParticlesRenderingObserver;
  57266. private _onBeforeSpritesRenderingObserver;
  57267. private _onAfterSpritesRenderingObserver;
  57268. private _onBeforePhysicsObserver;
  57269. private _onAfterPhysicsObserver;
  57270. private _onAfterAnimationsObserver;
  57271. private _onBeforeCameraRenderObserver;
  57272. private _onAfterCameraRenderObserver;
  57273. /**
  57274. * Gets the perf counter used for active meshes evaluation time
  57275. */
  57276. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  57277. /**
  57278. * Gets the active meshes evaluation time capture status
  57279. */
  57280. get captureActiveMeshesEvaluationTime(): boolean;
  57281. /**
  57282. * Enable or disable the active meshes evaluation time capture
  57283. */
  57284. set captureActiveMeshesEvaluationTime(value: boolean);
  57285. /**
  57286. * Gets the perf counter used for render targets render time
  57287. */
  57288. get renderTargetsRenderTimeCounter(): PerfCounter;
  57289. /**
  57290. * Gets the render targets render time capture status
  57291. */
  57292. get captureRenderTargetsRenderTime(): boolean;
  57293. /**
  57294. * Enable or disable the render targets render time capture
  57295. */
  57296. set captureRenderTargetsRenderTime(value: boolean);
  57297. /**
  57298. * Gets the perf counter used for particles render time
  57299. */
  57300. get particlesRenderTimeCounter(): PerfCounter;
  57301. /**
  57302. * Gets the particles render time capture status
  57303. */
  57304. get captureParticlesRenderTime(): boolean;
  57305. /**
  57306. * Enable or disable the particles render time capture
  57307. */
  57308. set captureParticlesRenderTime(value: boolean);
  57309. /**
  57310. * Gets the perf counter used for sprites render time
  57311. */
  57312. get spritesRenderTimeCounter(): PerfCounter;
  57313. /**
  57314. * Gets the sprites render time capture status
  57315. */
  57316. get captureSpritesRenderTime(): boolean;
  57317. /**
  57318. * Enable or disable the sprites render time capture
  57319. */
  57320. set captureSpritesRenderTime(value: boolean);
  57321. /**
  57322. * Gets the perf counter used for physics time
  57323. */
  57324. get physicsTimeCounter(): PerfCounter;
  57325. /**
  57326. * Gets the physics time capture status
  57327. */
  57328. get capturePhysicsTime(): boolean;
  57329. /**
  57330. * Enable or disable the physics time capture
  57331. */
  57332. set capturePhysicsTime(value: boolean);
  57333. /**
  57334. * Gets the perf counter used for animations time
  57335. */
  57336. get animationsTimeCounter(): PerfCounter;
  57337. /**
  57338. * Gets the animations time capture status
  57339. */
  57340. get captureAnimationsTime(): boolean;
  57341. /**
  57342. * Enable or disable the animations time capture
  57343. */
  57344. set captureAnimationsTime(value: boolean);
  57345. /**
  57346. * Gets the perf counter used for frame time capture
  57347. */
  57348. get frameTimeCounter(): PerfCounter;
  57349. /**
  57350. * Gets the frame time capture status
  57351. */
  57352. get captureFrameTime(): boolean;
  57353. /**
  57354. * Enable or disable the frame time capture
  57355. */
  57356. set captureFrameTime(value: boolean);
  57357. /**
  57358. * Gets the perf counter used for inter-frames time capture
  57359. */
  57360. get interFrameTimeCounter(): PerfCounter;
  57361. /**
  57362. * Gets the inter-frames time capture status
  57363. */
  57364. get captureInterFrameTime(): boolean;
  57365. /**
  57366. * Enable or disable the inter-frames time capture
  57367. */
  57368. set captureInterFrameTime(value: boolean);
  57369. /**
  57370. * Gets the perf counter used for render time capture
  57371. */
  57372. get renderTimeCounter(): PerfCounter;
  57373. /**
  57374. * Gets the render time capture status
  57375. */
  57376. get captureRenderTime(): boolean;
  57377. /**
  57378. * Enable or disable the render time capture
  57379. */
  57380. set captureRenderTime(value: boolean);
  57381. /**
  57382. * Gets the perf counter used for camera render time capture
  57383. */
  57384. get cameraRenderTimeCounter(): PerfCounter;
  57385. /**
  57386. * Gets the camera render time capture status
  57387. */
  57388. get captureCameraRenderTime(): boolean;
  57389. /**
  57390. * Enable or disable the camera render time capture
  57391. */
  57392. set captureCameraRenderTime(value: boolean);
  57393. /**
  57394. * Gets the perf counter used for draw calls
  57395. */
  57396. get drawCallsCounter(): PerfCounter;
  57397. /**
  57398. * Instantiates a new scene instrumentation.
  57399. * This class can be used to get instrumentation data from a Babylon engine
  57400. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  57401. * @param scene Defines the scene to instrument
  57402. */
  57403. constructor(
  57404. /**
  57405. * Defines the scene to instrument
  57406. */
  57407. scene: Scene);
  57408. /**
  57409. * Dispose and release associated resources.
  57410. */
  57411. dispose(): void;
  57412. }
  57413. }
  57414. declare module BABYLON {
  57415. /** @hidden */
  57416. export var glowMapGenerationPixelShader: {
  57417. name: string;
  57418. shader: string;
  57419. };
  57420. }
  57421. declare module BABYLON {
  57422. /** @hidden */
  57423. export var glowMapGenerationVertexShader: {
  57424. name: string;
  57425. shader: string;
  57426. };
  57427. }
  57428. declare module BABYLON {
  57429. /**
  57430. * Effect layer options. This helps customizing the behaviour
  57431. * of the effect layer.
  57432. */
  57433. export interface IEffectLayerOptions {
  57434. /**
  57435. * Multiplication factor apply to the canvas size to compute the render target size
  57436. * used to generated the objects (the smaller the faster).
  57437. */
  57438. mainTextureRatio: number;
  57439. /**
  57440. * Enforces a fixed size texture to ensure effect stability across devices.
  57441. */
  57442. mainTextureFixedSize?: number;
  57443. /**
  57444. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  57445. */
  57446. alphaBlendingMode: number;
  57447. /**
  57448. * The camera attached to the layer.
  57449. */
  57450. camera: Nullable<Camera>;
  57451. /**
  57452. * The rendering group to draw the layer in.
  57453. */
  57454. renderingGroupId: number;
  57455. }
  57456. /**
  57457. * The effect layer Helps adding post process effect blended with the main pass.
  57458. *
  57459. * This can be for instance use to generate glow or higlight effects on the scene.
  57460. *
  57461. * The effect layer class can not be used directly and is intented to inherited from to be
  57462. * customized per effects.
  57463. */
  57464. export abstract class EffectLayer {
  57465. private _vertexBuffers;
  57466. private _indexBuffer;
  57467. private _cachedDefines;
  57468. private _effectLayerMapGenerationEffect;
  57469. private _effectLayerOptions;
  57470. private _mergeEffect;
  57471. protected _scene: Scene;
  57472. protected _engine: Engine;
  57473. protected _maxSize: number;
  57474. protected _mainTextureDesiredSize: ISize;
  57475. protected _mainTexture: RenderTargetTexture;
  57476. protected _shouldRender: boolean;
  57477. protected _postProcesses: PostProcess[];
  57478. protected _textures: BaseTexture[];
  57479. protected _emissiveTextureAndColor: {
  57480. texture: Nullable<BaseTexture>;
  57481. color: Color4;
  57482. };
  57483. /**
  57484. * The name of the layer
  57485. */
  57486. name: string;
  57487. /**
  57488. * The clear color of the texture used to generate the glow map.
  57489. */
  57490. neutralColor: Color4;
  57491. /**
  57492. * Specifies whether the highlight layer is enabled or not.
  57493. */
  57494. isEnabled: boolean;
  57495. /**
  57496. * Gets the camera attached to the layer.
  57497. */
  57498. get camera(): Nullable<Camera>;
  57499. /**
  57500. * Gets the rendering group id the layer should render in.
  57501. */
  57502. get renderingGroupId(): number;
  57503. set renderingGroupId(renderingGroupId: number);
  57504. /**
  57505. * An event triggered when the effect layer has been disposed.
  57506. */
  57507. onDisposeObservable: Observable<EffectLayer>;
  57508. /**
  57509. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  57510. */
  57511. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  57512. /**
  57513. * An event triggered when the generated texture is being merged in the scene.
  57514. */
  57515. onBeforeComposeObservable: Observable<EffectLayer>;
  57516. /**
  57517. * An event triggered when the mesh is rendered into the effect render target.
  57518. */
  57519. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  57520. /**
  57521. * An event triggered after the mesh has been rendered into the effect render target.
  57522. */
  57523. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  57524. /**
  57525. * An event triggered when the generated texture has been merged in the scene.
  57526. */
  57527. onAfterComposeObservable: Observable<EffectLayer>;
  57528. /**
  57529. * An event triggered when the efffect layer changes its size.
  57530. */
  57531. onSizeChangedObservable: Observable<EffectLayer>;
  57532. /** @hidden */
  57533. static _SceneComponentInitialization: (scene: Scene) => void;
  57534. /**
  57535. * Instantiates a new effect Layer and references it in the scene.
  57536. * @param name The name of the layer
  57537. * @param scene The scene to use the layer in
  57538. */
  57539. constructor(
  57540. /** The Friendly of the effect in the scene */
  57541. name: string, scene: Scene);
  57542. /**
  57543. * Get the effect name of the layer.
  57544. * @return The effect name
  57545. */
  57546. abstract getEffectName(): string;
  57547. /**
  57548. * Checks for the readiness of the element composing the layer.
  57549. * @param subMesh the mesh to check for
  57550. * @param useInstances specify whether or not to use instances to render the mesh
  57551. * @return true if ready otherwise, false
  57552. */
  57553. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57554. /**
  57555. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  57556. * @returns true if the effect requires stencil during the main canvas render pass.
  57557. */
  57558. abstract needStencil(): boolean;
  57559. /**
  57560. * Create the merge effect. This is the shader use to blit the information back
  57561. * to the main canvas at the end of the scene rendering.
  57562. * @returns The effect containing the shader used to merge the effect on the main canvas
  57563. */
  57564. protected abstract _createMergeEffect(): Effect;
  57565. /**
  57566. * Creates the render target textures and post processes used in the effect layer.
  57567. */
  57568. protected abstract _createTextureAndPostProcesses(): void;
  57569. /**
  57570. * Implementation specific of rendering the generating effect on the main canvas.
  57571. * @param effect The effect used to render through
  57572. */
  57573. protected abstract _internalRender(effect: Effect): void;
  57574. /**
  57575. * Sets the required values for both the emissive texture and and the main color.
  57576. */
  57577. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57578. /**
  57579. * Free any resources and references associated to a mesh.
  57580. * Internal use
  57581. * @param mesh The mesh to free.
  57582. */
  57583. abstract _disposeMesh(mesh: Mesh): void;
  57584. /**
  57585. * Serializes this layer (Glow or Highlight for example)
  57586. * @returns a serialized layer object
  57587. */
  57588. abstract serialize?(): any;
  57589. /**
  57590. * Initializes the effect layer with the required options.
  57591. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  57592. */
  57593. protected _init(options: Partial<IEffectLayerOptions>): void;
  57594. /**
  57595. * Generates the index buffer of the full screen quad blending to the main canvas.
  57596. */
  57597. private _generateIndexBuffer;
  57598. /**
  57599. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  57600. */
  57601. private _generateVertexBuffer;
  57602. /**
  57603. * Sets the main texture desired size which is the closest power of two
  57604. * of the engine canvas size.
  57605. */
  57606. private _setMainTextureSize;
  57607. /**
  57608. * Creates the main texture for the effect layer.
  57609. */
  57610. protected _createMainTexture(): void;
  57611. /**
  57612. * Adds specific effects defines.
  57613. * @param defines The defines to add specifics to.
  57614. */
  57615. protected _addCustomEffectDefines(defines: string[]): void;
  57616. /**
  57617. * Checks for the readiness of the element composing the layer.
  57618. * @param subMesh the mesh to check for
  57619. * @param useInstances specify whether or not to use instances to render the mesh
  57620. * @param emissiveTexture the associated emissive texture used to generate the glow
  57621. * @return true if ready otherwise, false
  57622. */
  57623. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  57624. /**
  57625. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  57626. */
  57627. render(): void;
  57628. /**
  57629. * Determine if a given mesh will be used in the current effect.
  57630. * @param mesh mesh to test
  57631. * @returns true if the mesh will be used
  57632. */
  57633. hasMesh(mesh: AbstractMesh): boolean;
  57634. /**
  57635. * Returns true if the layer contains information to display, otherwise false.
  57636. * @returns true if the glow layer should be rendered
  57637. */
  57638. shouldRender(): boolean;
  57639. /**
  57640. * Returns true if the mesh should render, otherwise false.
  57641. * @param mesh The mesh to render
  57642. * @returns true if it should render otherwise false
  57643. */
  57644. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  57645. /**
  57646. * Returns true if the mesh can be rendered, otherwise false.
  57647. * @param mesh The mesh to render
  57648. * @param material The material used on the mesh
  57649. * @returns true if it can be rendered otherwise false
  57650. */
  57651. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57652. /**
  57653. * Returns true if the mesh should render, otherwise false.
  57654. * @param mesh The mesh to render
  57655. * @returns true if it should render otherwise false
  57656. */
  57657. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  57658. /**
  57659. * Renders the submesh passed in parameter to the generation map.
  57660. */
  57661. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  57662. /**
  57663. * Defines whether the current material of the mesh should be use to render the effect.
  57664. * @param mesh defines the current mesh to render
  57665. */
  57666. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  57667. /**
  57668. * Rebuild the required buffers.
  57669. * @hidden Internal use only.
  57670. */
  57671. _rebuild(): void;
  57672. /**
  57673. * Dispose only the render target textures and post process.
  57674. */
  57675. private _disposeTextureAndPostProcesses;
  57676. /**
  57677. * Dispose the highlight layer and free resources.
  57678. */
  57679. dispose(): void;
  57680. /**
  57681. * Gets the class name of the effect layer
  57682. * @returns the string with the class name of the effect layer
  57683. */
  57684. getClassName(): string;
  57685. /**
  57686. * Creates an effect layer from parsed effect layer data
  57687. * @param parsedEffectLayer defines effect layer data
  57688. * @param scene defines the current scene
  57689. * @param rootUrl defines the root URL containing the effect layer information
  57690. * @returns a parsed effect Layer
  57691. */
  57692. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  57693. }
  57694. }
  57695. declare module BABYLON {
  57696. interface AbstractScene {
  57697. /**
  57698. * The list of effect layers (highlights/glow) added to the scene
  57699. * @see https://doc.babylonjs.com/how_to/highlight_layer
  57700. * @see https://doc.babylonjs.com/how_to/glow_layer
  57701. */
  57702. effectLayers: Array<EffectLayer>;
  57703. /**
  57704. * Removes the given effect layer from this scene.
  57705. * @param toRemove defines the effect layer to remove
  57706. * @returns the index of the removed effect layer
  57707. */
  57708. removeEffectLayer(toRemove: EffectLayer): number;
  57709. /**
  57710. * Adds the given effect layer to this scene
  57711. * @param newEffectLayer defines the effect layer to add
  57712. */
  57713. addEffectLayer(newEffectLayer: EffectLayer): void;
  57714. }
  57715. /**
  57716. * Defines the layer scene component responsible to manage any effect layers
  57717. * in a given scene.
  57718. */
  57719. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  57720. /**
  57721. * The component name helpfull to identify the component in the list of scene components.
  57722. */
  57723. readonly name: string;
  57724. /**
  57725. * The scene the component belongs to.
  57726. */
  57727. scene: Scene;
  57728. private _engine;
  57729. private _renderEffects;
  57730. private _needStencil;
  57731. private _previousStencilState;
  57732. /**
  57733. * Creates a new instance of the component for the given scene
  57734. * @param scene Defines the scene to register the component in
  57735. */
  57736. constructor(scene: Scene);
  57737. /**
  57738. * Registers the component in a given scene
  57739. */
  57740. register(): void;
  57741. /**
  57742. * Rebuilds the elements related to this component in case of
  57743. * context lost for instance.
  57744. */
  57745. rebuild(): void;
  57746. /**
  57747. * Serializes the component data to the specified json object
  57748. * @param serializationObject The object to serialize to
  57749. */
  57750. serialize(serializationObject: any): void;
  57751. /**
  57752. * Adds all the elements from the container to the scene
  57753. * @param container the container holding the elements
  57754. */
  57755. addFromContainer(container: AbstractScene): void;
  57756. /**
  57757. * Removes all the elements in the container from the scene
  57758. * @param container contains the elements to remove
  57759. * @param dispose if the removed element should be disposed (default: false)
  57760. */
  57761. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57762. /**
  57763. * Disposes the component and the associated ressources.
  57764. */
  57765. dispose(): void;
  57766. private _isReadyForMesh;
  57767. private _renderMainTexture;
  57768. private _setStencil;
  57769. private _setStencilBack;
  57770. private _draw;
  57771. private _drawCamera;
  57772. private _drawRenderingGroup;
  57773. }
  57774. }
  57775. declare module BABYLON {
  57776. /** @hidden */
  57777. export var glowMapMergePixelShader: {
  57778. name: string;
  57779. shader: string;
  57780. };
  57781. }
  57782. declare module BABYLON {
  57783. /** @hidden */
  57784. export var glowMapMergeVertexShader: {
  57785. name: string;
  57786. shader: string;
  57787. };
  57788. }
  57789. declare module BABYLON {
  57790. interface AbstractScene {
  57791. /**
  57792. * Return a the first highlight layer of the scene with a given name.
  57793. * @param name The name of the highlight layer to look for.
  57794. * @return The highlight layer if found otherwise null.
  57795. */
  57796. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  57797. }
  57798. /**
  57799. * Glow layer options. This helps customizing the behaviour
  57800. * of the glow layer.
  57801. */
  57802. export interface IGlowLayerOptions {
  57803. /**
  57804. * Multiplication factor apply to the canvas size to compute the render target size
  57805. * used to generated the glowing objects (the smaller the faster).
  57806. */
  57807. mainTextureRatio: number;
  57808. /**
  57809. * Enforces a fixed size texture to ensure resize independant blur.
  57810. */
  57811. mainTextureFixedSize?: number;
  57812. /**
  57813. * How big is the kernel of the blur texture.
  57814. */
  57815. blurKernelSize: number;
  57816. /**
  57817. * The camera attached to the layer.
  57818. */
  57819. camera: Nullable<Camera>;
  57820. /**
  57821. * Enable MSAA by chosing the number of samples.
  57822. */
  57823. mainTextureSamples?: number;
  57824. /**
  57825. * The rendering group to draw the layer in.
  57826. */
  57827. renderingGroupId: number;
  57828. }
  57829. /**
  57830. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  57831. *
  57832. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  57833. *
  57834. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  57835. */
  57836. export class GlowLayer extends EffectLayer {
  57837. /**
  57838. * Effect Name of the layer.
  57839. */
  57840. static readonly EffectName: string;
  57841. /**
  57842. * The default blur kernel size used for the glow.
  57843. */
  57844. static DefaultBlurKernelSize: number;
  57845. /**
  57846. * The default texture size ratio used for the glow.
  57847. */
  57848. static DefaultTextureRatio: number;
  57849. /**
  57850. * Sets the kernel size of the blur.
  57851. */
  57852. set blurKernelSize(value: number);
  57853. /**
  57854. * Gets the kernel size of the blur.
  57855. */
  57856. get blurKernelSize(): number;
  57857. /**
  57858. * Sets the glow intensity.
  57859. */
  57860. set intensity(value: number);
  57861. /**
  57862. * Gets the glow intensity.
  57863. */
  57864. get intensity(): number;
  57865. private _options;
  57866. private _intensity;
  57867. private _horizontalBlurPostprocess1;
  57868. private _verticalBlurPostprocess1;
  57869. private _horizontalBlurPostprocess2;
  57870. private _verticalBlurPostprocess2;
  57871. private _blurTexture1;
  57872. private _blurTexture2;
  57873. private _postProcesses1;
  57874. private _postProcesses2;
  57875. private _includedOnlyMeshes;
  57876. private _excludedMeshes;
  57877. private _meshesUsingTheirOwnMaterials;
  57878. /**
  57879. * Callback used to let the user override the color selection on a per mesh basis
  57880. */
  57881. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  57882. /**
  57883. * Callback used to let the user override the texture selection on a per mesh basis
  57884. */
  57885. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  57886. /**
  57887. * Instantiates a new glow Layer and references it to the scene.
  57888. * @param name The name of the layer
  57889. * @param scene The scene to use the layer in
  57890. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  57891. */
  57892. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  57893. /**
  57894. * Get the effect name of the layer.
  57895. * @return The effect name
  57896. */
  57897. getEffectName(): string;
  57898. /**
  57899. * Create the merge effect. This is the shader use to blit the information back
  57900. * to the main canvas at the end of the scene rendering.
  57901. */
  57902. protected _createMergeEffect(): Effect;
  57903. /**
  57904. * Creates the render target textures and post processes used in the glow layer.
  57905. */
  57906. protected _createTextureAndPostProcesses(): void;
  57907. /**
  57908. * Checks for the readiness of the element composing the layer.
  57909. * @param subMesh the mesh to check for
  57910. * @param useInstances specify wether or not to use instances to render the mesh
  57911. * @param emissiveTexture the associated emissive texture used to generate the glow
  57912. * @return true if ready otherwise, false
  57913. */
  57914. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57915. /**
  57916. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  57917. */
  57918. needStencil(): boolean;
  57919. /**
  57920. * Returns true if the mesh can be rendered, otherwise false.
  57921. * @param mesh The mesh to render
  57922. * @param material The material used on the mesh
  57923. * @returns true if it can be rendered otherwise false
  57924. */
  57925. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57926. /**
  57927. * Implementation specific of rendering the generating effect on the main canvas.
  57928. * @param effect The effect used to render through
  57929. */
  57930. protected _internalRender(effect: Effect): void;
  57931. /**
  57932. * Sets the required values for both the emissive texture and and the main color.
  57933. */
  57934. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57935. /**
  57936. * Returns true if the mesh should render, otherwise false.
  57937. * @param mesh The mesh to render
  57938. * @returns true if it should render otherwise false
  57939. */
  57940. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57941. /**
  57942. * Adds specific effects defines.
  57943. * @param defines The defines to add specifics to.
  57944. */
  57945. protected _addCustomEffectDefines(defines: string[]): void;
  57946. /**
  57947. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  57948. * @param mesh The mesh to exclude from the glow layer
  57949. */
  57950. addExcludedMesh(mesh: Mesh): void;
  57951. /**
  57952. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  57953. * @param mesh The mesh to remove
  57954. */
  57955. removeExcludedMesh(mesh: Mesh): void;
  57956. /**
  57957. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  57958. * @param mesh The mesh to include in the glow layer
  57959. */
  57960. addIncludedOnlyMesh(mesh: Mesh): void;
  57961. /**
  57962. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  57963. * @param mesh The mesh to remove
  57964. */
  57965. removeIncludedOnlyMesh(mesh: Mesh): void;
  57966. /**
  57967. * Determine if a given mesh will be used in the glow layer
  57968. * @param mesh The mesh to test
  57969. * @returns true if the mesh will be highlighted by the current glow layer
  57970. */
  57971. hasMesh(mesh: AbstractMesh): boolean;
  57972. /**
  57973. * Defines whether the current material of the mesh should be use to render the effect.
  57974. * @param mesh defines the current mesh to render
  57975. */
  57976. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  57977. /**
  57978. * Add a mesh to be rendered through its own material and not with emissive only.
  57979. * @param mesh The mesh for which we need to use its material
  57980. */
  57981. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  57982. /**
  57983. * Remove a mesh from being rendered through its own material and not with emissive only.
  57984. * @param mesh The mesh for which we need to not use its material
  57985. */
  57986. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  57987. /**
  57988. * Free any resources and references associated to a mesh.
  57989. * Internal use
  57990. * @param mesh The mesh to free.
  57991. * @hidden
  57992. */
  57993. _disposeMesh(mesh: Mesh): void;
  57994. /**
  57995. * Gets the class name of the effect layer
  57996. * @returns the string with the class name of the effect layer
  57997. */
  57998. getClassName(): string;
  57999. /**
  58000. * Serializes this glow layer
  58001. * @returns a serialized glow layer object
  58002. */
  58003. serialize(): any;
  58004. /**
  58005. * Creates a Glow Layer from parsed glow layer data
  58006. * @param parsedGlowLayer defines glow layer data
  58007. * @param scene defines the current scene
  58008. * @param rootUrl defines the root URL containing the glow layer information
  58009. * @returns a parsed Glow Layer
  58010. */
  58011. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  58012. }
  58013. }
  58014. declare module BABYLON {
  58015. /** @hidden */
  58016. export var glowBlurPostProcessPixelShader: {
  58017. name: string;
  58018. shader: string;
  58019. };
  58020. }
  58021. declare module BABYLON {
  58022. interface AbstractScene {
  58023. /**
  58024. * Return a the first highlight layer of the scene with a given name.
  58025. * @param name The name of the highlight layer to look for.
  58026. * @return The highlight layer if found otherwise null.
  58027. */
  58028. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  58029. }
  58030. /**
  58031. * Highlight layer options. This helps customizing the behaviour
  58032. * of the highlight layer.
  58033. */
  58034. export interface IHighlightLayerOptions {
  58035. /**
  58036. * Multiplication factor apply to the canvas size to compute the render target size
  58037. * used to generated the glowing objects (the smaller the faster).
  58038. */
  58039. mainTextureRatio: number;
  58040. /**
  58041. * Enforces a fixed size texture to ensure resize independant blur.
  58042. */
  58043. mainTextureFixedSize?: number;
  58044. /**
  58045. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  58046. * of the picture to blur (the smaller the faster).
  58047. */
  58048. blurTextureSizeRatio: number;
  58049. /**
  58050. * How big in texel of the blur texture is the vertical blur.
  58051. */
  58052. blurVerticalSize: number;
  58053. /**
  58054. * How big in texel of the blur texture is the horizontal blur.
  58055. */
  58056. blurHorizontalSize: number;
  58057. /**
  58058. * Alpha blending mode used to apply the blur. Default is combine.
  58059. */
  58060. alphaBlendingMode: number;
  58061. /**
  58062. * The camera attached to the layer.
  58063. */
  58064. camera: Nullable<Camera>;
  58065. /**
  58066. * Should we display highlight as a solid stroke?
  58067. */
  58068. isStroke?: boolean;
  58069. /**
  58070. * The rendering group to draw the layer in.
  58071. */
  58072. renderingGroupId: number;
  58073. }
  58074. /**
  58075. * The highlight layer Helps adding a glow effect around a mesh.
  58076. *
  58077. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  58078. * glowy meshes to your scene.
  58079. *
  58080. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  58081. */
  58082. export class HighlightLayer extends EffectLayer {
  58083. name: string;
  58084. /**
  58085. * Effect Name of the highlight layer.
  58086. */
  58087. static readonly EffectName: string;
  58088. /**
  58089. * The neutral color used during the preparation of the glow effect.
  58090. * This is black by default as the blend operation is a blend operation.
  58091. */
  58092. static NeutralColor: Color4;
  58093. /**
  58094. * Stencil value used for glowing meshes.
  58095. */
  58096. static GlowingMeshStencilReference: number;
  58097. /**
  58098. * Stencil value used for the other meshes in the scene.
  58099. */
  58100. static NormalMeshStencilReference: number;
  58101. /**
  58102. * Specifies whether or not the inner glow is ACTIVE in the layer.
  58103. */
  58104. innerGlow: boolean;
  58105. /**
  58106. * Specifies whether or not the outer glow is ACTIVE in the layer.
  58107. */
  58108. outerGlow: boolean;
  58109. /**
  58110. * Specifies the horizontal size of the blur.
  58111. */
  58112. set blurHorizontalSize(value: number);
  58113. /**
  58114. * Specifies the vertical size of the blur.
  58115. */
  58116. set blurVerticalSize(value: number);
  58117. /**
  58118. * Gets the horizontal size of the blur.
  58119. */
  58120. get blurHorizontalSize(): number;
  58121. /**
  58122. * Gets the vertical size of the blur.
  58123. */
  58124. get blurVerticalSize(): number;
  58125. /**
  58126. * An event triggered when the highlight layer is being blurred.
  58127. */
  58128. onBeforeBlurObservable: Observable<HighlightLayer>;
  58129. /**
  58130. * An event triggered when the highlight layer has been blurred.
  58131. */
  58132. onAfterBlurObservable: Observable<HighlightLayer>;
  58133. private _instanceGlowingMeshStencilReference;
  58134. private _options;
  58135. private _downSamplePostprocess;
  58136. private _horizontalBlurPostprocess;
  58137. private _verticalBlurPostprocess;
  58138. private _blurTexture;
  58139. private _meshes;
  58140. private _excludedMeshes;
  58141. /**
  58142. * Instantiates a new highlight Layer and references it to the scene..
  58143. * @param name The name of the layer
  58144. * @param scene The scene to use the layer in
  58145. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  58146. */
  58147. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  58148. /**
  58149. * Get the effect name of the layer.
  58150. * @return The effect name
  58151. */
  58152. getEffectName(): string;
  58153. /**
  58154. * Create the merge effect. This is the shader use to blit the information back
  58155. * to the main canvas at the end of the scene rendering.
  58156. */
  58157. protected _createMergeEffect(): Effect;
  58158. /**
  58159. * Creates the render target textures and post processes used in the highlight layer.
  58160. */
  58161. protected _createTextureAndPostProcesses(): void;
  58162. /**
  58163. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  58164. */
  58165. needStencil(): boolean;
  58166. /**
  58167. * Checks for the readiness of the element composing the layer.
  58168. * @param subMesh the mesh to check for
  58169. * @param useInstances specify wether or not to use instances to render the mesh
  58170. * @param emissiveTexture the associated emissive texture used to generate the glow
  58171. * @return true if ready otherwise, false
  58172. */
  58173. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58174. /**
  58175. * Implementation specific of rendering the generating effect on the main canvas.
  58176. * @param effect The effect used to render through
  58177. */
  58178. protected _internalRender(effect: Effect): void;
  58179. /**
  58180. * Returns true if the layer contains information to display, otherwise false.
  58181. */
  58182. shouldRender(): boolean;
  58183. /**
  58184. * Returns true if the mesh should render, otherwise false.
  58185. * @param mesh The mesh to render
  58186. * @returns true if it should render otherwise false
  58187. */
  58188. protected _shouldRenderMesh(mesh: Mesh): boolean;
  58189. /**
  58190. * Returns true if the mesh can be rendered, otherwise false.
  58191. * @param mesh The mesh to render
  58192. * @param material The material used on the mesh
  58193. * @returns true if it can be rendered otherwise false
  58194. */
  58195. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58196. /**
  58197. * Adds specific effects defines.
  58198. * @param defines The defines to add specifics to.
  58199. */
  58200. protected _addCustomEffectDefines(defines: string[]): void;
  58201. /**
  58202. * Sets the required values for both the emissive texture and and the main color.
  58203. */
  58204. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58205. /**
  58206. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  58207. * @param mesh The mesh to exclude from the highlight layer
  58208. */
  58209. addExcludedMesh(mesh: Mesh): void;
  58210. /**
  58211. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  58212. * @param mesh The mesh to highlight
  58213. */
  58214. removeExcludedMesh(mesh: Mesh): void;
  58215. /**
  58216. * Determine if a given mesh will be highlighted by the current HighlightLayer
  58217. * @param mesh mesh to test
  58218. * @returns true if the mesh will be highlighted by the current HighlightLayer
  58219. */
  58220. hasMesh(mesh: AbstractMesh): boolean;
  58221. /**
  58222. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  58223. * @param mesh The mesh to highlight
  58224. * @param color The color of the highlight
  58225. * @param glowEmissiveOnly Extract the glow from the emissive texture
  58226. */
  58227. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  58228. /**
  58229. * Remove a mesh from the highlight layer in order to make it stop glowing.
  58230. * @param mesh The mesh to highlight
  58231. */
  58232. removeMesh(mesh: Mesh): void;
  58233. /**
  58234. * Remove all the meshes currently referenced in the highlight layer
  58235. */
  58236. removeAllMeshes(): void;
  58237. /**
  58238. * Force the stencil to the normal expected value for none glowing parts
  58239. */
  58240. private _defaultStencilReference;
  58241. /**
  58242. * Free any resources and references associated to a mesh.
  58243. * Internal use
  58244. * @param mesh The mesh to free.
  58245. * @hidden
  58246. */
  58247. _disposeMesh(mesh: Mesh): void;
  58248. /**
  58249. * Dispose the highlight layer and free resources.
  58250. */
  58251. dispose(): void;
  58252. /**
  58253. * Gets the class name of the effect layer
  58254. * @returns the string with the class name of the effect layer
  58255. */
  58256. getClassName(): string;
  58257. /**
  58258. * Serializes this Highlight layer
  58259. * @returns a serialized Highlight layer object
  58260. */
  58261. serialize(): any;
  58262. /**
  58263. * Creates a Highlight layer from parsed Highlight layer data
  58264. * @param parsedHightlightLayer defines the Highlight layer data
  58265. * @param scene defines the current scene
  58266. * @param rootUrl defines the root URL containing the Highlight layer information
  58267. * @returns a parsed Highlight layer
  58268. */
  58269. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  58270. }
  58271. }
  58272. declare module BABYLON {
  58273. interface AbstractScene {
  58274. /**
  58275. * The list of layers (background and foreground) of the scene
  58276. */
  58277. layers: Array<Layer>;
  58278. }
  58279. /**
  58280. * Defines the layer scene component responsible to manage any layers
  58281. * in a given scene.
  58282. */
  58283. export class LayerSceneComponent implements ISceneComponent {
  58284. /**
  58285. * The component name helpfull to identify the component in the list of scene components.
  58286. */
  58287. readonly name: string;
  58288. /**
  58289. * The scene the component belongs to.
  58290. */
  58291. scene: Scene;
  58292. private _engine;
  58293. /**
  58294. * Creates a new instance of the component for the given scene
  58295. * @param scene Defines the scene to register the component in
  58296. */
  58297. constructor(scene: Scene);
  58298. /**
  58299. * Registers the component in a given scene
  58300. */
  58301. register(): void;
  58302. /**
  58303. * Rebuilds the elements related to this component in case of
  58304. * context lost for instance.
  58305. */
  58306. rebuild(): void;
  58307. /**
  58308. * Disposes the component and the associated ressources.
  58309. */
  58310. dispose(): void;
  58311. private _draw;
  58312. private _drawCameraPredicate;
  58313. private _drawCameraBackground;
  58314. private _drawCameraForeground;
  58315. private _drawRenderTargetPredicate;
  58316. private _drawRenderTargetBackground;
  58317. private _drawRenderTargetForeground;
  58318. /**
  58319. * Adds all the elements from the container to the scene
  58320. * @param container the container holding the elements
  58321. */
  58322. addFromContainer(container: AbstractScene): void;
  58323. /**
  58324. * Removes all the elements in the container from the scene
  58325. * @param container contains the elements to remove
  58326. * @param dispose if the removed element should be disposed (default: false)
  58327. */
  58328. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58329. }
  58330. }
  58331. declare module BABYLON {
  58332. /** @hidden */
  58333. export var layerPixelShader: {
  58334. name: string;
  58335. shader: string;
  58336. };
  58337. }
  58338. declare module BABYLON {
  58339. /** @hidden */
  58340. export var layerVertexShader: {
  58341. name: string;
  58342. shader: string;
  58343. };
  58344. }
  58345. declare module BABYLON {
  58346. /**
  58347. * This represents a full screen 2d layer.
  58348. * This can be useful to display a picture in the background of your scene for instance.
  58349. * @see https://www.babylonjs-playground.com/#08A2BS#1
  58350. */
  58351. export class Layer {
  58352. /**
  58353. * Define the name of the layer.
  58354. */
  58355. name: string;
  58356. /**
  58357. * Define the texture the layer should display.
  58358. */
  58359. texture: Nullable<Texture>;
  58360. /**
  58361. * Is the layer in background or foreground.
  58362. */
  58363. isBackground: boolean;
  58364. /**
  58365. * Define the color of the layer (instead of texture).
  58366. */
  58367. color: Color4;
  58368. /**
  58369. * Define the scale of the layer in order to zoom in out of the texture.
  58370. */
  58371. scale: Vector2;
  58372. /**
  58373. * Define an offset for the layer in order to shift the texture.
  58374. */
  58375. offset: Vector2;
  58376. /**
  58377. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  58378. */
  58379. alphaBlendingMode: number;
  58380. /**
  58381. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  58382. * Alpha test will not mix with the background color in case of transparency.
  58383. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  58384. */
  58385. alphaTest: boolean;
  58386. /**
  58387. * Define a mask to restrict the layer to only some of the scene cameras.
  58388. */
  58389. layerMask: number;
  58390. /**
  58391. * Define the list of render target the layer is visible into.
  58392. */
  58393. renderTargetTextures: RenderTargetTexture[];
  58394. /**
  58395. * Define if the layer is only used in renderTarget or if it also
  58396. * renders in the main frame buffer of the canvas.
  58397. */
  58398. renderOnlyInRenderTargetTextures: boolean;
  58399. private _scene;
  58400. private _vertexBuffers;
  58401. private _indexBuffer;
  58402. private _effect;
  58403. private _previousDefines;
  58404. /**
  58405. * An event triggered when the layer is disposed.
  58406. */
  58407. onDisposeObservable: Observable<Layer>;
  58408. private _onDisposeObserver;
  58409. /**
  58410. * Back compatibility with callback before the onDisposeObservable existed.
  58411. * The set callback will be triggered when the layer has been disposed.
  58412. */
  58413. set onDispose(callback: () => void);
  58414. /**
  58415. * An event triggered before rendering the scene
  58416. */
  58417. onBeforeRenderObservable: Observable<Layer>;
  58418. private _onBeforeRenderObserver;
  58419. /**
  58420. * Back compatibility with callback before the onBeforeRenderObservable existed.
  58421. * The set callback will be triggered just before rendering the layer.
  58422. */
  58423. set onBeforeRender(callback: () => void);
  58424. /**
  58425. * An event triggered after rendering the scene
  58426. */
  58427. onAfterRenderObservable: Observable<Layer>;
  58428. private _onAfterRenderObserver;
  58429. /**
  58430. * Back compatibility with callback before the onAfterRenderObservable existed.
  58431. * The set callback will be triggered just after rendering the layer.
  58432. */
  58433. set onAfterRender(callback: () => void);
  58434. /**
  58435. * Instantiates a new layer.
  58436. * This represents a full screen 2d layer.
  58437. * This can be useful to display a picture in the background of your scene for instance.
  58438. * @see https://www.babylonjs-playground.com/#08A2BS#1
  58439. * @param name Define the name of the layer in the scene
  58440. * @param imgUrl Define the url of the texture to display in the layer
  58441. * @param scene Define the scene the layer belongs to
  58442. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  58443. * @param color Defines a color for the layer
  58444. */
  58445. constructor(
  58446. /**
  58447. * Define the name of the layer.
  58448. */
  58449. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  58450. private _createIndexBuffer;
  58451. /** @hidden */
  58452. _rebuild(): void;
  58453. /**
  58454. * Renders the layer in the scene.
  58455. */
  58456. render(): void;
  58457. /**
  58458. * Disposes and releases the associated ressources.
  58459. */
  58460. dispose(): void;
  58461. }
  58462. }
  58463. declare module BABYLON {
  58464. /** @hidden */
  58465. export var lensFlarePixelShader: {
  58466. name: string;
  58467. shader: string;
  58468. };
  58469. }
  58470. declare module BABYLON {
  58471. /** @hidden */
  58472. export var lensFlareVertexShader: {
  58473. name: string;
  58474. shader: string;
  58475. };
  58476. }
  58477. declare module BABYLON {
  58478. /**
  58479. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  58480. * It is usually composed of several `lensFlare`.
  58481. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58482. */
  58483. export class LensFlareSystem {
  58484. /**
  58485. * Define the name of the lens flare system
  58486. */
  58487. name: string;
  58488. /**
  58489. * List of lens flares used in this system.
  58490. */
  58491. lensFlares: LensFlare[];
  58492. /**
  58493. * Define a limit from the border the lens flare can be visible.
  58494. */
  58495. borderLimit: number;
  58496. /**
  58497. * Define a viewport border we do not want to see the lens flare in.
  58498. */
  58499. viewportBorder: number;
  58500. /**
  58501. * Define a predicate which could limit the list of meshes able to occlude the effect.
  58502. */
  58503. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  58504. /**
  58505. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  58506. */
  58507. layerMask: number;
  58508. /**
  58509. * Define the id of the lens flare system in the scene.
  58510. * (equal to name by default)
  58511. */
  58512. id: string;
  58513. private _scene;
  58514. private _emitter;
  58515. private _vertexBuffers;
  58516. private _indexBuffer;
  58517. private _effect;
  58518. private _positionX;
  58519. private _positionY;
  58520. private _isEnabled;
  58521. /** @hidden */
  58522. static _SceneComponentInitialization: (scene: Scene) => void;
  58523. /**
  58524. * Instantiates a lens flare system.
  58525. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  58526. * It is usually composed of several `lensFlare`.
  58527. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58528. * @param name Define the name of the lens flare system in the scene
  58529. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  58530. * @param scene Define the scene the lens flare system belongs to
  58531. */
  58532. constructor(
  58533. /**
  58534. * Define the name of the lens flare system
  58535. */
  58536. name: string, emitter: any, scene: Scene);
  58537. /**
  58538. * Define if the lens flare system is enabled.
  58539. */
  58540. get isEnabled(): boolean;
  58541. set isEnabled(value: boolean);
  58542. /**
  58543. * Get the scene the effects belongs to.
  58544. * @returns the scene holding the lens flare system
  58545. */
  58546. getScene(): Scene;
  58547. /**
  58548. * Get the emitter of the lens flare system.
  58549. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  58550. * @returns the emitter of the lens flare system
  58551. */
  58552. getEmitter(): any;
  58553. /**
  58554. * Set the emitter of the lens flare system.
  58555. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  58556. * @param newEmitter Define the new emitter of the system
  58557. */
  58558. setEmitter(newEmitter: any): void;
  58559. /**
  58560. * Get the lens flare system emitter position.
  58561. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  58562. * @returns the position
  58563. */
  58564. getEmitterPosition(): Vector3;
  58565. /**
  58566. * @hidden
  58567. */
  58568. computeEffectivePosition(globalViewport: Viewport): boolean;
  58569. /** @hidden */
  58570. _isVisible(): boolean;
  58571. /**
  58572. * @hidden
  58573. */
  58574. render(): boolean;
  58575. /**
  58576. * Dispose and release the lens flare with its associated resources.
  58577. */
  58578. dispose(): void;
  58579. /**
  58580. * Parse a lens flare system from a JSON repressentation
  58581. * @param parsedLensFlareSystem Define the JSON to parse
  58582. * @param scene Define the scene the parsed system should be instantiated in
  58583. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  58584. * @returns the parsed system
  58585. */
  58586. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  58587. /**
  58588. * Serialize the current Lens Flare System into a JSON representation.
  58589. * @returns the serialized JSON
  58590. */
  58591. serialize(): any;
  58592. }
  58593. }
  58594. declare module BABYLON {
  58595. /**
  58596. * This represents one of the lens effect in a `lensFlareSystem`.
  58597. * It controls one of the indiviual texture used in the effect.
  58598. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58599. */
  58600. export class LensFlare {
  58601. /**
  58602. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  58603. */
  58604. size: number;
  58605. /**
  58606. * 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.
  58607. */
  58608. position: number;
  58609. /**
  58610. * Define the lens color.
  58611. */
  58612. color: Color3;
  58613. /**
  58614. * Define the lens texture.
  58615. */
  58616. texture: Nullable<Texture>;
  58617. /**
  58618. * Define the alpha mode to render this particular lens.
  58619. */
  58620. alphaMode: number;
  58621. private _system;
  58622. /**
  58623. * Creates a new Lens Flare.
  58624. * This represents one of the lens effect in a `lensFlareSystem`.
  58625. * It controls one of the indiviual texture used in the effect.
  58626. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58627. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  58628. * @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.
  58629. * @param color Define the lens color
  58630. * @param imgUrl Define the lens texture url
  58631. * @param system Define the `lensFlareSystem` this flare is part of
  58632. * @returns The newly created Lens Flare
  58633. */
  58634. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  58635. /**
  58636. * Instantiates a new Lens Flare.
  58637. * This represents one of the lens effect in a `lensFlareSystem`.
  58638. * It controls one of the indiviual texture used in the effect.
  58639. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58640. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  58641. * @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.
  58642. * @param color Define the lens color
  58643. * @param imgUrl Define the lens texture url
  58644. * @param system Define the `lensFlareSystem` this flare is part of
  58645. */
  58646. constructor(
  58647. /**
  58648. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  58649. */
  58650. size: number,
  58651. /**
  58652. * 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.
  58653. */
  58654. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  58655. /**
  58656. * Dispose and release the lens flare with its associated resources.
  58657. */
  58658. dispose(): void;
  58659. }
  58660. }
  58661. declare module BABYLON {
  58662. interface AbstractScene {
  58663. /**
  58664. * The list of lens flare system added to the scene
  58665. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58666. */
  58667. lensFlareSystems: Array<LensFlareSystem>;
  58668. /**
  58669. * Removes the given lens flare system from this scene.
  58670. * @param toRemove The lens flare system to remove
  58671. * @returns The index of the removed lens flare system
  58672. */
  58673. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  58674. /**
  58675. * Adds the given lens flare system to this scene
  58676. * @param newLensFlareSystem The lens flare system to add
  58677. */
  58678. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  58679. /**
  58680. * Gets a lens flare system using its name
  58681. * @param name defines the name to look for
  58682. * @returns the lens flare system or null if not found
  58683. */
  58684. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  58685. /**
  58686. * Gets a lens flare system using its id
  58687. * @param id defines the id to look for
  58688. * @returns the lens flare system or null if not found
  58689. */
  58690. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  58691. }
  58692. /**
  58693. * Defines the lens flare scene component responsible to manage any lens flares
  58694. * in a given scene.
  58695. */
  58696. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  58697. /**
  58698. * The component name helpfull to identify the component in the list of scene components.
  58699. */
  58700. readonly name: string;
  58701. /**
  58702. * The scene the component belongs to.
  58703. */
  58704. scene: Scene;
  58705. /**
  58706. * Creates a new instance of the component for the given scene
  58707. * @param scene Defines the scene to register the component in
  58708. */
  58709. constructor(scene: Scene);
  58710. /**
  58711. * Registers the component in a given scene
  58712. */
  58713. register(): void;
  58714. /**
  58715. * Rebuilds the elements related to this component in case of
  58716. * context lost for instance.
  58717. */
  58718. rebuild(): void;
  58719. /**
  58720. * Adds all the elements from the container to the scene
  58721. * @param container the container holding the elements
  58722. */
  58723. addFromContainer(container: AbstractScene): void;
  58724. /**
  58725. * Removes all the elements in the container from the scene
  58726. * @param container contains the elements to remove
  58727. * @param dispose if the removed element should be disposed (default: false)
  58728. */
  58729. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58730. /**
  58731. * Serializes the component data to the specified json object
  58732. * @param serializationObject The object to serialize to
  58733. */
  58734. serialize(serializationObject: any): void;
  58735. /**
  58736. * Disposes the component and the associated ressources.
  58737. */
  58738. dispose(): void;
  58739. private _draw;
  58740. }
  58741. }
  58742. declare module BABYLON {
  58743. /** @hidden */
  58744. export var depthPixelShader: {
  58745. name: string;
  58746. shader: string;
  58747. };
  58748. }
  58749. declare module BABYLON {
  58750. /** @hidden */
  58751. export var depthVertexShader: {
  58752. name: string;
  58753. shader: string;
  58754. };
  58755. }
  58756. declare module BABYLON {
  58757. /**
  58758. * This represents a depth renderer in Babylon.
  58759. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  58760. */
  58761. export class DepthRenderer {
  58762. private _scene;
  58763. private _depthMap;
  58764. private _effect;
  58765. private readonly _storeNonLinearDepth;
  58766. private readonly _clearColor;
  58767. /** Get if the depth renderer is using packed depth or not */
  58768. readonly isPacked: boolean;
  58769. private _cachedDefines;
  58770. private _camera;
  58771. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  58772. enabled: boolean;
  58773. /**
  58774. * Specifiess that the depth renderer will only be used within
  58775. * the camera it is created for.
  58776. * This can help forcing its rendering during the camera processing.
  58777. */
  58778. useOnlyInActiveCamera: boolean;
  58779. /** @hidden */
  58780. static _SceneComponentInitialization: (scene: Scene) => void;
  58781. /**
  58782. * Instantiates a depth renderer
  58783. * @param scene The scene the renderer belongs to
  58784. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  58785. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  58786. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  58787. */
  58788. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  58789. /**
  58790. * Creates the depth rendering effect and checks if the effect is ready.
  58791. * @param subMesh The submesh to be used to render the depth map of
  58792. * @param useInstances If multiple world instances should be used
  58793. * @returns if the depth renderer is ready to render the depth map
  58794. */
  58795. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58796. /**
  58797. * Gets the texture which the depth map will be written to.
  58798. * @returns The depth map texture
  58799. */
  58800. getDepthMap(): RenderTargetTexture;
  58801. /**
  58802. * Disposes of the depth renderer.
  58803. */
  58804. dispose(): void;
  58805. }
  58806. }
  58807. declare module BABYLON {
  58808. /** @hidden */
  58809. export var minmaxReduxPixelShader: {
  58810. name: string;
  58811. shader: string;
  58812. };
  58813. }
  58814. declare module BABYLON {
  58815. /**
  58816. * This class computes a min/max reduction from a texture: it means it computes the minimum
  58817. * and maximum values from all values of the texture.
  58818. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  58819. * The source values are read from the red channel of the texture.
  58820. */
  58821. export class MinMaxReducer {
  58822. /**
  58823. * Observable triggered when the computation has been performed
  58824. */
  58825. onAfterReductionPerformed: Observable<{
  58826. min: number;
  58827. max: number;
  58828. }>;
  58829. protected _camera: Camera;
  58830. protected _sourceTexture: Nullable<RenderTargetTexture>;
  58831. protected _reductionSteps: Nullable<Array<PostProcess>>;
  58832. protected _postProcessManager: PostProcessManager;
  58833. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  58834. protected _forceFullscreenViewport: boolean;
  58835. /**
  58836. * Creates a min/max reducer
  58837. * @param camera The camera to use for the post processes
  58838. */
  58839. constructor(camera: Camera);
  58840. /**
  58841. * Gets the texture used to read the values from.
  58842. */
  58843. get sourceTexture(): Nullable<RenderTargetTexture>;
  58844. /**
  58845. * Sets the source texture to read the values from.
  58846. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  58847. * because in such textures '1' value must not be taken into account to compute the maximum
  58848. * as this value is used to clear the texture.
  58849. * Note that the computation is not activated by calling this function, you must call activate() for that!
  58850. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  58851. * @param depthRedux Indicates if the texture is a depth texture or not
  58852. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  58853. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  58854. */
  58855. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  58856. /**
  58857. * Defines the refresh rate of the computation.
  58858. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58859. */
  58860. get refreshRate(): number;
  58861. set refreshRate(value: number);
  58862. protected _activated: boolean;
  58863. /**
  58864. * Gets the activation status of the reducer
  58865. */
  58866. get activated(): boolean;
  58867. /**
  58868. * Activates the reduction computation.
  58869. * When activated, the observers registered in onAfterReductionPerformed are
  58870. * called after the compuation is performed
  58871. */
  58872. activate(): void;
  58873. /**
  58874. * Deactivates the reduction computation.
  58875. */
  58876. deactivate(): void;
  58877. /**
  58878. * Disposes the min/max reducer
  58879. * @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.
  58880. */
  58881. dispose(disposeAll?: boolean): void;
  58882. }
  58883. }
  58884. declare module BABYLON {
  58885. /**
  58886. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  58887. */
  58888. export class DepthReducer extends MinMaxReducer {
  58889. private _depthRenderer;
  58890. private _depthRendererId;
  58891. /**
  58892. * Gets the depth renderer used for the computation.
  58893. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  58894. */
  58895. get depthRenderer(): Nullable<DepthRenderer>;
  58896. /**
  58897. * Creates a depth reducer
  58898. * @param camera The camera used to render the depth texture
  58899. */
  58900. constructor(camera: Camera);
  58901. /**
  58902. * Sets the depth renderer to use to generate the depth map
  58903. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  58904. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  58905. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  58906. */
  58907. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  58908. /** @hidden */
  58909. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  58910. /**
  58911. * Activates the reduction computation.
  58912. * When activated, the observers registered in onAfterReductionPerformed are
  58913. * called after the compuation is performed
  58914. */
  58915. activate(): void;
  58916. /**
  58917. * Deactivates the reduction computation.
  58918. */
  58919. deactivate(): void;
  58920. /**
  58921. * Disposes the depth reducer
  58922. * @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.
  58923. */
  58924. dispose(disposeAll?: boolean): void;
  58925. }
  58926. }
  58927. declare module BABYLON {
  58928. /**
  58929. * A CSM implementation allowing casting shadows on large scenes.
  58930. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  58931. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  58932. */
  58933. export class CascadedShadowGenerator extends ShadowGenerator {
  58934. private static readonly frustumCornersNDCSpace;
  58935. /**
  58936. * Name of the CSM class
  58937. */
  58938. static CLASSNAME: string;
  58939. /**
  58940. * Defines the default number of cascades used by the CSM.
  58941. */
  58942. static readonly DEFAULT_CASCADES_COUNT: number;
  58943. /**
  58944. * Defines the minimum number of cascades used by the CSM.
  58945. */
  58946. static readonly MIN_CASCADES_COUNT: number;
  58947. /**
  58948. * Defines the maximum number of cascades used by the CSM.
  58949. */
  58950. static readonly MAX_CASCADES_COUNT: number;
  58951. protected _validateFilter(filter: number): number;
  58952. /**
  58953. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  58954. */
  58955. penumbraDarkness: number;
  58956. private _numCascades;
  58957. /**
  58958. * Gets or set the number of cascades used by the CSM.
  58959. */
  58960. get numCascades(): number;
  58961. set numCascades(value: number);
  58962. /**
  58963. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  58964. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  58965. */
  58966. stabilizeCascades: boolean;
  58967. private _freezeShadowCastersBoundingInfo;
  58968. private _freezeShadowCastersBoundingInfoObservable;
  58969. /**
  58970. * Enables or disables the shadow casters bounding info computation.
  58971. * If your shadow casters don't move, you can disable this feature.
  58972. * If it is enabled, the bounding box computation is done every frame.
  58973. */
  58974. get freezeShadowCastersBoundingInfo(): boolean;
  58975. set freezeShadowCastersBoundingInfo(freeze: boolean);
  58976. private _scbiMin;
  58977. private _scbiMax;
  58978. protected _computeShadowCastersBoundingInfo(): void;
  58979. protected _shadowCastersBoundingInfo: BoundingInfo;
  58980. /**
  58981. * Gets or sets the shadow casters bounding info.
  58982. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  58983. * so that the system won't overwrite the bounds you provide
  58984. */
  58985. get shadowCastersBoundingInfo(): BoundingInfo;
  58986. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  58987. protected _breaksAreDirty: boolean;
  58988. protected _minDistance: number;
  58989. protected _maxDistance: number;
  58990. /**
  58991. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  58992. *
  58993. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  58994. * If you don't know these values, simply leave them to their defaults and don't call this function.
  58995. * @param min minimal distance for the breaks (default to 0.)
  58996. * @param max maximal distance for the breaks (default to 1.)
  58997. */
  58998. setMinMaxDistance(min: number, max: number): void;
  58999. /** Gets the minimal distance used in the cascade break computation */
  59000. get minDistance(): number;
  59001. /** Gets the maximal distance used in the cascade break computation */
  59002. get maxDistance(): number;
  59003. /**
  59004. * Gets the class name of that object
  59005. * @returns "CascadedShadowGenerator"
  59006. */
  59007. getClassName(): string;
  59008. private _cascadeMinExtents;
  59009. private _cascadeMaxExtents;
  59010. /**
  59011. * Gets a cascade minimum extents
  59012. * @param cascadeIndex index of the cascade
  59013. * @returns the minimum cascade extents
  59014. */
  59015. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  59016. /**
  59017. * Gets a cascade maximum extents
  59018. * @param cascadeIndex index of the cascade
  59019. * @returns the maximum cascade extents
  59020. */
  59021. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  59022. private _cascades;
  59023. private _currentLayer;
  59024. private _viewSpaceFrustumsZ;
  59025. private _viewMatrices;
  59026. private _projectionMatrices;
  59027. private _transformMatrices;
  59028. private _transformMatricesAsArray;
  59029. private _frustumLengths;
  59030. private _lightSizeUVCorrection;
  59031. private _depthCorrection;
  59032. private _frustumCornersWorldSpace;
  59033. private _frustumCenter;
  59034. private _shadowCameraPos;
  59035. private _shadowMaxZ;
  59036. /**
  59037. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  59038. * It defaults to camera.maxZ
  59039. */
  59040. get shadowMaxZ(): number;
  59041. /**
  59042. * Sets the shadow max z distance.
  59043. */
  59044. set shadowMaxZ(value: number);
  59045. protected _debug: boolean;
  59046. /**
  59047. * Gets or sets the debug flag.
  59048. * When enabled, the cascades are materialized by different colors on the screen.
  59049. */
  59050. get debug(): boolean;
  59051. set debug(dbg: boolean);
  59052. private _depthClamp;
  59053. /**
  59054. * Gets or sets the depth clamping value.
  59055. *
  59056. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  59057. * to account for the shadow casters far away.
  59058. *
  59059. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  59060. */
  59061. get depthClamp(): boolean;
  59062. set depthClamp(value: boolean);
  59063. private _cascadeBlendPercentage;
  59064. /**
  59065. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  59066. * It defaults to 0.1 (10% blending).
  59067. */
  59068. get cascadeBlendPercentage(): number;
  59069. set cascadeBlendPercentage(value: number);
  59070. private _lambda;
  59071. /**
  59072. * Gets or set the lambda parameter.
  59073. * This parameter is used to split the camera frustum and create the cascades.
  59074. * 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.
  59075. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  59076. */
  59077. get lambda(): number;
  59078. set lambda(value: number);
  59079. /**
  59080. * Gets the view matrix corresponding to a given cascade
  59081. * @param cascadeNum cascade to retrieve the view matrix from
  59082. * @returns the cascade view matrix
  59083. */
  59084. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  59085. /**
  59086. * Gets the projection matrix corresponding to a given cascade
  59087. * @param cascadeNum cascade to retrieve the projection matrix from
  59088. * @returns the cascade projection matrix
  59089. */
  59090. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  59091. /**
  59092. * Gets the transformation matrix corresponding to a given cascade
  59093. * @param cascadeNum cascade to retrieve the transformation matrix from
  59094. * @returns the cascade transformation matrix
  59095. */
  59096. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  59097. private _depthRenderer;
  59098. /**
  59099. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  59100. *
  59101. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  59102. *
  59103. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  59104. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  59105. * @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
  59106. */
  59107. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  59108. private _depthReducer;
  59109. private _autoCalcDepthBounds;
  59110. /**
  59111. * Gets or sets the autoCalcDepthBounds property.
  59112. *
  59113. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  59114. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  59115. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  59116. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  59117. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  59118. */
  59119. get autoCalcDepthBounds(): boolean;
  59120. set autoCalcDepthBounds(value: boolean);
  59121. /**
  59122. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  59123. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  59124. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  59125. * for setting the refresh rate on the renderer yourself!
  59126. */
  59127. get autoCalcDepthBoundsRefreshRate(): number;
  59128. set autoCalcDepthBoundsRefreshRate(value: number);
  59129. /**
  59130. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  59131. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  59132. * you change the camera near/far planes!
  59133. */
  59134. splitFrustum(): void;
  59135. private _splitFrustum;
  59136. private _computeMatrices;
  59137. private _computeFrustumInWorldSpace;
  59138. private _computeCascadeFrustum;
  59139. /**
  59140. * Support test.
  59141. */
  59142. static get IsSupported(): boolean;
  59143. /** @hidden */
  59144. static _SceneComponentInitialization: (scene: Scene) => void;
  59145. /**
  59146. * Creates a Cascaded Shadow Generator object.
  59147. * A ShadowGenerator is the required tool to use the shadows.
  59148. * Each directional light casting shadows needs to use its own ShadowGenerator.
  59149. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  59150. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  59151. * @param light The directional light object generating the shadows.
  59152. * @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.
  59153. */
  59154. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  59155. protected _initializeGenerator(): void;
  59156. protected _createTargetRenderTexture(): void;
  59157. protected _initializeShadowMap(): void;
  59158. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  59159. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  59160. /**
  59161. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  59162. * @param defines Defines of the material we want to update
  59163. * @param lightIndex Index of the light in the enabled light list of the material
  59164. */
  59165. prepareDefines(defines: any, lightIndex: number): void;
  59166. /**
  59167. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  59168. * defined in the generator but impacting the effect).
  59169. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  59170. * @param effect The effect we are binfing the information for
  59171. */
  59172. bindShadowLight(lightIndex: string, effect: Effect): void;
  59173. /**
  59174. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  59175. * (eq to view projection * shadow projection matrices)
  59176. * @returns The transform matrix used to create the shadow map
  59177. */
  59178. getTransformMatrix(): Matrix;
  59179. /**
  59180. * Disposes the ShadowGenerator.
  59181. * Returns nothing.
  59182. */
  59183. dispose(): void;
  59184. /**
  59185. * Serializes the shadow generator setup to a json object.
  59186. * @returns The serialized JSON object
  59187. */
  59188. serialize(): any;
  59189. /**
  59190. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  59191. * @param parsedShadowGenerator The JSON object to parse
  59192. * @param scene The scene to create the shadow map for
  59193. * @returns The parsed shadow generator
  59194. */
  59195. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  59196. }
  59197. }
  59198. declare module BABYLON {
  59199. /**
  59200. * Defines the shadow generator component responsible to manage any shadow generators
  59201. * in a given scene.
  59202. */
  59203. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  59204. /**
  59205. * The component name helpfull to identify the component in the list of scene components.
  59206. */
  59207. readonly name: string;
  59208. /**
  59209. * The scene the component belongs to.
  59210. */
  59211. scene: Scene;
  59212. /**
  59213. * Creates a new instance of the component for the given scene
  59214. * @param scene Defines the scene to register the component in
  59215. */
  59216. constructor(scene: Scene);
  59217. /**
  59218. * Registers the component in a given scene
  59219. */
  59220. register(): void;
  59221. /**
  59222. * Rebuilds the elements related to this component in case of
  59223. * context lost for instance.
  59224. */
  59225. rebuild(): void;
  59226. /**
  59227. * Serializes the component data to the specified json object
  59228. * @param serializationObject The object to serialize to
  59229. */
  59230. serialize(serializationObject: any): void;
  59231. /**
  59232. * Adds all the elements from the container to the scene
  59233. * @param container the container holding the elements
  59234. */
  59235. addFromContainer(container: AbstractScene): void;
  59236. /**
  59237. * Removes all the elements in the container from the scene
  59238. * @param container contains the elements to remove
  59239. * @param dispose if the removed element should be disposed (default: false)
  59240. */
  59241. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59242. /**
  59243. * Rebuilds the elements related to this component in case of
  59244. * context lost for instance.
  59245. */
  59246. dispose(): void;
  59247. private _gatherRenderTargets;
  59248. }
  59249. }
  59250. declare module BABYLON {
  59251. /**
  59252. * A point light is a light defined by an unique point in world space.
  59253. * The light is emitted in every direction from this point.
  59254. * A good example of a point light is a standard light bulb.
  59255. * Documentation: https://doc.babylonjs.com/babylon101/lights
  59256. */
  59257. export class PointLight extends ShadowLight {
  59258. private _shadowAngle;
  59259. /**
  59260. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59261. * This specifies what angle the shadow will use to be created.
  59262. *
  59263. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  59264. */
  59265. get shadowAngle(): number;
  59266. /**
  59267. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59268. * This specifies what angle the shadow will use to be created.
  59269. *
  59270. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  59271. */
  59272. set shadowAngle(value: number);
  59273. /**
  59274. * Gets the direction if it has been set.
  59275. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59276. */
  59277. get direction(): Vector3;
  59278. /**
  59279. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59280. */
  59281. set direction(value: Vector3);
  59282. /**
  59283. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  59284. * A PointLight emits the light in every direction.
  59285. * It can cast shadows.
  59286. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  59287. * ```javascript
  59288. * var pointLight = new PointLight("pl", camera.position, scene);
  59289. * ```
  59290. * Documentation : https://doc.babylonjs.com/babylon101/lights
  59291. * @param name The light friendly name
  59292. * @param position The position of the point light in the scene
  59293. * @param scene The scene the lights belongs to
  59294. */
  59295. constructor(name: string, position: Vector3, scene: Scene);
  59296. /**
  59297. * Returns the string "PointLight"
  59298. * @returns the class name
  59299. */
  59300. getClassName(): string;
  59301. /**
  59302. * Returns the integer 0.
  59303. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  59304. */
  59305. getTypeID(): number;
  59306. /**
  59307. * Specifies wether or not the shadowmap should be a cube texture.
  59308. * @returns true if the shadowmap needs to be a cube texture.
  59309. */
  59310. needCube(): boolean;
  59311. /**
  59312. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  59313. * @param faceIndex The index of the face we are computed the direction to generate shadow
  59314. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  59315. */
  59316. getShadowDirection(faceIndex?: number): Vector3;
  59317. /**
  59318. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  59319. * - fov = PI / 2
  59320. * - aspect ratio : 1.0
  59321. * - z-near and far equal to the active camera minZ and maxZ.
  59322. * Returns the PointLight.
  59323. */
  59324. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59325. protected _buildUniformLayout(): void;
  59326. /**
  59327. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  59328. * @param effect The effect to update
  59329. * @param lightIndex The index of the light in the effect to update
  59330. * @returns The point light
  59331. */
  59332. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  59333. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  59334. /**
  59335. * Prepares the list of defines specific to the light type.
  59336. * @param defines the list of defines
  59337. * @param lightIndex defines the index of the light for the effect
  59338. */
  59339. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  59340. }
  59341. }
  59342. declare module BABYLON {
  59343. /**
  59344. * Header information of HDR texture files.
  59345. */
  59346. export interface HDRInfo {
  59347. /**
  59348. * The height of the texture in pixels.
  59349. */
  59350. height: number;
  59351. /**
  59352. * The width of the texture in pixels.
  59353. */
  59354. width: number;
  59355. /**
  59356. * The index of the beginning of the data in the binary file.
  59357. */
  59358. dataPosition: number;
  59359. }
  59360. /**
  59361. * This groups tools to convert HDR texture to native colors array.
  59362. */
  59363. export class HDRTools {
  59364. private static Ldexp;
  59365. private static Rgbe2float;
  59366. private static readStringLine;
  59367. /**
  59368. * Reads header information from an RGBE texture stored in a native array.
  59369. * More information on this format are available here:
  59370. * https://en.wikipedia.org/wiki/RGBE_image_format
  59371. *
  59372. * @param uint8array The binary file stored in native array.
  59373. * @return The header information.
  59374. */
  59375. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  59376. /**
  59377. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  59378. * This RGBE texture needs to store the information as a panorama.
  59379. *
  59380. * More information on this format are available here:
  59381. * https://en.wikipedia.org/wiki/RGBE_image_format
  59382. *
  59383. * @param buffer The binary file stored in an array buffer.
  59384. * @param size The expected size of the extracted cubemap.
  59385. * @return The Cube Map information.
  59386. */
  59387. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  59388. /**
  59389. * Returns the pixels data extracted from an RGBE texture.
  59390. * This pixels will be stored left to right up to down in the R G B order in one array.
  59391. *
  59392. * More information on this format are available here:
  59393. * https://en.wikipedia.org/wiki/RGBE_image_format
  59394. *
  59395. * @param uint8array The binary file stored in an array buffer.
  59396. * @param hdrInfo The header information of the file.
  59397. * @return The pixels data in RGB right to left up to down order.
  59398. */
  59399. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  59400. private static RGBE_ReadPixels_RLE;
  59401. private static RGBE_ReadPixels_NOT_RLE;
  59402. }
  59403. }
  59404. declare module BABYLON {
  59405. /**
  59406. * Effect Render Options
  59407. */
  59408. export interface IEffectRendererOptions {
  59409. /**
  59410. * Defines the vertices positions.
  59411. */
  59412. positions?: number[];
  59413. /**
  59414. * Defines the indices.
  59415. */
  59416. indices?: number[];
  59417. }
  59418. /**
  59419. * Helper class to render one or more effects.
  59420. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  59421. */
  59422. export class EffectRenderer {
  59423. private engine;
  59424. private static _DefaultOptions;
  59425. private _vertexBuffers;
  59426. private _indexBuffer;
  59427. private _fullscreenViewport;
  59428. /**
  59429. * Creates an effect renderer
  59430. * @param engine the engine to use for rendering
  59431. * @param options defines the options of the effect renderer
  59432. */
  59433. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  59434. /**
  59435. * Sets the current viewport in normalized coordinates 0-1
  59436. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  59437. */
  59438. setViewport(viewport?: Viewport): void;
  59439. /**
  59440. * Binds the embedded attributes buffer to the effect.
  59441. * @param effect Defines the effect to bind the attributes for
  59442. */
  59443. bindBuffers(effect: Effect): void;
  59444. /**
  59445. * Sets the current effect wrapper to use during draw.
  59446. * The effect needs to be ready before calling this api.
  59447. * This also sets the default full screen position attribute.
  59448. * @param effectWrapper Defines the effect to draw with
  59449. */
  59450. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  59451. /**
  59452. * Restores engine states
  59453. */
  59454. restoreStates(): void;
  59455. /**
  59456. * Draws a full screen quad.
  59457. */
  59458. draw(): void;
  59459. private isRenderTargetTexture;
  59460. /**
  59461. * renders one or more effects to a specified texture
  59462. * @param effectWrapper the effect to renderer
  59463. * @param outputTexture texture to draw to, if null it will render to the screen.
  59464. */
  59465. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  59466. /**
  59467. * Disposes of the effect renderer
  59468. */
  59469. dispose(): void;
  59470. }
  59471. /**
  59472. * Options to create an EffectWrapper
  59473. */
  59474. interface EffectWrapperCreationOptions {
  59475. /**
  59476. * Engine to use to create the effect
  59477. */
  59478. engine: ThinEngine;
  59479. /**
  59480. * Fragment shader for the effect
  59481. */
  59482. fragmentShader: string;
  59483. /**
  59484. * Use the shader store instead of direct source code
  59485. */
  59486. useShaderStore?: boolean;
  59487. /**
  59488. * Vertex shader for the effect
  59489. */
  59490. vertexShader?: string;
  59491. /**
  59492. * Attributes to use in the shader
  59493. */
  59494. attributeNames?: Array<string>;
  59495. /**
  59496. * Uniforms to use in the shader
  59497. */
  59498. uniformNames?: Array<string>;
  59499. /**
  59500. * Texture sampler names to use in the shader
  59501. */
  59502. samplerNames?: Array<string>;
  59503. /**
  59504. * Defines to use in the shader
  59505. */
  59506. defines?: Array<string>;
  59507. /**
  59508. * Callback when effect is compiled
  59509. */
  59510. onCompiled?: Nullable<(effect: Effect) => void>;
  59511. /**
  59512. * The friendly name of the effect displayed in Spector.
  59513. */
  59514. name?: string;
  59515. }
  59516. /**
  59517. * Wraps an effect to be used for rendering
  59518. */
  59519. export class EffectWrapper {
  59520. /**
  59521. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  59522. */
  59523. onApplyObservable: Observable<{}>;
  59524. /**
  59525. * The underlying effect
  59526. */
  59527. effect: Effect;
  59528. /**
  59529. * Creates an effect to be renderer
  59530. * @param creationOptions options to create the effect
  59531. */
  59532. constructor(creationOptions: EffectWrapperCreationOptions);
  59533. /**
  59534. * Disposes of the effect wrapper
  59535. */
  59536. dispose(): void;
  59537. }
  59538. }
  59539. declare module BABYLON {
  59540. /** @hidden */
  59541. export var hdrFilteringVertexShader: {
  59542. name: string;
  59543. shader: string;
  59544. };
  59545. }
  59546. declare module BABYLON {
  59547. /** @hidden */
  59548. export var hdrFilteringPixelShader: {
  59549. name: string;
  59550. shader: string;
  59551. };
  59552. }
  59553. declare module BABYLON {
  59554. /**
  59555. * Options for texture filtering
  59556. */
  59557. interface IHDRFilteringOptions {
  59558. /**
  59559. * Scales pixel intensity for the input HDR map.
  59560. */
  59561. hdrScale?: number;
  59562. /**
  59563. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  59564. */
  59565. quality?: number;
  59566. }
  59567. /**
  59568. * Filters HDR maps to get correct renderings of PBR reflections
  59569. */
  59570. export class HDRFiltering {
  59571. private _engine;
  59572. private _effectRenderer;
  59573. private _effectWrapper;
  59574. private _lodGenerationOffset;
  59575. private _lodGenerationScale;
  59576. /**
  59577. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  59578. * you care about baking speed.
  59579. */
  59580. quality: number;
  59581. /**
  59582. * Scales pixel intensity for the input HDR map.
  59583. */
  59584. hdrScale: number;
  59585. /**
  59586. * Instantiates HDR filter for reflection maps
  59587. *
  59588. * @param engine Thin engine
  59589. * @param options Options
  59590. */
  59591. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  59592. private _createRenderTarget;
  59593. private _prefilterInternal;
  59594. private _createEffect;
  59595. /**
  59596. * Get a value indicating if the filter is ready to be used
  59597. * @param texture Texture to filter
  59598. * @returns true if the filter is ready
  59599. */
  59600. isReady(texture: BaseTexture): boolean;
  59601. /**
  59602. * Prefilters a cube texture to have mipmap levels representing roughness values.
  59603. * Prefiltering will be invoked at the end of next rendering pass.
  59604. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  59605. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  59606. * @param texture Texture to filter
  59607. * @param onFinished Callback when filtering is done
  59608. * @return Promise called when prefiltering is done
  59609. */
  59610. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  59611. }
  59612. }
  59613. declare module BABYLON {
  59614. /**
  59615. * This represents a texture coming from an HDR input.
  59616. *
  59617. * The only supported format is currently panorama picture stored in RGBE format.
  59618. * Example of such files can be found on HDRLib: http://hdrlib.com/
  59619. */
  59620. export class HDRCubeTexture extends BaseTexture {
  59621. private static _facesMapping;
  59622. private _generateHarmonics;
  59623. private _noMipmap;
  59624. private _prefilterOnLoad;
  59625. private _textureMatrix;
  59626. private _size;
  59627. private _onLoad;
  59628. private _onError;
  59629. /**
  59630. * The texture URL.
  59631. */
  59632. url: string;
  59633. /**
  59634. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  59635. */
  59636. coordinatesMode: number;
  59637. protected _isBlocking: boolean;
  59638. /**
  59639. * Sets wether or not the texture is blocking during loading.
  59640. */
  59641. set isBlocking(value: boolean);
  59642. /**
  59643. * Gets wether or not the texture is blocking during loading.
  59644. */
  59645. get isBlocking(): boolean;
  59646. protected _rotationY: number;
  59647. /**
  59648. * Sets texture matrix rotation angle around Y axis in radians.
  59649. */
  59650. set rotationY(value: number);
  59651. /**
  59652. * Gets texture matrix rotation angle around Y axis radians.
  59653. */
  59654. get rotationY(): number;
  59655. /**
  59656. * Gets or sets the center of the bounding box associated with the cube texture
  59657. * It must define where the camera used to render the texture was set
  59658. */
  59659. boundingBoxPosition: Vector3;
  59660. private _boundingBoxSize;
  59661. /**
  59662. * Gets or sets the size of the bounding box associated with the cube texture
  59663. * When defined, the cubemap will switch to local mode
  59664. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  59665. * @example https://www.babylonjs-playground.com/#RNASML
  59666. */
  59667. set boundingBoxSize(value: Vector3);
  59668. get boundingBoxSize(): Vector3;
  59669. /**
  59670. * Instantiates an HDRTexture from the following parameters.
  59671. *
  59672. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  59673. * @param sceneOrEngine The scene or engine the texture will be used in
  59674. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59675. * @param noMipmap Forces to not generate the mipmap if true
  59676. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  59677. * @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)
  59678. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  59679. */
  59680. 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>);
  59681. /**
  59682. * Get the current class name of the texture useful for serialization or dynamic coding.
  59683. * @returns "HDRCubeTexture"
  59684. */
  59685. getClassName(): string;
  59686. /**
  59687. * Occurs when the file is raw .hdr file.
  59688. */
  59689. private loadTexture;
  59690. clone(): HDRCubeTexture;
  59691. delayLoad(): void;
  59692. /**
  59693. * Get the texture reflection matrix used to rotate/transform the reflection.
  59694. * @returns the reflection matrix
  59695. */
  59696. getReflectionTextureMatrix(): Matrix;
  59697. /**
  59698. * Set the texture reflection matrix used to rotate/transform the reflection.
  59699. * @param value Define the reflection matrix to set
  59700. */
  59701. setReflectionTextureMatrix(value: Matrix): void;
  59702. /**
  59703. * Parses a JSON representation of an HDR Texture in order to create the texture
  59704. * @param parsedTexture Define the JSON representation
  59705. * @param scene Define the scene the texture should be created in
  59706. * @param rootUrl Define the root url in case we need to load relative dependencies
  59707. * @returns the newly created texture after parsing
  59708. */
  59709. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  59710. serialize(): any;
  59711. }
  59712. }
  59713. declare module BABYLON {
  59714. /**
  59715. * Class used to control physics engine
  59716. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  59717. */
  59718. export class PhysicsEngine implements IPhysicsEngine {
  59719. private _physicsPlugin;
  59720. /**
  59721. * Global value used to control the smallest number supported by the simulation
  59722. */
  59723. static Epsilon: number;
  59724. private _impostors;
  59725. private _joints;
  59726. private _subTimeStep;
  59727. /**
  59728. * Gets the gravity vector used by the simulation
  59729. */
  59730. gravity: Vector3;
  59731. /**
  59732. * Factory used to create the default physics plugin.
  59733. * @returns The default physics plugin
  59734. */
  59735. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  59736. /**
  59737. * Creates a new Physics Engine
  59738. * @param gravity defines the gravity vector used by the simulation
  59739. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  59740. */
  59741. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  59742. /**
  59743. * Sets the gravity vector used by the simulation
  59744. * @param gravity defines the gravity vector to use
  59745. */
  59746. setGravity(gravity: Vector3): void;
  59747. /**
  59748. * Set the time step of the physics engine.
  59749. * Default is 1/60.
  59750. * To slow it down, enter 1/600 for example.
  59751. * To speed it up, 1/30
  59752. * @param newTimeStep defines the new timestep to apply to this world.
  59753. */
  59754. setTimeStep(newTimeStep?: number): void;
  59755. /**
  59756. * Get the time step of the physics engine.
  59757. * @returns the current time step
  59758. */
  59759. getTimeStep(): number;
  59760. /**
  59761. * Set the sub time step of the physics engine.
  59762. * Default is 0 meaning there is no sub steps
  59763. * To increase physics resolution precision, set a small value (like 1 ms)
  59764. * @param subTimeStep defines the new sub timestep used for physics resolution.
  59765. */
  59766. setSubTimeStep(subTimeStep?: number): void;
  59767. /**
  59768. * Get the sub time step of the physics engine.
  59769. * @returns the current sub time step
  59770. */
  59771. getSubTimeStep(): number;
  59772. /**
  59773. * Release all resources
  59774. */
  59775. dispose(): void;
  59776. /**
  59777. * Gets the name of the current physics plugin
  59778. * @returns the name of the plugin
  59779. */
  59780. getPhysicsPluginName(): string;
  59781. /**
  59782. * Adding a new impostor for the impostor tracking.
  59783. * This will be done by the impostor itself.
  59784. * @param impostor the impostor to add
  59785. */
  59786. addImpostor(impostor: PhysicsImpostor): void;
  59787. /**
  59788. * Remove an impostor from the engine.
  59789. * This impostor and its mesh will not longer be updated by the physics engine.
  59790. * @param impostor the impostor to remove
  59791. */
  59792. removeImpostor(impostor: PhysicsImpostor): void;
  59793. /**
  59794. * Add a joint to the physics engine
  59795. * @param mainImpostor defines the main impostor to which the joint is added.
  59796. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  59797. * @param joint defines the joint that will connect both impostors.
  59798. */
  59799. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59800. /**
  59801. * Removes a joint from the simulation
  59802. * @param mainImpostor defines the impostor used with the joint
  59803. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  59804. * @param joint defines the joint to remove
  59805. */
  59806. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59807. /**
  59808. * Called by the scene. No need to call it.
  59809. * @param delta defines the timespam between frames
  59810. */
  59811. _step(delta: number): void;
  59812. /**
  59813. * Gets the current plugin used to run the simulation
  59814. * @returns current plugin
  59815. */
  59816. getPhysicsPlugin(): IPhysicsEnginePlugin;
  59817. /**
  59818. * Gets the list of physic impostors
  59819. * @returns an array of PhysicsImpostor
  59820. */
  59821. getImpostors(): Array<PhysicsImpostor>;
  59822. /**
  59823. * Gets the impostor for a physics enabled object
  59824. * @param object defines the object impersonated by the impostor
  59825. * @returns the PhysicsImpostor or null if not found
  59826. */
  59827. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  59828. /**
  59829. * Gets the impostor for a physics body object
  59830. * @param body defines physics body used by the impostor
  59831. * @returns the PhysicsImpostor or null if not found
  59832. */
  59833. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  59834. /**
  59835. * Does a raycast in the physics world
  59836. * @param from when should the ray start?
  59837. * @param to when should the ray end?
  59838. * @returns PhysicsRaycastResult
  59839. */
  59840. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59841. }
  59842. }
  59843. declare module BABYLON {
  59844. /** @hidden */
  59845. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  59846. private _useDeltaForWorldStep;
  59847. world: any;
  59848. name: string;
  59849. private _physicsMaterials;
  59850. private _fixedTimeStep;
  59851. private _cannonRaycastResult;
  59852. private _raycastResult;
  59853. private _physicsBodysToRemoveAfterStep;
  59854. private _firstFrame;
  59855. BJSCANNON: any;
  59856. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  59857. setGravity(gravity: Vector3): void;
  59858. setTimeStep(timeStep: number): void;
  59859. getTimeStep(): number;
  59860. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59861. private _removeMarkedPhysicsBodiesFromWorld;
  59862. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59863. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59864. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59865. private _processChildMeshes;
  59866. removePhysicsBody(impostor: PhysicsImpostor): void;
  59867. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59868. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59869. private _addMaterial;
  59870. private _checkWithEpsilon;
  59871. private _createShape;
  59872. private _createHeightmap;
  59873. private _minus90X;
  59874. private _plus90X;
  59875. private _tmpPosition;
  59876. private _tmpDeltaPosition;
  59877. private _tmpUnityRotation;
  59878. private _updatePhysicsBodyTransformation;
  59879. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59880. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59881. isSupported(): boolean;
  59882. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59883. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59884. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59885. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59886. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59887. getBodyMass(impostor: PhysicsImpostor): number;
  59888. getBodyFriction(impostor: PhysicsImpostor): number;
  59889. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59890. getBodyRestitution(impostor: PhysicsImpostor): number;
  59891. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59892. sleepBody(impostor: PhysicsImpostor): void;
  59893. wakeUpBody(impostor: PhysicsImpostor): void;
  59894. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  59895. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  59896. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  59897. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59898. getRadius(impostor: PhysicsImpostor): number;
  59899. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59900. dispose(): void;
  59901. private _extendNamespace;
  59902. /**
  59903. * Does a raycast in the physics world
  59904. * @param from when should the ray start?
  59905. * @param to when should the ray end?
  59906. * @returns PhysicsRaycastResult
  59907. */
  59908. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59909. }
  59910. }
  59911. declare module BABYLON {
  59912. /** @hidden */
  59913. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  59914. private _useDeltaForWorldStep;
  59915. world: any;
  59916. name: string;
  59917. BJSOIMO: any;
  59918. private _raycastResult;
  59919. private _fixedTimeStep;
  59920. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  59921. setGravity(gravity: Vector3): void;
  59922. setTimeStep(timeStep: number): void;
  59923. getTimeStep(): number;
  59924. private _tmpImpostorsArray;
  59925. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59926. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59927. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59928. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59929. private _tmpPositionVector;
  59930. removePhysicsBody(impostor: PhysicsImpostor): void;
  59931. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59932. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59933. isSupported(): boolean;
  59934. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59935. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59936. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59937. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59938. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59939. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59940. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59941. getBodyMass(impostor: PhysicsImpostor): number;
  59942. getBodyFriction(impostor: PhysicsImpostor): number;
  59943. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59944. getBodyRestitution(impostor: PhysicsImpostor): number;
  59945. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59946. sleepBody(impostor: PhysicsImpostor): void;
  59947. wakeUpBody(impostor: PhysicsImpostor): void;
  59948. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  59949. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  59950. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  59951. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59952. getRadius(impostor: PhysicsImpostor): number;
  59953. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59954. dispose(): void;
  59955. /**
  59956. * Does a raycast in the physics world
  59957. * @param from when should the ray start?
  59958. * @param to when should the ray end?
  59959. * @returns PhysicsRaycastResult
  59960. */
  59961. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59962. }
  59963. }
  59964. declare module BABYLON {
  59965. /**
  59966. * Class containing static functions to help procedurally build meshes
  59967. */
  59968. export class RibbonBuilder {
  59969. /**
  59970. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59971. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59972. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59973. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59974. * * 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
  59975. * * 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
  59976. * * 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
  59977. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59978. * * 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
  59979. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59980. * * 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
  59981. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59982. * * 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
  59983. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59985. * @param name defines the name of the mesh
  59986. * @param options defines the options used to create the mesh
  59987. * @param scene defines the hosting scene
  59988. * @returns the ribbon mesh
  59989. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59990. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59991. */
  59992. static CreateRibbon(name: string, options: {
  59993. pathArray: Vector3[][];
  59994. closeArray?: boolean;
  59995. closePath?: boolean;
  59996. offset?: number;
  59997. updatable?: boolean;
  59998. sideOrientation?: number;
  59999. frontUVs?: Vector4;
  60000. backUVs?: Vector4;
  60001. instance?: Mesh;
  60002. invertUV?: boolean;
  60003. uvs?: Vector2[];
  60004. colors?: Color4[];
  60005. }, scene?: Nullable<Scene>): Mesh;
  60006. }
  60007. }
  60008. declare module BABYLON {
  60009. /**
  60010. * Class containing static functions to help procedurally build meshes
  60011. */
  60012. export class ShapeBuilder {
  60013. /**
  60014. * 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.
  60015. * * 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.
  60016. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60017. * * 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.
  60018. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  60019. * * 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
  60020. * * 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
  60021. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  60022. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60023. * * 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
  60024. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  60025. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60026. * @param name defines the name of the mesh
  60027. * @param options defines the options used to create the mesh
  60028. * @param scene defines the hosting scene
  60029. * @returns the extruded shape mesh
  60030. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60031. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60032. */
  60033. static ExtrudeShape(name: string, options: {
  60034. shape: Vector3[];
  60035. path: Vector3[];
  60036. scale?: number;
  60037. rotation?: number;
  60038. cap?: number;
  60039. updatable?: boolean;
  60040. sideOrientation?: number;
  60041. frontUVs?: Vector4;
  60042. backUVs?: Vector4;
  60043. instance?: Mesh;
  60044. invertUV?: boolean;
  60045. }, scene?: Nullable<Scene>): Mesh;
  60046. /**
  60047. * Creates an custom extruded shape mesh.
  60048. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  60049. * * 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.
  60050. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60051. * * 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
  60052. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  60053. * * 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
  60054. * * It must returns a float value that will be the scale value applied to the shape on each path point
  60055. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  60056. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  60057. * * 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
  60058. * * 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
  60059. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  60060. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60061. * * 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
  60062. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60063. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60064. * @param name defines the name of the mesh
  60065. * @param options defines the options used to create the mesh
  60066. * @param scene defines the hosting scene
  60067. * @returns the custom extruded shape mesh
  60068. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  60069. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60070. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60071. */
  60072. static ExtrudeShapeCustom(name: string, options: {
  60073. shape: Vector3[];
  60074. path: Vector3[];
  60075. scaleFunction?: any;
  60076. rotationFunction?: any;
  60077. ribbonCloseArray?: boolean;
  60078. ribbonClosePath?: boolean;
  60079. cap?: number;
  60080. updatable?: boolean;
  60081. sideOrientation?: number;
  60082. frontUVs?: Vector4;
  60083. backUVs?: Vector4;
  60084. instance?: Mesh;
  60085. invertUV?: boolean;
  60086. }, scene?: Nullable<Scene>): Mesh;
  60087. private static _ExtrudeShapeGeneric;
  60088. }
  60089. }
  60090. declare module BABYLON {
  60091. /**
  60092. * AmmoJS Physics plugin
  60093. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60094. * @see https://github.com/kripken/ammo.js/
  60095. */
  60096. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  60097. private _useDeltaForWorldStep;
  60098. /**
  60099. * Reference to the Ammo library
  60100. */
  60101. bjsAMMO: any;
  60102. /**
  60103. * Created ammoJS world which physics bodies are added to
  60104. */
  60105. world: any;
  60106. /**
  60107. * Name of the plugin
  60108. */
  60109. name: string;
  60110. private _timeStep;
  60111. private _fixedTimeStep;
  60112. private _maxSteps;
  60113. private _tmpQuaternion;
  60114. private _tmpAmmoTransform;
  60115. private _tmpAmmoQuaternion;
  60116. private _tmpAmmoConcreteContactResultCallback;
  60117. private _collisionConfiguration;
  60118. private _dispatcher;
  60119. private _overlappingPairCache;
  60120. private _solver;
  60121. private _softBodySolver;
  60122. private _tmpAmmoVectorA;
  60123. private _tmpAmmoVectorB;
  60124. private _tmpAmmoVectorC;
  60125. private _tmpAmmoVectorD;
  60126. private _tmpContactCallbackResult;
  60127. private _tmpAmmoVectorRCA;
  60128. private _tmpAmmoVectorRCB;
  60129. private _raycastResult;
  60130. private static readonly DISABLE_COLLISION_FLAG;
  60131. private static readonly KINEMATIC_FLAG;
  60132. private static readonly DISABLE_DEACTIVATION_FLAG;
  60133. /**
  60134. * Initializes the ammoJS plugin
  60135. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  60136. * @param ammoInjection can be used to inject your own ammo reference
  60137. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  60138. */
  60139. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  60140. /**
  60141. * Sets the gravity of the physics world (m/(s^2))
  60142. * @param gravity Gravity to set
  60143. */
  60144. setGravity(gravity: Vector3): void;
  60145. /**
  60146. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  60147. * @param timeStep timestep to use in seconds
  60148. */
  60149. setTimeStep(timeStep: number): void;
  60150. /**
  60151. * 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)
  60152. * @param fixedTimeStep fixedTimeStep to use in seconds
  60153. */
  60154. setFixedTimeStep(fixedTimeStep: number): void;
  60155. /**
  60156. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  60157. * @param maxSteps the maximum number of steps by the physics engine per frame
  60158. */
  60159. setMaxSteps(maxSteps: number): void;
  60160. /**
  60161. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  60162. * @returns the current timestep in seconds
  60163. */
  60164. getTimeStep(): number;
  60165. /**
  60166. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  60167. */
  60168. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  60169. private _isImpostorInContact;
  60170. private _isImpostorPairInContact;
  60171. private _stepSimulation;
  60172. /**
  60173. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  60174. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  60175. * After the step the babylon meshes are set to the position of the physics imposters
  60176. * @param delta amount of time to step forward
  60177. * @param impostors array of imposters to update before/after the step
  60178. */
  60179. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60180. /**
  60181. * Update babylon mesh to match physics world object
  60182. * @param impostor imposter to match
  60183. */
  60184. private _afterSoftStep;
  60185. /**
  60186. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  60187. * @param impostor imposter to match
  60188. */
  60189. private _ropeStep;
  60190. /**
  60191. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  60192. * @param impostor imposter to match
  60193. */
  60194. private _softbodyOrClothStep;
  60195. private _tmpMatrix;
  60196. /**
  60197. * Applies an impulse on the imposter
  60198. * @param impostor imposter to apply impulse to
  60199. * @param force amount of force to be applied to the imposter
  60200. * @param contactPoint the location to apply the impulse on the imposter
  60201. */
  60202. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60203. /**
  60204. * Applies a force on the imposter
  60205. * @param impostor imposter to apply force
  60206. * @param force amount of force to be applied to the imposter
  60207. * @param contactPoint the location to apply the force on the imposter
  60208. */
  60209. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60210. /**
  60211. * Creates a physics body using the plugin
  60212. * @param impostor the imposter to create the physics body on
  60213. */
  60214. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60215. /**
  60216. * Removes the physics body from the imposter and disposes of the body's memory
  60217. * @param impostor imposter to remove the physics body from
  60218. */
  60219. removePhysicsBody(impostor: PhysicsImpostor): void;
  60220. /**
  60221. * Generates a joint
  60222. * @param impostorJoint the imposter joint to create the joint with
  60223. */
  60224. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60225. /**
  60226. * Removes a joint
  60227. * @param impostorJoint the imposter joint to remove the joint from
  60228. */
  60229. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60230. private _addMeshVerts;
  60231. /**
  60232. * Initialise the soft body vertices to match its object's (mesh) vertices
  60233. * Softbody vertices (nodes) are in world space and to match this
  60234. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  60235. * @param impostor to create the softbody for
  60236. */
  60237. private _softVertexData;
  60238. /**
  60239. * Create an impostor's soft body
  60240. * @param impostor to create the softbody for
  60241. */
  60242. private _createSoftbody;
  60243. /**
  60244. * Create cloth for an impostor
  60245. * @param impostor to create the softbody for
  60246. */
  60247. private _createCloth;
  60248. /**
  60249. * Create rope for an impostor
  60250. * @param impostor to create the softbody for
  60251. */
  60252. private _createRope;
  60253. /**
  60254. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  60255. * @param impostor to create the custom physics shape for
  60256. */
  60257. private _createCustom;
  60258. private _addHullVerts;
  60259. private _createShape;
  60260. /**
  60261. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  60262. * @param impostor imposter containing the physics body and babylon object
  60263. */
  60264. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60265. /**
  60266. * Sets the babylon object's position/rotation from the physics body's position/rotation
  60267. * @param impostor imposter containing the physics body and babylon object
  60268. * @param newPosition new position
  60269. * @param newRotation new rotation
  60270. */
  60271. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60272. /**
  60273. * If this plugin is supported
  60274. * @returns true if its supported
  60275. */
  60276. isSupported(): boolean;
  60277. /**
  60278. * Sets the linear velocity of the physics body
  60279. * @param impostor imposter to set the velocity on
  60280. * @param velocity velocity to set
  60281. */
  60282. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60283. /**
  60284. * Sets the angular velocity of the physics body
  60285. * @param impostor imposter to set the velocity on
  60286. * @param velocity velocity to set
  60287. */
  60288. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60289. /**
  60290. * gets the linear velocity
  60291. * @param impostor imposter to get linear velocity from
  60292. * @returns linear velocity
  60293. */
  60294. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60295. /**
  60296. * gets the angular velocity
  60297. * @param impostor imposter to get angular velocity from
  60298. * @returns angular velocity
  60299. */
  60300. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60301. /**
  60302. * Sets the mass of physics body
  60303. * @param impostor imposter to set the mass on
  60304. * @param mass mass to set
  60305. */
  60306. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60307. /**
  60308. * Gets the mass of the physics body
  60309. * @param impostor imposter to get the mass from
  60310. * @returns mass
  60311. */
  60312. getBodyMass(impostor: PhysicsImpostor): number;
  60313. /**
  60314. * Gets friction of the impostor
  60315. * @param impostor impostor to get friction from
  60316. * @returns friction value
  60317. */
  60318. getBodyFriction(impostor: PhysicsImpostor): number;
  60319. /**
  60320. * Sets friction of the impostor
  60321. * @param impostor impostor to set friction on
  60322. * @param friction friction value
  60323. */
  60324. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60325. /**
  60326. * Gets restitution of the impostor
  60327. * @param impostor impostor to get restitution from
  60328. * @returns restitution value
  60329. */
  60330. getBodyRestitution(impostor: PhysicsImpostor): number;
  60331. /**
  60332. * Sets resitution of the impostor
  60333. * @param impostor impostor to set resitution on
  60334. * @param restitution resitution value
  60335. */
  60336. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60337. /**
  60338. * Gets pressure inside the impostor
  60339. * @param impostor impostor to get pressure from
  60340. * @returns pressure value
  60341. */
  60342. getBodyPressure(impostor: PhysicsImpostor): number;
  60343. /**
  60344. * Sets pressure inside a soft body impostor
  60345. * Cloth and rope must remain 0 pressure
  60346. * @param impostor impostor to set pressure on
  60347. * @param pressure pressure value
  60348. */
  60349. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  60350. /**
  60351. * Gets stiffness of the impostor
  60352. * @param impostor impostor to get stiffness from
  60353. * @returns pressure value
  60354. */
  60355. getBodyStiffness(impostor: PhysicsImpostor): number;
  60356. /**
  60357. * Sets stiffness of the impostor
  60358. * @param impostor impostor to set stiffness on
  60359. * @param stiffness stiffness value from 0 to 1
  60360. */
  60361. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  60362. /**
  60363. * Gets velocityIterations of the impostor
  60364. * @param impostor impostor to get velocity iterations from
  60365. * @returns velocityIterations value
  60366. */
  60367. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  60368. /**
  60369. * Sets velocityIterations of the impostor
  60370. * @param impostor impostor to set velocity iterations on
  60371. * @param velocityIterations velocityIterations value
  60372. */
  60373. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  60374. /**
  60375. * Gets positionIterations of the impostor
  60376. * @param impostor impostor to get position iterations from
  60377. * @returns positionIterations value
  60378. */
  60379. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  60380. /**
  60381. * Sets positionIterations of the impostor
  60382. * @param impostor impostor to set position on
  60383. * @param positionIterations positionIterations value
  60384. */
  60385. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  60386. /**
  60387. * Append an anchor to a cloth object
  60388. * @param impostor is the cloth impostor to add anchor to
  60389. * @param otherImpostor is the rigid impostor to anchor to
  60390. * @param width ratio across width from 0 to 1
  60391. * @param height ratio up height from 0 to 1
  60392. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  60393. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  60394. */
  60395. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  60396. /**
  60397. * Append an hook to a rope object
  60398. * @param impostor is the rope impostor to add hook to
  60399. * @param otherImpostor is the rigid impostor to hook to
  60400. * @param length ratio along the rope from 0 to 1
  60401. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  60402. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  60403. */
  60404. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  60405. /**
  60406. * Sleeps the physics body and stops it from being active
  60407. * @param impostor impostor to sleep
  60408. */
  60409. sleepBody(impostor: PhysicsImpostor): void;
  60410. /**
  60411. * Activates the physics body
  60412. * @param impostor impostor to activate
  60413. */
  60414. wakeUpBody(impostor: PhysicsImpostor): void;
  60415. /**
  60416. * Updates the distance parameters of the joint
  60417. * @param joint joint to update
  60418. * @param maxDistance maximum distance of the joint
  60419. * @param minDistance minimum distance of the joint
  60420. */
  60421. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  60422. /**
  60423. * Sets a motor on the joint
  60424. * @param joint joint to set motor on
  60425. * @param speed speed of the motor
  60426. * @param maxForce maximum force of the motor
  60427. * @param motorIndex index of the motor
  60428. */
  60429. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  60430. /**
  60431. * Sets the motors limit
  60432. * @param joint joint to set limit on
  60433. * @param upperLimit upper limit
  60434. * @param lowerLimit lower limit
  60435. */
  60436. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  60437. /**
  60438. * Syncs the position and rotation of a mesh with the impostor
  60439. * @param mesh mesh to sync
  60440. * @param impostor impostor to update the mesh with
  60441. */
  60442. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60443. /**
  60444. * Gets the radius of the impostor
  60445. * @param impostor impostor to get radius from
  60446. * @returns the radius
  60447. */
  60448. getRadius(impostor: PhysicsImpostor): number;
  60449. /**
  60450. * Gets the box size of the impostor
  60451. * @param impostor impostor to get box size from
  60452. * @param result the resulting box size
  60453. */
  60454. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60455. /**
  60456. * Disposes of the impostor
  60457. */
  60458. dispose(): void;
  60459. /**
  60460. * Does a raycast in the physics world
  60461. * @param from when should the ray start?
  60462. * @param to when should the ray end?
  60463. * @returns PhysicsRaycastResult
  60464. */
  60465. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60466. }
  60467. }
  60468. declare module BABYLON {
  60469. interface AbstractScene {
  60470. /**
  60471. * The list of reflection probes added to the scene
  60472. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  60473. */
  60474. reflectionProbes: Array<ReflectionProbe>;
  60475. /**
  60476. * Removes the given reflection probe from this scene.
  60477. * @param toRemove The reflection probe to remove
  60478. * @returns The index of the removed reflection probe
  60479. */
  60480. removeReflectionProbe(toRemove: ReflectionProbe): number;
  60481. /**
  60482. * Adds the given reflection probe to this scene.
  60483. * @param newReflectionProbe The reflection probe to add
  60484. */
  60485. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  60486. }
  60487. /**
  60488. * Class used to generate realtime reflection / refraction cube textures
  60489. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  60490. */
  60491. export class ReflectionProbe {
  60492. /** defines the name of the probe */
  60493. name: string;
  60494. private _scene;
  60495. private _renderTargetTexture;
  60496. private _projectionMatrix;
  60497. private _viewMatrix;
  60498. private _target;
  60499. private _add;
  60500. private _attachedMesh;
  60501. private _invertYAxis;
  60502. /** Gets or sets probe position (center of the cube map) */
  60503. position: Vector3;
  60504. /**
  60505. * Creates a new reflection probe
  60506. * @param name defines the name of the probe
  60507. * @param size defines the texture resolution (for each face)
  60508. * @param scene defines the hosting scene
  60509. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  60510. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  60511. */
  60512. constructor(
  60513. /** defines the name of the probe */
  60514. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  60515. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  60516. get samples(): number;
  60517. set samples(value: number);
  60518. /** Gets or sets the refresh rate to use (on every frame by default) */
  60519. get refreshRate(): number;
  60520. set refreshRate(value: number);
  60521. /**
  60522. * Gets the hosting scene
  60523. * @returns a Scene
  60524. */
  60525. getScene(): Scene;
  60526. /** Gets the internal CubeTexture used to render to */
  60527. get cubeTexture(): RenderTargetTexture;
  60528. /** Gets the list of meshes to render */
  60529. get renderList(): Nullable<AbstractMesh[]>;
  60530. /**
  60531. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  60532. * @param mesh defines the mesh to attach to
  60533. */
  60534. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  60535. /**
  60536. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  60537. * @param renderingGroupId The rendering group id corresponding to its index
  60538. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  60539. */
  60540. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  60541. /**
  60542. * Clean all associated resources
  60543. */
  60544. dispose(): void;
  60545. /**
  60546. * Converts the reflection probe information to a readable string for debug purpose.
  60547. * @param fullDetails Supports for multiple levels of logging within scene loading
  60548. * @returns the human readable reflection probe info
  60549. */
  60550. toString(fullDetails?: boolean): string;
  60551. /**
  60552. * Get the class name of the relfection probe.
  60553. * @returns "ReflectionProbe"
  60554. */
  60555. getClassName(): string;
  60556. /**
  60557. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  60558. * @returns The JSON representation of the texture
  60559. */
  60560. serialize(): any;
  60561. /**
  60562. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  60563. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  60564. * @param scene Define the scene the parsed reflection probe should be instantiated in
  60565. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  60566. * @returns The parsed reflection probe if successful
  60567. */
  60568. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  60569. }
  60570. }
  60571. declare module BABYLON {
  60572. /** @hidden */
  60573. export var _BabylonLoaderRegistered: boolean;
  60574. /**
  60575. * Helps setting up some configuration for the babylon file loader.
  60576. */
  60577. export class BabylonFileLoaderConfiguration {
  60578. /**
  60579. * The loader does not allow injecting custom physix engine into the plugins.
  60580. * Unfortunately in ES6, we need to manually inject them into the plugin.
  60581. * So you could set this variable to your engine import to make it work.
  60582. */
  60583. static LoaderInjectedPhysicsEngine: any;
  60584. }
  60585. }
  60586. declare module BABYLON {
  60587. /**
  60588. * The Physically based simple base material of BJS.
  60589. *
  60590. * This enables better naming and convention enforcements on top of the pbrMaterial.
  60591. * It is used as the base class for both the specGloss and metalRough conventions.
  60592. */
  60593. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  60594. /**
  60595. * Number of Simultaneous lights allowed on the material.
  60596. */
  60597. maxSimultaneousLights: number;
  60598. /**
  60599. * If sets to true, disables all the lights affecting the material.
  60600. */
  60601. disableLighting: boolean;
  60602. /**
  60603. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  60604. */
  60605. environmentTexture: BaseTexture;
  60606. /**
  60607. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  60608. */
  60609. invertNormalMapX: boolean;
  60610. /**
  60611. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  60612. */
  60613. invertNormalMapY: boolean;
  60614. /**
  60615. * Normal map used in the model.
  60616. */
  60617. normalTexture: BaseTexture;
  60618. /**
  60619. * Emissivie color used to self-illuminate the model.
  60620. */
  60621. emissiveColor: Color3;
  60622. /**
  60623. * Emissivie texture used to self-illuminate the model.
  60624. */
  60625. emissiveTexture: BaseTexture;
  60626. /**
  60627. * Occlusion Channel Strenght.
  60628. */
  60629. occlusionStrength: number;
  60630. /**
  60631. * Occlusion Texture of the material (adding extra occlusion effects).
  60632. */
  60633. occlusionTexture: BaseTexture;
  60634. /**
  60635. * Defines the alpha limits in alpha test mode.
  60636. */
  60637. alphaCutOff: number;
  60638. /**
  60639. * Gets the current double sided mode.
  60640. */
  60641. get doubleSided(): boolean;
  60642. /**
  60643. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  60644. */
  60645. set doubleSided(value: boolean);
  60646. /**
  60647. * Stores the pre-calculated light information of a mesh in a texture.
  60648. */
  60649. lightmapTexture: BaseTexture;
  60650. /**
  60651. * If true, the light map contains occlusion information instead of lighting info.
  60652. */
  60653. useLightmapAsShadowmap: boolean;
  60654. /**
  60655. * Instantiates a new PBRMaterial instance.
  60656. *
  60657. * @param name The material name
  60658. * @param scene The scene the material will be use in.
  60659. */
  60660. constructor(name: string, scene: Scene);
  60661. getClassName(): string;
  60662. }
  60663. }
  60664. declare module BABYLON {
  60665. /**
  60666. * The PBR material of BJS following the metal roughness convention.
  60667. *
  60668. * This fits to the PBR convention in the GLTF definition:
  60669. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  60670. */
  60671. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  60672. /**
  60673. * The base color has two different interpretations depending on the value of metalness.
  60674. * When the material is a metal, the base color is the specific measured reflectance value
  60675. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  60676. * of the material.
  60677. */
  60678. baseColor: Color3;
  60679. /**
  60680. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  60681. * well as opacity information in the alpha channel.
  60682. */
  60683. baseTexture: BaseTexture;
  60684. /**
  60685. * Specifies the metallic scalar value of the material.
  60686. * Can also be used to scale the metalness values of the metallic texture.
  60687. */
  60688. metallic: number;
  60689. /**
  60690. * Specifies the roughness scalar value of the material.
  60691. * Can also be used to scale the roughness values of the metallic texture.
  60692. */
  60693. roughness: number;
  60694. /**
  60695. * Texture containing both the metallic value in the B channel and the
  60696. * roughness value in the G channel to keep better precision.
  60697. */
  60698. metallicRoughnessTexture: BaseTexture;
  60699. /**
  60700. * Instantiates a new PBRMetalRoughnessMaterial instance.
  60701. *
  60702. * @param name The material name
  60703. * @param scene The scene the material will be use in.
  60704. */
  60705. constructor(name: string, scene: Scene);
  60706. /**
  60707. * Return the currrent class name of the material.
  60708. */
  60709. getClassName(): string;
  60710. /**
  60711. * Makes a duplicate of the current material.
  60712. * @param name - name to use for the new material.
  60713. */
  60714. clone(name: string): PBRMetallicRoughnessMaterial;
  60715. /**
  60716. * Serialize the material to a parsable JSON object.
  60717. */
  60718. serialize(): any;
  60719. /**
  60720. * Parses a JSON object correponding to the serialize function.
  60721. */
  60722. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  60723. }
  60724. }
  60725. declare module BABYLON {
  60726. /**
  60727. * The PBR material of BJS following the specular glossiness convention.
  60728. *
  60729. * This fits to the PBR convention in the GLTF definition:
  60730. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  60731. */
  60732. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  60733. /**
  60734. * Specifies the diffuse color of the material.
  60735. */
  60736. diffuseColor: Color3;
  60737. /**
  60738. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  60739. * channel.
  60740. */
  60741. diffuseTexture: BaseTexture;
  60742. /**
  60743. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  60744. */
  60745. specularColor: Color3;
  60746. /**
  60747. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  60748. */
  60749. glossiness: number;
  60750. /**
  60751. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  60752. */
  60753. specularGlossinessTexture: BaseTexture;
  60754. /**
  60755. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  60756. *
  60757. * @param name The material name
  60758. * @param scene The scene the material will be use in.
  60759. */
  60760. constructor(name: string, scene: Scene);
  60761. /**
  60762. * Return the currrent class name of the material.
  60763. */
  60764. getClassName(): string;
  60765. /**
  60766. * Makes a duplicate of the current material.
  60767. * @param name - name to use for the new material.
  60768. */
  60769. clone(name: string): PBRSpecularGlossinessMaterial;
  60770. /**
  60771. * Serialize the material to a parsable JSON object.
  60772. */
  60773. serialize(): any;
  60774. /**
  60775. * Parses a JSON object correponding to the serialize function.
  60776. */
  60777. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  60778. }
  60779. }
  60780. declare module BABYLON {
  60781. /**
  60782. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  60783. * It can help converting any input color in a desired output one. This can then be used to create effects
  60784. * from sepia, black and white to sixties or futuristic rendering...
  60785. *
  60786. * The only supported format is currently 3dl.
  60787. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  60788. */
  60789. export class ColorGradingTexture extends BaseTexture {
  60790. /**
  60791. * The texture URL.
  60792. */
  60793. url: string;
  60794. /**
  60795. * Empty line regex stored for GC.
  60796. */
  60797. private static _noneEmptyLineRegex;
  60798. private _textureMatrix;
  60799. private _onLoad;
  60800. /**
  60801. * Instantiates a ColorGradingTexture from the following parameters.
  60802. *
  60803. * @param url The location of the color gradind data (currently only supporting 3dl)
  60804. * @param sceneOrEngine The scene or engine the texture will be used in
  60805. * @param onLoad defines a callback triggered when the texture has been loaded
  60806. */
  60807. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  60808. /**
  60809. * Fires the onload event from the constructor if requested.
  60810. */
  60811. private _triggerOnLoad;
  60812. /**
  60813. * Returns the texture matrix used in most of the material.
  60814. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  60815. */
  60816. getTextureMatrix(): Matrix;
  60817. /**
  60818. * Occurs when the file being loaded is a .3dl LUT file.
  60819. */
  60820. private load3dlTexture;
  60821. /**
  60822. * Starts the loading process of the texture.
  60823. */
  60824. private loadTexture;
  60825. /**
  60826. * Clones the color gradind texture.
  60827. */
  60828. clone(): ColorGradingTexture;
  60829. /**
  60830. * Called during delayed load for textures.
  60831. */
  60832. delayLoad(): void;
  60833. /**
  60834. * Parses a color grading texture serialized by Babylon.
  60835. * @param parsedTexture The texture information being parsedTexture
  60836. * @param scene The scene to load the texture in
  60837. * @param rootUrl The root url of the data assets to load
  60838. * @return A color gradind texture
  60839. */
  60840. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  60841. /**
  60842. * Serializes the LUT texture to json format.
  60843. */
  60844. serialize(): any;
  60845. }
  60846. }
  60847. declare module BABYLON {
  60848. /**
  60849. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  60850. */
  60851. export class EquiRectangularCubeTexture extends BaseTexture {
  60852. /** The six faces of the cube. */
  60853. private static _FacesMapping;
  60854. private _noMipmap;
  60855. private _onLoad;
  60856. private _onError;
  60857. /** The size of the cubemap. */
  60858. private _size;
  60859. /** The buffer of the image. */
  60860. private _buffer;
  60861. /** The width of the input image. */
  60862. private _width;
  60863. /** The height of the input image. */
  60864. private _height;
  60865. /** The URL to the image. */
  60866. url: string;
  60867. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  60868. coordinatesMode: number;
  60869. /**
  60870. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  60871. * @param url The location of the image
  60872. * @param scene The scene the texture will be used in
  60873. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60874. * @param noMipmap Forces to not generate the mipmap if true
  60875. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  60876. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  60877. * @param onLoad — defines a callback called when texture is loaded
  60878. * @param onError — defines a callback called if there is an error
  60879. */
  60880. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  60881. /**
  60882. * Load the image data, by putting the image on a canvas and extracting its buffer.
  60883. */
  60884. private loadImage;
  60885. /**
  60886. * Convert the image buffer into a cubemap and create a CubeTexture.
  60887. */
  60888. private loadTexture;
  60889. /**
  60890. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  60891. * @param buffer The ArrayBuffer that should be converted.
  60892. * @returns The buffer as Float32Array.
  60893. */
  60894. private getFloat32ArrayFromArrayBuffer;
  60895. /**
  60896. * Get the current class name of the texture useful for serialization or dynamic coding.
  60897. * @returns "EquiRectangularCubeTexture"
  60898. */
  60899. getClassName(): string;
  60900. /**
  60901. * Create a clone of the current EquiRectangularCubeTexture and return it.
  60902. * @returns A clone of the current EquiRectangularCubeTexture.
  60903. */
  60904. clone(): EquiRectangularCubeTexture;
  60905. }
  60906. }
  60907. declare module BABYLON {
  60908. /**
  60909. * Defines the options related to the creation of an HtmlElementTexture
  60910. */
  60911. export interface IHtmlElementTextureOptions {
  60912. /**
  60913. * Defines wether mip maps should be created or not.
  60914. */
  60915. generateMipMaps?: boolean;
  60916. /**
  60917. * Defines the sampling mode of the texture.
  60918. */
  60919. samplingMode?: number;
  60920. /**
  60921. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  60922. */
  60923. engine: Nullable<ThinEngine>;
  60924. /**
  60925. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  60926. */
  60927. scene: Nullable<Scene>;
  60928. }
  60929. /**
  60930. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  60931. * To be as efficient as possible depending on your constraints nothing aside the first upload
  60932. * is automatically managed.
  60933. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  60934. * in your application.
  60935. *
  60936. * As the update is not automatic, you need to call them manually.
  60937. */
  60938. export class HtmlElementTexture extends BaseTexture {
  60939. /**
  60940. * The texture URL.
  60941. */
  60942. element: HTMLVideoElement | HTMLCanvasElement;
  60943. private static readonly DefaultOptions;
  60944. private _textureMatrix;
  60945. private _isVideo;
  60946. private _generateMipMaps;
  60947. private _samplingMode;
  60948. /**
  60949. * Instantiates a HtmlElementTexture from the following parameters.
  60950. *
  60951. * @param name Defines the name of the texture
  60952. * @param element Defines the video or canvas the texture is filled with
  60953. * @param options Defines the other none mandatory texture creation options
  60954. */
  60955. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  60956. private _createInternalTexture;
  60957. /**
  60958. * Returns the texture matrix used in most of the material.
  60959. */
  60960. getTextureMatrix(): Matrix;
  60961. /**
  60962. * Updates the content of the texture.
  60963. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  60964. */
  60965. update(invertY?: Nullable<boolean>): void;
  60966. }
  60967. }
  60968. declare module BABYLON {
  60969. /**
  60970. * Based on jsTGALoader - Javascript loader for TGA file
  60971. * By Vincent Thibault
  60972. * @see http://blog.robrowser.com/javascript-tga-loader.html
  60973. */
  60974. export class TGATools {
  60975. private static _TYPE_INDEXED;
  60976. private static _TYPE_RGB;
  60977. private static _TYPE_GREY;
  60978. private static _TYPE_RLE_INDEXED;
  60979. private static _TYPE_RLE_RGB;
  60980. private static _TYPE_RLE_GREY;
  60981. private static _ORIGIN_MASK;
  60982. private static _ORIGIN_SHIFT;
  60983. private static _ORIGIN_BL;
  60984. private static _ORIGIN_BR;
  60985. private static _ORIGIN_UL;
  60986. private static _ORIGIN_UR;
  60987. /**
  60988. * Gets the header of a TGA file
  60989. * @param data defines the TGA data
  60990. * @returns the header
  60991. */
  60992. static GetTGAHeader(data: Uint8Array): any;
  60993. /**
  60994. * Uploads TGA content to a Babylon Texture
  60995. * @hidden
  60996. */
  60997. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  60998. /** @hidden */
  60999. 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;
  61000. /** @hidden */
  61001. 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;
  61002. /** @hidden */
  61003. 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;
  61004. /** @hidden */
  61005. 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;
  61006. /** @hidden */
  61007. 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;
  61008. /** @hidden */
  61009. 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;
  61010. }
  61011. }
  61012. declare module BABYLON {
  61013. /**
  61014. * Implementation of the TGA Texture Loader.
  61015. * @hidden
  61016. */
  61017. export class _TGATextureLoader implements IInternalTextureLoader {
  61018. /**
  61019. * Defines wether the loader supports cascade loading the different faces.
  61020. */
  61021. readonly supportCascades: boolean;
  61022. /**
  61023. * This returns if the loader support the current file information.
  61024. * @param extension defines the file extension of the file being loaded
  61025. * @returns true if the loader can load the specified file
  61026. */
  61027. canLoad(extension: string): boolean;
  61028. /**
  61029. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61030. * @param data contains the texture data
  61031. * @param texture defines the BabylonJS internal texture
  61032. * @param createPolynomials will be true if polynomials have been requested
  61033. * @param onLoad defines the callback to trigger once the texture is ready
  61034. * @param onError defines the callback to trigger in case of error
  61035. */
  61036. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61037. /**
  61038. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61039. * @param data contains the texture data
  61040. * @param texture defines the BabylonJS internal texture
  61041. * @param callback defines the method to call once ready to upload
  61042. */
  61043. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61044. }
  61045. }
  61046. declare module BABYLON {
  61047. /**
  61048. * Info about the .basis files
  61049. */
  61050. class BasisFileInfo {
  61051. /**
  61052. * If the file has alpha
  61053. */
  61054. hasAlpha: boolean;
  61055. /**
  61056. * Info about each image of the basis file
  61057. */
  61058. images: Array<{
  61059. levels: Array<{
  61060. width: number;
  61061. height: number;
  61062. transcodedPixels: ArrayBufferView;
  61063. }>;
  61064. }>;
  61065. }
  61066. /**
  61067. * Result of transcoding a basis file
  61068. */
  61069. class TranscodeResult {
  61070. /**
  61071. * Info about the .basis file
  61072. */
  61073. fileInfo: BasisFileInfo;
  61074. /**
  61075. * Format to use when loading the file
  61076. */
  61077. format: number;
  61078. }
  61079. /**
  61080. * Configuration options for the Basis transcoder
  61081. */
  61082. export class BasisTranscodeConfiguration {
  61083. /**
  61084. * Supported compression formats used to determine the supported output format of the transcoder
  61085. */
  61086. supportedCompressionFormats?: {
  61087. /**
  61088. * etc1 compression format
  61089. */
  61090. etc1?: boolean;
  61091. /**
  61092. * s3tc compression format
  61093. */
  61094. s3tc?: boolean;
  61095. /**
  61096. * pvrtc compression format
  61097. */
  61098. pvrtc?: boolean;
  61099. /**
  61100. * etc2 compression format
  61101. */
  61102. etc2?: boolean;
  61103. };
  61104. /**
  61105. * If mipmap levels should be loaded for transcoded images (Default: true)
  61106. */
  61107. loadMipmapLevels?: boolean;
  61108. /**
  61109. * Index of a single image to load (Default: all images)
  61110. */
  61111. loadSingleImage?: number;
  61112. }
  61113. /**
  61114. * Used to load .Basis files
  61115. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  61116. */
  61117. export class BasisTools {
  61118. private static _IgnoreSupportedFormats;
  61119. /**
  61120. * URL to use when loading the basis transcoder
  61121. */
  61122. static JSModuleURL: string;
  61123. /**
  61124. * URL to use when loading the wasm module for the transcoder
  61125. */
  61126. static WasmModuleURL: string;
  61127. /**
  61128. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  61129. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  61130. * @returns internal format corresponding to the Basis format
  61131. */
  61132. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  61133. private static _WorkerPromise;
  61134. private static _Worker;
  61135. private static _actionId;
  61136. private static _CreateWorkerAsync;
  61137. /**
  61138. * Transcodes a loaded image file to compressed pixel data
  61139. * @param data image data to transcode
  61140. * @param config configuration options for the transcoding
  61141. * @returns a promise resulting in the transcoded image
  61142. */
  61143. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  61144. /**
  61145. * Loads a texture from the transcode result
  61146. * @param texture texture load to
  61147. * @param transcodeResult the result of transcoding the basis file to load from
  61148. */
  61149. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  61150. }
  61151. }
  61152. declare module BABYLON {
  61153. /**
  61154. * Loader for .basis file format
  61155. */
  61156. export class _BasisTextureLoader implements IInternalTextureLoader {
  61157. /**
  61158. * Defines whether the loader supports cascade loading the different faces.
  61159. */
  61160. readonly supportCascades: boolean;
  61161. /**
  61162. * This returns if the loader support the current file information.
  61163. * @param extension defines the file extension of the file being loaded
  61164. * @returns true if the loader can load the specified file
  61165. */
  61166. canLoad(extension: string): boolean;
  61167. /**
  61168. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61169. * @param data contains the texture data
  61170. * @param texture defines the BabylonJS internal texture
  61171. * @param createPolynomials will be true if polynomials have been requested
  61172. * @param onLoad defines the callback to trigger once the texture is ready
  61173. * @param onError defines the callback to trigger in case of error
  61174. */
  61175. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61176. /**
  61177. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61178. * @param data contains the texture data
  61179. * @param texture defines the BabylonJS internal texture
  61180. * @param callback defines the method to call once ready to upload
  61181. */
  61182. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61183. }
  61184. }
  61185. declare module BABYLON {
  61186. /**
  61187. * Defines the basic options interface of a TexturePacker Frame
  61188. */
  61189. export interface ITexturePackerFrame {
  61190. /**
  61191. * The frame ID
  61192. */
  61193. id: number;
  61194. /**
  61195. * The frames Scale
  61196. */
  61197. scale: Vector2;
  61198. /**
  61199. * The Frames offset
  61200. */
  61201. offset: Vector2;
  61202. }
  61203. /**
  61204. * This is a support class for frame Data on texture packer sets.
  61205. */
  61206. export class TexturePackerFrame implements ITexturePackerFrame {
  61207. /**
  61208. * The frame ID
  61209. */
  61210. id: number;
  61211. /**
  61212. * The frames Scale
  61213. */
  61214. scale: Vector2;
  61215. /**
  61216. * The Frames offset
  61217. */
  61218. offset: Vector2;
  61219. /**
  61220. * Initializes a texture package frame.
  61221. * @param id The numerical frame identifier
  61222. * @param scale Scalar Vector2 for UV frame
  61223. * @param offset Vector2 for the frame position in UV units.
  61224. * @returns TexturePackerFrame
  61225. */
  61226. constructor(id: number, scale: Vector2, offset: Vector2);
  61227. }
  61228. }
  61229. declare module BABYLON {
  61230. /**
  61231. * Defines the basic options interface of a TexturePacker
  61232. */
  61233. export interface ITexturePackerOptions {
  61234. /**
  61235. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  61236. */
  61237. map?: string[];
  61238. /**
  61239. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  61240. */
  61241. uvsIn?: string;
  61242. /**
  61243. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  61244. */
  61245. uvsOut?: string;
  61246. /**
  61247. * number representing the layout style. Defaults to LAYOUT_STRIP
  61248. */
  61249. layout?: number;
  61250. /**
  61251. * number of columns if using custom column count layout(2). This defaults to 4.
  61252. */
  61253. colnum?: number;
  61254. /**
  61255. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  61256. */
  61257. updateInputMeshes?: boolean;
  61258. /**
  61259. * boolean flag to dispose all the source textures. Defaults to true.
  61260. */
  61261. disposeSources?: boolean;
  61262. /**
  61263. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  61264. */
  61265. fillBlanks?: boolean;
  61266. /**
  61267. * string value representing the context fill style color. Defaults to 'black'.
  61268. */
  61269. customFillColor?: string;
  61270. /**
  61271. * Width and Height Value of each Frame in the TexturePacker Sets
  61272. */
  61273. frameSize?: number;
  61274. /**
  61275. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  61276. */
  61277. paddingRatio?: number;
  61278. /**
  61279. * Number that declares the fill method for the padding gutter.
  61280. */
  61281. paddingMode?: number;
  61282. /**
  61283. * If in SUBUV_COLOR padding mode what color to use.
  61284. */
  61285. paddingColor?: Color3 | Color4;
  61286. }
  61287. /**
  61288. * Defines the basic interface of a TexturePacker JSON File
  61289. */
  61290. export interface ITexturePackerJSON {
  61291. /**
  61292. * The frame ID
  61293. */
  61294. name: string;
  61295. /**
  61296. * The base64 channel data
  61297. */
  61298. sets: any;
  61299. /**
  61300. * The options of the Packer
  61301. */
  61302. options: ITexturePackerOptions;
  61303. /**
  61304. * The frame data of the Packer
  61305. */
  61306. frames: Array<number>;
  61307. }
  61308. /**
  61309. * This is a support class that generates a series of packed texture sets.
  61310. * @see https://doc.babylonjs.com/babylon101/materials
  61311. */
  61312. export class TexturePacker {
  61313. /** Packer Layout Constant 0 */
  61314. static readonly LAYOUT_STRIP: number;
  61315. /** Packer Layout Constant 1 */
  61316. static readonly LAYOUT_POWER2: number;
  61317. /** Packer Layout Constant 2 */
  61318. static readonly LAYOUT_COLNUM: number;
  61319. /** Packer Layout Constant 0 */
  61320. static readonly SUBUV_WRAP: number;
  61321. /** Packer Layout Constant 1 */
  61322. static readonly SUBUV_EXTEND: number;
  61323. /** Packer Layout Constant 2 */
  61324. static readonly SUBUV_COLOR: number;
  61325. /** The Name of the Texture Package */
  61326. name: string;
  61327. /** The scene scope of the TexturePacker */
  61328. scene: Scene;
  61329. /** The Meshes to target */
  61330. meshes: AbstractMesh[];
  61331. /** Arguments passed with the Constructor */
  61332. options: ITexturePackerOptions;
  61333. /** The promise that is started upon initialization */
  61334. promise: Nullable<Promise<TexturePacker | string>>;
  61335. /** The Container object for the channel sets that are generated */
  61336. sets: object;
  61337. /** The Container array for the frames that are generated */
  61338. frames: TexturePackerFrame[];
  61339. /** The expected number of textures the system is parsing. */
  61340. private _expecting;
  61341. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  61342. private _paddingValue;
  61343. /**
  61344. * Initializes a texture package series from an array of meshes or a single mesh.
  61345. * @param name The name of the package
  61346. * @param meshes The target meshes to compose the package from
  61347. * @param options The arguments that texture packer should follow while building.
  61348. * @param scene The scene which the textures are scoped to.
  61349. * @returns TexturePacker
  61350. */
  61351. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  61352. /**
  61353. * Starts the package process
  61354. * @param resolve The promises resolution function
  61355. * @returns TexturePacker
  61356. */
  61357. private _createFrames;
  61358. /**
  61359. * Calculates the Size of the Channel Sets
  61360. * @returns Vector2
  61361. */
  61362. private _calculateSize;
  61363. /**
  61364. * Calculates the UV data for the frames.
  61365. * @param baseSize the base frameSize
  61366. * @param padding the base frame padding
  61367. * @param dtSize size of the Dynamic Texture for that channel
  61368. * @param dtUnits is 1/dtSize
  61369. * @param update flag to update the input meshes
  61370. */
  61371. private _calculateMeshUVFrames;
  61372. /**
  61373. * Calculates the frames Offset.
  61374. * @param index of the frame
  61375. * @returns Vector2
  61376. */
  61377. private _getFrameOffset;
  61378. /**
  61379. * Updates a Mesh to the frame data
  61380. * @param mesh that is the target
  61381. * @param frameID or the frame index
  61382. */
  61383. private _updateMeshUV;
  61384. /**
  61385. * Updates a Meshes materials to use the texture packer channels
  61386. * @param m is the mesh to target
  61387. * @param force all channels on the packer to be set.
  61388. */
  61389. private _updateTextureReferences;
  61390. /**
  61391. * Public method to set a Mesh to a frame
  61392. * @param m that is the target
  61393. * @param frameID or the frame index
  61394. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  61395. */
  61396. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  61397. /**
  61398. * Starts the async promise to compile the texture packer.
  61399. * @returns Promise<void>
  61400. */
  61401. processAsync(): Promise<void>;
  61402. /**
  61403. * Disposes all textures associated with this packer
  61404. */
  61405. dispose(): void;
  61406. /**
  61407. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  61408. * @param imageType is the image type to use.
  61409. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  61410. */
  61411. download(imageType?: string, quality?: number): void;
  61412. /**
  61413. * Public method to load a texturePacker JSON file.
  61414. * @param data of the JSON file in string format.
  61415. */
  61416. updateFromJSON(data: string): void;
  61417. }
  61418. }
  61419. declare module BABYLON {
  61420. /**
  61421. * 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.
  61422. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  61423. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  61424. */
  61425. export class CustomProceduralTexture extends ProceduralTexture {
  61426. private _animate;
  61427. private _time;
  61428. private _config;
  61429. private _texturePath;
  61430. /**
  61431. * Instantiates a new Custom Procedural Texture.
  61432. * 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.
  61433. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  61434. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  61435. * @param name Define the name of the texture
  61436. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  61437. * @param size Define the size of the texture to create
  61438. * @param scene Define the scene the texture belongs to
  61439. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  61440. * @param generateMipMaps Define if the texture should creates mip maps or not
  61441. */
  61442. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  61443. private _loadJson;
  61444. /**
  61445. * Is the texture ready to be used ? (rendered at least once)
  61446. * @returns true if ready, otherwise, false.
  61447. */
  61448. isReady(): boolean;
  61449. /**
  61450. * Render the texture to its associated render target.
  61451. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  61452. */
  61453. render(useCameraPostProcess?: boolean): void;
  61454. /**
  61455. * Update the list of dependant textures samplers in the shader.
  61456. */
  61457. updateTextures(): void;
  61458. /**
  61459. * Update the uniform values of the procedural texture in the shader.
  61460. */
  61461. updateShaderUniforms(): void;
  61462. /**
  61463. * Define if the texture animates or not.
  61464. */
  61465. get animate(): boolean;
  61466. set animate(value: boolean);
  61467. }
  61468. }
  61469. declare module BABYLON {
  61470. /** @hidden */
  61471. export var noisePixelShader: {
  61472. name: string;
  61473. shader: string;
  61474. };
  61475. }
  61476. declare module BABYLON {
  61477. /**
  61478. * Class used to generate noise procedural textures
  61479. */
  61480. export class NoiseProceduralTexture extends ProceduralTexture {
  61481. private _time;
  61482. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  61483. brightness: number;
  61484. /** Defines the number of octaves to process */
  61485. octaves: number;
  61486. /** Defines the level of persistence (0.8 by default) */
  61487. persistence: number;
  61488. /** Gets or sets animation speed factor (default is 1) */
  61489. animationSpeedFactor: number;
  61490. /**
  61491. * Creates a new NoiseProceduralTexture
  61492. * @param name defines the name fo the texture
  61493. * @param size defines the size of the texture (default is 256)
  61494. * @param scene defines the hosting scene
  61495. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  61496. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  61497. */
  61498. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  61499. private _updateShaderUniforms;
  61500. protected _getDefines(): string;
  61501. /** Generate the current state of the procedural texture */
  61502. render(useCameraPostProcess?: boolean): void;
  61503. /**
  61504. * Serializes this noise procedural texture
  61505. * @returns a serialized noise procedural texture object
  61506. */
  61507. serialize(): any;
  61508. /**
  61509. * Clone the texture.
  61510. * @returns the cloned texture
  61511. */
  61512. clone(): NoiseProceduralTexture;
  61513. /**
  61514. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  61515. * @param parsedTexture defines parsed texture data
  61516. * @param scene defines the current scene
  61517. * @param rootUrl defines the root URL containing noise procedural texture information
  61518. * @returns a parsed NoiseProceduralTexture
  61519. */
  61520. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  61521. }
  61522. }
  61523. declare module BABYLON {
  61524. /**
  61525. * Raw cube texture where the raw buffers are passed in
  61526. */
  61527. export class RawCubeTexture extends CubeTexture {
  61528. /**
  61529. * Creates a cube texture where the raw buffers are passed in.
  61530. * @param scene defines the scene the texture is attached to
  61531. * @param data defines the array of data to use to create each face
  61532. * @param size defines the size of the textures
  61533. * @param format defines the format of the data
  61534. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  61535. * @param generateMipMaps defines if the engine should generate the mip levels
  61536. * @param invertY defines if data must be stored with Y axis inverted
  61537. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  61538. * @param compression defines the compression used (null by default)
  61539. */
  61540. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  61541. /**
  61542. * Updates the raw cube texture.
  61543. * @param data defines the data to store
  61544. * @param format defines the data format
  61545. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  61546. * @param invertY defines if data must be stored with Y axis inverted
  61547. * @param compression defines the compression used (null by default)
  61548. * @param level defines which level of the texture to update
  61549. */
  61550. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  61551. /**
  61552. * Updates a raw cube texture with RGBD encoded data.
  61553. * @param data defines the array of data [mipmap][face] to use to create each face
  61554. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  61555. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  61556. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  61557. * @returns a promsie that resolves when the operation is complete
  61558. */
  61559. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  61560. /**
  61561. * Clones the raw cube texture.
  61562. * @return a new cube texture
  61563. */
  61564. clone(): CubeTexture;
  61565. /** @hidden */
  61566. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  61567. }
  61568. }
  61569. declare module BABYLON {
  61570. /**
  61571. * Class used to store 2D array textures containing user data
  61572. */
  61573. export class RawTexture2DArray extends Texture {
  61574. /** Gets or sets the texture format to use */
  61575. format: number;
  61576. /**
  61577. * Create a new RawTexture2DArray
  61578. * @param data defines the data of the texture
  61579. * @param width defines the width of the texture
  61580. * @param height defines the height of the texture
  61581. * @param depth defines the number of layers of the texture
  61582. * @param format defines the texture format to use
  61583. * @param scene defines the hosting scene
  61584. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  61585. * @param invertY defines if texture must be stored with Y axis inverted
  61586. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61587. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  61588. */
  61589. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  61590. /** Gets or sets the texture format to use */
  61591. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  61592. /**
  61593. * Update the texture with new data
  61594. * @param data defines the data to store in the texture
  61595. */
  61596. update(data: ArrayBufferView): void;
  61597. }
  61598. }
  61599. declare module BABYLON {
  61600. /**
  61601. * Class used to store 3D textures containing user data
  61602. */
  61603. export class RawTexture3D extends Texture {
  61604. /** Gets or sets the texture format to use */
  61605. format: number;
  61606. /**
  61607. * Create a new RawTexture3D
  61608. * @param data defines the data of the texture
  61609. * @param width defines the width of the texture
  61610. * @param height defines the height of the texture
  61611. * @param depth defines the depth of the texture
  61612. * @param format defines the texture format to use
  61613. * @param scene defines the hosting scene
  61614. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  61615. * @param invertY defines if texture must be stored with Y axis inverted
  61616. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61617. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  61618. */
  61619. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  61620. /** Gets or sets the texture format to use */
  61621. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  61622. /**
  61623. * Update the texture with new data
  61624. * @param data defines the data to store in the texture
  61625. */
  61626. update(data: ArrayBufferView): void;
  61627. }
  61628. }
  61629. declare module BABYLON {
  61630. /**
  61631. * Creates a refraction texture used by refraction channel of the standard material.
  61632. * It is like a mirror but to see through a material.
  61633. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61634. */
  61635. export class RefractionTexture extends RenderTargetTexture {
  61636. /**
  61637. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  61638. * 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.
  61639. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61640. */
  61641. refractionPlane: Plane;
  61642. /**
  61643. * Define how deep under the surface we should see.
  61644. */
  61645. depth: number;
  61646. /**
  61647. * Creates a refraction texture used by refraction channel of the standard material.
  61648. * It is like a mirror but to see through a material.
  61649. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61650. * @param name Define the texture name
  61651. * @param size Define the size of the underlying texture
  61652. * @param scene Define the scene the refraction belongs to
  61653. * @param generateMipMaps Define if we need to generate mips level for the refraction
  61654. */
  61655. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  61656. /**
  61657. * Clone the refraction texture.
  61658. * @returns the cloned texture
  61659. */
  61660. clone(): RefractionTexture;
  61661. /**
  61662. * Serialize the texture to a JSON representation you could use in Parse later on
  61663. * @returns the serialized JSON representation
  61664. */
  61665. serialize(): any;
  61666. }
  61667. }
  61668. declare module BABYLON {
  61669. /**
  61670. * Block used to add support for vertex skinning (bones)
  61671. */
  61672. export class BonesBlock extends NodeMaterialBlock {
  61673. /**
  61674. * Creates a new BonesBlock
  61675. * @param name defines the block name
  61676. */
  61677. constructor(name: string);
  61678. /**
  61679. * Initialize the block and prepare the context for build
  61680. * @param state defines the state that will be used for the build
  61681. */
  61682. initialize(state: NodeMaterialBuildState): void;
  61683. /**
  61684. * Gets the current class name
  61685. * @returns the class name
  61686. */
  61687. getClassName(): string;
  61688. /**
  61689. * Gets the matrix indices input component
  61690. */
  61691. get matricesIndices(): NodeMaterialConnectionPoint;
  61692. /**
  61693. * Gets the matrix weights input component
  61694. */
  61695. get matricesWeights(): NodeMaterialConnectionPoint;
  61696. /**
  61697. * Gets the extra matrix indices input component
  61698. */
  61699. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  61700. /**
  61701. * Gets the extra matrix weights input component
  61702. */
  61703. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  61704. /**
  61705. * Gets the world input component
  61706. */
  61707. get world(): NodeMaterialConnectionPoint;
  61708. /**
  61709. * Gets the output component
  61710. */
  61711. get output(): NodeMaterialConnectionPoint;
  61712. autoConfigure(material: NodeMaterial): void;
  61713. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61714. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61715. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61716. protected _buildBlock(state: NodeMaterialBuildState): this;
  61717. }
  61718. }
  61719. declare module BABYLON {
  61720. /**
  61721. * Block used to add support for instances
  61722. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  61723. */
  61724. export class InstancesBlock extends NodeMaterialBlock {
  61725. /**
  61726. * Creates a new InstancesBlock
  61727. * @param name defines the block name
  61728. */
  61729. constructor(name: string);
  61730. /**
  61731. * Gets the current class name
  61732. * @returns the class name
  61733. */
  61734. getClassName(): string;
  61735. /**
  61736. * Gets the first world row input component
  61737. */
  61738. get world0(): NodeMaterialConnectionPoint;
  61739. /**
  61740. * Gets the second world row input component
  61741. */
  61742. get world1(): NodeMaterialConnectionPoint;
  61743. /**
  61744. * Gets the third world row input component
  61745. */
  61746. get world2(): NodeMaterialConnectionPoint;
  61747. /**
  61748. * Gets the forth world row input component
  61749. */
  61750. get world3(): NodeMaterialConnectionPoint;
  61751. /**
  61752. * Gets the world input component
  61753. */
  61754. get world(): NodeMaterialConnectionPoint;
  61755. /**
  61756. * Gets the output component
  61757. */
  61758. get output(): NodeMaterialConnectionPoint;
  61759. /**
  61760. * Gets the isntanceID component
  61761. */
  61762. get instanceID(): NodeMaterialConnectionPoint;
  61763. autoConfigure(material: NodeMaterial): void;
  61764. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  61765. protected _buildBlock(state: NodeMaterialBuildState): this;
  61766. }
  61767. }
  61768. declare module BABYLON {
  61769. /**
  61770. * Block used to add morph targets support to vertex shader
  61771. */
  61772. export class MorphTargetsBlock extends NodeMaterialBlock {
  61773. private _repeatableContentAnchor;
  61774. /**
  61775. * Create a new MorphTargetsBlock
  61776. * @param name defines the block name
  61777. */
  61778. constructor(name: string);
  61779. /**
  61780. * Gets the current class name
  61781. * @returns the class name
  61782. */
  61783. getClassName(): string;
  61784. /**
  61785. * Gets the position input component
  61786. */
  61787. get position(): NodeMaterialConnectionPoint;
  61788. /**
  61789. * Gets the normal input component
  61790. */
  61791. get normal(): NodeMaterialConnectionPoint;
  61792. /**
  61793. * Gets the tangent input component
  61794. */
  61795. get tangent(): NodeMaterialConnectionPoint;
  61796. /**
  61797. * Gets the tangent input component
  61798. */
  61799. get uv(): NodeMaterialConnectionPoint;
  61800. /**
  61801. * Gets the position output component
  61802. */
  61803. get positionOutput(): NodeMaterialConnectionPoint;
  61804. /**
  61805. * Gets the normal output component
  61806. */
  61807. get normalOutput(): NodeMaterialConnectionPoint;
  61808. /**
  61809. * Gets the tangent output component
  61810. */
  61811. get tangentOutput(): NodeMaterialConnectionPoint;
  61812. /**
  61813. * Gets the tangent output component
  61814. */
  61815. get uvOutput(): NodeMaterialConnectionPoint;
  61816. initialize(state: NodeMaterialBuildState): void;
  61817. autoConfigure(material: NodeMaterial): void;
  61818. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61819. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61820. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61821. protected _buildBlock(state: NodeMaterialBuildState): this;
  61822. }
  61823. }
  61824. declare module BABYLON {
  61825. /**
  61826. * Block used to get data information from a light
  61827. */
  61828. export class LightInformationBlock extends NodeMaterialBlock {
  61829. private _lightDataUniformName;
  61830. private _lightColorUniformName;
  61831. private _lightTypeDefineName;
  61832. /**
  61833. * Gets or sets the light associated with this block
  61834. */
  61835. light: Nullable<Light>;
  61836. /**
  61837. * Creates a new LightInformationBlock
  61838. * @param name defines the block name
  61839. */
  61840. constructor(name: string);
  61841. /**
  61842. * Gets the current class name
  61843. * @returns the class name
  61844. */
  61845. getClassName(): string;
  61846. /**
  61847. * Gets the world position input component
  61848. */
  61849. get worldPosition(): NodeMaterialConnectionPoint;
  61850. /**
  61851. * Gets the direction output component
  61852. */
  61853. get direction(): NodeMaterialConnectionPoint;
  61854. /**
  61855. * Gets the direction output component
  61856. */
  61857. get color(): NodeMaterialConnectionPoint;
  61858. /**
  61859. * Gets the direction output component
  61860. */
  61861. get intensity(): NodeMaterialConnectionPoint;
  61862. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61863. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61864. protected _buildBlock(state: NodeMaterialBuildState): this;
  61865. serialize(): any;
  61866. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61867. }
  61868. }
  61869. declare module BABYLON {
  61870. /**
  61871. * Block used to add image processing support to fragment shader
  61872. */
  61873. export class ImageProcessingBlock extends NodeMaterialBlock {
  61874. /**
  61875. * Create a new ImageProcessingBlock
  61876. * @param name defines the block name
  61877. */
  61878. constructor(name: string);
  61879. /**
  61880. * Gets the current class name
  61881. * @returns the class name
  61882. */
  61883. getClassName(): string;
  61884. /**
  61885. * Gets the color input component
  61886. */
  61887. get color(): NodeMaterialConnectionPoint;
  61888. /**
  61889. * Gets the output component
  61890. */
  61891. get output(): NodeMaterialConnectionPoint;
  61892. /**
  61893. * Initialize the block and prepare the context for build
  61894. * @param state defines the state that will be used for the build
  61895. */
  61896. initialize(state: NodeMaterialBuildState): void;
  61897. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61898. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61899. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61900. protected _buildBlock(state: NodeMaterialBuildState): this;
  61901. }
  61902. }
  61903. declare module BABYLON {
  61904. /**
  61905. * Block used to pertub normals based on a normal map
  61906. */
  61907. export class PerturbNormalBlock extends NodeMaterialBlock {
  61908. private _tangentSpaceParameterName;
  61909. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61910. invertX: boolean;
  61911. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61912. invertY: boolean;
  61913. /**
  61914. * Create a new PerturbNormalBlock
  61915. * @param name defines the block name
  61916. */
  61917. constructor(name: string);
  61918. /**
  61919. * Gets the current class name
  61920. * @returns the class name
  61921. */
  61922. getClassName(): string;
  61923. /**
  61924. * Gets the world position input component
  61925. */
  61926. get worldPosition(): NodeMaterialConnectionPoint;
  61927. /**
  61928. * Gets the world normal input component
  61929. */
  61930. get worldNormal(): NodeMaterialConnectionPoint;
  61931. /**
  61932. * Gets the world tangent input component
  61933. */
  61934. get worldTangent(): NodeMaterialConnectionPoint;
  61935. /**
  61936. * Gets the uv input component
  61937. */
  61938. get uv(): NodeMaterialConnectionPoint;
  61939. /**
  61940. * Gets the normal map color input component
  61941. */
  61942. get normalMapColor(): NodeMaterialConnectionPoint;
  61943. /**
  61944. * Gets the strength input component
  61945. */
  61946. get strength(): NodeMaterialConnectionPoint;
  61947. /**
  61948. * Gets the output component
  61949. */
  61950. get output(): NodeMaterialConnectionPoint;
  61951. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61952. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61953. autoConfigure(material: NodeMaterial): void;
  61954. protected _buildBlock(state: NodeMaterialBuildState): this;
  61955. protected _dumpPropertiesCode(): string;
  61956. serialize(): any;
  61957. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61958. }
  61959. }
  61960. declare module BABYLON {
  61961. /**
  61962. * Block used to discard a pixel if a value is smaller than a cutoff
  61963. */
  61964. export class DiscardBlock extends NodeMaterialBlock {
  61965. /**
  61966. * Create a new DiscardBlock
  61967. * @param name defines the block name
  61968. */
  61969. constructor(name: string);
  61970. /**
  61971. * Gets the current class name
  61972. * @returns the class name
  61973. */
  61974. getClassName(): string;
  61975. /**
  61976. * Gets the color input component
  61977. */
  61978. get value(): NodeMaterialConnectionPoint;
  61979. /**
  61980. * Gets the cutoff input component
  61981. */
  61982. get cutoff(): NodeMaterialConnectionPoint;
  61983. protected _buildBlock(state: NodeMaterialBuildState): this;
  61984. }
  61985. }
  61986. declare module BABYLON {
  61987. /**
  61988. * Block used to test if the fragment shader is front facing
  61989. */
  61990. export class FrontFacingBlock extends NodeMaterialBlock {
  61991. /**
  61992. * Creates a new FrontFacingBlock
  61993. * @param name defines the block name
  61994. */
  61995. constructor(name: string);
  61996. /**
  61997. * Gets the current class name
  61998. * @returns the class name
  61999. */
  62000. getClassName(): string;
  62001. /**
  62002. * Gets the output component
  62003. */
  62004. get output(): NodeMaterialConnectionPoint;
  62005. protected _buildBlock(state: NodeMaterialBuildState): this;
  62006. }
  62007. }
  62008. declare module BABYLON {
  62009. /**
  62010. * Block used to get the derivative value on x and y of a given input
  62011. */
  62012. export class DerivativeBlock extends NodeMaterialBlock {
  62013. /**
  62014. * Create a new DerivativeBlock
  62015. * @param name defines the block name
  62016. */
  62017. constructor(name: string);
  62018. /**
  62019. * Gets the current class name
  62020. * @returns the class name
  62021. */
  62022. getClassName(): string;
  62023. /**
  62024. * Gets the input component
  62025. */
  62026. get input(): NodeMaterialConnectionPoint;
  62027. /**
  62028. * Gets the derivative output on x
  62029. */
  62030. get dx(): NodeMaterialConnectionPoint;
  62031. /**
  62032. * Gets the derivative output on y
  62033. */
  62034. get dy(): NodeMaterialConnectionPoint;
  62035. protected _buildBlock(state: NodeMaterialBuildState): this;
  62036. }
  62037. }
  62038. declare module BABYLON {
  62039. /**
  62040. * Block used to make gl_FragCoord available
  62041. */
  62042. export class FragCoordBlock extends NodeMaterialBlock {
  62043. /**
  62044. * Creates a new FragCoordBlock
  62045. * @param name defines the block name
  62046. */
  62047. constructor(name: string);
  62048. /**
  62049. * Gets the current class name
  62050. * @returns the class name
  62051. */
  62052. getClassName(): string;
  62053. /**
  62054. * Gets the xy component
  62055. */
  62056. get xy(): NodeMaterialConnectionPoint;
  62057. /**
  62058. * Gets the xyz component
  62059. */
  62060. get xyz(): NodeMaterialConnectionPoint;
  62061. /**
  62062. * Gets the xyzw component
  62063. */
  62064. get xyzw(): NodeMaterialConnectionPoint;
  62065. /**
  62066. * Gets the x component
  62067. */
  62068. get x(): NodeMaterialConnectionPoint;
  62069. /**
  62070. * Gets the y component
  62071. */
  62072. get y(): NodeMaterialConnectionPoint;
  62073. /**
  62074. * Gets the z component
  62075. */
  62076. get z(): NodeMaterialConnectionPoint;
  62077. /**
  62078. * Gets the w component
  62079. */
  62080. get output(): NodeMaterialConnectionPoint;
  62081. protected writeOutputs(state: NodeMaterialBuildState): string;
  62082. protected _buildBlock(state: NodeMaterialBuildState): this;
  62083. }
  62084. }
  62085. declare module BABYLON {
  62086. /**
  62087. * Block used to get the screen sizes
  62088. */
  62089. export class ScreenSizeBlock extends NodeMaterialBlock {
  62090. private _varName;
  62091. private _scene;
  62092. /**
  62093. * Creates a new ScreenSizeBlock
  62094. * @param name defines the block name
  62095. */
  62096. constructor(name: string);
  62097. /**
  62098. * Gets the current class name
  62099. * @returns the class name
  62100. */
  62101. getClassName(): string;
  62102. /**
  62103. * Gets the xy component
  62104. */
  62105. get xy(): NodeMaterialConnectionPoint;
  62106. /**
  62107. * Gets the x component
  62108. */
  62109. get x(): NodeMaterialConnectionPoint;
  62110. /**
  62111. * Gets the y component
  62112. */
  62113. get y(): NodeMaterialConnectionPoint;
  62114. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62115. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  62116. protected _buildBlock(state: NodeMaterialBuildState): this;
  62117. }
  62118. }
  62119. declare module BABYLON {
  62120. /**
  62121. * Block used to add support for scene fog
  62122. */
  62123. export class FogBlock extends NodeMaterialBlock {
  62124. private _fogDistanceName;
  62125. private _fogParameters;
  62126. /**
  62127. * Create a new FogBlock
  62128. * @param name defines the block name
  62129. */
  62130. constructor(name: string);
  62131. /**
  62132. * Gets the current class name
  62133. * @returns the class name
  62134. */
  62135. getClassName(): string;
  62136. /**
  62137. * Gets the world position input component
  62138. */
  62139. get worldPosition(): NodeMaterialConnectionPoint;
  62140. /**
  62141. * Gets the view input component
  62142. */
  62143. get view(): NodeMaterialConnectionPoint;
  62144. /**
  62145. * Gets the color input component
  62146. */
  62147. get input(): NodeMaterialConnectionPoint;
  62148. /**
  62149. * Gets the fog color input component
  62150. */
  62151. get fogColor(): NodeMaterialConnectionPoint;
  62152. /**
  62153. * Gets the output component
  62154. */
  62155. get output(): NodeMaterialConnectionPoint;
  62156. autoConfigure(material: NodeMaterial): void;
  62157. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62158. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62159. protected _buildBlock(state: NodeMaterialBuildState): this;
  62160. }
  62161. }
  62162. declare module BABYLON {
  62163. /**
  62164. * Block used to add light in the fragment shader
  62165. */
  62166. export class LightBlock extends NodeMaterialBlock {
  62167. private _lightId;
  62168. /**
  62169. * Gets or sets the light associated with this block
  62170. */
  62171. light: Nullable<Light>;
  62172. /**
  62173. * Create a new LightBlock
  62174. * @param name defines the block name
  62175. */
  62176. constructor(name: string);
  62177. /**
  62178. * Gets the current class name
  62179. * @returns the class name
  62180. */
  62181. getClassName(): string;
  62182. /**
  62183. * Gets the world position input component
  62184. */
  62185. get worldPosition(): NodeMaterialConnectionPoint;
  62186. /**
  62187. * Gets the world normal input component
  62188. */
  62189. get worldNormal(): NodeMaterialConnectionPoint;
  62190. /**
  62191. * Gets the camera (or eye) position component
  62192. */
  62193. get cameraPosition(): NodeMaterialConnectionPoint;
  62194. /**
  62195. * Gets the glossiness component
  62196. */
  62197. get glossiness(): NodeMaterialConnectionPoint;
  62198. /**
  62199. * Gets the glossinness power component
  62200. */
  62201. get glossPower(): NodeMaterialConnectionPoint;
  62202. /**
  62203. * Gets the diffuse color component
  62204. */
  62205. get diffuseColor(): NodeMaterialConnectionPoint;
  62206. /**
  62207. * Gets the specular color component
  62208. */
  62209. get specularColor(): NodeMaterialConnectionPoint;
  62210. /**
  62211. * Gets the diffuse output component
  62212. */
  62213. get diffuseOutput(): NodeMaterialConnectionPoint;
  62214. /**
  62215. * Gets the specular output component
  62216. */
  62217. get specularOutput(): NodeMaterialConnectionPoint;
  62218. /**
  62219. * Gets the shadow output component
  62220. */
  62221. get shadow(): NodeMaterialConnectionPoint;
  62222. autoConfigure(material: NodeMaterial): void;
  62223. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62224. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  62225. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62226. private _injectVertexCode;
  62227. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62228. serialize(): any;
  62229. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62230. }
  62231. }
  62232. declare module BABYLON {
  62233. /**
  62234. * Block used to read a reflection texture from a sampler
  62235. */
  62236. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  62237. /**
  62238. * Create a new ReflectionTextureBlock
  62239. * @param name defines the block name
  62240. */
  62241. constructor(name: string);
  62242. /**
  62243. * Gets the current class name
  62244. * @returns the class name
  62245. */
  62246. getClassName(): string;
  62247. /**
  62248. * Gets the world position input component
  62249. */
  62250. get position(): NodeMaterialConnectionPoint;
  62251. /**
  62252. * Gets the world position input component
  62253. */
  62254. get worldPosition(): NodeMaterialConnectionPoint;
  62255. /**
  62256. * Gets the world normal input component
  62257. */
  62258. get worldNormal(): NodeMaterialConnectionPoint;
  62259. /**
  62260. * Gets the world input component
  62261. */
  62262. get world(): NodeMaterialConnectionPoint;
  62263. /**
  62264. * Gets the camera (or eye) position component
  62265. */
  62266. get cameraPosition(): NodeMaterialConnectionPoint;
  62267. /**
  62268. * Gets the view input component
  62269. */
  62270. get view(): NodeMaterialConnectionPoint;
  62271. /**
  62272. * Gets the rgb output component
  62273. */
  62274. get rgb(): NodeMaterialConnectionPoint;
  62275. /**
  62276. * Gets the rgba output component
  62277. */
  62278. get rgba(): NodeMaterialConnectionPoint;
  62279. /**
  62280. * Gets the r output component
  62281. */
  62282. get r(): NodeMaterialConnectionPoint;
  62283. /**
  62284. * Gets the g output component
  62285. */
  62286. get g(): NodeMaterialConnectionPoint;
  62287. /**
  62288. * Gets the b output component
  62289. */
  62290. get b(): NodeMaterialConnectionPoint;
  62291. /**
  62292. * Gets the a output component
  62293. */
  62294. get a(): NodeMaterialConnectionPoint;
  62295. autoConfigure(material: NodeMaterial): void;
  62296. protected _buildBlock(state: NodeMaterialBuildState): this;
  62297. }
  62298. }
  62299. declare module BABYLON {
  62300. /**
  62301. * Block used to add 2 vectors
  62302. */
  62303. export class AddBlock extends NodeMaterialBlock {
  62304. /**
  62305. * Creates a new AddBlock
  62306. * @param name defines the block name
  62307. */
  62308. constructor(name: string);
  62309. /**
  62310. * Gets the current class name
  62311. * @returns the class name
  62312. */
  62313. getClassName(): string;
  62314. /**
  62315. * Gets the left operand input component
  62316. */
  62317. get left(): NodeMaterialConnectionPoint;
  62318. /**
  62319. * Gets the right operand input component
  62320. */
  62321. get right(): NodeMaterialConnectionPoint;
  62322. /**
  62323. * Gets the output component
  62324. */
  62325. get output(): NodeMaterialConnectionPoint;
  62326. protected _buildBlock(state: NodeMaterialBuildState): this;
  62327. }
  62328. }
  62329. declare module BABYLON {
  62330. /**
  62331. * Block used to scale a vector by a float
  62332. */
  62333. export class ScaleBlock extends NodeMaterialBlock {
  62334. /**
  62335. * Creates a new ScaleBlock
  62336. * @param name defines the block name
  62337. */
  62338. constructor(name: string);
  62339. /**
  62340. * Gets the current class name
  62341. * @returns the class name
  62342. */
  62343. getClassName(): string;
  62344. /**
  62345. * Gets the input component
  62346. */
  62347. get input(): NodeMaterialConnectionPoint;
  62348. /**
  62349. * Gets the factor input component
  62350. */
  62351. get factor(): NodeMaterialConnectionPoint;
  62352. /**
  62353. * Gets the output component
  62354. */
  62355. get output(): NodeMaterialConnectionPoint;
  62356. protected _buildBlock(state: NodeMaterialBuildState): this;
  62357. }
  62358. }
  62359. declare module BABYLON {
  62360. /**
  62361. * Block used to clamp a float
  62362. */
  62363. export class ClampBlock extends NodeMaterialBlock {
  62364. /** Gets or sets the minimum range */
  62365. minimum: number;
  62366. /** Gets or sets the maximum range */
  62367. maximum: number;
  62368. /**
  62369. * Creates a new ClampBlock
  62370. * @param name defines the block name
  62371. */
  62372. constructor(name: string);
  62373. /**
  62374. * Gets the current class name
  62375. * @returns the class name
  62376. */
  62377. getClassName(): string;
  62378. /**
  62379. * Gets the value input component
  62380. */
  62381. get value(): NodeMaterialConnectionPoint;
  62382. /**
  62383. * Gets the output component
  62384. */
  62385. get output(): NodeMaterialConnectionPoint;
  62386. protected _buildBlock(state: NodeMaterialBuildState): this;
  62387. protected _dumpPropertiesCode(): string;
  62388. serialize(): any;
  62389. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62390. }
  62391. }
  62392. declare module BABYLON {
  62393. /**
  62394. * Block used to apply a cross product between 2 vectors
  62395. */
  62396. export class CrossBlock extends NodeMaterialBlock {
  62397. /**
  62398. * Creates a new CrossBlock
  62399. * @param name defines the block name
  62400. */
  62401. constructor(name: string);
  62402. /**
  62403. * Gets the current class name
  62404. * @returns the class name
  62405. */
  62406. getClassName(): string;
  62407. /**
  62408. * Gets the left operand input component
  62409. */
  62410. get left(): NodeMaterialConnectionPoint;
  62411. /**
  62412. * Gets the right operand input component
  62413. */
  62414. get right(): NodeMaterialConnectionPoint;
  62415. /**
  62416. * Gets the output component
  62417. */
  62418. get output(): NodeMaterialConnectionPoint;
  62419. protected _buildBlock(state: NodeMaterialBuildState): this;
  62420. }
  62421. }
  62422. declare module BABYLON {
  62423. /**
  62424. * Block used to apply a dot product between 2 vectors
  62425. */
  62426. export class DotBlock extends NodeMaterialBlock {
  62427. /**
  62428. * Creates a new DotBlock
  62429. * @param name defines the block name
  62430. */
  62431. constructor(name: string);
  62432. /**
  62433. * Gets the current class name
  62434. * @returns the class name
  62435. */
  62436. getClassName(): string;
  62437. /**
  62438. * Gets the left operand input component
  62439. */
  62440. get left(): NodeMaterialConnectionPoint;
  62441. /**
  62442. * Gets the right operand input component
  62443. */
  62444. get right(): NodeMaterialConnectionPoint;
  62445. /**
  62446. * Gets the output component
  62447. */
  62448. get output(): NodeMaterialConnectionPoint;
  62449. protected _buildBlock(state: NodeMaterialBuildState): this;
  62450. }
  62451. }
  62452. declare module BABYLON {
  62453. /**
  62454. * Block used to normalize a vector
  62455. */
  62456. export class NormalizeBlock extends NodeMaterialBlock {
  62457. /**
  62458. * Creates a new NormalizeBlock
  62459. * @param name defines the block name
  62460. */
  62461. constructor(name: string);
  62462. /**
  62463. * Gets the current class name
  62464. * @returns the class name
  62465. */
  62466. getClassName(): string;
  62467. /**
  62468. * Gets the input component
  62469. */
  62470. get input(): NodeMaterialConnectionPoint;
  62471. /**
  62472. * Gets the output component
  62473. */
  62474. get output(): NodeMaterialConnectionPoint;
  62475. protected _buildBlock(state: NodeMaterialBuildState): this;
  62476. }
  62477. }
  62478. declare module BABYLON {
  62479. /**
  62480. * Operations supported by the Trigonometry block
  62481. */
  62482. export enum TrigonometryBlockOperations {
  62483. /** Cos */
  62484. Cos = 0,
  62485. /** Sin */
  62486. Sin = 1,
  62487. /** Abs */
  62488. Abs = 2,
  62489. /** Exp */
  62490. Exp = 3,
  62491. /** Exp2 */
  62492. Exp2 = 4,
  62493. /** Round */
  62494. Round = 5,
  62495. /** Floor */
  62496. Floor = 6,
  62497. /** Ceiling */
  62498. Ceiling = 7,
  62499. /** Square root */
  62500. Sqrt = 8,
  62501. /** Log */
  62502. Log = 9,
  62503. /** Tangent */
  62504. Tan = 10,
  62505. /** Arc tangent */
  62506. ArcTan = 11,
  62507. /** Arc cosinus */
  62508. ArcCos = 12,
  62509. /** Arc sinus */
  62510. ArcSin = 13,
  62511. /** Fraction */
  62512. Fract = 14,
  62513. /** Sign */
  62514. Sign = 15,
  62515. /** To radians (from degrees) */
  62516. Radians = 16,
  62517. /** To degrees (from radians) */
  62518. Degrees = 17
  62519. }
  62520. /**
  62521. * Block used to apply trigonometry operation to floats
  62522. */
  62523. export class TrigonometryBlock extends NodeMaterialBlock {
  62524. /**
  62525. * Gets or sets the operation applied by the block
  62526. */
  62527. operation: TrigonometryBlockOperations;
  62528. /**
  62529. * Creates a new TrigonometryBlock
  62530. * @param name defines the block name
  62531. */
  62532. constructor(name: string);
  62533. /**
  62534. * Gets the current class name
  62535. * @returns the class name
  62536. */
  62537. getClassName(): string;
  62538. /**
  62539. * Gets the input component
  62540. */
  62541. get input(): NodeMaterialConnectionPoint;
  62542. /**
  62543. * Gets the output component
  62544. */
  62545. get output(): NodeMaterialConnectionPoint;
  62546. protected _buildBlock(state: NodeMaterialBuildState): this;
  62547. serialize(): any;
  62548. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62549. protected _dumpPropertiesCode(): string;
  62550. }
  62551. }
  62552. declare module BABYLON {
  62553. /**
  62554. * Block used to create a Color3/4 out of individual inputs (one for each component)
  62555. */
  62556. export class ColorMergerBlock extends NodeMaterialBlock {
  62557. /**
  62558. * Create a new ColorMergerBlock
  62559. * @param name defines the block name
  62560. */
  62561. constructor(name: string);
  62562. /**
  62563. * Gets the current class name
  62564. * @returns the class name
  62565. */
  62566. getClassName(): string;
  62567. /**
  62568. * Gets the rgb component (input)
  62569. */
  62570. get rgbIn(): NodeMaterialConnectionPoint;
  62571. /**
  62572. * Gets the r component (input)
  62573. */
  62574. get r(): NodeMaterialConnectionPoint;
  62575. /**
  62576. * Gets the g component (input)
  62577. */
  62578. get g(): NodeMaterialConnectionPoint;
  62579. /**
  62580. * Gets the b component (input)
  62581. */
  62582. get b(): NodeMaterialConnectionPoint;
  62583. /**
  62584. * Gets the a component (input)
  62585. */
  62586. get a(): NodeMaterialConnectionPoint;
  62587. /**
  62588. * Gets the rgba component (output)
  62589. */
  62590. get rgba(): NodeMaterialConnectionPoint;
  62591. /**
  62592. * Gets the rgb component (output)
  62593. */
  62594. get rgbOut(): NodeMaterialConnectionPoint;
  62595. /**
  62596. * Gets the rgb component (output)
  62597. * @deprecated Please use rgbOut instead.
  62598. */
  62599. get rgb(): NodeMaterialConnectionPoint;
  62600. protected _buildBlock(state: NodeMaterialBuildState): this;
  62601. }
  62602. }
  62603. declare module BABYLON {
  62604. /**
  62605. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  62606. */
  62607. export class VectorSplitterBlock extends NodeMaterialBlock {
  62608. /**
  62609. * Create a new VectorSplitterBlock
  62610. * @param name defines the block name
  62611. */
  62612. constructor(name: string);
  62613. /**
  62614. * Gets the current class name
  62615. * @returns the class name
  62616. */
  62617. getClassName(): string;
  62618. /**
  62619. * Gets the xyzw component (input)
  62620. */
  62621. get xyzw(): NodeMaterialConnectionPoint;
  62622. /**
  62623. * Gets the xyz component (input)
  62624. */
  62625. get xyzIn(): NodeMaterialConnectionPoint;
  62626. /**
  62627. * Gets the xy component (input)
  62628. */
  62629. get xyIn(): NodeMaterialConnectionPoint;
  62630. /**
  62631. * Gets the xyz component (output)
  62632. */
  62633. get xyzOut(): NodeMaterialConnectionPoint;
  62634. /**
  62635. * Gets the xy component (output)
  62636. */
  62637. get xyOut(): NodeMaterialConnectionPoint;
  62638. /**
  62639. * Gets the x component (output)
  62640. */
  62641. get x(): NodeMaterialConnectionPoint;
  62642. /**
  62643. * Gets the y component (output)
  62644. */
  62645. get y(): NodeMaterialConnectionPoint;
  62646. /**
  62647. * Gets the z component (output)
  62648. */
  62649. get z(): NodeMaterialConnectionPoint;
  62650. /**
  62651. * Gets the w component (output)
  62652. */
  62653. get w(): NodeMaterialConnectionPoint;
  62654. protected _inputRename(name: string): string;
  62655. protected _outputRename(name: string): string;
  62656. protected _buildBlock(state: NodeMaterialBuildState): this;
  62657. }
  62658. }
  62659. declare module BABYLON {
  62660. /**
  62661. * Block used to lerp between 2 values
  62662. */
  62663. export class LerpBlock extends NodeMaterialBlock {
  62664. /**
  62665. * Creates a new LerpBlock
  62666. * @param name defines the block name
  62667. */
  62668. constructor(name: string);
  62669. /**
  62670. * Gets the current class name
  62671. * @returns the class name
  62672. */
  62673. getClassName(): string;
  62674. /**
  62675. * Gets the left operand input component
  62676. */
  62677. get left(): NodeMaterialConnectionPoint;
  62678. /**
  62679. * Gets the right operand input component
  62680. */
  62681. get right(): NodeMaterialConnectionPoint;
  62682. /**
  62683. * Gets the gradient operand input component
  62684. */
  62685. get gradient(): NodeMaterialConnectionPoint;
  62686. /**
  62687. * Gets the output component
  62688. */
  62689. get output(): NodeMaterialConnectionPoint;
  62690. protected _buildBlock(state: NodeMaterialBuildState): this;
  62691. }
  62692. }
  62693. declare module BABYLON {
  62694. /**
  62695. * Block used to divide 2 vectors
  62696. */
  62697. export class DivideBlock extends NodeMaterialBlock {
  62698. /**
  62699. * Creates a new DivideBlock
  62700. * @param name defines the block name
  62701. */
  62702. constructor(name: string);
  62703. /**
  62704. * Gets the current class name
  62705. * @returns the class name
  62706. */
  62707. getClassName(): string;
  62708. /**
  62709. * Gets the left operand input component
  62710. */
  62711. get left(): NodeMaterialConnectionPoint;
  62712. /**
  62713. * Gets the right operand input component
  62714. */
  62715. get right(): NodeMaterialConnectionPoint;
  62716. /**
  62717. * Gets the output component
  62718. */
  62719. get output(): NodeMaterialConnectionPoint;
  62720. protected _buildBlock(state: NodeMaterialBuildState): this;
  62721. }
  62722. }
  62723. declare module BABYLON {
  62724. /**
  62725. * Block used to subtract 2 vectors
  62726. */
  62727. export class SubtractBlock extends NodeMaterialBlock {
  62728. /**
  62729. * Creates a new SubtractBlock
  62730. * @param name defines the block name
  62731. */
  62732. constructor(name: string);
  62733. /**
  62734. * Gets the current class name
  62735. * @returns the class name
  62736. */
  62737. getClassName(): string;
  62738. /**
  62739. * Gets the left operand input component
  62740. */
  62741. get left(): NodeMaterialConnectionPoint;
  62742. /**
  62743. * Gets the right operand input component
  62744. */
  62745. get right(): NodeMaterialConnectionPoint;
  62746. /**
  62747. * Gets the output component
  62748. */
  62749. get output(): NodeMaterialConnectionPoint;
  62750. protected _buildBlock(state: NodeMaterialBuildState): this;
  62751. }
  62752. }
  62753. declare module BABYLON {
  62754. /**
  62755. * Block used to step a value
  62756. */
  62757. export class StepBlock extends NodeMaterialBlock {
  62758. /**
  62759. * Creates a new StepBlock
  62760. * @param name defines the block name
  62761. */
  62762. constructor(name: string);
  62763. /**
  62764. * Gets the current class name
  62765. * @returns the class name
  62766. */
  62767. getClassName(): string;
  62768. /**
  62769. * Gets the value operand input component
  62770. */
  62771. get value(): NodeMaterialConnectionPoint;
  62772. /**
  62773. * Gets the edge operand input component
  62774. */
  62775. get edge(): NodeMaterialConnectionPoint;
  62776. /**
  62777. * Gets the output component
  62778. */
  62779. get output(): NodeMaterialConnectionPoint;
  62780. protected _buildBlock(state: NodeMaterialBuildState): this;
  62781. }
  62782. }
  62783. declare module BABYLON {
  62784. /**
  62785. * Block used to get the opposite (1 - x) of a value
  62786. */
  62787. export class OneMinusBlock extends NodeMaterialBlock {
  62788. /**
  62789. * Creates a new OneMinusBlock
  62790. * @param name defines the block name
  62791. */
  62792. constructor(name: string);
  62793. /**
  62794. * Gets the current class name
  62795. * @returns the class name
  62796. */
  62797. getClassName(): string;
  62798. /**
  62799. * Gets the input component
  62800. */
  62801. get input(): NodeMaterialConnectionPoint;
  62802. /**
  62803. * Gets the output component
  62804. */
  62805. get output(): NodeMaterialConnectionPoint;
  62806. protected _buildBlock(state: NodeMaterialBuildState): this;
  62807. }
  62808. }
  62809. declare module BABYLON {
  62810. /**
  62811. * Block used to get the view direction
  62812. */
  62813. export class ViewDirectionBlock extends NodeMaterialBlock {
  62814. /**
  62815. * Creates a new ViewDirectionBlock
  62816. * @param name defines the block name
  62817. */
  62818. constructor(name: string);
  62819. /**
  62820. * Gets the current class name
  62821. * @returns the class name
  62822. */
  62823. getClassName(): string;
  62824. /**
  62825. * Gets the world position component
  62826. */
  62827. get worldPosition(): NodeMaterialConnectionPoint;
  62828. /**
  62829. * Gets the camera position component
  62830. */
  62831. get cameraPosition(): NodeMaterialConnectionPoint;
  62832. /**
  62833. * Gets the output component
  62834. */
  62835. get output(): NodeMaterialConnectionPoint;
  62836. autoConfigure(material: NodeMaterial): void;
  62837. protected _buildBlock(state: NodeMaterialBuildState): this;
  62838. }
  62839. }
  62840. declare module BABYLON {
  62841. /**
  62842. * Block used to compute fresnel value
  62843. */
  62844. export class FresnelBlock extends NodeMaterialBlock {
  62845. /**
  62846. * Create a new FresnelBlock
  62847. * @param name defines the block name
  62848. */
  62849. constructor(name: string);
  62850. /**
  62851. * Gets the current class name
  62852. * @returns the class name
  62853. */
  62854. getClassName(): string;
  62855. /**
  62856. * Gets the world normal input component
  62857. */
  62858. get worldNormal(): NodeMaterialConnectionPoint;
  62859. /**
  62860. * Gets the view direction input component
  62861. */
  62862. get viewDirection(): NodeMaterialConnectionPoint;
  62863. /**
  62864. * Gets the bias input component
  62865. */
  62866. get bias(): NodeMaterialConnectionPoint;
  62867. /**
  62868. * Gets the camera (or eye) position component
  62869. */
  62870. get power(): NodeMaterialConnectionPoint;
  62871. /**
  62872. * Gets the fresnel output component
  62873. */
  62874. get fresnel(): NodeMaterialConnectionPoint;
  62875. autoConfigure(material: NodeMaterial): void;
  62876. protected _buildBlock(state: NodeMaterialBuildState): this;
  62877. }
  62878. }
  62879. declare module BABYLON {
  62880. /**
  62881. * Block used to get the max of 2 values
  62882. */
  62883. export class MaxBlock extends NodeMaterialBlock {
  62884. /**
  62885. * Creates a new MaxBlock
  62886. * @param name defines the block name
  62887. */
  62888. constructor(name: string);
  62889. /**
  62890. * Gets the current class name
  62891. * @returns the class name
  62892. */
  62893. getClassName(): string;
  62894. /**
  62895. * Gets the left operand input component
  62896. */
  62897. get left(): NodeMaterialConnectionPoint;
  62898. /**
  62899. * Gets the right operand input component
  62900. */
  62901. get right(): NodeMaterialConnectionPoint;
  62902. /**
  62903. * Gets the output component
  62904. */
  62905. get output(): NodeMaterialConnectionPoint;
  62906. protected _buildBlock(state: NodeMaterialBuildState): this;
  62907. }
  62908. }
  62909. declare module BABYLON {
  62910. /**
  62911. * Block used to get the min of 2 values
  62912. */
  62913. export class MinBlock extends NodeMaterialBlock {
  62914. /**
  62915. * Creates a new MinBlock
  62916. * @param name defines the block name
  62917. */
  62918. constructor(name: string);
  62919. /**
  62920. * Gets the current class name
  62921. * @returns the class name
  62922. */
  62923. getClassName(): string;
  62924. /**
  62925. * Gets the left operand input component
  62926. */
  62927. get left(): NodeMaterialConnectionPoint;
  62928. /**
  62929. * Gets the right operand input component
  62930. */
  62931. get right(): NodeMaterialConnectionPoint;
  62932. /**
  62933. * Gets the output component
  62934. */
  62935. get output(): NodeMaterialConnectionPoint;
  62936. protected _buildBlock(state: NodeMaterialBuildState): this;
  62937. }
  62938. }
  62939. declare module BABYLON {
  62940. /**
  62941. * Block used to get the distance between 2 values
  62942. */
  62943. export class DistanceBlock extends NodeMaterialBlock {
  62944. /**
  62945. * Creates a new DistanceBlock
  62946. * @param name defines the block name
  62947. */
  62948. constructor(name: string);
  62949. /**
  62950. * Gets the current class name
  62951. * @returns the class name
  62952. */
  62953. getClassName(): string;
  62954. /**
  62955. * Gets the left operand input component
  62956. */
  62957. get left(): NodeMaterialConnectionPoint;
  62958. /**
  62959. * Gets the right operand input component
  62960. */
  62961. get right(): NodeMaterialConnectionPoint;
  62962. /**
  62963. * Gets the output component
  62964. */
  62965. get output(): NodeMaterialConnectionPoint;
  62966. protected _buildBlock(state: NodeMaterialBuildState): this;
  62967. }
  62968. }
  62969. declare module BABYLON {
  62970. /**
  62971. * Block used to get the length of a vector
  62972. */
  62973. export class LengthBlock extends NodeMaterialBlock {
  62974. /**
  62975. * Creates a new LengthBlock
  62976. * @param name defines the block name
  62977. */
  62978. constructor(name: string);
  62979. /**
  62980. * Gets the current class name
  62981. * @returns the class name
  62982. */
  62983. getClassName(): string;
  62984. /**
  62985. * Gets the value input component
  62986. */
  62987. get value(): NodeMaterialConnectionPoint;
  62988. /**
  62989. * Gets the output component
  62990. */
  62991. get output(): NodeMaterialConnectionPoint;
  62992. protected _buildBlock(state: NodeMaterialBuildState): this;
  62993. }
  62994. }
  62995. declare module BABYLON {
  62996. /**
  62997. * Block used to get negative version of a value (i.e. x * -1)
  62998. */
  62999. export class NegateBlock extends NodeMaterialBlock {
  63000. /**
  63001. * Creates a new NegateBlock
  63002. * @param name defines the block name
  63003. */
  63004. constructor(name: string);
  63005. /**
  63006. * Gets the current class name
  63007. * @returns the class name
  63008. */
  63009. getClassName(): string;
  63010. /**
  63011. * Gets the value input component
  63012. */
  63013. get value(): NodeMaterialConnectionPoint;
  63014. /**
  63015. * Gets the output component
  63016. */
  63017. get output(): NodeMaterialConnectionPoint;
  63018. protected _buildBlock(state: NodeMaterialBuildState): this;
  63019. }
  63020. }
  63021. declare module BABYLON {
  63022. /**
  63023. * Block used to get the value of the first parameter raised to the power of the second
  63024. */
  63025. export class PowBlock extends NodeMaterialBlock {
  63026. /**
  63027. * Creates a new PowBlock
  63028. * @param name defines the block name
  63029. */
  63030. constructor(name: string);
  63031. /**
  63032. * Gets the current class name
  63033. * @returns the class name
  63034. */
  63035. getClassName(): string;
  63036. /**
  63037. * Gets the value operand input component
  63038. */
  63039. get value(): NodeMaterialConnectionPoint;
  63040. /**
  63041. * Gets the power operand input component
  63042. */
  63043. get power(): NodeMaterialConnectionPoint;
  63044. /**
  63045. * Gets the output component
  63046. */
  63047. get output(): NodeMaterialConnectionPoint;
  63048. protected _buildBlock(state: NodeMaterialBuildState): this;
  63049. }
  63050. }
  63051. declare module BABYLON {
  63052. /**
  63053. * Block used to get a random number
  63054. */
  63055. export class RandomNumberBlock extends NodeMaterialBlock {
  63056. /**
  63057. * Creates a new RandomNumberBlock
  63058. * @param name defines the block name
  63059. */
  63060. constructor(name: string);
  63061. /**
  63062. * Gets the current class name
  63063. * @returns the class name
  63064. */
  63065. getClassName(): string;
  63066. /**
  63067. * Gets the seed input component
  63068. */
  63069. get seed(): NodeMaterialConnectionPoint;
  63070. /**
  63071. * Gets the output component
  63072. */
  63073. get output(): NodeMaterialConnectionPoint;
  63074. protected _buildBlock(state: NodeMaterialBuildState): this;
  63075. }
  63076. }
  63077. declare module BABYLON {
  63078. /**
  63079. * Block used to compute arc tangent of 2 values
  63080. */
  63081. export class ArcTan2Block extends NodeMaterialBlock {
  63082. /**
  63083. * Creates a new ArcTan2Block
  63084. * @param name defines the block name
  63085. */
  63086. constructor(name: string);
  63087. /**
  63088. * Gets the current class name
  63089. * @returns the class name
  63090. */
  63091. getClassName(): string;
  63092. /**
  63093. * Gets the x operand input component
  63094. */
  63095. get x(): NodeMaterialConnectionPoint;
  63096. /**
  63097. * Gets the y operand input component
  63098. */
  63099. get y(): NodeMaterialConnectionPoint;
  63100. /**
  63101. * Gets the output component
  63102. */
  63103. get output(): NodeMaterialConnectionPoint;
  63104. protected _buildBlock(state: NodeMaterialBuildState): this;
  63105. }
  63106. }
  63107. declare module BABYLON {
  63108. /**
  63109. * Block used to smooth step a value
  63110. */
  63111. export class SmoothStepBlock extends NodeMaterialBlock {
  63112. /**
  63113. * Creates a new SmoothStepBlock
  63114. * @param name defines the block name
  63115. */
  63116. constructor(name: string);
  63117. /**
  63118. * Gets the current class name
  63119. * @returns the class name
  63120. */
  63121. getClassName(): string;
  63122. /**
  63123. * Gets the value operand input component
  63124. */
  63125. get value(): NodeMaterialConnectionPoint;
  63126. /**
  63127. * Gets the first edge operand input component
  63128. */
  63129. get edge0(): NodeMaterialConnectionPoint;
  63130. /**
  63131. * Gets the second edge operand input component
  63132. */
  63133. get edge1(): NodeMaterialConnectionPoint;
  63134. /**
  63135. * Gets the output component
  63136. */
  63137. get output(): NodeMaterialConnectionPoint;
  63138. protected _buildBlock(state: NodeMaterialBuildState): this;
  63139. }
  63140. }
  63141. declare module BABYLON {
  63142. /**
  63143. * Block used to get the reciprocal (1 / x) of a value
  63144. */
  63145. export class ReciprocalBlock extends NodeMaterialBlock {
  63146. /**
  63147. * Creates a new ReciprocalBlock
  63148. * @param name defines the block name
  63149. */
  63150. constructor(name: string);
  63151. /**
  63152. * Gets the current class name
  63153. * @returns the class name
  63154. */
  63155. getClassName(): string;
  63156. /**
  63157. * Gets the input component
  63158. */
  63159. get input(): NodeMaterialConnectionPoint;
  63160. /**
  63161. * Gets the output component
  63162. */
  63163. get output(): NodeMaterialConnectionPoint;
  63164. protected _buildBlock(state: NodeMaterialBuildState): this;
  63165. }
  63166. }
  63167. declare module BABYLON {
  63168. /**
  63169. * Block used to replace a color by another one
  63170. */
  63171. export class ReplaceColorBlock extends NodeMaterialBlock {
  63172. /**
  63173. * Creates a new ReplaceColorBlock
  63174. * @param name defines the block name
  63175. */
  63176. constructor(name: string);
  63177. /**
  63178. * Gets the current class name
  63179. * @returns the class name
  63180. */
  63181. getClassName(): string;
  63182. /**
  63183. * Gets the value input component
  63184. */
  63185. get value(): NodeMaterialConnectionPoint;
  63186. /**
  63187. * Gets the reference input component
  63188. */
  63189. get reference(): NodeMaterialConnectionPoint;
  63190. /**
  63191. * Gets the distance input component
  63192. */
  63193. get distance(): NodeMaterialConnectionPoint;
  63194. /**
  63195. * Gets the replacement input component
  63196. */
  63197. get replacement(): NodeMaterialConnectionPoint;
  63198. /**
  63199. * Gets the output component
  63200. */
  63201. get output(): NodeMaterialConnectionPoint;
  63202. protected _buildBlock(state: NodeMaterialBuildState): this;
  63203. }
  63204. }
  63205. declare module BABYLON {
  63206. /**
  63207. * Block used to posterize a value
  63208. * @see https://en.wikipedia.org/wiki/Posterization
  63209. */
  63210. export class PosterizeBlock extends NodeMaterialBlock {
  63211. /**
  63212. * Creates a new PosterizeBlock
  63213. * @param name defines the block name
  63214. */
  63215. constructor(name: string);
  63216. /**
  63217. * Gets the current class name
  63218. * @returns the class name
  63219. */
  63220. getClassName(): string;
  63221. /**
  63222. * Gets the value input component
  63223. */
  63224. get value(): NodeMaterialConnectionPoint;
  63225. /**
  63226. * Gets the steps input component
  63227. */
  63228. get steps(): NodeMaterialConnectionPoint;
  63229. /**
  63230. * Gets the output component
  63231. */
  63232. get output(): NodeMaterialConnectionPoint;
  63233. protected _buildBlock(state: NodeMaterialBuildState): this;
  63234. }
  63235. }
  63236. declare module BABYLON {
  63237. /**
  63238. * Operations supported by the Wave block
  63239. */
  63240. export enum WaveBlockKind {
  63241. /** SawTooth */
  63242. SawTooth = 0,
  63243. /** Square */
  63244. Square = 1,
  63245. /** Triangle */
  63246. Triangle = 2
  63247. }
  63248. /**
  63249. * Block used to apply wave operation to floats
  63250. */
  63251. export class WaveBlock extends NodeMaterialBlock {
  63252. /**
  63253. * Gets or sets the kibnd of wave to be applied by the block
  63254. */
  63255. kind: WaveBlockKind;
  63256. /**
  63257. * Creates a new WaveBlock
  63258. * @param name defines the block name
  63259. */
  63260. constructor(name: string);
  63261. /**
  63262. * Gets the current class name
  63263. * @returns the class name
  63264. */
  63265. getClassName(): string;
  63266. /**
  63267. * Gets the input component
  63268. */
  63269. get input(): NodeMaterialConnectionPoint;
  63270. /**
  63271. * Gets the output component
  63272. */
  63273. get output(): NodeMaterialConnectionPoint;
  63274. protected _buildBlock(state: NodeMaterialBuildState): this;
  63275. serialize(): any;
  63276. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63277. }
  63278. }
  63279. declare module BABYLON {
  63280. /**
  63281. * Class used to store a color step for the GradientBlock
  63282. */
  63283. export class GradientBlockColorStep {
  63284. /**
  63285. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63286. */
  63287. step: number;
  63288. /**
  63289. * Gets or sets the color associated with this step
  63290. */
  63291. color: Color3;
  63292. /**
  63293. * Creates a new GradientBlockColorStep
  63294. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  63295. * @param color defines the color associated with this step
  63296. */
  63297. constructor(
  63298. /**
  63299. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63300. */
  63301. step: number,
  63302. /**
  63303. * Gets or sets the color associated with this step
  63304. */
  63305. color: Color3);
  63306. }
  63307. /**
  63308. * Block used to return a color from a gradient based on an input value between 0 and 1
  63309. */
  63310. export class GradientBlock extends NodeMaterialBlock {
  63311. /**
  63312. * Gets or sets the list of color steps
  63313. */
  63314. colorSteps: GradientBlockColorStep[];
  63315. /**
  63316. * Creates a new GradientBlock
  63317. * @param name defines the block name
  63318. */
  63319. constructor(name: string);
  63320. /**
  63321. * Gets the current class name
  63322. * @returns the class name
  63323. */
  63324. getClassName(): string;
  63325. /**
  63326. * Gets the gradient input component
  63327. */
  63328. get gradient(): NodeMaterialConnectionPoint;
  63329. /**
  63330. * Gets the output component
  63331. */
  63332. get output(): NodeMaterialConnectionPoint;
  63333. private _writeColorConstant;
  63334. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63335. serialize(): any;
  63336. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63337. protected _dumpPropertiesCode(): string;
  63338. }
  63339. }
  63340. declare module BABYLON {
  63341. /**
  63342. * Block used to normalize lerp between 2 values
  63343. */
  63344. export class NLerpBlock extends NodeMaterialBlock {
  63345. /**
  63346. * Creates a new NLerpBlock
  63347. * @param name defines the block name
  63348. */
  63349. constructor(name: string);
  63350. /**
  63351. * Gets the current class name
  63352. * @returns the class name
  63353. */
  63354. getClassName(): string;
  63355. /**
  63356. * Gets the left operand input component
  63357. */
  63358. get left(): NodeMaterialConnectionPoint;
  63359. /**
  63360. * Gets the right operand input component
  63361. */
  63362. get right(): NodeMaterialConnectionPoint;
  63363. /**
  63364. * Gets the gradient operand input component
  63365. */
  63366. get gradient(): NodeMaterialConnectionPoint;
  63367. /**
  63368. * Gets the output component
  63369. */
  63370. get output(): NodeMaterialConnectionPoint;
  63371. protected _buildBlock(state: NodeMaterialBuildState): this;
  63372. }
  63373. }
  63374. declare module BABYLON {
  63375. /**
  63376. * block used to Generate a Worley Noise 3D Noise Pattern
  63377. */
  63378. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  63379. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63380. manhattanDistance: boolean;
  63381. /**
  63382. * Creates a new WorleyNoise3DBlock
  63383. * @param name defines the block name
  63384. */
  63385. constructor(name: string);
  63386. /**
  63387. * Gets the current class name
  63388. * @returns the class name
  63389. */
  63390. getClassName(): string;
  63391. /**
  63392. * Gets the seed input component
  63393. */
  63394. get seed(): NodeMaterialConnectionPoint;
  63395. /**
  63396. * Gets the jitter input component
  63397. */
  63398. get jitter(): NodeMaterialConnectionPoint;
  63399. /**
  63400. * Gets the output component
  63401. */
  63402. get output(): NodeMaterialConnectionPoint;
  63403. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63404. /**
  63405. * Exposes the properties to the UI?
  63406. */
  63407. protected _dumpPropertiesCode(): string;
  63408. /**
  63409. * Exposes the properties to the Seralize?
  63410. */
  63411. serialize(): any;
  63412. /**
  63413. * Exposes the properties to the deseralize?
  63414. */
  63415. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63416. }
  63417. }
  63418. declare module BABYLON {
  63419. /**
  63420. * block used to Generate a Simplex Perlin 3d Noise Pattern
  63421. */
  63422. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  63423. /**
  63424. * Creates a new SimplexPerlin3DBlock
  63425. * @param name defines the block name
  63426. */
  63427. constructor(name: string);
  63428. /**
  63429. * Gets the current class name
  63430. * @returns the class name
  63431. */
  63432. getClassName(): string;
  63433. /**
  63434. * Gets the seed operand input component
  63435. */
  63436. get seed(): NodeMaterialConnectionPoint;
  63437. /**
  63438. * Gets the output component
  63439. */
  63440. get output(): NodeMaterialConnectionPoint;
  63441. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63442. }
  63443. }
  63444. declare module BABYLON {
  63445. /**
  63446. * Block used to blend normals
  63447. */
  63448. export class NormalBlendBlock extends NodeMaterialBlock {
  63449. /**
  63450. * Creates a new NormalBlendBlock
  63451. * @param name defines the block name
  63452. */
  63453. constructor(name: string);
  63454. /**
  63455. * Gets the current class name
  63456. * @returns the class name
  63457. */
  63458. getClassName(): string;
  63459. /**
  63460. * Gets the first input component
  63461. */
  63462. get normalMap0(): NodeMaterialConnectionPoint;
  63463. /**
  63464. * Gets the second input component
  63465. */
  63466. get normalMap1(): NodeMaterialConnectionPoint;
  63467. /**
  63468. * Gets the output component
  63469. */
  63470. get output(): NodeMaterialConnectionPoint;
  63471. protected _buildBlock(state: NodeMaterialBuildState): this;
  63472. }
  63473. }
  63474. declare module BABYLON {
  63475. /**
  63476. * Block used to rotate a 2d vector by a given angle
  63477. */
  63478. export class Rotate2dBlock extends NodeMaterialBlock {
  63479. /**
  63480. * Creates a new Rotate2dBlock
  63481. * @param name defines the block name
  63482. */
  63483. constructor(name: string);
  63484. /**
  63485. * Gets the current class name
  63486. * @returns the class name
  63487. */
  63488. getClassName(): string;
  63489. /**
  63490. * Gets the input vector
  63491. */
  63492. get input(): NodeMaterialConnectionPoint;
  63493. /**
  63494. * Gets the input angle
  63495. */
  63496. get angle(): NodeMaterialConnectionPoint;
  63497. /**
  63498. * Gets the output component
  63499. */
  63500. get output(): NodeMaterialConnectionPoint;
  63501. autoConfigure(material: NodeMaterial): void;
  63502. protected _buildBlock(state: NodeMaterialBuildState): this;
  63503. }
  63504. }
  63505. declare module BABYLON {
  63506. /**
  63507. * Block used to get the reflected vector from a direction and a normal
  63508. */
  63509. export class ReflectBlock extends NodeMaterialBlock {
  63510. /**
  63511. * Creates a new ReflectBlock
  63512. * @param name defines the block name
  63513. */
  63514. constructor(name: string);
  63515. /**
  63516. * Gets the current class name
  63517. * @returns the class name
  63518. */
  63519. getClassName(): string;
  63520. /**
  63521. * Gets the incident component
  63522. */
  63523. get incident(): NodeMaterialConnectionPoint;
  63524. /**
  63525. * Gets the normal component
  63526. */
  63527. get normal(): NodeMaterialConnectionPoint;
  63528. /**
  63529. * Gets the output component
  63530. */
  63531. get output(): NodeMaterialConnectionPoint;
  63532. protected _buildBlock(state: NodeMaterialBuildState): this;
  63533. }
  63534. }
  63535. declare module BABYLON {
  63536. /**
  63537. * Block used to get the refracted vector from a direction and a normal
  63538. */
  63539. export class RefractBlock extends NodeMaterialBlock {
  63540. /**
  63541. * Creates a new RefractBlock
  63542. * @param name defines the block name
  63543. */
  63544. constructor(name: string);
  63545. /**
  63546. * Gets the current class name
  63547. * @returns the class name
  63548. */
  63549. getClassName(): string;
  63550. /**
  63551. * Gets the incident component
  63552. */
  63553. get incident(): NodeMaterialConnectionPoint;
  63554. /**
  63555. * Gets the normal component
  63556. */
  63557. get normal(): NodeMaterialConnectionPoint;
  63558. /**
  63559. * Gets the index of refraction component
  63560. */
  63561. get ior(): NodeMaterialConnectionPoint;
  63562. /**
  63563. * Gets the output component
  63564. */
  63565. get output(): NodeMaterialConnectionPoint;
  63566. protected _buildBlock(state: NodeMaterialBuildState): this;
  63567. }
  63568. }
  63569. declare module BABYLON {
  63570. /**
  63571. * Block used to desaturate a color
  63572. */
  63573. export class DesaturateBlock extends NodeMaterialBlock {
  63574. /**
  63575. * Creates a new DesaturateBlock
  63576. * @param name defines the block name
  63577. */
  63578. constructor(name: string);
  63579. /**
  63580. * Gets the current class name
  63581. * @returns the class name
  63582. */
  63583. getClassName(): string;
  63584. /**
  63585. * Gets the color operand input component
  63586. */
  63587. get color(): NodeMaterialConnectionPoint;
  63588. /**
  63589. * Gets the level operand input component
  63590. */
  63591. get level(): NodeMaterialConnectionPoint;
  63592. /**
  63593. * Gets the output component
  63594. */
  63595. get output(): NodeMaterialConnectionPoint;
  63596. protected _buildBlock(state: NodeMaterialBuildState): this;
  63597. }
  63598. }
  63599. declare module BABYLON {
  63600. /**
  63601. * Block used to implement the ambient occlusion module of the PBR material
  63602. */
  63603. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  63604. /**
  63605. * Create a new AmbientOcclusionBlock
  63606. * @param name defines the block name
  63607. */
  63608. constructor(name: string);
  63609. /**
  63610. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  63611. */
  63612. useAmbientInGrayScale: boolean;
  63613. /**
  63614. * Initialize the block and prepare the context for build
  63615. * @param state defines the state that will be used for the build
  63616. */
  63617. initialize(state: NodeMaterialBuildState): void;
  63618. /**
  63619. * Gets the current class name
  63620. * @returns the class name
  63621. */
  63622. getClassName(): string;
  63623. /**
  63624. * Gets the texture input component
  63625. */
  63626. get texture(): NodeMaterialConnectionPoint;
  63627. /**
  63628. * Gets the texture intensity component
  63629. */
  63630. get intensity(): NodeMaterialConnectionPoint;
  63631. /**
  63632. * Gets the direct light intensity input component
  63633. */
  63634. get directLightIntensity(): NodeMaterialConnectionPoint;
  63635. /**
  63636. * Gets the ambient occlusion object output component
  63637. */
  63638. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63639. /**
  63640. * Gets the main code of the block (fragment side)
  63641. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  63642. * @returns the shader code
  63643. */
  63644. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  63645. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63646. protected _buildBlock(state: NodeMaterialBuildState): this;
  63647. protected _dumpPropertiesCode(): string;
  63648. serialize(): any;
  63649. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63650. }
  63651. }
  63652. declare module BABYLON {
  63653. /**
  63654. * Block used to implement the reflection module of the PBR material
  63655. */
  63656. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  63657. /** @hidden */
  63658. _defineLODReflectionAlpha: string;
  63659. /** @hidden */
  63660. _defineLinearSpecularReflection: string;
  63661. private _vEnvironmentIrradianceName;
  63662. /** @hidden */
  63663. _vReflectionMicrosurfaceInfosName: string;
  63664. /** @hidden */
  63665. _vReflectionInfosName: string;
  63666. /** @hidden */
  63667. _vReflectionFilteringInfoName: string;
  63668. private _scene;
  63669. /**
  63670. * The three properties below are set by the main PBR block prior to calling methods of this class.
  63671. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  63672. * It's less burden on the user side in the editor part.
  63673. */
  63674. /** @hidden */
  63675. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  63676. /** @hidden */
  63677. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  63678. /** @hidden */
  63679. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  63680. /**
  63681. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  63682. * diffuse part of the IBL.
  63683. */
  63684. useSphericalHarmonics: boolean;
  63685. /**
  63686. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  63687. */
  63688. forceIrradianceInFragment: boolean;
  63689. /**
  63690. * Create a new ReflectionBlock
  63691. * @param name defines the block name
  63692. */
  63693. constructor(name: string);
  63694. /**
  63695. * Gets the current class name
  63696. * @returns the class name
  63697. */
  63698. getClassName(): string;
  63699. /**
  63700. * Gets the position input component
  63701. */
  63702. get position(): NodeMaterialConnectionPoint;
  63703. /**
  63704. * Gets the world position input component
  63705. */
  63706. get worldPosition(): NodeMaterialConnectionPoint;
  63707. /**
  63708. * Gets the world normal input component
  63709. */
  63710. get worldNormal(): NodeMaterialConnectionPoint;
  63711. /**
  63712. * Gets the world input component
  63713. */
  63714. get world(): NodeMaterialConnectionPoint;
  63715. /**
  63716. * Gets the camera (or eye) position component
  63717. */
  63718. get cameraPosition(): NodeMaterialConnectionPoint;
  63719. /**
  63720. * Gets the view input component
  63721. */
  63722. get view(): NodeMaterialConnectionPoint;
  63723. /**
  63724. * Gets the color input component
  63725. */
  63726. get color(): NodeMaterialConnectionPoint;
  63727. /**
  63728. * Gets the reflection object output component
  63729. */
  63730. get reflection(): NodeMaterialConnectionPoint;
  63731. /**
  63732. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  63733. */
  63734. get hasTexture(): boolean;
  63735. /**
  63736. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  63737. */
  63738. get reflectionColor(): string;
  63739. protected _getTexture(): Nullable<BaseTexture>;
  63740. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63741. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63742. /**
  63743. * Gets the code to inject in the vertex shader
  63744. * @param state current state of the node material building
  63745. * @returns the shader code
  63746. */
  63747. handleVertexSide(state: NodeMaterialBuildState): string;
  63748. /**
  63749. * Gets the main code of the block (fragment side)
  63750. * @param state current state of the node material building
  63751. * @param normalVarName name of the existing variable corresponding to the normal
  63752. * @returns the shader code
  63753. */
  63754. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  63755. protected _buildBlock(state: NodeMaterialBuildState): this;
  63756. protected _dumpPropertiesCode(): string;
  63757. serialize(): any;
  63758. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63759. }
  63760. }
  63761. declare module BABYLON {
  63762. /**
  63763. * Block used to implement the sheen module of the PBR material
  63764. */
  63765. export class SheenBlock extends NodeMaterialBlock {
  63766. /**
  63767. * Create a new SheenBlock
  63768. * @param name defines the block name
  63769. */
  63770. constructor(name: string);
  63771. /**
  63772. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  63773. * It allows the strength of the sheen effect to not depend on the base color of the material,
  63774. * making it easier to setup and tweak the effect
  63775. */
  63776. albedoScaling: boolean;
  63777. /**
  63778. * Defines if the sheen is linked to the sheen color.
  63779. */
  63780. linkSheenWithAlbedo: boolean;
  63781. /**
  63782. * Initialize the block and prepare the context for build
  63783. * @param state defines the state that will be used for the build
  63784. */
  63785. initialize(state: NodeMaterialBuildState): void;
  63786. /**
  63787. * Gets the current class name
  63788. * @returns the class name
  63789. */
  63790. getClassName(): string;
  63791. /**
  63792. * Gets the intensity input component
  63793. */
  63794. get intensity(): NodeMaterialConnectionPoint;
  63795. /**
  63796. * Gets the color input component
  63797. */
  63798. get color(): NodeMaterialConnectionPoint;
  63799. /**
  63800. * Gets the roughness input component
  63801. */
  63802. get roughness(): NodeMaterialConnectionPoint;
  63803. /**
  63804. * Gets the sheen object output component
  63805. */
  63806. get sheen(): NodeMaterialConnectionPoint;
  63807. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63808. /**
  63809. * Gets the main code of the block (fragment side)
  63810. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63811. * @returns the shader code
  63812. */
  63813. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  63814. protected _buildBlock(state: NodeMaterialBuildState): this;
  63815. protected _dumpPropertiesCode(): string;
  63816. serialize(): any;
  63817. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63818. }
  63819. }
  63820. declare module BABYLON {
  63821. /**
  63822. * Block used to implement the reflectivity module of the PBR material
  63823. */
  63824. export class ReflectivityBlock extends NodeMaterialBlock {
  63825. private _metallicReflectanceColor;
  63826. private _metallicF0Factor;
  63827. /** @hidden */
  63828. _vMetallicReflectanceFactorsName: string;
  63829. /**
  63830. * The property below is set by the main PBR block prior to calling methods of this class.
  63831. */
  63832. /** @hidden */
  63833. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  63834. /**
  63835. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  63836. */
  63837. useAmbientOcclusionFromMetallicTextureRed: boolean;
  63838. /**
  63839. * Specifies if the metallic texture contains the metallness information in its blue channel.
  63840. */
  63841. useMetallnessFromMetallicTextureBlue: boolean;
  63842. /**
  63843. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  63844. */
  63845. useRoughnessFromMetallicTextureAlpha: boolean;
  63846. /**
  63847. * Specifies if the metallic texture contains the roughness information in its green channel.
  63848. */
  63849. useRoughnessFromMetallicTextureGreen: boolean;
  63850. /**
  63851. * Create a new ReflectivityBlock
  63852. * @param name defines the block name
  63853. */
  63854. constructor(name: string);
  63855. /**
  63856. * Initialize the block and prepare the context for build
  63857. * @param state defines the state that will be used for the build
  63858. */
  63859. initialize(state: NodeMaterialBuildState): void;
  63860. /**
  63861. * Gets the current class name
  63862. * @returns the class name
  63863. */
  63864. getClassName(): string;
  63865. /**
  63866. * Gets the metallic input component
  63867. */
  63868. get metallic(): NodeMaterialConnectionPoint;
  63869. /**
  63870. * Gets the roughness input component
  63871. */
  63872. get roughness(): NodeMaterialConnectionPoint;
  63873. /**
  63874. * Gets the texture input component
  63875. */
  63876. get texture(): NodeMaterialConnectionPoint;
  63877. /**
  63878. * Gets the reflectivity object output component
  63879. */
  63880. get reflectivity(): NodeMaterialConnectionPoint;
  63881. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63882. /**
  63883. * Gets the main code of the block (fragment side)
  63884. * @param state current state of the node material building
  63885. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  63886. * @returns the shader code
  63887. */
  63888. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  63889. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63890. protected _buildBlock(state: NodeMaterialBuildState): this;
  63891. protected _dumpPropertiesCode(): string;
  63892. serialize(): any;
  63893. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63894. }
  63895. }
  63896. declare module BABYLON {
  63897. /**
  63898. * Block used to implement the anisotropy module of the PBR material
  63899. */
  63900. export class AnisotropyBlock extends NodeMaterialBlock {
  63901. /**
  63902. * The two properties below are set by the main PBR block prior to calling methods of this class.
  63903. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  63904. * It's less burden on the user side in the editor part.
  63905. */
  63906. /** @hidden */
  63907. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  63908. /** @hidden */
  63909. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  63910. /**
  63911. * Create a new AnisotropyBlock
  63912. * @param name defines the block name
  63913. */
  63914. constructor(name: string);
  63915. /**
  63916. * Initialize the block and prepare the context for build
  63917. * @param state defines the state that will be used for the build
  63918. */
  63919. initialize(state: NodeMaterialBuildState): void;
  63920. /**
  63921. * Gets the current class name
  63922. * @returns the class name
  63923. */
  63924. getClassName(): string;
  63925. /**
  63926. * Gets the intensity input component
  63927. */
  63928. get intensity(): NodeMaterialConnectionPoint;
  63929. /**
  63930. * Gets the direction input component
  63931. */
  63932. get direction(): NodeMaterialConnectionPoint;
  63933. /**
  63934. * Gets the texture input component
  63935. */
  63936. get texture(): NodeMaterialConnectionPoint;
  63937. /**
  63938. * Gets the uv input component
  63939. */
  63940. get uv(): NodeMaterialConnectionPoint;
  63941. /**
  63942. * Gets the worldTangent input component
  63943. */
  63944. get worldTangent(): NodeMaterialConnectionPoint;
  63945. /**
  63946. * Gets the anisotropy object output component
  63947. */
  63948. get anisotropy(): NodeMaterialConnectionPoint;
  63949. private _generateTBNSpace;
  63950. /**
  63951. * Gets the main code of the block (fragment side)
  63952. * @param state current state of the node material building
  63953. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  63954. * @returns the shader code
  63955. */
  63956. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  63957. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63958. protected _buildBlock(state: NodeMaterialBuildState): this;
  63959. }
  63960. }
  63961. declare module BABYLON {
  63962. /**
  63963. * Block used to implement the clear coat module of the PBR material
  63964. */
  63965. export class ClearCoatBlock extends NodeMaterialBlock {
  63966. private _scene;
  63967. /**
  63968. * Create a new ClearCoatBlock
  63969. * @param name defines the block name
  63970. */
  63971. constructor(name: string);
  63972. /**
  63973. * Initialize the block and prepare the context for build
  63974. * @param state defines the state that will be used for the build
  63975. */
  63976. initialize(state: NodeMaterialBuildState): void;
  63977. /**
  63978. * Gets the current class name
  63979. * @returns the class name
  63980. */
  63981. getClassName(): string;
  63982. /**
  63983. * Gets the intensity input component
  63984. */
  63985. get intensity(): NodeMaterialConnectionPoint;
  63986. /**
  63987. * Gets the roughness input component
  63988. */
  63989. get roughness(): NodeMaterialConnectionPoint;
  63990. /**
  63991. * Gets the ior input component
  63992. */
  63993. get ior(): NodeMaterialConnectionPoint;
  63994. /**
  63995. * Gets the texture input component
  63996. */
  63997. get texture(): NodeMaterialConnectionPoint;
  63998. /**
  63999. * Gets the bump texture input component
  64000. */
  64001. get bumpTexture(): NodeMaterialConnectionPoint;
  64002. /**
  64003. * Gets the uv input component
  64004. */
  64005. get uv(): NodeMaterialConnectionPoint;
  64006. /**
  64007. * Gets the tint color input component
  64008. */
  64009. get tintColor(): NodeMaterialConnectionPoint;
  64010. /**
  64011. * Gets the tint "at distance" input component
  64012. */
  64013. get tintAtDistance(): NodeMaterialConnectionPoint;
  64014. /**
  64015. * Gets the tint thickness input component
  64016. */
  64017. get tintThickness(): NodeMaterialConnectionPoint;
  64018. /**
  64019. * Gets the world tangent input component
  64020. */
  64021. get worldTangent(): NodeMaterialConnectionPoint;
  64022. /**
  64023. * Gets the clear coat object output component
  64024. */
  64025. get clearcoat(): NodeMaterialConnectionPoint;
  64026. autoConfigure(material: NodeMaterial): void;
  64027. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64028. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64029. private _generateTBNSpace;
  64030. /**
  64031. * Gets the main code of the block (fragment side)
  64032. * @param state current state of the node material building
  64033. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  64034. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64035. * @param worldPosVarName name of the variable holding the world position
  64036. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64037. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  64038. * @param worldNormalVarName name of the variable holding the world normal
  64039. * @returns the shader code
  64040. */
  64041. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  64042. protected _buildBlock(state: NodeMaterialBuildState): this;
  64043. }
  64044. }
  64045. declare module BABYLON {
  64046. /**
  64047. * Block used to implement the sub surface module of the PBR material
  64048. */
  64049. export class SubSurfaceBlock extends NodeMaterialBlock {
  64050. /**
  64051. * Create a new SubSurfaceBlock
  64052. * @param name defines the block name
  64053. */
  64054. constructor(name: string);
  64055. /**
  64056. * Stores the intensity of the different subsurface effects in the thickness texture.
  64057. * * the green channel is the translucency intensity.
  64058. * * the blue channel is the scattering intensity.
  64059. * * the alpha channel is the refraction intensity.
  64060. */
  64061. useMaskFromThicknessTexture: boolean;
  64062. /**
  64063. * Initialize the block and prepare the context for build
  64064. * @param state defines the state that will be used for the build
  64065. */
  64066. initialize(state: NodeMaterialBuildState): void;
  64067. /**
  64068. * Gets the current class name
  64069. * @returns the class name
  64070. */
  64071. getClassName(): string;
  64072. /**
  64073. * Gets the min thickness input component
  64074. */
  64075. get minThickness(): NodeMaterialConnectionPoint;
  64076. /**
  64077. * Gets the max thickness input component
  64078. */
  64079. get maxThickness(): NodeMaterialConnectionPoint;
  64080. /**
  64081. * Gets the thickness texture component
  64082. */
  64083. get thicknessTexture(): NodeMaterialConnectionPoint;
  64084. /**
  64085. * Gets the tint color input component
  64086. */
  64087. get tintColor(): NodeMaterialConnectionPoint;
  64088. /**
  64089. * Gets the translucency intensity input component
  64090. */
  64091. get translucencyIntensity(): NodeMaterialConnectionPoint;
  64092. /**
  64093. * Gets the translucency diffusion distance input component
  64094. */
  64095. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  64096. /**
  64097. * Gets the refraction object parameters
  64098. */
  64099. get refraction(): NodeMaterialConnectionPoint;
  64100. /**
  64101. * Gets the sub surface object output component
  64102. */
  64103. get subsurface(): NodeMaterialConnectionPoint;
  64104. autoConfigure(material: NodeMaterial): void;
  64105. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64106. /**
  64107. * Gets the main code of the block (fragment side)
  64108. * @param state current state of the node material building
  64109. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  64110. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64111. * @param worldPosVarName name of the variable holding the world position
  64112. * @returns the shader code
  64113. */
  64114. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  64115. protected _buildBlock(state: NodeMaterialBuildState): this;
  64116. }
  64117. }
  64118. declare module BABYLON {
  64119. /**
  64120. * Block used to implement the PBR metallic/roughness model
  64121. */
  64122. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  64123. /**
  64124. * Gets or sets the light associated with this block
  64125. */
  64126. light: Nullable<Light>;
  64127. private _lightId;
  64128. private _scene;
  64129. private _environmentBRDFTexture;
  64130. private _environmentBrdfSamplerName;
  64131. private _vNormalWName;
  64132. private _invertNormalName;
  64133. /**
  64134. * Create a new ReflectionBlock
  64135. * @param name defines the block name
  64136. */
  64137. constructor(name: string);
  64138. /**
  64139. * Intensity of the direct lights e.g. the four lights available in your scene.
  64140. * This impacts both the direct diffuse and specular highlights.
  64141. */
  64142. directIntensity: number;
  64143. /**
  64144. * Intensity of the environment e.g. how much the environment will light the object
  64145. * either through harmonics for rough material or through the refelction for shiny ones.
  64146. */
  64147. environmentIntensity: number;
  64148. /**
  64149. * This is a special control allowing the reduction of the specular highlights coming from the
  64150. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  64151. */
  64152. specularIntensity: number;
  64153. /**
  64154. * Defines the falloff type used in this material.
  64155. * It by default is Physical.
  64156. */
  64157. lightFalloff: number;
  64158. /**
  64159. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  64160. */
  64161. useAlphaFromAlbedoTexture: boolean;
  64162. /**
  64163. * Specifies that alpha test should be used
  64164. */
  64165. useAlphaTest: boolean;
  64166. /**
  64167. * Defines the alpha limits in alpha test mode.
  64168. */
  64169. alphaTestCutoff: number;
  64170. /**
  64171. * Specifies that alpha blending should be used
  64172. */
  64173. useAlphaBlending: boolean;
  64174. /**
  64175. * Defines if the alpha value should be determined via the rgb values.
  64176. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  64177. */
  64178. opacityRGB: boolean;
  64179. /**
  64180. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  64181. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  64182. */
  64183. useRadianceOverAlpha: boolean;
  64184. /**
  64185. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  64186. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  64187. */
  64188. useSpecularOverAlpha: boolean;
  64189. /**
  64190. * Enables specular anti aliasing in the PBR shader.
  64191. * It will both interacts on the Geometry for analytical and IBL lighting.
  64192. * It also prefilter the roughness map based on the bump values.
  64193. */
  64194. enableSpecularAntiAliasing: boolean;
  64195. /**
  64196. * Enables realtime filtering on the texture.
  64197. */
  64198. realTimeFiltering: boolean;
  64199. /**
  64200. * Quality switch for realtime filtering
  64201. */
  64202. realTimeFilteringQuality: number;
  64203. /**
  64204. * Defines if the material uses energy conservation.
  64205. */
  64206. useEnergyConservation: boolean;
  64207. /**
  64208. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  64209. * too much the area relying on ambient texture to define their ambient occlusion.
  64210. */
  64211. useRadianceOcclusion: boolean;
  64212. /**
  64213. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  64214. * makes the reflect vector face the model (under horizon).
  64215. */
  64216. useHorizonOcclusion: boolean;
  64217. /**
  64218. * If set to true, no lighting calculations will be applied.
  64219. */
  64220. unlit: boolean;
  64221. /**
  64222. * Force normal to face away from face.
  64223. */
  64224. forceNormalForward: boolean;
  64225. /**
  64226. * Defines the material debug mode.
  64227. * It helps seeing only some components of the material while troubleshooting.
  64228. */
  64229. debugMode: number;
  64230. /**
  64231. * Specify from where on screen the debug mode should start.
  64232. * The value goes from -1 (full screen) to 1 (not visible)
  64233. * It helps with side by side comparison against the final render
  64234. * This defaults to 0
  64235. */
  64236. debugLimit: number;
  64237. /**
  64238. * As the default viewing range might not be enough (if the ambient is really small for instance)
  64239. * You can use the factor to better multiply the final value.
  64240. */
  64241. debugFactor: number;
  64242. /**
  64243. * Initialize the block and prepare the context for build
  64244. * @param state defines the state that will be used for the build
  64245. */
  64246. initialize(state: NodeMaterialBuildState): void;
  64247. /**
  64248. * Gets the current class name
  64249. * @returns the class name
  64250. */
  64251. getClassName(): string;
  64252. /**
  64253. * Gets the world position input component
  64254. */
  64255. get worldPosition(): NodeMaterialConnectionPoint;
  64256. /**
  64257. * Gets the world normal input component
  64258. */
  64259. get worldNormal(): NodeMaterialConnectionPoint;
  64260. /**
  64261. * Gets the perturbed normal input component
  64262. */
  64263. get perturbedNormal(): NodeMaterialConnectionPoint;
  64264. /**
  64265. * Gets the camera position input component
  64266. */
  64267. get cameraPosition(): NodeMaterialConnectionPoint;
  64268. /**
  64269. * Gets the base color input component
  64270. */
  64271. get baseColor(): NodeMaterialConnectionPoint;
  64272. /**
  64273. * Gets the opacity texture input component
  64274. */
  64275. get opacityTexture(): NodeMaterialConnectionPoint;
  64276. /**
  64277. * Gets the ambient color input component
  64278. */
  64279. get ambientColor(): NodeMaterialConnectionPoint;
  64280. /**
  64281. * Gets the reflectivity object parameters
  64282. */
  64283. get reflectivity(): NodeMaterialConnectionPoint;
  64284. /**
  64285. * Gets the ambient occlusion object parameters
  64286. */
  64287. get ambientOcclusion(): NodeMaterialConnectionPoint;
  64288. /**
  64289. * Gets the reflection object parameters
  64290. */
  64291. get reflection(): NodeMaterialConnectionPoint;
  64292. /**
  64293. * Gets the sheen object parameters
  64294. */
  64295. get sheen(): NodeMaterialConnectionPoint;
  64296. /**
  64297. * Gets the clear coat object parameters
  64298. */
  64299. get clearcoat(): NodeMaterialConnectionPoint;
  64300. /**
  64301. * Gets the sub surface object parameters
  64302. */
  64303. get subsurface(): NodeMaterialConnectionPoint;
  64304. /**
  64305. * Gets the anisotropy object parameters
  64306. */
  64307. get anisotropy(): NodeMaterialConnectionPoint;
  64308. /**
  64309. * Gets the ambient output component
  64310. */
  64311. get ambient(): NodeMaterialConnectionPoint;
  64312. /**
  64313. * Gets the diffuse output component
  64314. */
  64315. get diffuse(): NodeMaterialConnectionPoint;
  64316. /**
  64317. * Gets the specular output component
  64318. */
  64319. get specular(): NodeMaterialConnectionPoint;
  64320. /**
  64321. * Gets the sheen output component
  64322. */
  64323. get sheenDir(): NodeMaterialConnectionPoint;
  64324. /**
  64325. * Gets the clear coat output component
  64326. */
  64327. get clearcoatDir(): NodeMaterialConnectionPoint;
  64328. /**
  64329. * Gets the indirect diffuse output component
  64330. */
  64331. get diffuseIndirect(): NodeMaterialConnectionPoint;
  64332. /**
  64333. * Gets the indirect specular output component
  64334. */
  64335. get specularIndirect(): NodeMaterialConnectionPoint;
  64336. /**
  64337. * Gets the indirect sheen output component
  64338. */
  64339. get sheenIndirect(): NodeMaterialConnectionPoint;
  64340. /**
  64341. * Gets the indirect clear coat output component
  64342. */
  64343. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  64344. /**
  64345. * Gets the refraction output component
  64346. */
  64347. get refraction(): NodeMaterialConnectionPoint;
  64348. /**
  64349. * Gets the global lighting output component
  64350. */
  64351. get lighting(): NodeMaterialConnectionPoint;
  64352. /**
  64353. * Gets the shadow output component
  64354. */
  64355. get shadow(): NodeMaterialConnectionPoint;
  64356. /**
  64357. * Gets the alpha output component
  64358. */
  64359. get alpha(): NodeMaterialConnectionPoint;
  64360. autoConfigure(material: NodeMaterial): void;
  64361. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64362. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64363. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64364. private _injectVertexCode;
  64365. /**
  64366. * Gets the code corresponding to the albedo/opacity module
  64367. * @returns the shader code
  64368. */
  64369. getAlbedoOpacityCode(): string;
  64370. protected _buildBlock(state: NodeMaterialBuildState): this;
  64371. protected _dumpPropertiesCode(): string;
  64372. serialize(): any;
  64373. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64374. }
  64375. }
  64376. declare module BABYLON {
  64377. /**
  64378. * Block used to compute value of one parameter modulo another
  64379. */
  64380. export class ModBlock extends NodeMaterialBlock {
  64381. /**
  64382. * Creates a new ModBlock
  64383. * @param name defines the block name
  64384. */
  64385. constructor(name: string);
  64386. /**
  64387. * Gets the current class name
  64388. * @returns the class name
  64389. */
  64390. getClassName(): string;
  64391. /**
  64392. * Gets the left operand input component
  64393. */
  64394. get left(): NodeMaterialConnectionPoint;
  64395. /**
  64396. * Gets the right operand input component
  64397. */
  64398. get right(): NodeMaterialConnectionPoint;
  64399. /**
  64400. * Gets the output component
  64401. */
  64402. get output(): NodeMaterialConnectionPoint;
  64403. protected _buildBlock(state: NodeMaterialBuildState): this;
  64404. }
  64405. }
  64406. declare module BABYLON {
  64407. /**
  64408. * Helper class to push actions to a pool of workers.
  64409. */
  64410. export class WorkerPool implements IDisposable {
  64411. private _workerInfos;
  64412. private _pendingActions;
  64413. /**
  64414. * Constructor
  64415. * @param workers Array of workers to use for actions
  64416. */
  64417. constructor(workers: Array<Worker>);
  64418. /**
  64419. * Terminates all workers and clears any pending actions.
  64420. */
  64421. dispose(): void;
  64422. /**
  64423. * Pushes an action to the worker pool. If all the workers are active, the action will be
  64424. * pended until a worker has completed its action.
  64425. * @param action The action to perform. Call onComplete when the action is complete.
  64426. */
  64427. push(action: (worker: Worker, onComplete: () => void) => void): void;
  64428. private _execute;
  64429. }
  64430. }
  64431. declare module BABYLON {
  64432. /**
  64433. * Configuration for Draco compression
  64434. */
  64435. export interface IDracoCompressionConfiguration {
  64436. /**
  64437. * Configuration for the decoder.
  64438. */
  64439. decoder: {
  64440. /**
  64441. * The url to the WebAssembly module.
  64442. */
  64443. wasmUrl?: string;
  64444. /**
  64445. * The url to the WebAssembly binary.
  64446. */
  64447. wasmBinaryUrl?: string;
  64448. /**
  64449. * The url to the fallback JavaScript module.
  64450. */
  64451. fallbackUrl?: string;
  64452. };
  64453. }
  64454. /**
  64455. * Draco compression (https://google.github.io/draco/)
  64456. *
  64457. * This class wraps the Draco module.
  64458. *
  64459. * **Encoder**
  64460. *
  64461. * The encoder is not currently implemented.
  64462. *
  64463. * **Decoder**
  64464. *
  64465. * 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.
  64466. *
  64467. * To update the configuration, use the following code:
  64468. * ```javascript
  64469. * DracoCompression.Configuration = {
  64470. * decoder: {
  64471. * wasmUrl: "<url to the WebAssembly library>",
  64472. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  64473. * fallbackUrl: "<url to the fallback JavaScript library>",
  64474. * }
  64475. * };
  64476. * ```
  64477. *
  64478. * 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.
  64479. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  64480. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  64481. *
  64482. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  64483. * ```javascript
  64484. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  64485. * ```
  64486. *
  64487. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  64488. */
  64489. export class DracoCompression implements IDisposable {
  64490. private _workerPoolPromise?;
  64491. private _decoderModulePromise?;
  64492. /**
  64493. * The configuration. Defaults to the following urls:
  64494. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  64495. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  64496. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  64497. */
  64498. static Configuration: IDracoCompressionConfiguration;
  64499. /**
  64500. * Returns true if the decoder configuration is available.
  64501. */
  64502. static get DecoderAvailable(): boolean;
  64503. /**
  64504. * Default number of workers to create when creating the draco compression object.
  64505. */
  64506. static DefaultNumWorkers: number;
  64507. private static GetDefaultNumWorkers;
  64508. private static _Default;
  64509. /**
  64510. * Default instance for the draco compression object.
  64511. */
  64512. static get Default(): DracoCompression;
  64513. /**
  64514. * Constructor
  64515. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  64516. */
  64517. constructor(numWorkers?: number);
  64518. /**
  64519. * Stop all async operations and release resources.
  64520. */
  64521. dispose(): void;
  64522. /**
  64523. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  64524. * @returns a promise that resolves when ready
  64525. */
  64526. whenReadyAsync(): Promise<void>;
  64527. /**
  64528. * Decode Draco compressed mesh data to vertex data.
  64529. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  64530. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  64531. * @returns A promise that resolves with the decoded vertex data
  64532. */
  64533. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  64534. [kind: string]: number;
  64535. }): Promise<VertexData>;
  64536. }
  64537. }
  64538. declare module BABYLON {
  64539. /**
  64540. * Class for building Constructive Solid Geometry
  64541. */
  64542. export class CSG {
  64543. private polygons;
  64544. /**
  64545. * The world matrix
  64546. */
  64547. matrix: Matrix;
  64548. /**
  64549. * Stores the position
  64550. */
  64551. position: Vector3;
  64552. /**
  64553. * Stores the rotation
  64554. */
  64555. rotation: Vector3;
  64556. /**
  64557. * Stores the rotation quaternion
  64558. */
  64559. rotationQuaternion: Nullable<Quaternion>;
  64560. /**
  64561. * Stores the scaling vector
  64562. */
  64563. scaling: Vector3;
  64564. /**
  64565. * Convert the Mesh to CSG
  64566. * @param mesh The Mesh to convert to CSG
  64567. * @returns A new CSG from the Mesh
  64568. */
  64569. static FromMesh(mesh: Mesh): CSG;
  64570. /**
  64571. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  64572. * @param polygons Polygons used to construct a CSG solid
  64573. */
  64574. private static FromPolygons;
  64575. /**
  64576. * Clones, or makes a deep copy, of the CSG
  64577. * @returns A new CSG
  64578. */
  64579. clone(): CSG;
  64580. /**
  64581. * Unions this CSG with another CSG
  64582. * @param csg The CSG to union against this CSG
  64583. * @returns The unioned CSG
  64584. */
  64585. union(csg: CSG): CSG;
  64586. /**
  64587. * Unions this CSG with another CSG in place
  64588. * @param csg The CSG to union against this CSG
  64589. */
  64590. unionInPlace(csg: CSG): void;
  64591. /**
  64592. * Subtracts this CSG with another CSG
  64593. * @param csg The CSG to subtract against this CSG
  64594. * @returns A new CSG
  64595. */
  64596. subtract(csg: CSG): CSG;
  64597. /**
  64598. * Subtracts this CSG with another CSG in place
  64599. * @param csg The CSG to subtact against this CSG
  64600. */
  64601. subtractInPlace(csg: CSG): void;
  64602. /**
  64603. * Intersect this CSG with another CSG
  64604. * @param csg The CSG to intersect against this CSG
  64605. * @returns A new CSG
  64606. */
  64607. intersect(csg: CSG): CSG;
  64608. /**
  64609. * Intersects this CSG with another CSG in place
  64610. * @param csg The CSG to intersect against this CSG
  64611. */
  64612. intersectInPlace(csg: CSG): void;
  64613. /**
  64614. * Return a new CSG solid with solid and empty space switched. This solid is
  64615. * not modified.
  64616. * @returns A new CSG solid with solid and empty space switched
  64617. */
  64618. inverse(): CSG;
  64619. /**
  64620. * Inverses the CSG in place
  64621. */
  64622. inverseInPlace(): void;
  64623. /**
  64624. * This is used to keep meshes transformations so they can be restored
  64625. * when we build back a Babylon Mesh
  64626. * NB : All CSG operations are performed in world coordinates
  64627. * @param csg The CSG to copy the transform attributes from
  64628. * @returns This CSG
  64629. */
  64630. copyTransformAttributes(csg: CSG): CSG;
  64631. /**
  64632. * Build Raw mesh from CSG
  64633. * Coordinates here are in world space
  64634. * @param name The name of the mesh geometry
  64635. * @param scene The Scene
  64636. * @param keepSubMeshes Specifies if the submeshes should be kept
  64637. * @returns A new Mesh
  64638. */
  64639. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64640. /**
  64641. * Build Mesh from CSG taking material and transforms into account
  64642. * @param name The name of the Mesh
  64643. * @param material The material of the Mesh
  64644. * @param scene The Scene
  64645. * @param keepSubMeshes Specifies if submeshes should be kept
  64646. * @returns The new Mesh
  64647. */
  64648. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64649. }
  64650. }
  64651. declare module BABYLON {
  64652. /**
  64653. * Class used to create a trail following a mesh
  64654. */
  64655. export class TrailMesh extends Mesh {
  64656. private _generator;
  64657. private _autoStart;
  64658. private _running;
  64659. private _diameter;
  64660. private _length;
  64661. private _sectionPolygonPointsCount;
  64662. private _sectionVectors;
  64663. private _sectionNormalVectors;
  64664. private _beforeRenderObserver;
  64665. /**
  64666. * @constructor
  64667. * @param name The value used by scene.getMeshByName() to do a lookup.
  64668. * @param generator The mesh or transform node to generate a trail.
  64669. * @param scene The scene to add this mesh to.
  64670. * @param diameter Diameter of trailing mesh. Default is 1.
  64671. * @param length Length of trailing mesh. Default is 60.
  64672. * @param autoStart Automatically start trailing mesh. Default true.
  64673. */
  64674. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  64675. /**
  64676. * "TrailMesh"
  64677. * @returns "TrailMesh"
  64678. */
  64679. getClassName(): string;
  64680. private _createMesh;
  64681. /**
  64682. * Start trailing mesh.
  64683. */
  64684. start(): void;
  64685. /**
  64686. * Stop trailing mesh.
  64687. */
  64688. stop(): void;
  64689. /**
  64690. * Update trailing mesh geometry.
  64691. */
  64692. update(): void;
  64693. /**
  64694. * Returns a new TrailMesh object.
  64695. * @param name is a string, the name given to the new mesh
  64696. * @param newGenerator use new generator object for cloned trail mesh
  64697. * @returns a new mesh
  64698. */
  64699. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  64700. /**
  64701. * Serializes this trail mesh
  64702. * @param serializationObject object to write serialization to
  64703. */
  64704. serialize(serializationObject: any): void;
  64705. /**
  64706. * Parses a serialized trail mesh
  64707. * @param parsedMesh the serialized mesh
  64708. * @param scene the scene to create the trail mesh in
  64709. * @returns the created trail mesh
  64710. */
  64711. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  64712. }
  64713. }
  64714. declare module BABYLON {
  64715. /**
  64716. * Class containing static functions to help procedurally build meshes
  64717. */
  64718. export class TiledBoxBuilder {
  64719. /**
  64720. * Creates a box mesh
  64721. * 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)
  64722. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64723. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64724. * * 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
  64725. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64726. * @param name defines the name of the mesh
  64727. * @param options defines the options used to create the mesh
  64728. * @param scene defines the hosting scene
  64729. * @returns the box mesh
  64730. */
  64731. static CreateTiledBox(name: string, options: {
  64732. pattern?: number;
  64733. width?: number;
  64734. height?: number;
  64735. depth?: number;
  64736. tileSize?: number;
  64737. tileWidth?: number;
  64738. tileHeight?: number;
  64739. alignHorizontal?: number;
  64740. alignVertical?: number;
  64741. faceUV?: Vector4[];
  64742. faceColors?: Color4[];
  64743. sideOrientation?: number;
  64744. updatable?: boolean;
  64745. }, scene?: Nullable<Scene>): Mesh;
  64746. }
  64747. }
  64748. declare module BABYLON {
  64749. /**
  64750. * Class containing static functions to help procedurally build meshes
  64751. */
  64752. export class TorusKnotBuilder {
  64753. /**
  64754. * Creates a torus knot mesh
  64755. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64756. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64757. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64758. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64759. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64760. * * 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
  64761. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64762. * @param name defines the name of the mesh
  64763. * @param options defines the options used to create the mesh
  64764. * @param scene defines the hosting scene
  64765. * @returns the torus knot mesh
  64766. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64767. */
  64768. static CreateTorusKnot(name: string, options: {
  64769. radius?: number;
  64770. tube?: number;
  64771. radialSegments?: number;
  64772. tubularSegments?: number;
  64773. p?: number;
  64774. q?: number;
  64775. updatable?: boolean;
  64776. sideOrientation?: number;
  64777. frontUVs?: Vector4;
  64778. backUVs?: Vector4;
  64779. }, scene: any): Mesh;
  64780. }
  64781. }
  64782. declare module BABYLON {
  64783. /**
  64784. * Polygon
  64785. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  64786. */
  64787. export class Polygon {
  64788. /**
  64789. * Creates a rectangle
  64790. * @param xmin bottom X coord
  64791. * @param ymin bottom Y coord
  64792. * @param xmax top X coord
  64793. * @param ymax top Y coord
  64794. * @returns points that make the resulting rectation
  64795. */
  64796. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  64797. /**
  64798. * Creates a circle
  64799. * @param radius radius of circle
  64800. * @param cx scale in x
  64801. * @param cy scale in y
  64802. * @param numberOfSides number of sides that make up the circle
  64803. * @returns points that make the resulting circle
  64804. */
  64805. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  64806. /**
  64807. * Creates a polygon from input string
  64808. * @param input Input polygon data
  64809. * @returns the parsed points
  64810. */
  64811. static Parse(input: string): Vector2[];
  64812. /**
  64813. * Starts building a polygon from x and y coordinates
  64814. * @param x x coordinate
  64815. * @param y y coordinate
  64816. * @returns the started path2
  64817. */
  64818. static StartingAt(x: number, y: number): Path2;
  64819. }
  64820. /**
  64821. * Builds a polygon
  64822. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  64823. */
  64824. export class PolygonMeshBuilder {
  64825. private _points;
  64826. private _outlinepoints;
  64827. private _holes;
  64828. private _name;
  64829. private _scene;
  64830. private _epoints;
  64831. private _eholes;
  64832. private _addToepoint;
  64833. /**
  64834. * Babylon reference to the earcut plugin.
  64835. */
  64836. bjsEarcut: any;
  64837. /**
  64838. * Creates a PolygonMeshBuilder
  64839. * @param name name of the builder
  64840. * @param contours Path of the polygon
  64841. * @param scene scene to add to when creating the mesh
  64842. * @param earcutInjection can be used to inject your own earcut reference
  64843. */
  64844. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  64845. /**
  64846. * Adds a whole within the polygon
  64847. * @param hole Array of points defining the hole
  64848. * @returns this
  64849. */
  64850. addHole(hole: Vector2[]): PolygonMeshBuilder;
  64851. /**
  64852. * Creates the polygon
  64853. * @param updatable If the mesh should be updatable
  64854. * @param depth The depth of the mesh created
  64855. * @returns the created mesh
  64856. */
  64857. build(updatable?: boolean, depth?: number): Mesh;
  64858. /**
  64859. * Creates the polygon
  64860. * @param depth The depth of the mesh created
  64861. * @returns the created VertexData
  64862. */
  64863. buildVertexData(depth?: number): VertexData;
  64864. /**
  64865. * Adds a side to the polygon
  64866. * @param positions points that make the polygon
  64867. * @param normals normals of the polygon
  64868. * @param uvs uvs of the polygon
  64869. * @param indices indices of the polygon
  64870. * @param bounds bounds of the polygon
  64871. * @param points points of the polygon
  64872. * @param depth depth of the polygon
  64873. * @param flip flip of the polygon
  64874. */
  64875. private addSide;
  64876. }
  64877. }
  64878. declare module BABYLON {
  64879. /**
  64880. * Class containing static functions to help procedurally build meshes
  64881. */
  64882. export class PolygonBuilder {
  64883. /**
  64884. * Creates a polygon mesh
  64885. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64886. * * 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
  64887. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64889. * * 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)
  64890. * * Remember you can only change the shape positions, not their number when updating a polygon
  64891. * @param name defines the name of the mesh
  64892. * @param options defines the options used to create the mesh
  64893. * @param scene defines the hosting scene
  64894. * @param earcutInjection can be used to inject your own earcut reference
  64895. * @returns the polygon mesh
  64896. */
  64897. static CreatePolygon(name: string, options: {
  64898. shape: Vector3[];
  64899. holes?: Vector3[][];
  64900. depth?: number;
  64901. faceUV?: Vector4[];
  64902. faceColors?: Color4[];
  64903. updatable?: boolean;
  64904. sideOrientation?: number;
  64905. frontUVs?: Vector4;
  64906. backUVs?: Vector4;
  64907. wrap?: boolean;
  64908. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64909. /**
  64910. * Creates an extruded polygon mesh, with depth in the Y direction.
  64911. * * 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)
  64912. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64913. * @param name defines the name of the mesh
  64914. * @param options defines the options used to create the mesh
  64915. * @param scene defines the hosting scene
  64916. * @param earcutInjection can be used to inject your own earcut reference
  64917. * @returns the polygon mesh
  64918. */
  64919. static ExtrudePolygon(name: string, options: {
  64920. shape: Vector3[];
  64921. holes?: Vector3[][];
  64922. depth?: number;
  64923. faceUV?: Vector4[];
  64924. faceColors?: Color4[];
  64925. updatable?: boolean;
  64926. sideOrientation?: number;
  64927. frontUVs?: Vector4;
  64928. backUVs?: Vector4;
  64929. wrap?: boolean;
  64930. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64931. }
  64932. }
  64933. declare module BABYLON {
  64934. /**
  64935. * Class containing static functions to help procedurally build meshes
  64936. */
  64937. export class LatheBuilder {
  64938. /**
  64939. * Creates lathe mesh.
  64940. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64941. * * 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
  64942. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64943. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64944. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64945. * * 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
  64946. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64947. * * 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
  64948. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64949. * * 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
  64950. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64951. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64952. * @param name defines the name of the mesh
  64953. * @param options defines the options used to create the mesh
  64954. * @param scene defines the hosting scene
  64955. * @returns the lathe mesh
  64956. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64957. */
  64958. static CreateLathe(name: string, options: {
  64959. shape: Vector3[];
  64960. radius?: number;
  64961. tessellation?: number;
  64962. clip?: number;
  64963. arc?: number;
  64964. closed?: boolean;
  64965. updatable?: boolean;
  64966. sideOrientation?: number;
  64967. frontUVs?: Vector4;
  64968. backUVs?: Vector4;
  64969. cap?: number;
  64970. invertUV?: boolean;
  64971. }, scene?: Nullable<Scene>): Mesh;
  64972. }
  64973. }
  64974. declare module BABYLON {
  64975. /**
  64976. * Class containing static functions to help procedurally build meshes
  64977. */
  64978. export class TiledPlaneBuilder {
  64979. /**
  64980. * Creates a tiled plane mesh
  64981. * * The parameter `pattern` will, depending on value, do nothing or
  64982. * * * flip (reflect about central vertical) alternate tiles across and up
  64983. * * * flip every tile on alternate rows
  64984. * * * rotate (180 degs) alternate tiles across and up
  64985. * * * rotate every tile on alternate rows
  64986. * * * flip and rotate alternate tiles across and up
  64987. * * * flip and rotate every tile on alternate rows
  64988. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  64989. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  64990. * * 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
  64991. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64992. * * 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)
  64993. * * 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)
  64994. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64995. * @param name defines the name of the mesh
  64996. * @param options defines the options used to create the mesh
  64997. * @param scene defines the hosting scene
  64998. * @returns the box mesh
  64999. */
  65000. static CreateTiledPlane(name: string, options: {
  65001. pattern?: number;
  65002. tileSize?: number;
  65003. tileWidth?: number;
  65004. tileHeight?: number;
  65005. size?: number;
  65006. width?: number;
  65007. height?: number;
  65008. alignHorizontal?: number;
  65009. alignVertical?: number;
  65010. sideOrientation?: number;
  65011. frontUVs?: Vector4;
  65012. backUVs?: Vector4;
  65013. updatable?: boolean;
  65014. }, scene?: Nullable<Scene>): Mesh;
  65015. }
  65016. }
  65017. declare module BABYLON {
  65018. /**
  65019. * Class containing static functions to help procedurally build meshes
  65020. */
  65021. export class TubeBuilder {
  65022. /**
  65023. * Creates a tube mesh.
  65024. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65025. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65026. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65027. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65028. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65029. * * 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)
  65030. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65031. * * 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
  65032. * * 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
  65033. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65034. * * 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
  65035. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65036. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65037. * @param name defines the name of the mesh
  65038. * @param options defines the options used to create the mesh
  65039. * @param scene defines the hosting scene
  65040. * @returns the tube mesh
  65041. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65042. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65043. */
  65044. static CreateTube(name: string, options: {
  65045. path: Vector3[];
  65046. radius?: number;
  65047. tessellation?: number;
  65048. radiusFunction?: {
  65049. (i: number, distance: number): number;
  65050. };
  65051. cap?: number;
  65052. arc?: number;
  65053. updatable?: boolean;
  65054. sideOrientation?: number;
  65055. frontUVs?: Vector4;
  65056. backUVs?: Vector4;
  65057. instance?: Mesh;
  65058. invertUV?: boolean;
  65059. }, scene?: Nullable<Scene>): Mesh;
  65060. }
  65061. }
  65062. declare module BABYLON {
  65063. /**
  65064. * Class containing static functions to help procedurally build meshes
  65065. */
  65066. export class IcoSphereBuilder {
  65067. /**
  65068. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65069. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65070. * * 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`)
  65071. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65072. * * 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
  65073. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65074. * * 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
  65075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65076. * @param name defines the name of the mesh
  65077. * @param options defines the options used to create the mesh
  65078. * @param scene defines the hosting scene
  65079. * @returns the icosahedron mesh
  65080. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65081. */
  65082. static CreateIcoSphere(name: string, options: {
  65083. radius?: number;
  65084. radiusX?: number;
  65085. radiusY?: number;
  65086. radiusZ?: number;
  65087. flat?: boolean;
  65088. subdivisions?: number;
  65089. sideOrientation?: number;
  65090. frontUVs?: Vector4;
  65091. backUVs?: Vector4;
  65092. updatable?: boolean;
  65093. }, scene?: Nullable<Scene>): Mesh;
  65094. }
  65095. }
  65096. declare module BABYLON {
  65097. /**
  65098. * Class containing static functions to help procedurally build meshes
  65099. */
  65100. export class DecalBuilder {
  65101. /**
  65102. * Creates a decal mesh.
  65103. * 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
  65104. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65105. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65106. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65107. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65108. * @param name defines the name of the mesh
  65109. * @param sourceMesh defines the mesh where the decal must be applied
  65110. * @param options defines the options used to create the mesh
  65111. * @param scene defines the hosting scene
  65112. * @returns the decal mesh
  65113. * @see https://doc.babylonjs.com/how_to/decals
  65114. */
  65115. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65116. position?: Vector3;
  65117. normal?: Vector3;
  65118. size?: Vector3;
  65119. angle?: number;
  65120. }): Mesh;
  65121. }
  65122. }
  65123. declare module BABYLON {
  65124. /**
  65125. * Class containing static functions to help procedurally build meshes
  65126. */
  65127. export class MeshBuilder {
  65128. /**
  65129. * Creates a box mesh
  65130. * * The parameter `size` sets the size (float) of each box side (default 1)
  65131. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  65132. * * 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)
  65133. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65134. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65135. * * 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
  65136. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65137. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65138. * @param name defines the name of the mesh
  65139. * @param options defines the options used to create the mesh
  65140. * @param scene defines the hosting scene
  65141. * @returns the box mesh
  65142. */
  65143. static CreateBox(name: string, options: {
  65144. size?: number;
  65145. width?: number;
  65146. height?: number;
  65147. depth?: number;
  65148. faceUV?: Vector4[];
  65149. faceColors?: Color4[];
  65150. sideOrientation?: number;
  65151. frontUVs?: Vector4;
  65152. backUVs?: Vector4;
  65153. wrap?: boolean;
  65154. topBaseAt?: number;
  65155. bottomBaseAt?: number;
  65156. updatable?: boolean;
  65157. }, scene?: Nullable<Scene>): Mesh;
  65158. /**
  65159. * Creates a tiled box mesh
  65160. * * faceTiles sets the pattern, tile size and number of tiles for a face
  65161. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65162. * @param name defines the name of the mesh
  65163. * @param options defines the options used to create the mesh
  65164. * @param scene defines the hosting scene
  65165. * @returns the tiled box mesh
  65166. */
  65167. static CreateTiledBox(name: string, options: {
  65168. pattern?: number;
  65169. size?: number;
  65170. width?: number;
  65171. height?: number;
  65172. depth: number;
  65173. tileSize?: number;
  65174. tileWidth?: number;
  65175. tileHeight?: number;
  65176. faceUV?: Vector4[];
  65177. faceColors?: Color4[];
  65178. alignHorizontal?: number;
  65179. alignVertical?: number;
  65180. sideOrientation?: number;
  65181. updatable?: boolean;
  65182. }, scene?: Nullable<Scene>): Mesh;
  65183. /**
  65184. * Creates a sphere mesh
  65185. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  65186. * * 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`)
  65187. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  65188. * * 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
  65189. * * 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)
  65190. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65191. * * 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
  65192. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65193. * @param name defines the name of the mesh
  65194. * @param options defines the options used to create the mesh
  65195. * @param scene defines the hosting scene
  65196. * @returns the sphere mesh
  65197. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  65198. */
  65199. static CreateSphere(name: string, options: {
  65200. segments?: number;
  65201. diameter?: number;
  65202. diameterX?: number;
  65203. diameterY?: number;
  65204. diameterZ?: number;
  65205. arc?: number;
  65206. slice?: number;
  65207. sideOrientation?: number;
  65208. frontUVs?: Vector4;
  65209. backUVs?: Vector4;
  65210. updatable?: boolean;
  65211. }, scene?: Nullable<Scene>): Mesh;
  65212. /**
  65213. * Creates a plane polygonal mesh. By default, this is a disc
  65214. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  65215. * * 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
  65216. * * 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
  65217. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65218. * * 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
  65219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65220. * @param name defines the name of the mesh
  65221. * @param options defines the options used to create the mesh
  65222. * @param scene defines the hosting scene
  65223. * @returns the plane polygonal mesh
  65224. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  65225. */
  65226. static CreateDisc(name: string, options: {
  65227. radius?: number;
  65228. tessellation?: number;
  65229. arc?: number;
  65230. updatable?: boolean;
  65231. sideOrientation?: number;
  65232. frontUVs?: Vector4;
  65233. backUVs?: Vector4;
  65234. }, scene?: Nullable<Scene>): Mesh;
  65235. /**
  65236. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65237. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65238. * * 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`)
  65239. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65240. * * 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
  65241. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65242. * * 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
  65243. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65244. * @param name defines the name of the mesh
  65245. * @param options defines the options used to create the mesh
  65246. * @param scene defines the hosting scene
  65247. * @returns the icosahedron mesh
  65248. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65249. */
  65250. static CreateIcoSphere(name: string, options: {
  65251. radius?: number;
  65252. radiusX?: number;
  65253. radiusY?: number;
  65254. radiusZ?: number;
  65255. flat?: boolean;
  65256. subdivisions?: number;
  65257. sideOrientation?: number;
  65258. frontUVs?: Vector4;
  65259. backUVs?: Vector4;
  65260. updatable?: boolean;
  65261. }, scene?: Nullable<Scene>): Mesh;
  65262. /**
  65263. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65264. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  65265. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  65266. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  65267. * * 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
  65268. * * 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
  65269. * * 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
  65270. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65271. * * 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
  65272. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65273. * * 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
  65274. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  65275. * * 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
  65276. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  65277. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65278. * @param name defines the name of the mesh
  65279. * @param options defines the options used to create the mesh
  65280. * @param scene defines the hosting scene
  65281. * @returns the ribbon mesh
  65282. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  65283. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65284. */
  65285. static CreateRibbon(name: string, options: {
  65286. pathArray: Vector3[][];
  65287. closeArray?: boolean;
  65288. closePath?: boolean;
  65289. offset?: number;
  65290. updatable?: boolean;
  65291. sideOrientation?: number;
  65292. frontUVs?: Vector4;
  65293. backUVs?: Vector4;
  65294. instance?: Mesh;
  65295. invertUV?: boolean;
  65296. uvs?: Vector2[];
  65297. colors?: Color4[];
  65298. }, scene?: Nullable<Scene>): Mesh;
  65299. /**
  65300. * Creates a cylinder or a cone mesh
  65301. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  65302. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  65303. * * 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.
  65304. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  65305. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  65306. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  65307. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  65308. * * 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).
  65309. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  65310. * * 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).
  65311. * * 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
  65312. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  65313. * * 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
  65314. * * 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.
  65315. * * If `enclose` is false, a ring surface is one element.
  65316. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  65317. * * 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
  65318. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65319. * * 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
  65320. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65321. * @param name defines the name of the mesh
  65322. * @param options defines the options used to create the mesh
  65323. * @param scene defines the hosting scene
  65324. * @returns the cylinder mesh
  65325. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  65326. */
  65327. static CreateCylinder(name: string, options: {
  65328. height?: number;
  65329. diameterTop?: number;
  65330. diameterBottom?: number;
  65331. diameter?: number;
  65332. tessellation?: number;
  65333. subdivisions?: number;
  65334. arc?: number;
  65335. faceColors?: Color4[];
  65336. faceUV?: Vector4[];
  65337. updatable?: boolean;
  65338. hasRings?: boolean;
  65339. enclose?: boolean;
  65340. cap?: number;
  65341. sideOrientation?: number;
  65342. frontUVs?: Vector4;
  65343. backUVs?: Vector4;
  65344. }, scene?: Nullable<Scene>): Mesh;
  65345. /**
  65346. * Creates a torus mesh
  65347. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  65348. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  65349. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  65350. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65351. * * 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
  65352. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65353. * @param name defines the name of the mesh
  65354. * @param options defines the options used to create the mesh
  65355. * @param scene defines the hosting scene
  65356. * @returns the torus mesh
  65357. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  65358. */
  65359. static CreateTorus(name: string, options: {
  65360. diameter?: number;
  65361. thickness?: number;
  65362. tessellation?: number;
  65363. updatable?: boolean;
  65364. sideOrientation?: number;
  65365. frontUVs?: Vector4;
  65366. backUVs?: Vector4;
  65367. }, scene?: Nullable<Scene>): Mesh;
  65368. /**
  65369. * Creates a torus knot mesh
  65370. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65371. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65372. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65373. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65374. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65375. * * 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
  65376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65377. * @param name defines the name of the mesh
  65378. * @param options defines the options used to create the mesh
  65379. * @param scene defines the hosting scene
  65380. * @returns the torus knot mesh
  65381. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65382. */
  65383. static CreateTorusKnot(name: string, options: {
  65384. radius?: number;
  65385. tube?: number;
  65386. radialSegments?: number;
  65387. tubularSegments?: number;
  65388. p?: number;
  65389. q?: number;
  65390. updatable?: boolean;
  65391. sideOrientation?: number;
  65392. frontUVs?: Vector4;
  65393. backUVs?: Vector4;
  65394. }, scene?: Nullable<Scene>): Mesh;
  65395. /**
  65396. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  65397. * * 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
  65398. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  65399. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  65400. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  65401. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  65402. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  65403. * * 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
  65404. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  65405. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65406. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  65407. * @param name defines the name of the new line system
  65408. * @param options defines the options used to create the line system
  65409. * @param scene defines the hosting scene
  65410. * @returns a new line system mesh
  65411. */
  65412. static CreateLineSystem(name: string, options: {
  65413. lines: Vector3[][];
  65414. updatable?: boolean;
  65415. instance?: Nullable<LinesMesh>;
  65416. colors?: Nullable<Color4[][]>;
  65417. useVertexAlpha?: boolean;
  65418. }, scene: Nullable<Scene>): LinesMesh;
  65419. /**
  65420. * Creates a line mesh
  65421. * 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
  65422. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  65423. * * The parameter `points` is an array successive Vector3
  65424. * * 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
  65425. * * The optional parameter `colors` is an array of successive Color4, one per line point
  65426. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  65427. * * When updating an instance, remember that only point positions can change, not the number of points
  65428. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65429. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  65430. * @param name defines the name of the new line system
  65431. * @param options defines the options used to create the line system
  65432. * @param scene defines the hosting scene
  65433. * @returns a new line mesh
  65434. */
  65435. static CreateLines(name: string, options: {
  65436. points: Vector3[];
  65437. updatable?: boolean;
  65438. instance?: Nullable<LinesMesh>;
  65439. colors?: Color4[];
  65440. useVertexAlpha?: boolean;
  65441. }, scene?: Nullable<Scene>): LinesMesh;
  65442. /**
  65443. * Creates a dashed line mesh
  65444. * * 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
  65445. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  65446. * * The parameter `points` is an array successive Vector3
  65447. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  65448. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  65449. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  65450. * * 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
  65451. * * When updating an instance, remember that only point positions can change, not the number of points
  65452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65453. * @param name defines the name of the mesh
  65454. * @param options defines the options used to create the mesh
  65455. * @param scene defines the hosting scene
  65456. * @returns the dashed line mesh
  65457. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  65458. */
  65459. static CreateDashedLines(name: string, options: {
  65460. points: Vector3[];
  65461. dashSize?: number;
  65462. gapSize?: number;
  65463. dashNb?: number;
  65464. updatable?: boolean;
  65465. instance?: LinesMesh;
  65466. }, scene?: Nullable<Scene>): LinesMesh;
  65467. /**
  65468. * 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.
  65469. * * 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.
  65470. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65471. * * 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.
  65472. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  65473. * * 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
  65474. * * 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
  65475. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  65476. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65477. * * 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
  65478. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  65479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65480. * @param name defines the name of the mesh
  65481. * @param options defines the options used to create the mesh
  65482. * @param scene defines the hosting scene
  65483. * @returns the extruded shape mesh
  65484. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65485. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65486. */
  65487. static ExtrudeShape(name: string, options: {
  65488. shape: Vector3[];
  65489. path: Vector3[];
  65490. scale?: number;
  65491. rotation?: number;
  65492. cap?: number;
  65493. updatable?: boolean;
  65494. sideOrientation?: number;
  65495. frontUVs?: Vector4;
  65496. backUVs?: Vector4;
  65497. instance?: Mesh;
  65498. invertUV?: boolean;
  65499. }, scene?: Nullable<Scene>): Mesh;
  65500. /**
  65501. * Creates an custom extruded shape mesh.
  65502. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  65503. * * 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.
  65504. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65505. * * 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
  65506. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  65507. * * 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
  65508. * * It must returns a float value that will be the scale value applied to the shape on each path point
  65509. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  65510. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  65511. * * 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
  65512. * * 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
  65513. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  65514. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65515. * * 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
  65516. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65518. * @param name defines the name of the mesh
  65519. * @param options defines the options used to create the mesh
  65520. * @param scene defines the hosting scene
  65521. * @returns the custom extruded shape mesh
  65522. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  65523. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65524. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65525. */
  65526. static ExtrudeShapeCustom(name: string, options: {
  65527. shape: Vector3[];
  65528. path: Vector3[];
  65529. scaleFunction?: any;
  65530. rotationFunction?: any;
  65531. ribbonCloseArray?: boolean;
  65532. ribbonClosePath?: boolean;
  65533. cap?: number;
  65534. updatable?: boolean;
  65535. sideOrientation?: number;
  65536. frontUVs?: Vector4;
  65537. backUVs?: Vector4;
  65538. instance?: Mesh;
  65539. invertUV?: boolean;
  65540. }, scene?: Nullable<Scene>): Mesh;
  65541. /**
  65542. * Creates lathe mesh.
  65543. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65544. * * 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
  65545. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65546. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65547. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65548. * * 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
  65549. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65550. * * 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
  65551. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65552. * * 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
  65553. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65554. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65555. * @param name defines the name of the mesh
  65556. * @param options defines the options used to create the mesh
  65557. * @param scene defines the hosting scene
  65558. * @returns the lathe mesh
  65559. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65560. */
  65561. static CreateLathe(name: string, options: {
  65562. shape: Vector3[];
  65563. radius?: number;
  65564. tessellation?: number;
  65565. clip?: number;
  65566. arc?: number;
  65567. closed?: boolean;
  65568. updatable?: boolean;
  65569. sideOrientation?: number;
  65570. frontUVs?: Vector4;
  65571. backUVs?: Vector4;
  65572. cap?: number;
  65573. invertUV?: boolean;
  65574. }, scene?: Nullable<Scene>): Mesh;
  65575. /**
  65576. * Creates a tiled plane mesh
  65577. * * You can set a limited pattern arrangement with the tiles
  65578. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65579. * * 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
  65580. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65581. * @param name defines the name of the mesh
  65582. * @param options defines the options used to create the mesh
  65583. * @param scene defines the hosting scene
  65584. * @returns the plane mesh
  65585. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65586. */
  65587. static CreateTiledPlane(name: string, options: {
  65588. pattern?: number;
  65589. tileSize?: number;
  65590. tileWidth?: number;
  65591. tileHeight?: number;
  65592. size?: number;
  65593. width?: number;
  65594. height?: number;
  65595. alignHorizontal?: number;
  65596. alignVertical?: number;
  65597. sideOrientation?: number;
  65598. frontUVs?: Vector4;
  65599. backUVs?: Vector4;
  65600. updatable?: boolean;
  65601. }, scene?: Nullable<Scene>): Mesh;
  65602. /**
  65603. * Creates a plane mesh
  65604. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  65605. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  65606. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  65607. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65608. * * 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
  65609. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65610. * @param name defines the name of the mesh
  65611. * @param options defines the options used to create the mesh
  65612. * @param scene defines the hosting scene
  65613. * @returns the plane mesh
  65614. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65615. */
  65616. static CreatePlane(name: string, options: {
  65617. size?: number;
  65618. width?: number;
  65619. height?: number;
  65620. sideOrientation?: number;
  65621. frontUVs?: Vector4;
  65622. backUVs?: Vector4;
  65623. updatable?: boolean;
  65624. sourcePlane?: Plane;
  65625. }, scene?: Nullable<Scene>): Mesh;
  65626. /**
  65627. * Creates a ground mesh
  65628. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  65629. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  65630. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65631. * @param name defines the name of the mesh
  65632. * @param options defines the options used to create the mesh
  65633. * @param scene defines the hosting scene
  65634. * @returns the ground mesh
  65635. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  65636. */
  65637. static CreateGround(name: string, options: {
  65638. width?: number;
  65639. height?: number;
  65640. subdivisions?: number;
  65641. subdivisionsX?: number;
  65642. subdivisionsY?: number;
  65643. updatable?: boolean;
  65644. }, scene?: Nullable<Scene>): Mesh;
  65645. /**
  65646. * Creates a tiled ground mesh
  65647. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  65648. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  65649. * * 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
  65650. * * 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
  65651. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65652. * @param name defines the name of the mesh
  65653. * @param options defines the options used to create the mesh
  65654. * @param scene defines the hosting scene
  65655. * @returns the tiled ground mesh
  65656. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  65657. */
  65658. static CreateTiledGround(name: string, options: {
  65659. xmin: number;
  65660. zmin: number;
  65661. xmax: number;
  65662. zmax: number;
  65663. subdivisions?: {
  65664. w: number;
  65665. h: number;
  65666. };
  65667. precision?: {
  65668. w: number;
  65669. h: number;
  65670. };
  65671. updatable?: boolean;
  65672. }, scene?: Nullable<Scene>): Mesh;
  65673. /**
  65674. * Creates a ground mesh from a height map
  65675. * * The parameter `url` sets the URL of the height map image resource.
  65676. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  65677. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  65678. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  65679. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  65680. * * 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.
  65681. * * 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).
  65682. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  65683. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65684. * @param name defines the name of the mesh
  65685. * @param url defines the url to the height map
  65686. * @param options defines the options used to create the mesh
  65687. * @param scene defines the hosting scene
  65688. * @returns the ground mesh
  65689. * @see https://doc.babylonjs.com/babylon101/height_map
  65690. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  65691. */
  65692. static CreateGroundFromHeightMap(name: string, url: string, options: {
  65693. width?: number;
  65694. height?: number;
  65695. subdivisions?: number;
  65696. minHeight?: number;
  65697. maxHeight?: number;
  65698. colorFilter?: Color3;
  65699. alphaFilter?: number;
  65700. updatable?: boolean;
  65701. onReady?: (mesh: GroundMesh) => void;
  65702. }, scene?: Nullable<Scene>): GroundMesh;
  65703. /**
  65704. * Creates a polygon mesh
  65705. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65706. * * 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
  65707. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65709. * * 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)
  65710. * * Remember you can only change the shape positions, not their number when updating a polygon
  65711. * @param name defines the name of the mesh
  65712. * @param options defines the options used to create the mesh
  65713. * @param scene defines the hosting scene
  65714. * @param earcutInjection can be used to inject your own earcut reference
  65715. * @returns the polygon mesh
  65716. */
  65717. static CreatePolygon(name: string, options: {
  65718. shape: Vector3[];
  65719. holes?: Vector3[][];
  65720. depth?: number;
  65721. faceUV?: Vector4[];
  65722. faceColors?: Color4[];
  65723. updatable?: boolean;
  65724. sideOrientation?: number;
  65725. frontUVs?: Vector4;
  65726. backUVs?: Vector4;
  65727. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65728. /**
  65729. * Creates an extruded polygon mesh, with depth in the Y direction.
  65730. * * 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)
  65731. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65732. * @param name defines the name of the mesh
  65733. * @param options defines the options used to create the mesh
  65734. * @param scene defines the hosting scene
  65735. * @param earcutInjection can be used to inject your own earcut reference
  65736. * @returns the polygon mesh
  65737. */
  65738. static ExtrudePolygon(name: string, options: {
  65739. shape: Vector3[];
  65740. holes?: Vector3[][];
  65741. depth?: number;
  65742. faceUV?: Vector4[];
  65743. faceColors?: Color4[];
  65744. updatable?: boolean;
  65745. sideOrientation?: number;
  65746. frontUVs?: Vector4;
  65747. backUVs?: Vector4;
  65748. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65749. /**
  65750. * Creates a tube mesh.
  65751. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65752. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65753. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65754. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65755. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65756. * * 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)
  65757. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65758. * * 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
  65759. * * 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
  65760. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65761. * * 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
  65762. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65763. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65764. * @param name defines the name of the mesh
  65765. * @param options defines the options used to create the mesh
  65766. * @param scene defines the hosting scene
  65767. * @returns the tube mesh
  65768. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65769. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65770. */
  65771. static CreateTube(name: string, options: {
  65772. path: Vector3[];
  65773. radius?: number;
  65774. tessellation?: number;
  65775. radiusFunction?: {
  65776. (i: number, distance: number): number;
  65777. };
  65778. cap?: number;
  65779. arc?: number;
  65780. updatable?: boolean;
  65781. sideOrientation?: number;
  65782. frontUVs?: Vector4;
  65783. backUVs?: Vector4;
  65784. instance?: Mesh;
  65785. invertUV?: boolean;
  65786. }, scene?: Nullable<Scene>): Mesh;
  65787. /**
  65788. * Creates a polyhedron mesh
  65789. * * 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
  65790. * * The parameter `size` (positive float, default 1) sets the polygon size
  65791. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  65792. * * 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`
  65793. * * 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
  65794. * * 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)`)
  65795. * * 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
  65796. * * 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
  65797. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65798. * * 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
  65799. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65800. * @param name defines the name of the mesh
  65801. * @param options defines the options used to create the mesh
  65802. * @param scene defines the hosting scene
  65803. * @returns the polyhedron mesh
  65804. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  65805. */
  65806. static CreatePolyhedron(name: string, options: {
  65807. type?: number;
  65808. size?: number;
  65809. sizeX?: number;
  65810. sizeY?: number;
  65811. sizeZ?: number;
  65812. custom?: any;
  65813. faceUV?: Vector4[];
  65814. faceColors?: Color4[];
  65815. flat?: boolean;
  65816. updatable?: boolean;
  65817. sideOrientation?: number;
  65818. frontUVs?: Vector4;
  65819. backUVs?: Vector4;
  65820. }, scene?: Nullable<Scene>): Mesh;
  65821. /**
  65822. * Creates a decal mesh.
  65823. * 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
  65824. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65825. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65826. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65827. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65828. * @param name defines the name of the mesh
  65829. * @param sourceMesh defines the mesh where the decal must be applied
  65830. * @param options defines the options used to create the mesh
  65831. * @param scene defines the hosting scene
  65832. * @returns the decal mesh
  65833. * @see https://doc.babylonjs.com/how_to/decals
  65834. */
  65835. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65836. position?: Vector3;
  65837. normal?: Vector3;
  65838. size?: Vector3;
  65839. angle?: number;
  65840. }): Mesh;
  65841. }
  65842. }
  65843. declare module BABYLON {
  65844. /**
  65845. * A simplifier interface for future simplification implementations
  65846. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65847. */
  65848. export interface ISimplifier {
  65849. /**
  65850. * Simplification of a given mesh according to the given settings.
  65851. * Since this requires computation, it is assumed that the function runs async.
  65852. * @param settings The settings of the simplification, including quality and distance
  65853. * @param successCallback A callback that will be called after the mesh was simplified.
  65854. * @param errorCallback in case of an error, this callback will be called. optional.
  65855. */
  65856. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  65857. }
  65858. /**
  65859. * Expected simplification settings.
  65860. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  65861. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65862. */
  65863. export interface ISimplificationSettings {
  65864. /**
  65865. * Gets or sets the expected quality
  65866. */
  65867. quality: number;
  65868. /**
  65869. * Gets or sets the distance when this optimized version should be used
  65870. */
  65871. distance: number;
  65872. /**
  65873. * Gets an already optimized mesh
  65874. */
  65875. optimizeMesh?: boolean;
  65876. }
  65877. /**
  65878. * Class used to specify simplification options
  65879. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65880. */
  65881. export class SimplificationSettings implements ISimplificationSettings {
  65882. /** expected quality */
  65883. quality: number;
  65884. /** distance when this optimized version should be used */
  65885. distance: number;
  65886. /** already optimized mesh */
  65887. optimizeMesh?: boolean | undefined;
  65888. /**
  65889. * Creates a SimplificationSettings
  65890. * @param quality expected quality
  65891. * @param distance distance when this optimized version should be used
  65892. * @param optimizeMesh already optimized mesh
  65893. */
  65894. constructor(
  65895. /** expected quality */
  65896. quality: number,
  65897. /** distance when this optimized version should be used */
  65898. distance: number,
  65899. /** already optimized mesh */
  65900. optimizeMesh?: boolean | undefined);
  65901. }
  65902. /**
  65903. * Interface used to define a simplification task
  65904. */
  65905. export interface ISimplificationTask {
  65906. /**
  65907. * Array of settings
  65908. */
  65909. settings: Array<ISimplificationSettings>;
  65910. /**
  65911. * Simplification type
  65912. */
  65913. simplificationType: SimplificationType;
  65914. /**
  65915. * Mesh to simplify
  65916. */
  65917. mesh: Mesh;
  65918. /**
  65919. * Callback called on success
  65920. */
  65921. successCallback?: () => void;
  65922. /**
  65923. * Defines if parallel processing can be used
  65924. */
  65925. parallelProcessing: boolean;
  65926. }
  65927. /**
  65928. * Queue used to order the simplification tasks
  65929. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65930. */
  65931. export class SimplificationQueue {
  65932. private _simplificationArray;
  65933. /**
  65934. * Gets a boolean indicating that the process is still running
  65935. */
  65936. running: boolean;
  65937. /**
  65938. * Creates a new queue
  65939. */
  65940. constructor();
  65941. /**
  65942. * Adds a new simplification task
  65943. * @param task defines a task to add
  65944. */
  65945. addTask(task: ISimplificationTask): void;
  65946. /**
  65947. * Execute next task
  65948. */
  65949. executeNext(): void;
  65950. /**
  65951. * Execute a simplification task
  65952. * @param task defines the task to run
  65953. */
  65954. runSimplification(task: ISimplificationTask): void;
  65955. private getSimplifier;
  65956. }
  65957. /**
  65958. * The implemented types of simplification
  65959. * At the moment only Quadratic Error Decimation is implemented
  65960. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65961. */
  65962. export enum SimplificationType {
  65963. /** Quadratic error decimation */
  65964. QUADRATIC = 0
  65965. }
  65966. /**
  65967. * An implementation of the Quadratic Error simplification algorithm.
  65968. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  65969. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  65970. * @author RaananW
  65971. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65972. */
  65973. export class QuadraticErrorSimplification implements ISimplifier {
  65974. private _mesh;
  65975. private triangles;
  65976. private vertices;
  65977. private references;
  65978. private _reconstructedMesh;
  65979. /** Gets or sets the number pf sync interations */
  65980. syncIterations: number;
  65981. /** Gets or sets the aggressiveness of the simplifier */
  65982. aggressiveness: number;
  65983. /** Gets or sets the number of allowed iterations for decimation */
  65984. decimationIterations: number;
  65985. /** Gets or sets the espilon to use for bounding box computation */
  65986. boundingBoxEpsilon: number;
  65987. /**
  65988. * Creates a new QuadraticErrorSimplification
  65989. * @param _mesh defines the target mesh
  65990. */
  65991. constructor(_mesh: Mesh);
  65992. /**
  65993. * Simplification of a given mesh according to the given settings.
  65994. * Since this requires computation, it is assumed that the function runs async.
  65995. * @param settings The settings of the simplification, including quality and distance
  65996. * @param successCallback A callback that will be called after the mesh was simplified.
  65997. */
  65998. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  65999. private runDecimation;
  66000. private initWithMesh;
  66001. private init;
  66002. private reconstructMesh;
  66003. private initDecimatedMesh;
  66004. private isFlipped;
  66005. private updateTriangles;
  66006. private identifyBorder;
  66007. private updateMesh;
  66008. private vertexError;
  66009. private calculateError;
  66010. }
  66011. }
  66012. declare module BABYLON {
  66013. interface Scene {
  66014. /** @hidden (Backing field) */
  66015. _simplificationQueue: SimplificationQueue;
  66016. /**
  66017. * Gets or sets the simplification queue attached to the scene
  66018. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66019. */
  66020. simplificationQueue: SimplificationQueue;
  66021. }
  66022. interface Mesh {
  66023. /**
  66024. * Simplify the mesh according to the given array of settings.
  66025. * Function will return immediately and will simplify async
  66026. * @param settings a collection of simplification settings
  66027. * @param parallelProcessing should all levels calculate parallel or one after the other
  66028. * @param simplificationType the type of simplification to run
  66029. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  66030. * @returns the current mesh
  66031. */
  66032. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  66033. }
  66034. /**
  66035. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  66036. * created in a scene
  66037. */
  66038. export class SimplicationQueueSceneComponent implements ISceneComponent {
  66039. /**
  66040. * The component name helpfull to identify the component in the list of scene components.
  66041. */
  66042. readonly name: string;
  66043. /**
  66044. * The scene the component belongs to.
  66045. */
  66046. scene: Scene;
  66047. /**
  66048. * Creates a new instance of the component for the given scene
  66049. * @param scene Defines the scene to register the component in
  66050. */
  66051. constructor(scene: Scene);
  66052. /**
  66053. * Registers the component in a given scene
  66054. */
  66055. register(): void;
  66056. /**
  66057. * Rebuilds the elements related to this component in case of
  66058. * context lost for instance.
  66059. */
  66060. rebuild(): void;
  66061. /**
  66062. * Disposes the component and the associated ressources
  66063. */
  66064. dispose(): void;
  66065. private _beforeCameraUpdate;
  66066. }
  66067. }
  66068. declare module BABYLON {
  66069. interface Mesh {
  66070. /**
  66071. * Creates a new thin instance
  66072. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  66073. * @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
  66074. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  66075. */
  66076. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  66077. /**
  66078. * Adds the transformation (matrix) of the current mesh as a thin instance
  66079. * @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
  66080. * @returns the thin instance index number
  66081. */
  66082. thinInstanceAddSelf(refresh: boolean): number;
  66083. /**
  66084. * Registers a custom attribute to be used with thin instances
  66085. * @param kind name of the attribute
  66086. * @param stride size in floats of the attribute
  66087. */
  66088. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  66089. /**
  66090. * Sets the matrix of a thin instance
  66091. * @param index index of the thin instance
  66092. * @param matrix matrix to set
  66093. * @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
  66094. */
  66095. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  66096. /**
  66097. * Sets the value of a custom attribute for a thin instance
  66098. * @param kind name of the attribute
  66099. * @param index index of the thin instance
  66100. * @param value value to set
  66101. * @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
  66102. */
  66103. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  66104. /**
  66105. * 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.
  66106. */
  66107. thinInstanceCount: number;
  66108. /**
  66109. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  66110. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  66111. * @param buffer buffer to set
  66112. * @param stride size in floats of each value of the buffer
  66113. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  66114. */
  66115. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  66116. /**
  66117. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  66118. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  66119. */
  66120. thinInstanceBufferUpdated(kind: string): void;
  66121. /**
  66122. * Refreshes the bounding info, taking into account all the thin instances defined
  66123. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  66124. */
  66125. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  66126. /** @hidden */
  66127. _thinInstanceInitializeUserStorage(): void;
  66128. /** @hidden */
  66129. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  66130. /** @hidden */
  66131. _userThinInstanceBuffersStorage: {
  66132. data: {
  66133. [key: string]: Float32Array;
  66134. };
  66135. sizes: {
  66136. [key: string]: number;
  66137. };
  66138. vertexBuffers: {
  66139. [key: string]: Nullable<VertexBuffer>;
  66140. };
  66141. strides: {
  66142. [key: string]: number;
  66143. };
  66144. };
  66145. }
  66146. }
  66147. declare module BABYLON {
  66148. /**
  66149. * Navigation plugin interface to add navigation constrained by a navigation mesh
  66150. */
  66151. export interface INavigationEnginePlugin {
  66152. /**
  66153. * plugin name
  66154. */
  66155. name: string;
  66156. /**
  66157. * Creates a navigation mesh
  66158. * @param meshes array of all the geometry used to compute the navigatio mesh
  66159. * @param parameters bunch of parameters used to filter geometry
  66160. */
  66161. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66162. /**
  66163. * Create a navigation mesh debug mesh
  66164. * @param scene is where the mesh will be added
  66165. * @returns debug display mesh
  66166. */
  66167. createDebugNavMesh(scene: Scene): Mesh;
  66168. /**
  66169. * Get a navigation mesh constrained position, closest to the parameter position
  66170. * @param position world position
  66171. * @returns the closest point to position constrained by the navigation mesh
  66172. */
  66173. getClosestPoint(position: Vector3): Vector3;
  66174. /**
  66175. * Get a navigation mesh constrained position, closest to the parameter position
  66176. * @param position world position
  66177. * @param result output the closest point to position constrained by the navigation mesh
  66178. */
  66179. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66180. /**
  66181. * Get a navigation mesh constrained position, within a particular radius
  66182. * @param position world position
  66183. * @param maxRadius the maximum distance to the constrained world position
  66184. * @returns the closest point to position constrained by the navigation mesh
  66185. */
  66186. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66187. /**
  66188. * Get a navigation mesh constrained position, within a particular radius
  66189. * @param position world position
  66190. * @param maxRadius the maximum distance to the constrained world position
  66191. * @param result output the closest point to position constrained by the navigation mesh
  66192. */
  66193. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66194. /**
  66195. * Compute the final position from a segment made of destination-position
  66196. * @param position world position
  66197. * @param destination world position
  66198. * @returns the resulting point along the navmesh
  66199. */
  66200. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66201. /**
  66202. * Compute the final position from a segment made of destination-position
  66203. * @param position world position
  66204. * @param destination world position
  66205. * @param result output the resulting point along the navmesh
  66206. */
  66207. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66208. /**
  66209. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66210. * @param start world position
  66211. * @param end world position
  66212. * @returns array containing world position composing the path
  66213. */
  66214. computePath(start: Vector3, end: Vector3): Vector3[];
  66215. /**
  66216. * If this plugin is supported
  66217. * @returns true if plugin is supported
  66218. */
  66219. isSupported(): boolean;
  66220. /**
  66221. * Create a new Crowd so you can add agents
  66222. * @param maxAgents the maximum agent count in the crowd
  66223. * @param maxAgentRadius the maximum radius an agent can have
  66224. * @param scene to attach the crowd to
  66225. * @returns the crowd you can add agents to
  66226. */
  66227. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66228. /**
  66229. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66230. * The queries will try to find a solution within those bounds
  66231. * default is (1,1,1)
  66232. * @param extent x,y,z value that define the extent around the queries point of reference
  66233. */
  66234. setDefaultQueryExtent(extent: Vector3): void;
  66235. /**
  66236. * Get the Bounding box extent specified by setDefaultQueryExtent
  66237. * @returns the box extent values
  66238. */
  66239. getDefaultQueryExtent(): Vector3;
  66240. /**
  66241. * build the navmesh from a previously saved state using getNavmeshData
  66242. * @param data the Uint8Array returned by getNavmeshData
  66243. */
  66244. buildFromNavmeshData(data: Uint8Array): void;
  66245. /**
  66246. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66247. * @returns data the Uint8Array that can be saved and reused
  66248. */
  66249. getNavmeshData(): Uint8Array;
  66250. /**
  66251. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66252. * @param result output the box extent values
  66253. */
  66254. getDefaultQueryExtentToRef(result: Vector3): void;
  66255. /**
  66256. * Release all resources
  66257. */
  66258. dispose(): void;
  66259. }
  66260. /**
  66261. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  66262. */
  66263. export interface ICrowd {
  66264. /**
  66265. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  66266. * You can attach anything to that node. The node position is updated in the scene update tick.
  66267. * @param pos world position that will be constrained by the navigation mesh
  66268. * @param parameters agent parameters
  66269. * @param transform hooked to the agent that will be update by the scene
  66270. * @returns agent index
  66271. */
  66272. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66273. /**
  66274. * Returns the agent position in world space
  66275. * @param index agent index returned by addAgent
  66276. * @returns world space position
  66277. */
  66278. getAgentPosition(index: number): Vector3;
  66279. /**
  66280. * Gets the agent position result in world space
  66281. * @param index agent index returned by addAgent
  66282. * @param result output world space position
  66283. */
  66284. getAgentPositionToRef(index: number, result: Vector3): void;
  66285. /**
  66286. * Gets the agent velocity in world space
  66287. * @param index agent index returned by addAgent
  66288. * @returns world space velocity
  66289. */
  66290. getAgentVelocity(index: number): Vector3;
  66291. /**
  66292. * Gets the agent velocity result in world space
  66293. * @param index agent index returned by addAgent
  66294. * @param result output world space velocity
  66295. */
  66296. getAgentVelocityToRef(index: number, result: Vector3): void;
  66297. /**
  66298. * remove a particular agent previously created
  66299. * @param index agent index returned by addAgent
  66300. */
  66301. removeAgent(index: number): void;
  66302. /**
  66303. * get the list of all agents attached to this crowd
  66304. * @returns list of agent indices
  66305. */
  66306. getAgents(): number[];
  66307. /**
  66308. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66309. * @param deltaTime in seconds
  66310. */
  66311. update(deltaTime: number): void;
  66312. /**
  66313. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66314. * @param index agent index returned by addAgent
  66315. * @param destination targeted world position
  66316. */
  66317. agentGoto(index: number, destination: Vector3): void;
  66318. /**
  66319. * Teleport the agent to a new position
  66320. * @param index agent index returned by addAgent
  66321. * @param destination targeted world position
  66322. */
  66323. agentTeleport(index: number, destination: Vector3): void;
  66324. /**
  66325. * Update agent parameters
  66326. * @param index agent index returned by addAgent
  66327. * @param parameters agent parameters
  66328. */
  66329. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66330. /**
  66331. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66332. * The queries will try to find a solution within those bounds
  66333. * default is (1,1,1)
  66334. * @param extent x,y,z value that define the extent around the queries point of reference
  66335. */
  66336. setDefaultQueryExtent(extent: Vector3): void;
  66337. /**
  66338. * Get the Bounding box extent specified by setDefaultQueryExtent
  66339. * @returns the box extent values
  66340. */
  66341. getDefaultQueryExtent(): Vector3;
  66342. /**
  66343. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66344. * @param result output the box extent values
  66345. */
  66346. getDefaultQueryExtentToRef(result: Vector3): void;
  66347. /**
  66348. * Release all resources
  66349. */
  66350. dispose(): void;
  66351. }
  66352. /**
  66353. * Configures an agent
  66354. */
  66355. export interface IAgentParameters {
  66356. /**
  66357. * Agent radius. [Limit: >= 0]
  66358. */
  66359. radius: number;
  66360. /**
  66361. * Agent height. [Limit: > 0]
  66362. */
  66363. height: number;
  66364. /**
  66365. * Maximum allowed acceleration. [Limit: >= 0]
  66366. */
  66367. maxAcceleration: number;
  66368. /**
  66369. * Maximum allowed speed. [Limit: >= 0]
  66370. */
  66371. maxSpeed: number;
  66372. /**
  66373. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  66374. */
  66375. collisionQueryRange: number;
  66376. /**
  66377. * The path visibility optimization range. [Limit: > 0]
  66378. */
  66379. pathOptimizationRange: number;
  66380. /**
  66381. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  66382. */
  66383. separationWeight: number;
  66384. }
  66385. /**
  66386. * Configures the navigation mesh creation
  66387. */
  66388. export interface INavMeshParameters {
  66389. /**
  66390. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  66391. */
  66392. cs: number;
  66393. /**
  66394. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  66395. */
  66396. ch: number;
  66397. /**
  66398. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  66399. */
  66400. walkableSlopeAngle: number;
  66401. /**
  66402. * Minimum floor to 'ceiling' height that will still allow the floor area to
  66403. * be considered walkable. [Limit: >= 3] [Units: vx]
  66404. */
  66405. walkableHeight: number;
  66406. /**
  66407. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  66408. */
  66409. walkableClimb: number;
  66410. /**
  66411. * The distance to erode/shrink the walkable area of the heightfield away from
  66412. * obstructions. [Limit: >=0] [Units: vx]
  66413. */
  66414. walkableRadius: number;
  66415. /**
  66416. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  66417. */
  66418. maxEdgeLen: number;
  66419. /**
  66420. * The maximum distance a simplfied contour's border edges should deviate
  66421. * the original raw contour. [Limit: >=0] [Units: vx]
  66422. */
  66423. maxSimplificationError: number;
  66424. /**
  66425. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  66426. */
  66427. minRegionArea: number;
  66428. /**
  66429. * Any regions with a span count smaller than this value will, if possible,
  66430. * be merged with larger regions. [Limit: >=0] [Units: vx]
  66431. */
  66432. mergeRegionArea: number;
  66433. /**
  66434. * The maximum number of vertices allowed for polygons generated during the
  66435. * contour to polygon conversion process. [Limit: >= 3]
  66436. */
  66437. maxVertsPerPoly: number;
  66438. /**
  66439. * Sets the sampling distance to use when generating the detail mesh.
  66440. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  66441. */
  66442. detailSampleDist: number;
  66443. /**
  66444. * The maximum distance the detail mesh surface should deviate from heightfield
  66445. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  66446. */
  66447. detailSampleMaxError: number;
  66448. }
  66449. }
  66450. declare module BABYLON {
  66451. /**
  66452. * RecastJS navigation plugin
  66453. */
  66454. export class RecastJSPlugin implements INavigationEnginePlugin {
  66455. /**
  66456. * Reference to the Recast library
  66457. */
  66458. bjsRECAST: any;
  66459. /**
  66460. * plugin name
  66461. */
  66462. name: string;
  66463. /**
  66464. * the first navmesh created. We might extend this to support multiple navmeshes
  66465. */
  66466. navMesh: any;
  66467. /**
  66468. * Initializes the recastJS plugin
  66469. * @param recastInjection can be used to inject your own recast reference
  66470. */
  66471. constructor(recastInjection?: any);
  66472. /**
  66473. * Creates a navigation mesh
  66474. * @param meshes array of all the geometry used to compute the navigatio mesh
  66475. * @param parameters bunch of parameters used to filter geometry
  66476. */
  66477. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66478. /**
  66479. * Create a navigation mesh debug mesh
  66480. * @param scene is where the mesh will be added
  66481. * @returns debug display mesh
  66482. */
  66483. createDebugNavMesh(scene: Scene): Mesh;
  66484. /**
  66485. * Get a navigation mesh constrained position, closest to the parameter position
  66486. * @param position world position
  66487. * @returns the closest point to position constrained by the navigation mesh
  66488. */
  66489. getClosestPoint(position: Vector3): Vector3;
  66490. /**
  66491. * Get a navigation mesh constrained position, closest to the parameter position
  66492. * @param position world position
  66493. * @param result output the closest point to position constrained by the navigation mesh
  66494. */
  66495. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66496. /**
  66497. * Get a navigation mesh constrained position, within a particular radius
  66498. * @param position world position
  66499. * @param maxRadius the maximum distance to the constrained world position
  66500. * @returns the closest point to position constrained by the navigation mesh
  66501. */
  66502. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66503. /**
  66504. * Get a navigation mesh constrained position, within a particular radius
  66505. * @param position world position
  66506. * @param maxRadius the maximum distance to the constrained world position
  66507. * @param result output the closest point to position constrained by the navigation mesh
  66508. */
  66509. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66510. /**
  66511. * Compute the final position from a segment made of destination-position
  66512. * @param position world position
  66513. * @param destination world position
  66514. * @returns the resulting point along the navmesh
  66515. */
  66516. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66517. /**
  66518. * Compute the final position from a segment made of destination-position
  66519. * @param position world position
  66520. * @param destination world position
  66521. * @param result output the resulting point along the navmesh
  66522. */
  66523. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66524. /**
  66525. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66526. * @param start world position
  66527. * @param end world position
  66528. * @returns array containing world position composing the path
  66529. */
  66530. computePath(start: Vector3, end: Vector3): Vector3[];
  66531. /**
  66532. * Create a new Crowd so you can add agents
  66533. * @param maxAgents the maximum agent count in the crowd
  66534. * @param maxAgentRadius the maximum radius an agent can have
  66535. * @param scene to attach the crowd to
  66536. * @returns the crowd you can add agents to
  66537. */
  66538. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66539. /**
  66540. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66541. * The queries will try to find a solution within those bounds
  66542. * default is (1,1,1)
  66543. * @param extent x,y,z value that define the extent around the queries point of reference
  66544. */
  66545. setDefaultQueryExtent(extent: Vector3): void;
  66546. /**
  66547. * Get the Bounding box extent specified by setDefaultQueryExtent
  66548. * @returns the box extent values
  66549. */
  66550. getDefaultQueryExtent(): Vector3;
  66551. /**
  66552. * build the navmesh from a previously saved state using getNavmeshData
  66553. * @param data the Uint8Array returned by getNavmeshData
  66554. */
  66555. buildFromNavmeshData(data: Uint8Array): void;
  66556. /**
  66557. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66558. * @returns data the Uint8Array that can be saved and reused
  66559. */
  66560. getNavmeshData(): Uint8Array;
  66561. /**
  66562. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66563. * @param result output the box extent values
  66564. */
  66565. getDefaultQueryExtentToRef(result: Vector3): void;
  66566. /**
  66567. * Disposes
  66568. */
  66569. dispose(): void;
  66570. /**
  66571. * If this plugin is supported
  66572. * @returns true if plugin is supported
  66573. */
  66574. isSupported(): boolean;
  66575. }
  66576. /**
  66577. * Recast detour crowd implementation
  66578. */
  66579. export class RecastJSCrowd implements ICrowd {
  66580. /**
  66581. * Recast/detour plugin
  66582. */
  66583. bjsRECASTPlugin: RecastJSPlugin;
  66584. /**
  66585. * Link to the detour crowd
  66586. */
  66587. recastCrowd: any;
  66588. /**
  66589. * One transform per agent
  66590. */
  66591. transforms: TransformNode[];
  66592. /**
  66593. * All agents created
  66594. */
  66595. agents: number[];
  66596. /**
  66597. * Link to the scene is kept to unregister the crowd from the scene
  66598. */
  66599. private _scene;
  66600. /**
  66601. * Observer for crowd updates
  66602. */
  66603. private _onBeforeAnimationsObserver;
  66604. /**
  66605. * Constructor
  66606. * @param plugin recastJS plugin
  66607. * @param maxAgents the maximum agent count in the crowd
  66608. * @param maxAgentRadius the maximum radius an agent can have
  66609. * @param scene to attach the crowd to
  66610. * @returns the crowd you can add agents to
  66611. */
  66612. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  66613. /**
  66614. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  66615. * You can attach anything to that node. The node position is updated in the scene update tick.
  66616. * @param pos world position that will be constrained by the navigation mesh
  66617. * @param parameters agent parameters
  66618. * @param transform hooked to the agent that will be update by the scene
  66619. * @returns agent index
  66620. */
  66621. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66622. /**
  66623. * Returns the agent position in world space
  66624. * @param index agent index returned by addAgent
  66625. * @returns world space position
  66626. */
  66627. getAgentPosition(index: number): Vector3;
  66628. /**
  66629. * Returns the agent position result in world space
  66630. * @param index agent index returned by addAgent
  66631. * @param result output world space position
  66632. */
  66633. getAgentPositionToRef(index: number, result: Vector3): void;
  66634. /**
  66635. * Returns the agent velocity in world space
  66636. * @param index agent index returned by addAgent
  66637. * @returns world space velocity
  66638. */
  66639. getAgentVelocity(index: number): Vector3;
  66640. /**
  66641. * Returns the agent velocity result in world space
  66642. * @param index agent index returned by addAgent
  66643. * @param result output world space velocity
  66644. */
  66645. getAgentVelocityToRef(index: number, result: Vector3): void;
  66646. /**
  66647. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66648. * @param index agent index returned by addAgent
  66649. * @param destination targeted world position
  66650. */
  66651. agentGoto(index: number, destination: Vector3): void;
  66652. /**
  66653. * Teleport the agent to a new position
  66654. * @param index agent index returned by addAgent
  66655. * @param destination targeted world position
  66656. */
  66657. agentTeleport(index: number, destination: Vector3): void;
  66658. /**
  66659. * Update agent parameters
  66660. * @param index agent index returned by addAgent
  66661. * @param parameters agent parameters
  66662. */
  66663. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66664. /**
  66665. * remove a particular agent previously created
  66666. * @param index agent index returned by addAgent
  66667. */
  66668. removeAgent(index: number): void;
  66669. /**
  66670. * get the list of all agents attached to this crowd
  66671. * @returns list of agent indices
  66672. */
  66673. getAgents(): number[];
  66674. /**
  66675. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66676. * @param deltaTime in seconds
  66677. */
  66678. update(deltaTime: number): void;
  66679. /**
  66680. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66681. * The queries will try to find a solution within those bounds
  66682. * default is (1,1,1)
  66683. * @param extent x,y,z value that define the extent around the queries point of reference
  66684. */
  66685. setDefaultQueryExtent(extent: Vector3): void;
  66686. /**
  66687. * Get the Bounding box extent specified by setDefaultQueryExtent
  66688. * @returns the box extent values
  66689. */
  66690. getDefaultQueryExtent(): Vector3;
  66691. /**
  66692. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66693. * @param result output the box extent values
  66694. */
  66695. getDefaultQueryExtentToRef(result: Vector3): void;
  66696. /**
  66697. * Release all resources
  66698. */
  66699. dispose(): void;
  66700. }
  66701. }
  66702. declare module BABYLON {
  66703. /**
  66704. * Class used to enable access to IndexedDB
  66705. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  66706. */
  66707. export class Database implements IOfflineProvider {
  66708. private _callbackManifestChecked;
  66709. private _currentSceneUrl;
  66710. private _db;
  66711. private _enableSceneOffline;
  66712. private _enableTexturesOffline;
  66713. private _manifestVersionFound;
  66714. private _mustUpdateRessources;
  66715. private _hasReachedQuota;
  66716. private _isSupported;
  66717. private _idbFactory;
  66718. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  66719. private static IsUASupportingBlobStorage;
  66720. /**
  66721. * Gets a boolean indicating if Database storate is enabled (off by default)
  66722. */
  66723. static IDBStorageEnabled: boolean;
  66724. /**
  66725. * Gets a boolean indicating if scene must be saved in the database
  66726. */
  66727. get enableSceneOffline(): boolean;
  66728. /**
  66729. * Gets a boolean indicating if textures must be saved in the database
  66730. */
  66731. get enableTexturesOffline(): boolean;
  66732. /**
  66733. * Creates a new Database
  66734. * @param urlToScene defines the url to load the scene
  66735. * @param callbackManifestChecked defines the callback to use when manifest is checked
  66736. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  66737. */
  66738. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  66739. private static _ParseURL;
  66740. private static _ReturnFullUrlLocation;
  66741. private _checkManifestFile;
  66742. /**
  66743. * Open the database and make it available
  66744. * @param successCallback defines the callback to call on success
  66745. * @param errorCallback defines the callback to call on error
  66746. */
  66747. open(successCallback: () => void, errorCallback: () => void): void;
  66748. /**
  66749. * Loads an image from the database
  66750. * @param url defines the url to load from
  66751. * @param image defines the target DOM image
  66752. */
  66753. loadImage(url: string, image: HTMLImageElement): void;
  66754. private _loadImageFromDBAsync;
  66755. private _saveImageIntoDBAsync;
  66756. private _checkVersionFromDB;
  66757. private _loadVersionFromDBAsync;
  66758. private _saveVersionIntoDBAsync;
  66759. /**
  66760. * Loads a file from database
  66761. * @param url defines the URL to load from
  66762. * @param sceneLoaded defines a callback to call on success
  66763. * @param progressCallBack defines a callback to call when progress changed
  66764. * @param errorCallback defines a callback to call on error
  66765. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  66766. */
  66767. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  66768. private _loadFileAsync;
  66769. private _saveFileAsync;
  66770. /**
  66771. * Validates if xhr data is correct
  66772. * @param xhr defines the request to validate
  66773. * @param dataType defines the expected data type
  66774. * @returns true if data is correct
  66775. */
  66776. private static _ValidateXHRData;
  66777. }
  66778. }
  66779. declare module BABYLON {
  66780. /** @hidden */
  66781. export var gpuUpdateParticlesPixelShader: {
  66782. name: string;
  66783. shader: string;
  66784. };
  66785. }
  66786. declare module BABYLON {
  66787. /** @hidden */
  66788. export var gpuUpdateParticlesVertexShader: {
  66789. name: string;
  66790. shader: string;
  66791. };
  66792. }
  66793. declare module BABYLON {
  66794. /** @hidden */
  66795. export var clipPlaneFragmentDeclaration2: {
  66796. name: string;
  66797. shader: string;
  66798. };
  66799. }
  66800. declare module BABYLON {
  66801. /** @hidden */
  66802. export var gpuRenderParticlesPixelShader: {
  66803. name: string;
  66804. shader: string;
  66805. };
  66806. }
  66807. declare module BABYLON {
  66808. /** @hidden */
  66809. export var clipPlaneVertexDeclaration2: {
  66810. name: string;
  66811. shader: string;
  66812. };
  66813. }
  66814. declare module BABYLON {
  66815. /** @hidden */
  66816. export var gpuRenderParticlesVertexShader: {
  66817. name: string;
  66818. shader: string;
  66819. };
  66820. }
  66821. declare module BABYLON {
  66822. /**
  66823. * This represents a GPU particle system in Babylon
  66824. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  66825. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  66826. */
  66827. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  66828. /**
  66829. * The layer mask we are rendering the particles through.
  66830. */
  66831. layerMask: number;
  66832. private _capacity;
  66833. private _activeCount;
  66834. private _currentActiveCount;
  66835. private _accumulatedCount;
  66836. private _renderEffect;
  66837. private _updateEffect;
  66838. private _buffer0;
  66839. private _buffer1;
  66840. private _spriteBuffer;
  66841. private _updateVAO;
  66842. private _renderVAO;
  66843. private _targetIndex;
  66844. private _sourceBuffer;
  66845. private _targetBuffer;
  66846. private _engine;
  66847. private _currentRenderId;
  66848. private _started;
  66849. private _stopped;
  66850. private _timeDelta;
  66851. private _randomTexture;
  66852. private _randomTexture2;
  66853. private _attributesStrideSize;
  66854. private _updateEffectOptions;
  66855. private _randomTextureSize;
  66856. private _actualFrame;
  66857. private _customEffect;
  66858. private readonly _rawTextureWidth;
  66859. /**
  66860. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  66861. */
  66862. static get IsSupported(): boolean;
  66863. /**
  66864. * An event triggered when the system is disposed.
  66865. */
  66866. onDisposeObservable: Observable<IParticleSystem>;
  66867. /**
  66868. * Gets the maximum number of particles active at the same time.
  66869. * @returns The max number of active particles.
  66870. */
  66871. getCapacity(): number;
  66872. /**
  66873. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  66874. * to override the particles.
  66875. */
  66876. forceDepthWrite: boolean;
  66877. /**
  66878. * Gets or set the number of active particles
  66879. */
  66880. get activeParticleCount(): number;
  66881. set activeParticleCount(value: number);
  66882. private _preWarmDone;
  66883. /**
  66884. * Specifies if the particles are updated in emitter local space or world space.
  66885. */
  66886. isLocal: boolean;
  66887. /**
  66888. * Is this system ready to be used/rendered
  66889. * @return true if the system is ready
  66890. */
  66891. isReady(): boolean;
  66892. /**
  66893. * Gets if the system has been started. (Note: this will still be true after stop is called)
  66894. * @returns True if it has been started, otherwise false.
  66895. */
  66896. isStarted(): boolean;
  66897. /**
  66898. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  66899. * @returns True if it has been stopped, otherwise false.
  66900. */
  66901. isStopped(): boolean;
  66902. /**
  66903. * Gets a boolean indicating that the system is stopping
  66904. * @returns true if the system is currently stopping
  66905. */
  66906. isStopping(): boolean;
  66907. /**
  66908. * Gets the number of particles active at the same time.
  66909. * @returns The number of active particles.
  66910. */
  66911. getActiveCount(): number;
  66912. /**
  66913. * Starts the particle system and begins to emit
  66914. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  66915. */
  66916. start(delay?: number): void;
  66917. /**
  66918. * Stops the particle system.
  66919. */
  66920. stop(): void;
  66921. /**
  66922. * Remove all active particles
  66923. */
  66924. reset(): void;
  66925. /**
  66926. * Returns the string "GPUParticleSystem"
  66927. * @returns a string containing the class name
  66928. */
  66929. getClassName(): string;
  66930. /**
  66931. * Gets the custom effect used to render the particles
  66932. * @param blendMode Blend mode for which the effect should be retrieved
  66933. * @returns The effect
  66934. */
  66935. getCustomEffect(blendMode?: number): Nullable<Effect>;
  66936. /**
  66937. * Sets the custom effect used to render the particles
  66938. * @param effect The effect to set
  66939. * @param blendMode Blend mode for which the effect should be set
  66940. */
  66941. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  66942. /** @hidden */
  66943. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  66944. /**
  66945. * Observable that will be called just before the particles are drawn
  66946. */
  66947. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  66948. /**
  66949. * Gets the name of the particle vertex shader
  66950. */
  66951. get vertexShaderName(): string;
  66952. private _colorGradientsTexture;
  66953. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  66954. /**
  66955. * Adds a new color gradient
  66956. * @param gradient defines the gradient to use (between 0 and 1)
  66957. * @param color1 defines the color to affect to the specified gradient
  66958. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  66959. * @returns the current particle system
  66960. */
  66961. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  66962. private _refreshColorGradient;
  66963. /** Force the system to rebuild all gradients that need to be resync */
  66964. forceRefreshGradients(): void;
  66965. /**
  66966. * Remove a specific color gradient
  66967. * @param gradient defines the gradient to remove
  66968. * @returns the current particle system
  66969. */
  66970. removeColorGradient(gradient: number): GPUParticleSystem;
  66971. private _angularSpeedGradientsTexture;
  66972. private _sizeGradientsTexture;
  66973. private _velocityGradientsTexture;
  66974. private _limitVelocityGradientsTexture;
  66975. private _dragGradientsTexture;
  66976. private _addFactorGradient;
  66977. /**
  66978. * Adds a new size gradient
  66979. * @param gradient defines the gradient to use (between 0 and 1)
  66980. * @param factor defines the size factor to affect to the specified gradient
  66981. * @returns the current particle system
  66982. */
  66983. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  66984. /**
  66985. * Remove a specific size gradient
  66986. * @param gradient defines the gradient to remove
  66987. * @returns the current particle system
  66988. */
  66989. removeSizeGradient(gradient: number): GPUParticleSystem;
  66990. private _refreshFactorGradient;
  66991. /**
  66992. * Adds a new angular speed gradient
  66993. * @param gradient defines the gradient to use (between 0 and 1)
  66994. * @param factor defines the angular speed to affect to the specified gradient
  66995. * @returns the current particle system
  66996. */
  66997. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  66998. /**
  66999. * Remove a specific angular speed gradient
  67000. * @param gradient defines the gradient to remove
  67001. * @returns the current particle system
  67002. */
  67003. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  67004. /**
  67005. * Adds a new velocity gradient
  67006. * @param gradient defines the gradient to use (between 0 and 1)
  67007. * @param factor defines the velocity to affect to the specified gradient
  67008. * @returns the current particle system
  67009. */
  67010. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67011. /**
  67012. * Remove a specific velocity gradient
  67013. * @param gradient defines the gradient to remove
  67014. * @returns the current particle system
  67015. */
  67016. removeVelocityGradient(gradient: number): GPUParticleSystem;
  67017. /**
  67018. * Adds a new limit velocity gradient
  67019. * @param gradient defines the gradient to use (between 0 and 1)
  67020. * @param factor defines the limit velocity value to affect to the specified gradient
  67021. * @returns the current particle system
  67022. */
  67023. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67024. /**
  67025. * Remove a specific limit velocity gradient
  67026. * @param gradient defines the gradient to remove
  67027. * @returns the current particle system
  67028. */
  67029. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  67030. /**
  67031. * Adds a new drag gradient
  67032. * @param gradient defines the gradient to use (between 0 and 1)
  67033. * @param factor defines the drag value to affect to the specified gradient
  67034. * @returns the current particle system
  67035. */
  67036. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  67037. /**
  67038. * Remove a specific drag gradient
  67039. * @param gradient defines the gradient to remove
  67040. * @returns the current particle system
  67041. */
  67042. removeDragGradient(gradient: number): GPUParticleSystem;
  67043. /**
  67044. * Not supported by GPUParticleSystem
  67045. * @param gradient defines the gradient to use (between 0 and 1)
  67046. * @param factor defines the emit rate value to affect to the specified gradient
  67047. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67048. * @returns the current particle system
  67049. */
  67050. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67051. /**
  67052. * Not supported by GPUParticleSystem
  67053. * @param gradient defines the gradient to remove
  67054. * @returns the current particle system
  67055. */
  67056. removeEmitRateGradient(gradient: number): IParticleSystem;
  67057. /**
  67058. * Not supported by GPUParticleSystem
  67059. * @param gradient defines the gradient to use (between 0 and 1)
  67060. * @param factor defines the start size value to affect to the specified gradient
  67061. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67062. * @returns the current particle system
  67063. */
  67064. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67065. /**
  67066. * Not supported by GPUParticleSystem
  67067. * @param gradient defines the gradient to remove
  67068. * @returns the current particle system
  67069. */
  67070. removeStartSizeGradient(gradient: number): IParticleSystem;
  67071. /**
  67072. * Not supported by GPUParticleSystem
  67073. * @param gradient defines the gradient to use (between 0 and 1)
  67074. * @param min defines the color remap minimal range
  67075. * @param max defines the color remap maximal range
  67076. * @returns the current particle system
  67077. */
  67078. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67079. /**
  67080. * Not supported by GPUParticleSystem
  67081. * @param gradient defines the gradient to remove
  67082. * @returns the current particle system
  67083. */
  67084. removeColorRemapGradient(): IParticleSystem;
  67085. /**
  67086. * Not supported by GPUParticleSystem
  67087. * @param gradient defines the gradient to use (between 0 and 1)
  67088. * @param min defines the alpha remap minimal range
  67089. * @param max defines the alpha remap maximal range
  67090. * @returns the current particle system
  67091. */
  67092. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67093. /**
  67094. * Not supported by GPUParticleSystem
  67095. * @param gradient defines the gradient to remove
  67096. * @returns the current particle system
  67097. */
  67098. removeAlphaRemapGradient(): IParticleSystem;
  67099. /**
  67100. * Not supported by GPUParticleSystem
  67101. * @param gradient defines the gradient to use (between 0 and 1)
  67102. * @param color defines the color to affect to the specified gradient
  67103. * @returns the current particle system
  67104. */
  67105. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  67106. /**
  67107. * Not supported by GPUParticleSystem
  67108. * @param gradient defines the gradient to remove
  67109. * @returns the current particle system
  67110. */
  67111. removeRampGradient(): IParticleSystem;
  67112. /**
  67113. * Not supported by GPUParticleSystem
  67114. * @returns the list of ramp gradients
  67115. */
  67116. getRampGradients(): Nullable<Array<Color3Gradient>>;
  67117. /**
  67118. * Not supported by GPUParticleSystem
  67119. * Gets or sets a boolean indicating that ramp gradients must be used
  67120. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  67121. */
  67122. get useRampGradients(): boolean;
  67123. set useRampGradients(value: boolean);
  67124. /**
  67125. * Not supported by GPUParticleSystem
  67126. * @param gradient defines the gradient to use (between 0 and 1)
  67127. * @param factor defines the life time factor to affect to the specified gradient
  67128. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67129. * @returns the current particle system
  67130. */
  67131. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67132. /**
  67133. * Not supported by GPUParticleSystem
  67134. * @param gradient defines the gradient to remove
  67135. * @returns the current particle system
  67136. */
  67137. removeLifeTimeGradient(gradient: number): IParticleSystem;
  67138. /**
  67139. * Instantiates a GPU particle system.
  67140. * 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.
  67141. * @param name The name of the particle system
  67142. * @param options The options used to create the system
  67143. * @param scene The scene the particle system belongs to
  67144. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  67145. * @param customEffect a custom effect used to change the way particles are rendered by default
  67146. */
  67147. constructor(name: string, options: Partial<{
  67148. capacity: number;
  67149. randomTextureSize: number;
  67150. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  67151. protected _reset(): void;
  67152. private _createUpdateVAO;
  67153. private _createRenderVAO;
  67154. private _initialize;
  67155. /** @hidden */
  67156. _recreateUpdateEffect(): void;
  67157. private _getEffect;
  67158. /**
  67159. * Fill the defines array according to the current settings of the particle system
  67160. * @param defines Array to be updated
  67161. * @param blendMode blend mode to take into account when updating the array
  67162. */
  67163. fillDefines(defines: Array<string>, blendMode?: number): void;
  67164. /**
  67165. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  67166. * @param uniforms Uniforms array to fill
  67167. * @param attributes Attributes array to fill
  67168. * @param samplers Samplers array to fill
  67169. */
  67170. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  67171. /** @hidden */
  67172. _recreateRenderEffect(): Effect;
  67173. /**
  67174. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  67175. * @param preWarm defines if we are in the pre-warmimg phase
  67176. */
  67177. animate(preWarm?: boolean): void;
  67178. private _createFactorGradientTexture;
  67179. private _createSizeGradientTexture;
  67180. private _createAngularSpeedGradientTexture;
  67181. private _createVelocityGradientTexture;
  67182. private _createLimitVelocityGradientTexture;
  67183. private _createDragGradientTexture;
  67184. private _createColorGradientTexture;
  67185. /**
  67186. * Renders the particle system in its current state
  67187. * @param preWarm defines if the system should only update the particles but not render them
  67188. * @returns the current number of particles
  67189. */
  67190. render(preWarm?: boolean): number;
  67191. /**
  67192. * Rebuilds the particle system
  67193. */
  67194. rebuild(): void;
  67195. private _releaseBuffers;
  67196. private _releaseVAOs;
  67197. /**
  67198. * Disposes the particle system and free the associated resources
  67199. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  67200. */
  67201. dispose(disposeTexture?: boolean): void;
  67202. /**
  67203. * Clones the particle system.
  67204. * @param name The name of the cloned object
  67205. * @param newEmitter The new emitter to use
  67206. * @returns the cloned particle system
  67207. */
  67208. clone(name: string, newEmitter: any): GPUParticleSystem;
  67209. /**
  67210. * Serializes the particle system to a JSON object
  67211. * @param serializeTexture defines if the texture must be serialized as well
  67212. * @returns the JSON object
  67213. */
  67214. serialize(serializeTexture?: boolean): any;
  67215. /**
  67216. * Parses a JSON object to create a GPU particle system.
  67217. * @param parsedParticleSystem The JSON object to parse
  67218. * @param scene The scene to create the particle system in
  67219. * @param rootUrl The root url to use to load external dependencies like texture
  67220. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  67221. * @returns the parsed GPU particle system
  67222. */
  67223. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  67224. }
  67225. }
  67226. declare module BABYLON {
  67227. /**
  67228. * Represents a set of particle systems working together to create a specific effect
  67229. */
  67230. export class ParticleSystemSet implements IDisposable {
  67231. /**
  67232. * Gets or sets base Assets URL
  67233. */
  67234. static BaseAssetsUrl: string;
  67235. private _emitterCreationOptions;
  67236. private _emitterNode;
  67237. /**
  67238. * Gets the particle system list
  67239. */
  67240. systems: IParticleSystem[];
  67241. /**
  67242. * Gets the emitter node used with this set
  67243. */
  67244. get emitterNode(): Nullable<TransformNode>;
  67245. /**
  67246. * Creates a new emitter mesh as a sphere
  67247. * @param options defines the options used to create the sphere
  67248. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  67249. * @param scene defines the hosting scene
  67250. */
  67251. setEmitterAsSphere(options: {
  67252. diameter: number;
  67253. segments: number;
  67254. color: Color3;
  67255. }, renderingGroupId: number, scene: Scene): void;
  67256. /**
  67257. * Starts all particle systems of the set
  67258. * @param emitter defines an optional mesh to use as emitter for the particle systems
  67259. */
  67260. start(emitter?: AbstractMesh): void;
  67261. /**
  67262. * Release all associated resources
  67263. */
  67264. dispose(): void;
  67265. /**
  67266. * Serialize the set into a JSON compatible object
  67267. * @param serializeTexture defines if the texture must be serialized as well
  67268. * @returns a JSON compatible representation of the set
  67269. */
  67270. serialize(serializeTexture?: boolean): any;
  67271. /**
  67272. * Parse a new ParticleSystemSet from a serialized source
  67273. * @param data defines a JSON compatible representation of the set
  67274. * @param scene defines the hosting scene
  67275. * @param gpu defines if we want GPU particles or CPU particles
  67276. * @returns a new ParticleSystemSet
  67277. */
  67278. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  67279. }
  67280. }
  67281. declare module BABYLON {
  67282. /**
  67283. * This class is made for on one-liner static method to help creating particle system set.
  67284. */
  67285. export class ParticleHelper {
  67286. /**
  67287. * Gets or sets base Assets URL
  67288. */
  67289. static BaseAssetsUrl: string;
  67290. /** Define the Url to load snippets */
  67291. static SnippetUrl: string;
  67292. /**
  67293. * Create a default particle system that you can tweak
  67294. * @param emitter defines the emitter to use
  67295. * @param capacity defines the system capacity (default is 500 particles)
  67296. * @param scene defines the hosting scene
  67297. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  67298. * @returns the new Particle system
  67299. */
  67300. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  67301. /**
  67302. * This is the main static method (one-liner) of this helper to create different particle systems
  67303. * @param type This string represents the type to the particle system to create
  67304. * @param scene The scene where the particle system should live
  67305. * @param gpu If the system will use gpu
  67306. * @returns the ParticleSystemSet created
  67307. */
  67308. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  67309. /**
  67310. * Static function used to export a particle system to a ParticleSystemSet variable.
  67311. * Please note that the emitter shape is not exported
  67312. * @param systems defines the particle systems to export
  67313. * @returns the created particle system set
  67314. */
  67315. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  67316. /**
  67317. * Creates a particle system from a snippet saved in a remote file
  67318. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  67319. * @param url defines the url to load from
  67320. * @param scene defines the hosting scene
  67321. * @param gpu If the system will use gpu
  67322. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67323. * @returns a promise that will resolve to the new particle system
  67324. */
  67325. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  67326. /**
  67327. * Creates a particle system from a snippet saved by the particle system editor
  67328. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  67329. * @param scene defines the hosting scene
  67330. * @param gpu If the system will use gpu
  67331. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67332. * @returns a promise that will resolve to the new particle system
  67333. */
  67334. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  67335. }
  67336. }
  67337. declare module BABYLON {
  67338. interface Engine {
  67339. /**
  67340. * Create an effect to use with particle systems.
  67341. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  67342. * the particle system for which you want to create a custom effect in the last parameter
  67343. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  67344. * @param uniformsNames defines a list of attribute names
  67345. * @param samplers defines an array of string used to represent textures
  67346. * @param defines defines the string containing the defines to use to compile the shaders
  67347. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  67348. * @param onCompiled defines a function to call when the effect creation is successful
  67349. * @param onError defines a function to call when the effect creation has failed
  67350. * @param particleSystem the particle system you want to create the effect for
  67351. * @returns the new Effect
  67352. */
  67353. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  67354. }
  67355. interface Mesh {
  67356. /**
  67357. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  67358. * @returns an array of IParticleSystem
  67359. */
  67360. getEmittedParticleSystems(): IParticleSystem[];
  67361. /**
  67362. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  67363. * @returns an array of IParticleSystem
  67364. */
  67365. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  67366. }
  67367. }
  67368. declare module BABYLON {
  67369. /** Defines the 4 color options */
  67370. export enum PointColor {
  67371. /** color value */
  67372. Color = 2,
  67373. /** uv value */
  67374. UV = 1,
  67375. /** random value */
  67376. Random = 0,
  67377. /** stated value */
  67378. Stated = 3
  67379. }
  67380. /**
  67381. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  67382. * 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.
  67383. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  67384. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  67385. *
  67386. * Full documentation here : TO BE ENTERED
  67387. */
  67388. export class PointsCloudSystem implements IDisposable {
  67389. /**
  67390. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  67391. * Example : var p = SPS.particles[i];
  67392. */
  67393. particles: CloudPoint[];
  67394. /**
  67395. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  67396. */
  67397. nbParticles: number;
  67398. /**
  67399. * This a counter for your own usage. It's not set by any SPS functions.
  67400. */
  67401. counter: number;
  67402. /**
  67403. * The PCS name. This name is also given to the underlying mesh.
  67404. */
  67405. name: string;
  67406. /**
  67407. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  67408. */
  67409. mesh: Mesh;
  67410. /**
  67411. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  67412. * Please read :
  67413. */
  67414. vars: any;
  67415. /**
  67416. * @hidden
  67417. */
  67418. _size: number;
  67419. private _scene;
  67420. private _promises;
  67421. private _positions;
  67422. private _indices;
  67423. private _normals;
  67424. private _colors;
  67425. private _uvs;
  67426. private _indices32;
  67427. private _positions32;
  67428. private _colors32;
  67429. private _uvs32;
  67430. private _updatable;
  67431. private _isVisibilityBoxLocked;
  67432. private _alwaysVisible;
  67433. private _groups;
  67434. private _groupCounter;
  67435. private _computeParticleColor;
  67436. private _computeParticleTexture;
  67437. private _computeParticleRotation;
  67438. private _computeBoundingBox;
  67439. private _isReady;
  67440. /**
  67441. * Creates a PCS (Points Cloud System) object
  67442. * @param name (String) is the PCS name, this will be the underlying mesh name
  67443. * @param pointSize (number) is the size for each point
  67444. * @param scene (Scene) is the scene in which the PCS is added
  67445. * @param options defines the options of the PCS e.g.
  67446. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  67447. */
  67448. constructor(name: string, pointSize: number, scene: Scene, options?: {
  67449. updatable?: boolean;
  67450. });
  67451. /**
  67452. * Builds the PCS underlying mesh. Returns a standard Mesh.
  67453. * If no points were added to the PCS, the returned mesh is just a single point.
  67454. * @returns a promise for the created mesh
  67455. */
  67456. buildMeshAsync(): Promise<Mesh>;
  67457. /**
  67458. * @hidden
  67459. */
  67460. private _buildMesh;
  67461. private _addParticle;
  67462. private _randomUnitVector;
  67463. private _getColorIndicesForCoord;
  67464. private _setPointsColorOrUV;
  67465. private _colorFromTexture;
  67466. private _calculateDensity;
  67467. /**
  67468. * Adds points to the PCS in random positions within a unit sphere
  67469. * @param nb (positive integer) the number of particles to be created from this model
  67470. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  67471. * @returns the number of groups in the system
  67472. */
  67473. addPoints(nb: number, pointFunction?: any): number;
  67474. /**
  67475. * Adds points to the PCS from the surface of the model shape
  67476. * @param mesh is any Mesh object that will be used as a surface model for the points
  67477. * @param nb (positive integer) the number of particles to be created from this model
  67478. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67479. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67480. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67481. * @returns the number of groups in the system
  67482. */
  67483. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67484. /**
  67485. * Adds points to the PCS inside the model shape
  67486. * @param mesh is any Mesh object that will be used as a surface model for the points
  67487. * @param nb (positive integer) the number of particles to be created from this model
  67488. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67489. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67490. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67491. * @returns the number of groups in the system
  67492. */
  67493. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67494. /**
  67495. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  67496. * This method calls `updateParticle()` for each particle of the SPS.
  67497. * For an animated SPS, it is usually called within the render loop.
  67498. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  67499. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  67500. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  67501. * @returns the PCS.
  67502. */
  67503. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  67504. /**
  67505. * Disposes the PCS.
  67506. */
  67507. dispose(): void;
  67508. /**
  67509. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  67510. * doc :
  67511. * @returns the PCS.
  67512. */
  67513. refreshVisibleSize(): PointsCloudSystem;
  67514. /**
  67515. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  67516. * @param size the size (float) of the visibility box
  67517. * note : this doesn't lock the PCS mesh bounding box.
  67518. * doc :
  67519. */
  67520. setVisibilityBox(size: number): void;
  67521. /**
  67522. * Gets whether the PCS is always visible or not
  67523. * doc :
  67524. */
  67525. get isAlwaysVisible(): boolean;
  67526. /**
  67527. * Sets the PCS as always visible or not
  67528. * doc :
  67529. */
  67530. set isAlwaysVisible(val: boolean);
  67531. /**
  67532. * Tells to `setParticles()` to compute the particle rotations or not
  67533. * Default value : false. The PCS is faster when it's set to false
  67534. * Note : particle rotations are only applied to parent particles
  67535. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  67536. */
  67537. set computeParticleRotation(val: boolean);
  67538. /**
  67539. * Tells to `setParticles()` to compute the particle colors or not.
  67540. * Default value : true. The PCS is faster when it's set to false.
  67541. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67542. */
  67543. set computeParticleColor(val: boolean);
  67544. set computeParticleTexture(val: boolean);
  67545. /**
  67546. * Gets if `setParticles()` computes the particle colors or not.
  67547. * Default value : false. The PCS is faster when it's set to false.
  67548. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67549. */
  67550. get computeParticleColor(): boolean;
  67551. /**
  67552. * Gets if `setParticles()` computes the particle textures or not.
  67553. * Default value : false. The PCS is faster when it's set to false.
  67554. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  67555. */
  67556. get computeParticleTexture(): boolean;
  67557. /**
  67558. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  67559. */
  67560. set computeBoundingBox(val: boolean);
  67561. /**
  67562. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  67563. */
  67564. get computeBoundingBox(): boolean;
  67565. /**
  67566. * This function does nothing. It may be overwritten to set all the particle first values.
  67567. * The PCS doesn't call this function, you may have to call it by your own.
  67568. * doc :
  67569. */
  67570. initParticles(): void;
  67571. /**
  67572. * This function does nothing. It may be overwritten to recycle a particle
  67573. * The PCS doesn't call this function, you can to call it
  67574. * doc :
  67575. * @param particle The particle to recycle
  67576. * @returns the recycled particle
  67577. */
  67578. recycleParticle(particle: CloudPoint): CloudPoint;
  67579. /**
  67580. * Updates a particle : this function should be overwritten by the user.
  67581. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  67582. * doc :
  67583. * @example : just set a particle position or velocity and recycle conditions
  67584. * @param particle The particle to update
  67585. * @returns the updated particle
  67586. */
  67587. updateParticle(particle: CloudPoint): CloudPoint;
  67588. /**
  67589. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  67590. * This does nothing and may be overwritten by the user.
  67591. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  67592. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  67593. * @param update the boolean update value actually passed to setParticles()
  67594. */
  67595. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67596. /**
  67597. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  67598. * This will be passed three parameters.
  67599. * This does nothing and may be overwritten by the user.
  67600. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  67601. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  67602. * @param update the boolean update value actually passed to setParticles()
  67603. */
  67604. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67605. }
  67606. }
  67607. declare module BABYLON {
  67608. /**
  67609. * Represents one particle of a points cloud system.
  67610. */
  67611. export class CloudPoint {
  67612. /**
  67613. * particle global index
  67614. */
  67615. idx: number;
  67616. /**
  67617. * The color of the particle
  67618. */
  67619. color: Nullable<Color4>;
  67620. /**
  67621. * The world space position of the particle.
  67622. */
  67623. position: Vector3;
  67624. /**
  67625. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  67626. */
  67627. rotation: Vector3;
  67628. /**
  67629. * The world space rotation quaternion of the particle.
  67630. */
  67631. rotationQuaternion: Nullable<Quaternion>;
  67632. /**
  67633. * The uv of the particle.
  67634. */
  67635. uv: Nullable<Vector2>;
  67636. /**
  67637. * The current speed of the particle.
  67638. */
  67639. velocity: Vector3;
  67640. /**
  67641. * The pivot point in the particle local space.
  67642. */
  67643. pivot: Vector3;
  67644. /**
  67645. * Must the particle be translated from its pivot point in its local space ?
  67646. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  67647. * Default : false
  67648. */
  67649. translateFromPivot: boolean;
  67650. /**
  67651. * Index of this particle in the global "positions" array (Internal use)
  67652. * @hidden
  67653. */
  67654. _pos: number;
  67655. /**
  67656. * @hidden Index of this particle in the global "indices" array (Internal use)
  67657. */
  67658. _ind: number;
  67659. /**
  67660. * Group this particle belongs to
  67661. */
  67662. _group: PointsGroup;
  67663. /**
  67664. * Group id of this particle
  67665. */
  67666. groupId: number;
  67667. /**
  67668. * Index of the particle in its group id (Internal use)
  67669. */
  67670. idxInGroup: number;
  67671. /**
  67672. * @hidden Particle BoundingInfo object (Internal use)
  67673. */
  67674. _boundingInfo: BoundingInfo;
  67675. /**
  67676. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  67677. */
  67678. _pcs: PointsCloudSystem;
  67679. /**
  67680. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  67681. */
  67682. _stillInvisible: boolean;
  67683. /**
  67684. * @hidden Last computed particle rotation matrix
  67685. */
  67686. _rotationMatrix: number[];
  67687. /**
  67688. * Parent particle Id, if any.
  67689. * Default null.
  67690. */
  67691. parentId: Nullable<number>;
  67692. /**
  67693. * @hidden Internal global position in the PCS.
  67694. */
  67695. _globalPosition: Vector3;
  67696. /**
  67697. * Creates a Point Cloud object.
  67698. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  67699. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  67700. * @param group (PointsGroup) is the group the particle belongs to
  67701. * @param groupId (integer) is the group identifier in the PCS.
  67702. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  67703. * @param pcs defines the PCS it is associated to
  67704. */
  67705. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  67706. /**
  67707. * get point size
  67708. */
  67709. get size(): Vector3;
  67710. /**
  67711. * Set point size
  67712. */
  67713. set size(scale: Vector3);
  67714. /**
  67715. * Legacy support, changed quaternion to rotationQuaternion
  67716. */
  67717. get quaternion(): Nullable<Quaternion>;
  67718. /**
  67719. * Legacy support, changed quaternion to rotationQuaternion
  67720. */
  67721. set quaternion(q: Nullable<Quaternion>);
  67722. /**
  67723. * Returns a boolean. True if the particle intersects a mesh, else false
  67724. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  67725. * @param target is the object (point or mesh) what the intersection is computed against
  67726. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  67727. * @returns true if it intersects
  67728. */
  67729. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  67730. /**
  67731. * get the rotation matrix of the particle
  67732. * @hidden
  67733. */
  67734. getRotationMatrix(m: Matrix): void;
  67735. }
  67736. /**
  67737. * Represents a group of points in a points cloud system
  67738. * * PCS internal tool, don't use it manually.
  67739. */
  67740. export class PointsGroup {
  67741. /**
  67742. * The group id
  67743. * @hidden
  67744. */
  67745. groupID: number;
  67746. /**
  67747. * image data for group (internal use)
  67748. * @hidden
  67749. */
  67750. _groupImageData: Nullable<ArrayBufferView>;
  67751. /**
  67752. * Image Width (internal use)
  67753. * @hidden
  67754. */
  67755. _groupImgWidth: number;
  67756. /**
  67757. * Image Height (internal use)
  67758. * @hidden
  67759. */
  67760. _groupImgHeight: number;
  67761. /**
  67762. * Custom position function (internal use)
  67763. * @hidden
  67764. */
  67765. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  67766. /**
  67767. * density per facet for surface points
  67768. * @hidden
  67769. */
  67770. _groupDensity: number[];
  67771. /**
  67772. * Only when points are colored by texture carries pointer to texture list array
  67773. * @hidden
  67774. */
  67775. _textureNb: number;
  67776. /**
  67777. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  67778. * PCS internal tool, don't use it manually.
  67779. * @hidden
  67780. */
  67781. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  67782. }
  67783. }
  67784. declare module BABYLON {
  67785. interface Scene {
  67786. /** @hidden (Backing field) */
  67787. _physicsEngine: Nullable<IPhysicsEngine>;
  67788. /** @hidden */
  67789. _physicsTimeAccumulator: number;
  67790. /**
  67791. * Gets the current physics engine
  67792. * @returns a IPhysicsEngine or null if none attached
  67793. */
  67794. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  67795. /**
  67796. * Enables physics to the current scene
  67797. * @param gravity defines the scene's gravity for the physics engine
  67798. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  67799. * @return a boolean indicating if the physics engine was initialized
  67800. */
  67801. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  67802. /**
  67803. * Disables and disposes the physics engine associated with the scene
  67804. */
  67805. disablePhysicsEngine(): void;
  67806. /**
  67807. * Gets a boolean indicating if there is an active physics engine
  67808. * @returns a boolean indicating if there is an active physics engine
  67809. */
  67810. isPhysicsEnabled(): boolean;
  67811. /**
  67812. * Deletes a physics compound impostor
  67813. * @param compound defines the compound to delete
  67814. */
  67815. deleteCompoundImpostor(compound: any): void;
  67816. /**
  67817. * An event triggered when physic simulation is about to be run
  67818. */
  67819. onBeforePhysicsObservable: Observable<Scene>;
  67820. /**
  67821. * An event triggered when physic simulation has been done
  67822. */
  67823. onAfterPhysicsObservable: Observable<Scene>;
  67824. }
  67825. interface AbstractMesh {
  67826. /** @hidden */
  67827. _physicsImpostor: Nullable<PhysicsImpostor>;
  67828. /**
  67829. * Gets or sets impostor used for physic simulation
  67830. * @see https://doc.babylonjs.com/features/physics_engine
  67831. */
  67832. physicsImpostor: Nullable<PhysicsImpostor>;
  67833. /**
  67834. * Gets the current physics impostor
  67835. * @see https://doc.babylonjs.com/features/physics_engine
  67836. * @returns a physics impostor or null
  67837. */
  67838. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  67839. /** Apply a physic impulse to the mesh
  67840. * @param force defines the force to apply
  67841. * @param contactPoint defines where to apply the force
  67842. * @returns the current mesh
  67843. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  67844. */
  67845. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  67846. /**
  67847. * Creates a physic joint between two meshes
  67848. * @param otherMesh defines the other mesh to use
  67849. * @param pivot1 defines the pivot to use on this mesh
  67850. * @param pivot2 defines the pivot to use on the other mesh
  67851. * @param options defines additional options (can be plugin dependent)
  67852. * @returns the current mesh
  67853. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  67854. */
  67855. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  67856. /** @hidden */
  67857. _disposePhysicsObserver: Nullable<Observer<Node>>;
  67858. }
  67859. /**
  67860. * Defines the physics engine scene component responsible to manage a physics engine
  67861. */
  67862. export class PhysicsEngineSceneComponent implements ISceneComponent {
  67863. /**
  67864. * The component name helpful to identify the component in the list of scene components.
  67865. */
  67866. readonly name: string;
  67867. /**
  67868. * The scene the component belongs to.
  67869. */
  67870. scene: Scene;
  67871. /**
  67872. * Creates a new instance of the component for the given scene
  67873. * @param scene Defines the scene to register the component in
  67874. */
  67875. constructor(scene: Scene);
  67876. /**
  67877. * Registers the component in a given scene
  67878. */
  67879. register(): void;
  67880. /**
  67881. * Rebuilds the elements related to this component in case of
  67882. * context lost for instance.
  67883. */
  67884. rebuild(): void;
  67885. /**
  67886. * Disposes the component and the associated ressources
  67887. */
  67888. dispose(): void;
  67889. }
  67890. }
  67891. declare module BABYLON {
  67892. /**
  67893. * A helper for physics simulations
  67894. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67895. */
  67896. export class PhysicsHelper {
  67897. private _scene;
  67898. private _physicsEngine;
  67899. /**
  67900. * Initializes the Physics helper
  67901. * @param scene Babylon.js scene
  67902. */
  67903. constructor(scene: Scene);
  67904. /**
  67905. * Applies a radial explosion impulse
  67906. * @param origin the origin of the explosion
  67907. * @param radiusOrEventOptions the radius or the options of radial explosion
  67908. * @param strength the explosion strength
  67909. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67910. * @returns A physics radial explosion event, or null
  67911. */
  67912. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67913. /**
  67914. * Applies a radial explosion force
  67915. * @param origin the origin of the explosion
  67916. * @param radiusOrEventOptions the radius or the options of radial explosion
  67917. * @param strength the explosion strength
  67918. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67919. * @returns A physics radial explosion event, or null
  67920. */
  67921. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67922. /**
  67923. * Creates a gravitational field
  67924. * @param origin the origin of the explosion
  67925. * @param radiusOrEventOptions the radius or the options of radial explosion
  67926. * @param strength the explosion strength
  67927. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67928. * @returns A physics gravitational field event, or null
  67929. */
  67930. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  67931. /**
  67932. * Creates a physics updraft event
  67933. * @param origin the origin of the updraft
  67934. * @param radiusOrEventOptions the radius or the options of the updraft
  67935. * @param strength the strength of the updraft
  67936. * @param height the height of the updraft
  67937. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  67938. * @returns A physics updraft event, or null
  67939. */
  67940. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  67941. /**
  67942. * Creates a physics vortex event
  67943. * @param origin the of the vortex
  67944. * @param radiusOrEventOptions the radius or the options of the vortex
  67945. * @param strength the strength of the vortex
  67946. * @param height the height of the vortex
  67947. * @returns a Physics vortex event, or null
  67948. * A physics vortex event or null
  67949. */
  67950. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  67951. }
  67952. /**
  67953. * Represents a physics radial explosion event
  67954. */
  67955. class PhysicsRadialExplosionEvent {
  67956. private _scene;
  67957. private _options;
  67958. private _sphere;
  67959. private _dataFetched;
  67960. /**
  67961. * Initializes a radial explosioin event
  67962. * @param _scene BabylonJS scene
  67963. * @param _options The options for the vortex event
  67964. */
  67965. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  67966. /**
  67967. * Returns the data related to the radial explosion event (sphere).
  67968. * @returns The radial explosion event data
  67969. */
  67970. getData(): PhysicsRadialExplosionEventData;
  67971. /**
  67972. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  67973. * @param impostor A physics imposter
  67974. * @param origin the origin of the explosion
  67975. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  67976. */
  67977. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  67978. /**
  67979. * Triggers affecterd impostors callbacks
  67980. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  67981. */
  67982. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  67983. /**
  67984. * Disposes the sphere.
  67985. * @param force Specifies if the sphere should be disposed by force
  67986. */
  67987. dispose(force?: boolean): void;
  67988. /*** Helpers ***/
  67989. private _prepareSphere;
  67990. private _intersectsWithSphere;
  67991. }
  67992. /**
  67993. * Represents a gravitational field event
  67994. */
  67995. class PhysicsGravitationalFieldEvent {
  67996. private _physicsHelper;
  67997. private _scene;
  67998. private _origin;
  67999. private _options;
  68000. private _tickCallback;
  68001. private _sphere;
  68002. private _dataFetched;
  68003. /**
  68004. * Initializes the physics gravitational field event
  68005. * @param _physicsHelper A physics helper
  68006. * @param _scene BabylonJS scene
  68007. * @param _origin The origin position of the gravitational field event
  68008. * @param _options The options for the vortex event
  68009. */
  68010. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  68011. /**
  68012. * Returns the data related to the gravitational field event (sphere).
  68013. * @returns A gravitational field event
  68014. */
  68015. getData(): PhysicsGravitationalFieldEventData;
  68016. /**
  68017. * Enables the gravitational field.
  68018. */
  68019. enable(): void;
  68020. /**
  68021. * Disables the gravitational field.
  68022. */
  68023. disable(): void;
  68024. /**
  68025. * Disposes the sphere.
  68026. * @param force The force to dispose from the gravitational field event
  68027. */
  68028. dispose(force?: boolean): void;
  68029. private _tick;
  68030. }
  68031. /**
  68032. * Represents a physics updraft event
  68033. */
  68034. class PhysicsUpdraftEvent {
  68035. private _scene;
  68036. private _origin;
  68037. private _options;
  68038. private _physicsEngine;
  68039. private _originTop;
  68040. private _originDirection;
  68041. private _tickCallback;
  68042. private _cylinder;
  68043. private _cylinderPosition;
  68044. private _dataFetched;
  68045. /**
  68046. * Initializes the physics updraft event
  68047. * @param _scene BabylonJS scene
  68048. * @param _origin The origin position of the updraft
  68049. * @param _options The options for the updraft event
  68050. */
  68051. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  68052. /**
  68053. * Returns the data related to the updraft event (cylinder).
  68054. * @returns A physics updraft event
  68055. */
  68056. getData(): PhysicsUpdraftEventData;
  68057. /**
  68058. * Enables the updraft.
  68059. */
  68060. enable(): void;
  68061. /**
  68062. * Disables the updraft.
  68063. */
  68064. disable(): void;
  68065. /**
  68066. * Disposes the cylinder.
  68067. * @param force Specifies if the updraft should be disposed by force
  68068. */
  68069. dispose(force?: boolean): void;
  68070. private getImpostorHitData;
  68071. private _tick;
  68072. /*** Helpers ***/
  68073. private _prepareCylinder;
  68074. private _intersectsWithCylinder;
  68075. }
  68076. /**
  68077. * Represents a physics vortex event
  68078. */
  68079. class PhysicsVortexEvent {
  68080. private _scene;
  68081. private _origin;
  68082. private _options;
  68083. private _physicsEngine;
  68084. private _originTop;
  68085. private _tickCallback;
  68086. private _cylinder;
  68087. private _cylinderPosition;
  68088. private _dataFetched;
  68089. /**
  68090. * Initializes the physics vortex event
  68091. * @param _scene The BabylonJS scene
  68092. * @param _origin The origin position of the vortex
  68093. * @param _options The options for the vortex event
  68094. */
  68095. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  68096. /**
  68097. * Returns the data related to the vortex event (cylinder).
  68098. * @returns The physics vortex event data
  68099. */
  68100. getData(): PhysicsVortexEventData;
  68101. /**
  68102. * Enables the vortex.
  68103. */
  68104. enable(): void;
  68105. /**
  68106. * Disables the cortex.
  68107. */
  68108. disable(): void;
  68109. /**
  68110. * Disposes the sphere.
  68111. * @param force
  68112. */
  68113. dispose(force?: boolean): void;
  68114. private getImpostorHitData;
  68115. private _tick;
  68116. /*** Helpers ***/
  68117. private _prepareCylinder;
  68118. private _intersectsWithCylinder;
  68119. }
  68120. /**
  68121. * Options fot the radial explosion event
  68122. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68123. */
  68124. export class PhysicsRadialExplosionEventOptions {
  68125. /**
  68126. * The radius of the sphere for the radial explosion.
  68127. */
  68128. radius: number;
  68129. /**
  68130. * The strenth of the explosion.
  68131. */
  68132. strength: number;
  68133. /**
  68134. * The strenght of the force in correspondence to the distance of the affected object
  68135. */
  68136. falloff: PhysicsRadialImpulseFalloff;
  68137. /**
  68138. * Sphere options for the radial explosion.
  68139. */
  68140. sphere: {
  68141. segments: number;
  68142. diameter: number;
  68143. };
  68144. /**
  68145. * Sphere options for the radial explosion.
  68146. */
  68147. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  68148. }
  68149. /**
  68150. * Options fot the updraft event
  68151. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68152. */
  68153. export class PhysicsUpdraftEventOptions {
  68154. /**
  68155. * The radius of the cylinder for the vortex
  68156. */
  68157. radius: number;
  68158. /**
  68159. * The strenth of the updraft.
  68160. */
  68161. strength: number;
  68162. /**
  68163. * The height of the cylinder for the updraft.
  68164. */
  68165. height: number;
  68166. /**
  68167. * The mode for the the updraft.
  68168. */
  68169. updraftMode: PhysicsUpdraftMode;
  68170. }
  68171. /**
  68172. * Options fot the vortex event
  68173. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68174. */
  68175. export class PhysicsVortexEventOptions {
  68176. /**
  68177. * The radius of the cylinder for the vortex
  68178. */
  68179. radius: number;
  68180. /**
  68181. * The strenth of the vortex.
  68182. */
  68183. strength: number;
  68184. /**
  68185. * The height of the cylinder for the vortex.
  68186. */
  68187. height: number;
  68188. /**
  68189. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  68190. */
  68191. centripetalForceThreshold: number;
  68192. /**
  68193. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  68194. */
  68195. centripetalForceMultiplier: number;
  68196. /**
  68197. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  68198. */
  68199. centrifugalForceMultiplier: number;
  68200. /**
  68201. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  68202. */
  68203. updraftForceMultiplier: number;
  68204. }
  68205. /**
  68206. * The strenght of the force in correspondence to the distance of the affected object
  68207. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68208. */
  68209. export enum PhysicsRadialImpulseFalloff {
  68210. /** Defines that impulse is constant in strength across it's whole radius */
  68211. Constant = 0,
  68212. /** Defines that impulse gets weaker if it's further from the origin */
  68213. Linear = 1
  68214. }
  68215. /**
  68216. * The strength of the force in correspondence to the distance of the affected object
  68217. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68218. */
  68219. export enum PhysicsUpdraftMode {
  68220. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  68221. Center = 0,
  68222. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  68223. Perpendicular = 1
  68224. }
  68225. /**
  68226. * Interface for a physics hit data
  68227. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68228. */
  68229. export interface PhysicsHitData {
  68230. /**
  68231. * The force applied at the contact point
  68232. */
  68233. force: Vector3;
  68234. /**
  68235. * The contact point
  68236. */
  68237. contactPoint: Vector3;
  68238. /**
  68239. * The distance from the origin to the contact point
  68240. */
  68241. distanceFromOrigin: number;
  68242. }
  68243. /**
  68244. * Interface for radial explosion event data
  68245. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68246. */
  68247. export interface PhysicsRadialExplosionEventData {
  68248. /**
  68249. * A sphere used for the radial explosion event
  68250. */
  68251. sphere: Mesh;
  68252. }
  68253. /**
  68254. * Interface for gravitational field event data
  68255. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68256. */
  68257. export interface PhysicsGravitationalFieldEventData {
  68258. /**
  68259. * A sphere mesh used for the gravitational field event
  68260. */
  68261. sphere: Mesh;
  68262. }
  68263. /**
  68264. * Interface for updraft event data
  68265. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68266. */
  68267. export interface PhysicsUpdraftEventData {
  68268. /**
  68269. * A cylinder used for the updraft event
  68270. */
  68271. cylinder: Mesh;
  68272. }
  68273. /**
  68274. * Interface for vortex event data
  68275. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68276. */
  68277. export interface PhysicsVortexEventData {
  68278. /**
  68279. * A cylinder used for the vortex event
  68280. */
  68281. cylinder: Mesh;
  68282. }
  68283. /**
  68284. * Interface for an affected physics impostor
  68285. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68286. */
  68287. export interface PhysicsAffectedImpostorWithData {
  68288. /**
  68289. * The impostor affected by the effect
  68290. */
  68291. impostor: PhysicsImpostor;
  68292. /**
  68293. * The data about the hit/horce from the explosion
  68294. */
  68295. hitData: PhysicsHitData;
  68296. }
  68297. }
  68298. declare module BABYLON {
  68299. /** @hidden */
  68300. export var blackAndWhitePixelShader: {
  68301. name: string;
  68302. shader: string;
  68303. };
  68304. }
  68305. declare module BABYLON {
  68306. /**
  68307. * Post process used to render in black and white
  68308. */
  68309. export class BlackAndWhitePostProcess extends PostProcess {
  68310. /**
  68311. * Linear about to convert he result to black and white (default: 1)
  68312. */
  68313. degree: number;
  68314. /**
  68315. * Creates a black and white post process
  68316. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  68317. * @param name The name of the effect.
  68318. * @param options The required width/height ratio to downsize to before computing the render pass.
  68319. * @param camera The camera to apply the render pass to.
  68320. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68321. * @param engine The engine which the post process will be applied. (default: current engine)
  68322. * @param reusable If the post process can be reused on the same frame. (default: false)
  68323. */
  68324. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68325. }
  68326. }
  68327. declare module BABYLON {
  68328. /**
  68329. * This represents a set of one or more post processes in Babylon.
  68330. * A post process can be used to apply a shader to a texture after it is rendered.
  68331. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68332. */
  68333. export class PostProcessRenderEffect {
  68334. private _postProcesses;
  68335. private _getPostProcesses;
  68336. private _singleInstance;
  68337. private _cameras;
  68338. private _indicesForCamera;
  68339. /**
  68340. * Name of the effect
  68341. * @hidden
  68342. */
  68343. _name: string;
  68344. /**
  68345. * Instantiates a post process render effect.
  68346. * A post process can be used to apply a shader to a texture after it is rendered.
  68347. * @param engine The engine the effect is tied to
  68348. * @param name The name of the effect
  68349. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  68350. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  68351. */
  68352. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  68353. /**
  68354. * Checks if all the post processes in the effect are supported.
  68355. */
  68356. get isSupported(): boolean;
  68357. /**
  68358. * Updates the current state of the effect
  68359. * @hidden
  68360. */
  68361. _update(): void;
  68362. /**
  68363. * Attaches the effect on cameras
  68364. * @param cameras The camera to attach to.
  68365. * @hidden
  68366. */
  68367. _attachCameras(cameras: Camera): void;
  68368. /**
  68369. * Attaches the effect on cameras
  68370. * @param cameras The camera to attach to.
  68371. * @hidden
  68372. */
  68373. _attachCameras(cameras: Camera[]): void;
  68374. /**
  68375. * Detaches the effect on cameras
  68376. * @param cameras The camera to detatch from.
  68377. * @hidden
  68378. */
  68379. _detachCameras(cameras: Camera): void;
  68380. /**
  68381. * Detatches the effect on cameras
  68382. * @param cameras The camera to detatch from.
  68383. * @hidden
  68384. */
  68385. _detachCameras(cameras: Camera[]): void;
  68386. /**
  68387. * Enables the effect on given cameras
  68388. * @param cameras The camera to enable.
  68389. * @hidden
  68390. */
  68391. _enable(cameras: Camera): void;
  68392. /**
  68393. * Enables the effect on given cameras
  68394. * @param cameras The camera to enable.
  68395. * @hidden
  68396. */
  68397. _enable(cameras: Nullable<Camera[]>): void;
  68398. /**
  68399. * Disables the effect on the given cameras
  68400. * @param cameras The camera to disable.
  68401. * @hidden
  68402. */
  68403. _disable(cameras: Camera): void;
  68404. /**
  68405. * Disables the effect on the given cameras
  68406. * @param cameras The camera to disable.
  68407. * @hidden
  68408. */
  68409. _disable(cameras: Nullable<Camera[]>): void;
  68410. /**
  68411. * Gets a list of the post processes contained in the effect.
  68412. * @param camera The camera to get the post processes on.
  68413. * @returns The list of the post processes in the effect.
  68414. */
  68415. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  68416. }
  68417. }
  68418. declare module BABYLON {
  68419. /** @hidden */
  68420. export var extractHighlightsPixelShader: {
  68421. name: string;
  68422. shader: string;
  68423. };
  68424. }
  68425. declare module BABYLON {
  68426. /**
  68427. * 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.
  68428. */
  68429. export class ExtractHighlightsPostProcess extends PostProcess {
  68430. /**
  68431. * The luminance threshold, pixels below this value will be set to black.
  68432. */
  68433. threshold: number;
  68434. /** @hidden */
  68435. _exposure: number;
  68436. /**
  68437. * Post process which has the input texture to be used when performing highlight extraction
  68438. * @hidden
  68439. */
  68440. _inputPostProcess: Nullable<PostProcess>;
  68441. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68442. }
  68443. }
  68444. declare module BABYLON {
  68445. /** @hidden */
  68446. export var bloomMergePixelShader: {
  68447. name: string;
  68448. shader: string;
  68449. };
  68450. }
  68451. declare module BABYLON {
  68452. /**
  68453. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68454. */
  68455. export class BloomMergePostProcess extends PostProcess {
  68456. /** Weight of the bloom to be added to the original input. */
  68457. weight: number;
  68458. /**
  68459. * Creates a new instance of @see BloomMergePostProcess
  68460. * @param name The name of the effect.
  68461. * @param originalFromInput Post process which's input will be used for the merge.
  68462. * @param blurred Blurred highlights post process which's output will be used.
  68463. * @param weight Weight of the bloom to be added to the original input.
  68464. * @param options The required width/height ratio to downsize to before computing the render pass.
  68465. * @param camera The camera to apply the render pass to.
  68466. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68467. * @param engine The engine which the post process will be applied. (default: current engine)
  68468. * @param reusable If the post process can be reused on the same frame. (default: false)
  68469. * @param textureType Type of textures used when performing the post process. (default: 0)
  68470. * @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)
  68471. */
  68472. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  68473. /** Weight of the bloom to be added to the original input. */
  68474. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68475. }
  68476. }
  68477. declare module BABYLON {
  68478. /**
  68479. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  68480. */
  68481. export class BloomEffect extends PostProcessRenderEffect {
  68482. private bloomScale;
  68483. /**
  68484. * @hidden Internal
  68485. */
  68486. _effects: Array<PostProcess>;
  68487. /**
  68488. * @hidden Internal
  68489. */
  68490. _downscale: ExtractHighlightsPostProcess;
  68491. private _blurX;
  68492. private _blurY;
  68493. private _merge;
  68494. /**
  68495. * The luminance threshold to find bright areas of the image to bloom.
  68496. */
  68497. get threshold(): number;
  68498. set threshold(value: number);
  68499. /**
  68500. * The strength of the bloom.
  68501. */
  68502. get weight(): number;
  68503. set weight(value: number);
  68504. /**
  68505. * Specifies the size of the bloom blur kernel, relative to the final output size
  68506. */
  68507. get kernel(): number;
  68508. set kernel(value: number);
  68509. /**
  68510. * Creates a new instance of @see BloomEffect
  68511. * @param scene The scene the effect belongs to.
  68512. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  68513. * @param bloomKernel The size of the kernel to be used when applying the blur.
  68514. * @param bloomWeight The the strength of bloom.
  68515. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68516. * @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)
  68517. */
  68518. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  68519. /**
  68520. * Disposes each of the internal effects for a given camera.
  68521. * @param camera The camera to dispose the effect on.
  68522. */
  68523. disposeEffects(camera: Camera): void;
  68524. /**
  68525. * @hidden Internal
  68526. */
  68527. _updateEffects(): void;
  68528. /**
  68529. * Internal
  68530. * @returns if all the contained post processes are ready.
  68531. * @hidden
  68532. */
  68533. _isReady(): boolean;
  68534. }
  68535. }
  68536. declare module BABYLON {
  68537. /** @hidden */
  68538. export var chromaticAberrationPixelShader: {
  68539. name: string;
  68540. shader: string;
  68541. };
  68542. }
  68543. declare module BABYLON {
  68544. /**
  68545. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  68546. */
  68547. export class ChromaticAberrationPostProcess extends PostProcess {
  68548. /**
  68549. * The amount of seperation of rgb channels (default: 30)
  68550. */
  68551. aberrationAmount: number;
  68552. /**
  68553. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  68554. */
  68555. radialIntensity: number;
  68556. /**
  68557. * 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))
  68558. */
  68559. direction: Vector2;
  68560. /**
  68561. * 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))
  68562. */
  68563. centerPosition: Vector2;
  68564. /**
  68565. * Creates a new instance ChromaticAberrationPostProcess
  68566. * @param name The name of the effect.
  68567. * @param screenWidth The width of the screen to apply the effect on.
  68568. * @param screenHeight The height of the screen to apply the effect on.
  68569. * @param options The required width/height ratio to downsize to before computing the render pass.
  68570. * @param camera The camera to apply the render pass to.
  68571. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68572. * @param engine The engine which the post process will be applied. (default: current engine)
  68573. * @param reusable If the post process can be reused on the same frame. (default: false)
  68574. * @param textureType Type of textures used when performing the post process. (default: 0)
  68575. * @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)
  68576. */
  68577. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68578. }
  68579. }
  68580. declare module BABYLON {
  68581. /** @hidden */
  68582. export var circleOfConfusionPixelShader: {
  68583. name: string;
  68584. shader: string;
  68585. };
  68586. }
  68587. declare module BABYLON {
  68588. /**
  68589. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  68590. */
  68591. export class CircleOfConfusionPostProcess extends PostProcess {
  68592. /**
  68593. * 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.
  68594. */
  68595. lensSize: number;
  68596. /**
  68597. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68598. */
  68599. fStop: number;
  68600. /**
  68601. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68602. */
  68603. focusDistance: number;
  68604. /**
  68605. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  68606. */
  68607. focalLength: number;
  68608. private _depthTexture;
  68609. /**
  68610. * Creates a new instance CircleOfConfusionPostProcess
  68611. * @param name The name of the effect.
  68612. * @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.
  68613. * @param options The required width/height ratio to downsize to before computing the render pass.
  68614. * @param camera The camera to apply the render pass to.
  68615. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68616. * @param engine The engine which the post process will be applied. (default: current engine)
  68617. * @param reusable If the post process can be reused on the same frame. (default: false)
  68618. * @param textureType Type of textures used when performing the post process. (default: 0)
  68619. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  68620. */
  68621. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68622. /**
  68623. * 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.
  68624. */
  68625. set depthTexture(value: RenderTargetTexture);
  68626. }
  68627. }
  68628. declare module BABYLON {
  68629. /** @hidden */
  68630. export var colorCorrectionPixelShader: {
  68631. name: string;
  68632. shader: string;
  68633. };
  68634. }
  68635. declare module BABYLON {
  68636. /**
  68637. *
  68638. * This post-process allows the modification of rendered colors by using
  68639. * a 'look-up table' (LUT). This effect is also called Color Grading.
  68640. *
  68641. * The object needs to be provided an url to a texture containing the color
  68642. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  68643. * Use an image editing software to tweak the LUT to match your needs.
  68644. *
  68645. * For an example of a color LUT, see here:
  68646. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  68647. * For explanations on color grading, see here:
  68648. * @see http://udn.epicgames.com/Three/ColorGrading.html
  68649. *
  68650. */
  68651. export class ColorCorrectionPostProcess extends PostProcess {
  68652. private _colorTableTexture;
  68653. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68654. }
  68655. }
  68656. declare module BABYLON {
  68657. /** @hidden */
  68658. export var convolutionPixelShader: {
  68659. name: string;
  68660. shader: string;
  68661. };
  68662. }
  68663. declare module BABYLON {
  68664. /**
  68665. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  68666. * input texture to perform effects such as edge detection or sharpening
  68667. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68668. */
  68669. export class ConvolutionPostProcess extends PostProcess {
  68670. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68671. kernel: number[];
  68672. /**
  68673. * Creates a new instance ConvolutionPostProcess
  68674. * @param name The name of the effect.
  68675. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  68676. * @param options The required width/height ratio to downsize to before computing the render pass.
  68677. * @param camera The camera to apply the render pass to.
  68678. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68679. * @param engine The engine which the post process will be applied. (default: current engine)
  68680. * @param reusable If the post process can be reused on the same frame. (default: false)
  68681. * @param textureType Type of textures used when performing the post process. (default: 0)
  68682. */
  68683. constructor(name: string,
  68684. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68685. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68686. /**
  68687. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68688. */
  68689. static EdgeDetect0Kernel: number[];
  68690. /**
  68691. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68692. */
  68693. static EdgeDetect1Kernel: number[];
  68694. /**
  68695. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68696. */
  68697. static EdgeDetect2Kernel: number[];
  68698. /**
  68699. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68700. */
  68701. static SharpenKernel: number[];
  68702. /**
  68703. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68704. */
  68705. static EmbossKernel: number[];
  68706. /**
  68707. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68708. */
  68709. static GaussianKernel: number[];
  68710. }
  68711. }
  68712. declare module BABYLON {
  68713. /**
  68714. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  68715. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  68716. * based on samples that have a large difference in distance than the center pixel.
  68717. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  68718. */
  68719. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  68720. direction: Vector2;
  68721. /**
  68722. * Creates a new instance CircleOfConfusionPostProcess
  68723. * @param name The name of the effect.
  68724. * @param scene The scene the effect belongs to.
  68725. * @param direction The direction the blur should be applied.
  68726. * @param kernel The size of the kernel used to blur.
  68727. * @param options The required width/height ratio to downsize to before computing the render pass.
  68728. * @param camera The camera to apply the render pass to.
  68729. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  68730. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  68731. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68732. * @param engine The engine which the post process will be applied. (default: current engine)
  68733. * @param reusable If the post process can be reused on the same frame. (default: false)
  68734. * @param textureType Type of textures used when performing the post process. (default: 0)
  68735. * @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)
  68736. */
  68737. 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);
  68738. }
  68739. }
  68740. declare module BABYLON {
  68741. /** @hidden */
  68742. export var depthOfFieldMergePixelShader: {
  68743. name: string;
  68744. shader: string;
  68745. };
  68746. }
  68747. declare module BABYLON {
  68748. /**
  68749. * Options to be set when merging outputs from the default pipeline.
  68750. */
  68751. export class DepthOfFieldMergePostProcessOptions {
  68752. /**
  68753. * The original image to merge on top of
  68754. */
  68755. originalFromInput: PostProcess;
  68756. /**
  68757. * Parameters to perform the merge of the depth of field effect
  68758. */
  68759. depthOfField?: {
  68760. circleOfConfusion: PostProcess;
  68761. blurSteps: Array<PostProcess>;
  68762. };
  68763. /**
  68764. * Parameters to perform the merge of bloom effect
  68765. */
  68766. bloom?: {
  68767. blurred: PostProcess;
  68768. weight: number;
  68769. };
  68770. }
  68771. /**
  68772. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68773. */
  68774. export class DepthOfFieldMergePostProcess extends PostProcess {
  68775. private blurSteps;
  68776. /**
  68777. * Creates a new instance of DepthOfFieldMergePostProcess
  68778. * @param name The name of the effect.
  68779. * @param originalFromInput Post process which's input will be used for the merge.
  68780. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  68781. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  68782. * @param options The required width/height ratio to downsize to before computing the render pass.
  68783. * @param camera The camera to apply the render pass to.
  68784. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68785. * @param engine The engine which the post process will be applied. (default: current engine)
  68786. * @param reusable If the post process can be reused on the same frame. (default: false)
  68787. * @param textureType Type of textures used when performing the post process. (default: 0)
  68788. * @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)
  68789. */
  68790. 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);
  68791. /**
  68792. * Updates the effect with the current post process compile time values and recompiles the shader.
  68793. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68794. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68795. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68796. * @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
  68797. * @param onCompiled Called when the shader has been compiled.
  68798. * @param onError Called if there is an error when compiling a shader.
  68799. */
  68800. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68801. }
  68802. }
  68803. declare module BABYLON {
  68804. /**
  68805. * Specifies the level of max blur that should be applied when using the depth of field effect
  68806. */
  68807. export enum DepthOfFieldEffectBlurLevel {
  68808. /**
  68809. * Subtle blur
  68810. */
  68811. Low = 0,
  68812. /**
  68813. * Medium blur
  68814. */
  68815. Medium = 1,
  68816. /**
  68817. * Large blur
  68818. */
  68819. High = 2
  68820. }
  68821. /**
  68822. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  68823. */
  68824. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  68825. private _circleOfConfusion;
  68826. /**
  68827. * @hidden Internal, blurs from high to low
  68828. */
  68829. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  68830. private _depthOfFieldBlurY;
  68831. private _dofMerge;
  68832. /**
  68833. * @hidden Internal post processes in depth of field effect
  68834. */
  68835. _effects: Array<PostProcess>;
  68836. /**
  68837. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  68838. */
  68839. set focalLength(value: number);
  68840. get focalLength(): number;
  68841. /**
  68842. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68843. */
  68844. set fStop(value: number);
  68845. get fStop(): number;
  68846. /**
  68847. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68848. */
  68849. set focusDistance(value: number);
  68850. get focusDistance(): number;
  68851. /**
  68852. * 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.
  68853. */
  68854. set lensSize(value: number);
  68855. get lensSize(): number;
  68856. /**
  68857. * Creates a new instance DepthOfFieldEffect
  68858. * @param scene The scene the effect belongs to.
  68859. * @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.
  68860. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68861. * @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)
  68862. */
  68863. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  68864. /**
  68865. * Get the current class name of the current effet
  68866. * @returns "DepthOfFieldEffect"
  68867. */
  68868. getClassName(): string;
  68869. /**
  68870. * 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.
  68871. */
  68872. set depthTexture(value: RenderTargetTexture);
  68873. /**
  68874. * Disposes each of the internal effects for a given camera.
  68875. * @param camera The camera to dispose the effect on.
  68876. */
  68877. disposeEffects(camera: Camera): void;
  68878. /**
  68879. * @hidden Internal
  68880. */
  68881. _updateEffects(): void;
  68882. /**
  68883. * Internal
  68884. * @returns if all the contained post processes are ready.
  68885. * @hidden
  68886. */
  68887. _isReady(): boolean;
  68888. }
  68889. }
  68890. declare module BABYLON {
  68891. /** @hidden */
  68892. export var displayPassPixelShader: {
  68893. name: string;
  68894. shader: string;
  68895. };
  68896. }
  68897. declare module BABYLON {
  68898. /**
  68899. * DisplayPassPostProcess which produces an output the same as it's input
  68900. */
  68901. export class DisplayPassPostProcess extends PostProcess {
  68902. /**
  68903. * Creates the DisplayPassPostProcess
  68904. * @param name The name of the effect.
  68905. * @param options The required width/height ratio to downsize to before computing the render pass.
  68906. * @param camera The camera to apply the render pass to.
  68907. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68908. * @param engine The engine which the post process will be applied. (default: current engine)
  68909. * @param reusable If the post process can be reused on the same frame. (default: false)
  68910. */
  68911. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68912. }
  68913. }
  68914. declare module BABYLON {
  68915. /** @hidden */
  68916. export var filterPixelShader: {
  68917. name: string;
  68918. shader: string;
  68919. };
  68920. }
  68921. declare module BABYLON {
  68922. /**
  68923. * Applies a kernel filter to the image
  68924. */
  68925. export class FilterPostProcess extends PostProcess {
  68926. /** The matrix to be applied to the image */
  68927. kernelMatrix: Matrix;
  68928. /**
  68929. *
  68930. * @param name The name of the effect.
  68931. * @param kernelMatrix The matrix to be applied to the image
  68932. * @param options The required width/height ratio to downsize to before computing the render pass.
  68933. * @param camera The camera to apply the render pass to.
  68934. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68935. * @param engine The engine which the post process will be applied. (default: current engine)
  68936. * @param reusable If the post process can be reused on the same frame. (default: false)
  68937. */
  68938. constructor(name: string,
  68939. /** The matrix to be applied to the image */
  68940. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68941. }
  68942. }
  68943. declare module BABYLON {
  68944. /** @hidden */
  68945. export var fxaaPixelShader: {
  68946. name: string;
  68947. shader: string;
  68948. };
  68949. }
  68950. declare module BABYLON {
  68951. /** @hidden */
  68952. export var fxaaVertexShader: {
  68953. name: string;
  68954. shader: string;
  68955. };
  68956. }
  68957. declare module BABYLON {
  68958. /**
  68959. * Fxaa post process
  68960. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  68961. */
  68962. export class FxaaPostProcess extends PostProcess {
  68963. /** @hidden */
  68964. texelWidth: number;
  68965. /** @hidden */
  68966. texelHeight: number;
  68967. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68968. private _getDefines;
  68969. }
  68970. }
  68971. declare module BABYLON {
  68972. /** @hidden */
  68973. export var grainPixelShader: {
  68974. name: string;
  68975. shader: string;
  68976. };
  68977. }
  68978. declare module BABYLON {
  68979. /**
  68980. * The GrainPostProcess adds noise to the image at mid luminance levels
  68981. */
  68982. export class GrainPostProcess extends PostProcess {
  68983. /**
  68984. * The intensity of the grain added (default: 30)
  68985. */
  68986. intensity: number;
  68987. /**
  68988. * If the grain should be randomized on every frame
  68989. */
  68990. animated: boolean;
  68991. /**
  68992. * Creates a new instance of @see GrainPostProcess
  68993. * @param name The name of the effect.
  68994. * @param options The required width/height ratio to downsize to before computing the render pass.
  68995. * @param camera The camera to apply the render pass to.
  68996. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68997. * @param engine The engine which the post process will be applied. (default: current engine)
  68998. * @param reusable If the post process can be reused on the same frame. (default: false)
  68999. * @param textureType Type of textures used when performing the post process. (default: 0)
  69000. * @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)
  69001. */
  69002. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69003. }
  69004. }
  69005. declare module BABYLON {
  69006. /** @hidden */
  69007. export var highlightsPixelShader: {
  69008. name: string;
  69009. shader: string;
  69010. };
  69011. }
  69012. declare module BABYLON {
  69013. /**
  69014. * Extracts highlights from the image
  69015. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69016. */
  69017. export class HighlightsPostProcess extends PostProcess {
  69018. /**
  69019. * Extracts highlights from the image
  69020. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69021. * @param name The name of the effect.
  69022. * @param options The required width/height ratio to downsize to before computing the render pass.
  69023. * @param camera The camera to apply the render pass to.
  69024. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69025. * @param engine The engine which the post process will be applied. (default: current engine)
  69026. * @param reusable If the post process can be reused on the same frame. (default: false)
  69027. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  69028. */
  69029. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69030. }
  69031. }
  69032. declare module BABYLON {
  69033. /** @hidden */
  69034. export var mrtFragmentDeclaration: {
  69035. name: string;
  69036. shader: string;
  69037. };
  69038. }
  69039. declare module BABYLON {
  69040. /** @hidden */
  69041. export var geometryPixelShader: {
  69042. name: string;
  69043. shader: string;
  69044. };
  69045. }
  69046. declare module BABYLON {
  69047. /** @hidden */
  69048. export var geometryVertexShader: {
  69049. name: string;
  69050. shader: string;
  69051. };
  69052. }
  69053. declare module BABYLON {
  69054. /** @hidden */
  69055. interface ISavedTransformationMatrix {
  69056. world: Matrix;
  69057. viewProjection: Matrix;
  69058. }
  69059. /**
  69060. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  69061. */
  69062. export class GeometryBufferRenderer {
  69063. /**
  69064. * Constant used to retrieve the position texture index in the G-Buffer textures array
  69065. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  69066. */
  69067. static readonly POSITION_TEXTURE_TYPE: number;
  69068. /**
  69069. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  69070. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  69071. */
  69072. static readonly VELOCITY_TEXTURE_TYPE: number;
  69073. /**
  69074. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  69075. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  69076. */
  69077. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  69078. /**
  69079. * Dictionary used to store the previous transformation matrices of each rendered mesh
  69080. * in order to compute objects velocities when enableVelocity is set to "true"
  69081. * @hidden
  69082. */
  69083. _previousTransformationMatrices: {
  69084. [index: number]: ISavedTransformationMatrix;
  69085. };
  69086. /**
  69087. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  69088. * in order to compute objects velocities when enableVelocity is set to "true"
  69089. * @hidden
  69090. */
  69091. _previousBonesTransformationMatrices: {
  69092. [index: number]: Float32Array;
  69093. };
  69094. /**
  69095. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  69096. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  69097. */
  69098. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  69099. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  69100. renderTransparentMeshes: boolean;
  69101. private _scene;
  69102. private _resizeObserver;
  69103. private _multiRenderTarget;
  69104. private _ratio;
  69105. private _enablePosition;
  69106. private _enableVelocity;
  69107. private _enableReflectivity;
  69108. private _positionIndex;
  69109. private _velocityIndex;
  69110. private _reflectivityIndex;
  69111. protected _effect: Effect;
  69112. protected _cachedDefines: string;
  69113. /**
  69114. * Set the render list (meshes to be rendered) used in the G buffer.
  69115. */
  69116. set renderList(meshes: Mesh[]);
  69117. /**
  69118. * Gets wether or not G buffer are supported by the running hardware.
  69119. * This requires draw buffer supports
  69120. */
  69121. get isSupported(): boolean;
  69122. /**
  69123. * Returns the index of the given texture type in the G-Buffer textures array
  69124. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  69125. * @returns the index of the given texture type in the G-Buffer textures array
  69126. */
  69127. getTextureIndex(textureType: number): number;
  69128. /**
  69129. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  69130. */
  69131. get enablePosition(): boolean;
  69132. /**
  69133. * Sets whether or not objects positions are enabled for the G buffer.
  69134. */
  69135. set enablePosition(enable: boolean);
  69136. /**
  69137. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  69138. */
  69139. get enableVelocity(): boolean;
  69140. /**
  69141. * Sets wether or not objects velocities are enabled for the G buffer.
  69142. */
  69143. set enableVelocity(enable: boolean);
  69144. /**
  69145. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  69146. */
  69147. get enableReflectivity(): boolean;
  69148. /**
  69149. * Sets wether or not objects roughness are enabled for the G buffer.
  69150. */
  69151. set enableReflectivity(enable: boolean);
  69152. /**
  69153. * Gets the scene associated with the buffer.
  69154. */
  69155. get scene(): Scene;
  69156. /**
  69157. * Gets the ratio used by the buffer during its creation.
  69158. * How big is the buffer related to the main canvas.
  69159. */
  69160. get ratio(): number;
  69161. /** @hidden */
  69162. static _SceneComponentInitialization: (scene: Scene) => void;
  69163. /**
  69164. * Creates a new G Buffer for the scene
  69165. * @param scene The scene the buffer belongs to
  69166. * @param ratio How big is the buffer related to the main canvas.
  69167. */
  69168. constructor(scene: Scene, ratio?: number);
  69169. /**
  69170. * Checks wether everything is ready to render a submesh to the G buffer.
  69171. * @param subMesh the submesh to check readiness for
  69172. * @param useInstances is the mesh drawn using instance or not
  69173. * @returns true if ready otherwise false
  69174. */
  69175. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69176. /**
  69177. * Gets the current underlying G Buffer.
  69178. * @returns the buffer
  69179. */
  69180. getGBuffer(): MultiRenderTarget;
  69181. /**
  69182. * Gets the number of samples used to render the buffer (anti aliasing).
  69183. */
  69184. get samples(): number;
  69185. /**
  69186. * Sets the number of samples used to render the buffer (anti aliasing).
  69187. */
  69188. set samples(value: number);
  69189. /**
  69190. * Disposes the renderer and frees up associated resources.
  69191. */
  69192. dispose(): void;
  69193. protected _createRenderTargets(): void;
  69194. private _copyBonesTransformationMatrices;
  69195. }
  69196. }
  69197. declare module BABYLON {
  69198. interface Scene {
  69199. /** @hidden (Backing field) */
  69200. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  69201. /**
  69202. * Gets or Sets the current geometry buffer associated to the scene.
  69203. */
  69204. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  69205. /**
  69206. * Enables a GeometryBufferRender and associates it with the scene
  69207. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  69208. * @returns the GeometryBufferRenderer
  69209. */
  69210. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  69211. /**
  69212. * Disables the GeometryBufferRender associated with the scene
  69213. */
  69214. disableGeometryBufferRenderer(): void;
  69215. }
  69216. /**
  69217. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  69218. * in several rendering techniques.
  69219. */
  69220. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  69221. /**
  69222. * The component name helpful to identify the component in the list of scene components.
  69223. */
  69224. readonly name: string;
  69225. /**
  69226. * The scene the component belongs to.
  69227. */
  69228. scene: Scene;
  69229. /**
  69230. * Creates a new instance of the component for the given scene
  69231. * @param scene Defines the scene to register the component in
  69232. */
  69233. constructor(scene: Scene);
  69234. /**
  69235. * Registers the component in a given scene
  69236. */
  69237. register(): void;
  69238. /**
  69239. * Rebuilds the elements related to this component in case of
  69240. * context lost for instance.
  69241. */
  69242. rebuild(): void;
  69243. /**
  69244. * Disposes the component and the associated ressources
  69245. */
  69246. dispose(): void;
  69247. private _gatherRenderTargets;
  69248. }
  69249. }
  69250. declare module BABYLON {
  69251. /** @hidden */
  69252. export var motionBlurPixelShader: {
  69253. name: string;
  69254. shader: string;
  69255. };
  69256. }
  69257. declare module BABYLON {
  69258. /**
  69259. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  69260. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  69261. * As an example, all you have to do is to create the post-process:
  69262. * var mb = new BABYLON.MotionBlurPostProcess(
  69263. * 'mb', // The name of the effect.
  69264. * scene, // The scene containing the objects to blur according to their velocity.
  69265. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  69266. * camera // The camera to apply the render pass to.
  69267. * );
  69268. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  69269. */
  69270. export class MotionBlurPostProcess extends PostProcess {
  69271. /**
  69272. * Defines how much the image is blurred by the movement. Default value is equal to 1
  69273. */
  69274. motionStrength: number;
  69275. /**
  69276. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  69277. */
  69278. get motionBlurSamples(): number;
  69279. /**
  69280. * Sets the number of iterations to be used for motion blur quality
  69281. */
  69282. set motionBlurSamples(samples: number);
  69283. private _motionBlurSamples;
  69284. private _geometryBufferRenderer;
  69285. /**
  69286. * Creates a new instance MotionBlurPostProcess
  69287. * @param name The name of the effect.
  69288. * @param scene The scene containing the objects to blur according to their velocity.
  69289. * @param options The required width/height ratio to downsize to before computing the render pass.
  69290. * @param camera The camera to apply the render pass to.
  69291. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69292. * @param engine The engine which the post process will be applied. (default: current engine)
  69293. * @param reusable If the post process can be reused on the same frame. (default: false)
  69294. * @param textureType Type of textures used when performing the post process. (default: 0)
  69295. * @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)
  69296. */
  69297. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69298. /**
  69299. * Excludes the given skinned mesh from computing bones velocities.
  69300. * 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.
  69301. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  69302. */
  69303. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69304. /**
  69305. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  69306. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  69307. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  69308. */
  69309. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69310. /**
  69311. * Disposes the post process.
  69312. * @param camera The camera to dispose the post process on.
  69313. */
  69314. dispose(camera?: Camera): void;
  69315. }
  69316. }
  69317. declare module BABYLON {
  69318. /** @hidden */
  69319. export var refractionPixelShader: {
  69320. name: string;
  69321. shader: string;
  69322. };
  69323. }
  69324. declare module BABYLON {
  69325. /**
  69326. * Post process which applies a refractin texture
  69327. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69328. */
  69329. export class RefractionPostProcess extends PostProcess {
  69330. /** the base color of the refraction (used to taint the rendering) */
  69331. color: Color3;
  69332. /** simulated refraction depth */
  69333. depth: number;
  69334. /** the coefficient of the base color (0 to remove base color tainting) */
  69335. colorLevel: number;
  69336. private _refTexture;
  69337. private _ownRefractionTexture;
  69338. /**
  69339. * Gets or sets the refraction texture
  69340. * Please note that you are responsible for disposing the texture if you set it manually
  69341. */
  69342. get refractionTexture(): Texture;
  69343. set refractionTexture(value: Texture);
  69344. /**
  69345. * Initializes the RefractionPostProcess
  69346. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69347. * @param name The name of the effect.
  69348. * @param refractionTextureUrl Url of the refraction texture to use
  69349. * @param color the base color of the refraction (used to taint the rendering)
  69350. * @param depth simulated refraction depth
  69351. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  69352. * @param camera The camera to apply the render pass to.
  69353. * @param options The required width/height ratio to downsize to before computing the render pass.
  69354. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69355. * @param engine The engine which the post process will be applied. (default: current engine)
  69356. * @param reusable If the post process can be reused on the same frame. (default: false)
  69357. */
  69358. constructor(name: string, refractionTextureUrl: string,
  69359. /** the base color of the refraction (used to taint the rendering) */
  69360. color: Color3,
  69361. /** simulated refraction depth */
  69362. depth: number,
  69363. /** the coefficient of the base color (0 to remove base color tainting) */
  69364. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69365. /**
  69366. * Disposes of the post process
  69367. * @param camera Camera to dispose post process on
  69368. */
  69369. dispose(camera: Camera): void;
  69370. }
  69371. }
  69372. declare module BABYLON {
  69373. /** @hidden */
  69374. export var sharpenPixelShader: {
  69375. name: string;
  69376. shader: string;
  69377. };
  69378. }
  69379. declare module BABYLON {
  69380. /**
  69381. * The SharpenPostProcess applies a sharpen kernel to every pixel
  69382. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69383. */
  69384. export class SharpenPostProcess extends PostProcess {
  69385. /**
  69386. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  69387. */
  69388. colorAmount: number;
  69389. /**
  69390. * How much sharpness should be applied (default: 0.3)
  69391. */
  69392. edgeAmount: number;
  69393. /**
  69394. * Creates a new instance ConvolutionPostProcess
  69395. * @param name The name of the effect.
  69396. * @param options The required width/height ratio to downsize to before computing the render pass.
  69397. * @param camera The camera to apply the render pass to.
  69398. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69399. * @param engine The engine which the post process will be applied. (default: current engine)
  69400. * @param reusable If the post process can be reused on the same frame. (default: false)
  69401. * @param textureType Type of textures used when performing the post process. (default: 0)
  69402. * @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)
  69403. */
  69404. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69405. }
  69406. }
  69407. declare module BABYLON {
  69408. /**
  69409. * PostProcessRenderPipeline
  69410. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69411. */
  69412. export class PostProcessRenderPipeline {
  69413. private engine;
  69414. private _renderEffects;
  69415. private _renderEffectsForIsolatedPass;
  69416. /**
  69417. * List of inspectable custom properties (used by the Inspector)
  69418. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  69419. */
  69420. inspectableCustomProperties: IInspectable[];
  69421. /**
  69422. * @hidden
  69423. */
  69424. protected _cameras: Camera[];
  69425. /** @hidden */
  69426. _name: string;
  69427. /**
  69428. * Gets pipeline name
  69429. */
  69430. get name(): string;
  69431. /** Gets the list of attached cameras */
  69432. get cameras(): Camera[];
  69433. /**
  69434. * Initializes a PostProcessRenderPipeline
  69435. * @param engine engine to add the pipeline to
  69436. * @param name name of the pipeline
  69437. */
  69438. constructor(engine: Engine, name: string);
  69439. /**
  69440. * Gets the class name
  69441. * @returns "PostProcessRenderPipeline"
  69442. */
  69443. getClassName(): string;
  69444. /**
  69445. * If all the render effects in the pipeline are supported
  69446. */
  69447. get isSupported(): boolean;
  69448. /**
  69449. * Adds an effect to the pipeline
  69450. * @param renderEffect the effect to add
  69451. */
  69452. addEffect(renderEffect: PostProcessRenderEffect): void;
  69453. /** @hidden */
  69454. _rebuild(): void;
  69455. /** @hidden */
  69456. _enableEffect(renderEffectName: string, cameras: Camera): void;
  69457. /** @hidden */
  69458. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  69459. /** @hidden */
  69460. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  69461. /** @hidden */
  69462. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  69463. /** @hidden */
  69464. _attachCameras(cameras: Camera, unique: boolean): void;
  69465. /** @hidden */
  69466. _attachCameras(cameras: Camera[], unique: boolean): void;
  69467. /** @hidden */
  69468. _detachCameras(cameras: Camera): void;
  69469. /** @hidden */
  69470. _detachCameras(cameras: Nullable<Camera[]>): void;
  69471. /** @hidden */
  69472. _update(): void;
  69473. /** @hidden */
  69474. _reset(): void;
  69475. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  69476. /**
  69477. * Sets the required values to the prepass renderer.
  69478. * @param prePassRenderer defines the prepass renderer to setup.
  69479. * @returns true if the pre pass is needed.
  69480. */
  69481. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  69482. /**
  69483. * Disposes of the pipeline
  69484. */
  69485. dispose(): void;
  69486. }
  69487. }
  69488. declare module BABYLON {
  69489. /**
  69490. * PostProcessRenderPipelineManager class
  69491. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69492. */
  69493. export class PostProcessRenderPipelineManager {
  69494. private _renderPipelines;
  69495. /**
  69496. * Initializes a PostProcessRenderPipelineManager
  69497. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69498. */
  69499. constructor();
  69500. /**
  69501. * Gets the list of supported render pipelines
  69502. */
  69503. get supportedPipelines(): PostProcessRenderPipeline[];
  69504. /**
  69505. * Adds a pipeline to the manager
  69506. * @param renderPipeline The pipeline to add
  69507. */
  69508. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  69509. /**
  69510. * Attaches a camera to the pipeline
  69511. * @param renderPipelineName The name of the pipeline to attach to
  69512. * @param cameras the camera to attach
  69513. * @param unique if the camera can be attached multiple times to the pipeline
  69514. */
  69515. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  69516. /**
  69517. * Detaches a camera from the pipeline
  69518. * @param renderPipelineName The name of the pipeline to detach from
  69519. * @param cameras the camera to detach
  69520. */
  69521. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  69522. /**
  69523. * Enables an effect by name on a pipeline
  69524. * @param renderPipelineName the name of the pipeline to enable the effect in
  69525. * @param renderEffectName the name of the effect to enable
  69526. * @param cameras the cameras that the effect should be enabled on
  69527. */
  69528. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69529. /**
  69530. * Disables an effect by name on a pipeline
  69531. * @param renderPipelineName the name of the pipeline to disable the effect in
  69532. * @param renderEffectName the name of the effect to disable
  69533. * @param cameras the cameras that the effect should be disabled on
  69534. */
  69535. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69536. /**
  69537. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  69538. */
  69539. update(): void;
  69540. /** @hidden */
  69541. _rebuild(): void;
  69542. /**
  69543. * Disposes of the manager and pipelines
  69544. */
  69545. dispose(): void;
  69546. }
  69547. }
  69548. declare module BABYLON {
  69549. interface Scene {
  69550. /** @hidden (Backing field) */
  69551. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69552. /**
  69553. * Gets the postprocess render pipeline manager
  69554. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69555. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69556. */
  69557. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69558. }
  69559. /**
  69560. * Defines the Render Pipeline scene component responsible to rendering pipelines
  69561. */
  69562. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  69563. /**
  69564. * The component name helpfull to identify the component in the list of scene components.
  69565. */
  69566. readonly name: string;
  69567. /**
  69568. * The scene the component belongs to.
  69569. */
  69570. scene: Scene;
  69571. /**
  69572. * Creates a new instance of the component for the given scene
  69573. * @param scene Defines the scene to register the component in
  69574. */
  69575. constructor(scene: Scene);
  69576. /**
  69577. * Registers the component in a given scene
  69578. */
  69579. register(): void;
  69580. /**
  69581. * Rebuilds the elements related to this component in case of
  69582. * context lost for instance.
  69583. */
  69584. rebuild(): void;
  69585. /**
  69586. * Disposes the component and the associated ressources
  69587. */
  69588. dispose(): void;
  69589. private _gatherRenderTargets;
  69590. }
  69591. }
  69592. declare module BABYLON {
  69593. /**
  69594. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  69595. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69596. */
  69597. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69598. private _scene;
  69599. private _camerasToBeAttached;
  69600. /**
  69601. * ID of the sharpen post process,
  69602. */
  69603. private readonly SharpenPostProcessId;
  69604. /**
  69605. * @ignore
  69606. * ID of the image processing post process;
  69607. */
  69608. readonly ImageProcessingPostProcessId: string;
  69609. /**
  69610. * @ignore
  69611. * ID of the Fast Approximate Anti-Aliasing post process;
  69612. */
  69613. readonly FxaaPostProcessId: string;
  69614. /**
  69615. * ID of the chromatic aberration post process,
  69616. */
  69617. private readonly ChromaticAberrationPostProcessId;
  69618. /**
  69619. * ID of the grain post process
  69620. */
  69621. private readonly GrainPostProcessId;
  69622. /**
  69623. * Sharpen post process which will apply a sharpen convolution to enhance edges
  69624. */
  69625. sharpen: SharpenPostProcess;
  69626. private _sharpenEffect;
  69627. private bloom;
  69628. /**
  69629. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  69630. */
  69631. depthOfField: DepthOfFieldEffect;
  69632. /**
  69633. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69634. */
  69635. fxaa: FxaaPostProcess;
  69636. /**
  69637. * Image post processing pass used to perform operations such as tone mapping or color grading.
  69638. */
  69639. imageProcessing: ImageProcessingPostProcess;
  69640. /**
  69641. * Chromatic aberration post process which will shift rgb colors in the image
  69642. */
  69643. chromaticAberration: ChromaticAberrationPostProcess;
  69644. private _chromaticAberrationEffect;
  69645. /**
  69646. * Grain post process which add noise to the image
  69647. */
  69648. grain: GrainPostProcess;
  69649. private _grainEffect;
  69650. /**
  69651. * Glow post process which adds a glow to emissive areas of the image
  69652. */
  69653. private _glowLayer;
  69654. /**
  69655. * Animations which can be used to tweak settings over a period of time
  69656. */
  69657. animations: Animation[];
  69658. private _imageProcessingConfigurationObserver;
  69659. private _sharpenEnabled;
  69660. private _bloomEnabled;
  69661. private _depthOfFieldEnabled;
  69662. private _depthOfFieldBlurLevel;
  69663. private _fxaaEnabled;
  69664. private _imageProcessingEnabled;
  69665. private _defaultPipelineTextureType;
  69666. private _bloomScale;
  69667. private _chromaticAberrationEnabled;
  69668. private _grainEnabled;
  69669. private _buildAllowed;
  69670. /**
  69671. * Gets active scene
  69672. */
  69673. get scene(): Scene;
  69674. /**
  69675. * Enable or disable the sharpen process from the pipeline
  69676. */
  69677. set sharpenEnabled(enabled: boolean);
  69678. get sharpenEnabled(): boolean;
  69679. private _resizeObserver;
  69680. private _hardwareScaleLevel;
  69681. private _bloomKernel;
  69682. /**
  69683. * Specifies the size of the bloom blur kernel, relative to the final output size
  69684. */
  69685. get bloomKernel(): number;
  69686. set bloomKernel(value: number);
  69687. /**
  69688. * Specifies the weight of the bloom in the final rendering
  69689. */
  69690. private _bloomWeight;
  69691. /**
  69692. * Specifies the luma threshold for the area that will be blurred by the bloom
  69693. */
  69694. private _bloomThreshold;
  69695. private _hdr;
  69696. /**
  69697. * The strength of the bloom.
  69698. */
  69699. set bloomWeight(value: number);
  69700. get bloomWeight(): number;
  69701. /**
  69702. * The strength of the bloom.
  69703. */
  69704. set bloomThreshold(value: number);
  69705. get bloomThreshold(): number;
  69706. /**
  69707. * The scale of the bloom, lower value will provide better performance.
  69708. */
  69709. set bloomScale(value: number);
  69710. get bloomScale(): number;
  69711. /**
  69712. * Enable or disable the bloom from the pipeline
  69713. */
  69714. set bloomEnabled(enabled: boolean);
  69715. get bloomEnabled(): boolean;
  69716. private _rebuildBloom;
  69717. /**
  69718. * If the depth of field is enabled.
  69719. */
  69720. get depthOfFieldEnabled(): boolean;
  69721. set depthOfFieldEnabled(enabled: boolean);
  69722. /**
  69723. * Blur level of the depth of field effect. (Higher blur will effect performance)
  69724. */
  69725. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  69726. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  69727. /**
  69728. * If the anti aliasing is enabled.
  69729. */
  69730. set fxaaEnabled(enabled: boolean);
  69731. get fxaaEnabled(): boolean;
  69732. private _samples;
  69733. /**
  69734. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69735. */
  69736. set samples(sampleCount: number);
  69737. get samples(): number;
  69738. /**
  69739. * If image processing is enabled.
  69740. */
  69741. set imageProcessingEnabled(enabled: boolean);
  69742. get imageProcessingEnabled(): boolean;
  69743. /**
  69744. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  69745. */
  69746. set glowLayerEnabled(enabled: boolean);
  69747. get glowLayerEnabled(): boolean;
  69748. /**
  69749. * Gets the glow layer (or null if not defined)
  69750. */
  69751. get glowLayer(): Nullable<GlowLayer>;
  69752. /**
  69753. * Enable or disable the chromaticAberration process from the pipeline
  69754. */
  69755. set chromaticAberrationEnabled(enabled: boolean);
  69756. get chromaticAberrationEnabled(): boolean;
  69757. /**
  69758. * Enable or disable the grain process from the pipeline
  69759. */
  69760. set grainEnabled(enabled: boolean);
  69761. get grainEnabled(): boolean;
  69762. /**
  69763. * @constructor
  69764. * @param name - The rendering pipeline name (default: "")
  69765. * @param hdr - If high dynamic range textures should be used (default: true)
  69766. * @param scene - The scene linked to this pipeline (default: the last created scene)
  69767. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  69768. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  69769. */
  69770. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  69771. /**
  69772. * Get the class name
  69773. * @returns "DefaultRenderingPipeline"
  69774. */
  69775. getClassName(): string;
  69776. /**
  69777. * Force the compilation of the entire pipeline.
  69778. */
  69779. prepare(): void;
  69780. private _hasCleared;
  69781. private _prevPostProcess;
  69782. private _prevPrevPostProcess;
  69783. private _setAutoClearAndTextureSharing;
  69784. private _depthOfFieldSceneObserver;
  69785. private _buildPipeline;
  69786. private _disposePostProcesses;
  69787. /**
  69788. * Adds a camera to the pipeline
  69789. * @param camera the camera to be added
  69790. */
  69791. addCamera(camera: Camera): void;
  69792. /**
  69793. * Removes a camera from the pipeline
  69794. * @param camera the camera to remove
  69795. */
  69796. removeCamera(camera: Camera): void;
  69797. /**
  69798. * Dispose of the pipeline and stop all post processes
  69799. */
  69800. dispose(): void;
  69801. /**
  69802. * Serialize the rendering pipeline (Used when exporting)
  69803. * @returns the serialized object
  69804. */
  69805. serialize(): any;
  69806. /**
  69807. * Parse the serialized pipeline
  69808. * @param source Source pipeline.
  69809. * @param scene The scene to load the pipeline to.
  69810. * @param rootUrl The URL of the serialized pipeline.
  69811. * @returns An instantiated pipeline from the serialized object.
  69812. */
  69813. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  69814. }
  69815. }
  69816. declare module BABYLON {
  69817. /** @hidden */
  69818. export var lensHighlightsPixelShader: {
  69819. name: string;
  69820. shader: string;
  69821. };
  69822. }
  69823. declare module BABYLON {
  69824. /** @hidden */
  69825. export var depthOfFieldPixelShader: {
  69826. name: string;
  69827. shader: string;
  69828. };
  69829. }
  69830. declare module BABYLON {
  69831. /**
  69832. * BABYLON.JS Chromatic Aberration GLSL Shader
  69833. * Author: Olivier Guyot
  69834. * Separates very slightly R, G and B colors on the edges of the screen
  69835. * Inspired by Francois Tarlier & Martins Upitis
  69836. */
  69837. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  69838. /**
  69839. * @ignore
  69840. * The chromatic aberration PostProcess id in the pipeline
  69841. */
  69842. LensChromaticAberrationEffect: string;
  69843. /**
  69844. * @ignore
  69845. * The highlights enhancing PostProcess id in the pipeline
  69846. */
  69847. HighlightsEnhancingEffect: string;
  69848. /**
  69849. * @ignore
  69850. * The depth-of-field PostProcess id in the pipeline
  69851. */
  69852. LensDepthOfFieldEffect: string;
  69853. private _scene;
  69854. private _depthTexture;
  69855. private _grainTexture;
  69856. private _chromaticAberrationPostProcess;
  69857. private _highlightsPostProcess;
  69858. private _depthOfFieldPostProcess;
  69859. private _edgeBlur;
  69860. private _grainAmount;
  69861. private _chromaticAberration;
  69862. private _distortion;
  69863. private _highlightsGain;
  69864. private _highlightsThreshold;
  69865. private _dofDistance;
  69866. private _dofAperture;
  69867. private _dofDarken;
  69868. private _dofPentagon;
  69869. private _blurNoise;
  69870. /**
  69871. * @constructor
  69872. *
  69873. * Effect parameters are as follow:
  69874. * {
  69875. * chromatic_aberration: number; // from 0 to x (1 for realism)
  69876. * edge_blur: number; // from 0 to x (1 for realism)
  69877. * distortion: number; // from 0 to x (1 for realism)
  69878. * grain_amount: number; // from 0 to 1
  69879. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  69880. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  69881. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  69882. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  69883. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  69884. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  69885. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  69886. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  69887. * }
  69888. * Note: if an effect parameter is unset, effect is disabled
  69889. *
  69890. * @param name The rendering pipeline name
  69891. * @param parameters - An object containing all parameters (see above)
  69892. * @param scene The scene linked to this pipeline
  69893. * @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)
  69894. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69895. */
  69896. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  69897. /**
  69898. * Get the class name
  69899. * @returns "LensRenderingPipeline"
  69900. */
  69901. getClassName(): string;
  69902. /**
  69903. * Gets associated scene
  69904. */
  69905. get scene(): Scene;
  69906. /**
  69907. * Gets or sets the edge blur
  69908. */
  69909. get edgeBlur(): number;
  69910. set edgeBlur(value: number);
  69911. /**
  69912. * Gets or sets the grain amount
  69913. */
  69914. get grainAmount(): number;
  69915. set grainAmount(value: number);
  69916. /**
  69917. * Gets or sets the chromatic aberration amount
  69918. */
  69919. get chromaticAberration(): number;
  69920. set chromaticAberration(value: number);
  69921. /**
  69922. * Gets or sets the depth of field aperture
  69923. */
  69924. get dofAperture(): number;
  69925. set dofAperture(value: number);
  69926. /**
  69927. * Gets or sets the edge distortion
  69928. */
  69929. get edgeDistortion(): number;
  69930. set edgeDistortion(value: number);
  69931. /**
  69932. * Gets or sets the depth of field distortion
  69933. */
  69934. get dofDistortion(): number;
  69935. set dofDistortion(value: number);
  69936. /**
  69937. * Gets or sets the darken out of focus amount
  69938. */
  69939. get darkenOutOfFocus(): number;
  69940. set darkenOutOfFocus(value: number);
  69941. /**
  69942. * Gets or sets a boolean indicating if blur noise is enabled
  69943. */
  69944. get blurNoise(): boolean;
  69945. set blurNoise(value: boolean);
  69946. /**
  69947. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  69948. */
  69949. get pentagonBokeh(): boolean;
  69950. set pentagonBokeh(value: boolean);
  69951. /**
  69952. * Gets or sets the highlight grain amount
  69953. */
  69954. get highlightsGain(): number;
  69955. set highlightsGain(value: number);
  69956. /**
  69957. * Gets or sets the highlight threshold
  69958. */
  69959. get highlightsThreshold(): number;
  69960. set highlightsThreshold(value: number);
  69961. /**
  69962. * Sets the amount of blur at the edges
  69963. * @param amount blur amount
  69964. */
  69965. setEdgeBlur(amount: number): void;
  69966. /**
  69967. * Sets edge blur to 0
  69968. */
  69969. disableEdgeBlur(): void;
  69970. /**
  69971. * Sets the amout of grain
  69972. * @param amount Amount of grain
  69973. */
  69974. setGrainAmount(amount: number): void;
  69975. /**
  69976. * Set grain amount to 0
  69977. */
  69978. disableGrain(): void;
  69979. /**
  69980. * Sets the chromatic aberration amount
  69981. * @param amount amount of chromatic aberration
  69982. */
  69983. setChromaticAberration(amount: number): void;
  69984. /**
  69985. * Sets chromatic aberration amount to 0
  69986. */
  69987. disableChromaticAberration(): void;
  69988. /**
  69989. * Sets the EdgeDistortion amount
  69990. * @param amount amount of EdgeDistortion
  69991. */
  69992. setEdgeDistortion(amount: number): void;
  69993. /**
  69994. * Sets edge distortion to 0
  69995. */
  69996. disableEdgeDistortion(): void;
  69997. /**
  69998. * Sets the FocusDistance amount
  69999. * @param amount amount of FocusDistance
  70000. */
  70001. setFocusDistance(amount: number): void;
  70002. /**
  70003. * Disables depth of field
  70004. */
  70005. disableDepthOfField(): void;
  70006. /**
  70007. * Sets the Aperture amount
  70008. * @param amount amount of Aperture
  70009. */
  70010. setAperture(amount: number): void;
  70011. /**
  70012. * Sets the DarkenOutOfFocus amount
  70013. * @param amount amount of DarkenOutOfFocus
  70014. */
  70015. setDarkenOutOfFocus(amount: number): void;
  70016. private _pentagonBokehIsEnabled;
  70017. /**
  70018. * Creates a pentagon bokeh effect
  70019. */
  70020. enablePentagonBokeh(): void;
  70021. /**
  70022. * Disables the pentagon bokeh effect
  70023. */
  70024. disablePentagonBokeh(): void;
  70025. /**
  70026. * Enables noise blur
  70027. */
  70028. enableNoiseBlur(): void;
  70029. /**
  70030. * Disables noise blur
  70031. */
  70032. disableNoiseBlur(): void;
  70033. /**
  70034. * Sets the HighlightsGain amount
  70035. * @param amount amount of HighlightsGain
  70036. */
  70037. setHighlightsGain(amount: number): void;
  70038. /**
  70039. * Sets the HighlightsThreshold amount
  70040. * @param amount amount of HighlightsThreshold
  70041. */
  70042. setHighlightsThreshold(amount: number): void;
  70043. /**
  70044. * Disables highlights
  70045. */
  70046. disableHighlights(): void;
  70047. /**
  70048. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  70049. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  70050. */
  70051. dispose(disableDepthRender?: boolean): void;
  70052. private _createChromaticAberrationPostProcess;
  70053. private _createHighlightsPostProcess;
  70054. private _createDepthOfFieldPostProcess;
  70055. private _createGrainTexture;
  70056. }
  70057. }
  70058. declare module BABYLON {
  70059. /** @hidden */
  70060. export var ssao2PixelShader: {
  70061. name: string;
  70062. shader: string;
  70063. };
  70064. }
  70065. declare module BABYLON {
  70066. /** @hidden */
  70067. export var ssaoCombinePixelShader: {
  70068. name: string;
  70069. shader: string;
  70070. };
  70071. }
  70072. declare module BABYLON {
  70073. /**
  70074. * Render pipeline to produce ssao effect
  70075. */
  70076. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  70077. /**
  70078. * @ignore
  70079. * The PassPostProcess id in the pipeline that contains the original scene color
  70080. */
  70081. SSAOOriginalSceneColorEffect: string;
  70082. /**
  70083. * @ignore
  70084. * The SSAO PostProcess id in the pipeline
  70085. */
  70086. SSAORenderEffect: string;
  70087. /**
  70088. * @ignore
  70089. * The horizontal blur PostProcess id in the pipeline
  70090. */
  70091. SSAOBlurHRenderEffect: string;
  70092. /**
  70093. * @ignore
  70094. * The vertical blur PostProcess id in the pipeline
  70095. */
  70096. SSAOBlurVRenderEffect: string;
  70097. /**
  70098. * @ignore
  70099. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70100. */
  70101. SSAOCombineRenderEffect: string;
  70102. /**
  70103. * The output strength of the SSAO post-process. Default value is 1.0.
  70104. */
  70105. totalStrength: number;
  70106. /**
  70107. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  70108. */
  70109. maxZ: number;
  70110. /**
  70111. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  70112. */
  70113. minZAspect: number;
  70114. private _samples;
  70115. /**
  70116. * Number of samples used for the SSAO calculations. Default value is 8
  70117. */
  70118. set samples(n: number);
  70119. get samples(): number;
  70120. private _textureSamples;
  70121. /**
  70122. * Number of samples to use for antialiasing
  70123. */
  70124. set textureSamples(n: number);
  70125. get textureSamples(): number;
  70126. /**
  70127. * Force rendering the geometry through geometry buffer
  70128. */
  70129. private _forceGeometryBuffer;
  70130. /**
  70131. * Ratio object used for SSAO ratio and blur ratio
  70132. */
  70133. private _ratio;
  70134. /**
  70135. * Dynamically generated sphere sampler.
  70136. */
  70137. private _sampleSphere;
  70138. /**
  70139. * Blur filter offsets
  70140. */
  70141. private _samplerOffsets;
  70142. private _expensiveBlur;
  70143. /**
  70144. * If bilateral blur should be used
  70145. */
  70146. set expensiveBlur(b: boolean);
  70147. get expensiveBlur(): boolean;
  70148. /**
  70149. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  70150. */
  70151. radius: number;
  70152. /**
  70153. * The base color of the SSAO post-process
  70154. * The final result is "base + ssao" between [0, 1]
  70155. */
  70156. base: number;
  70157. /**
  70158. * Support test.
  70159. */
  70160. static get IsSupported(): boolean;
  70161. private _scene;
  70162. private _randomTexture;
  70163. private _originalColorPostProcess;
  70164. private _ssaoPostProcess;
  70165. private _blurHPostProcess;
  70166. private _blurVPostProcess;
  70167. private _ssaoCombinePostProcess;
  70168. private _prePassRenderer;
  70169. /**
  70170. * Gets active scene
  70171. */
  70172. get scene(): Scene;
  70173. /**
  70174. * @constructor
  70175. * @param name The rendering pipeline name
  70176. * @param scene The scene linked to this pipeline
  70177. * @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 }
  70178. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70179. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  70180. */
  70181. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  70182. /**
  70183. * Get the class name
  70184. * @returns "SSAO2RenderingPipeline"
  70185. */
  70186. getClassName(): string;
  70187. /**
  70188. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70189. */
  70190. dispose(disableGeometryBufferRenderer?: boolean): void;
  70191. private _createBlurPostProcess;
  70192. /** @hidden */
  70193. _rebuild(): void;
  70194. private _bits;
  70195. private _radicalInverse_VdC;
  70196. private _hammersley;
  70197. private _hemisphereSample_uniform;
  70198. private _generateHemisphere;
  70199. private _getDefinesForSSAO;
  70200. private _createSSAOPostProcess;
  70201. private _createSSAOCombinePostProcess;
  70202. private _createRandomTexture;
  70203. /**
  70204. * Serialize the rendering pipeline (Used when exporting)
  70205. * @returns the serialized object
  70206. */
  70207. serialize(): any;
  70208. /**
  70209. * Parse the serialized pipeline
  70210. * @param source Source pipeline.
  70211. * @param scene The scene to load the pipeline to.
  70212. * @param rootUrl The URL of the serialized pipeline.
  70213. * @returns An instantiated pipeline from the serialized object.
  70214. */
  70215. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  70216. /**
  70217. * Sets the required values to the prepass renderer.
  70218. * @param prePassRenderer defines the prepass renderer to setup
  70219. * @returns true if the pre pass is needed.
  70220. */
  70221. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  70222. }
  70223. }
  70224. declare module BABYLON {
  70225. /** @hidden */
  70226. export var ssaoPixelShader: {
  70227. name: string;
  70228. shader: string;
  70229. };
  70230. }
  70231. declare module BABYLON {
  70232. /**
  70233. * Render pipeline to produce ssao effect
  70234. */
  70235. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  70236. /**
  70237. * @ignore
  70238. * The PassPostProcess id in the pipeline that contains the original scene color
  70239. */
  70240. SSAOOriginalSceneColorEffect: string;
  70241. /**
  70242. * @ignore
  70243. * The SSAO PostProcess id in the pipeline
  70244. */
  70245. SSAORenderEffect: string;
  70246. /**
  70247. * @ignore
  70248. * The horizontal blur PostProcess id in the pipeline
  70249. */
  70250. SSAOBlurHRenderEffect: string;
  70251. /**
  70252. * @ignore
  70253. * The vertical blur PostProcess id in the pipeline
  70254. */
  70255. SSAOBlurVRenderEffect: string;
  70256. /**
  70257. * @ignore
  70258. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70259. */
  70260. SSAOCombineRenderEffect: string;
  70261. /**
  70262. * The output strength of the SSAO post-process. Default value is 1.0.
  70263. */
  70264. totalStrength: number;
  70265. /**
  70266. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  70267. */
  70268. radius: number;
  70269. /**
  70270. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  70271. * Must not be equal to fallOff and superior to fallOff.
  70272. * Default value is 0.0075
  70273. */
  70274. area: number;
  70275. /**
  70276. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  70277. * Must not be equal to area and inferior to area.
  70278. * Default value is 0.000001
  70279. */
  70280. fallOff: number;
  70281. /**
  70282. * The base color of the SSAO post-process
  70283. * The final result is "base + ssao" between [0, 1]
  70284. */
  70285. base: number;
  70286. private _scene;
  70287. private _depthTexture;
  70288. private _randomTexture;
  70289. private _originalColorPostProcess;
  70290. private _ssaoPostProcess;
  70291. private _blurHPostProcess;
  70292. private _blurVPostProcess;
  70293. private _ssaoCombinePostProcess;
  70294. private _firstUpdate;
  70295. /**
  70296. * Gets active scene
  70297. */
  70298. get scene(): Scene;
  70299. /**
  70300. * @constructor
  70301. * @param name - The rendering pipeline name
  70302. * @param scene - The scene linked to this pipeline
  70303. * @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 }
  70304. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  70305. */
  70306. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  70307. /**
  70308. * Get the class name
  70309. * @returns "SSAORenderingPipeline"
  70310. */
  70311. getClassName(): string;
  70312. /**
  70313. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70314. */
  70315. dispose(disableDepthRender?: boolean): void;
  70316. private _createBlurPostProcess;
  70317. /** @hidden */
  70318. _rebuild(): void;
  70319. private _createSSAOPostProcess;
  70320. private _createSSAOCombinePostProcess;
  70321. private _createRandomTexture;
  70322. }
  70323. }
  70324. declare module BABYLON {
  70325. /** @hidden */
  70326. export var screenSpaceReflectionPixelShader: {
  70327. name: string;
  70328. shader: string;
  70329. };
  70330. }
  70331. declare module BABYLON {
  70332. /**
  70333. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  70334. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  70335. */
  70336. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  70337. /**
  70338. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  70339. */
  70340. threshold: number;
  70341. /**
  70342. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  70343. */
  70344. strength: number;
  70345. /**
  70346. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  70347. */
  70348. reflectionSpecularFalloffExponent: number;
  70349. /**
  70350. * 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]
  70351. */
  70352. step: number;
  70353. /**
  70354. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  70355. */
  70356. roughnessFactor: number;
  70357. private _geometryBufferRenderer;
  70358. private _enableSmoothReflections;
  70359. private _reflectionSamples;
  70360. private _smoothSteps;
  70361. /**
  70362. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  70363. * @param name The name of the effect.
  70364. * @param scene The scene containing the objects to calculate reflections.
  70365. * @param options The required width/height ratio to downsize to before computing the render pass.
  70366. * @param camera The camera to apply the render pass to.
  70367. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70368. * @param engine The engine which the post process will be applied. (default: current engine)
  70369. * @param reusable If the post process can be reused on the same frame. (default: false)
  70370. * @param textureType Type of textures used when performing the post process. (default: 0)
  70371. * @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)
  70372. */
  70373. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70374. /**
  70375. * Gets wether or not smoothing reflections is enabled.
  70376. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70377. */
  70378. get enableSmoothReflections(): boolean;
  70379. /**
  70380. * Sets wether or not smoothing reflections is enabled.
  70381. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70382. */
  70383. set enableSmoothReflections(enabled: boolean);
  70384. /**
  70385. * Gets the number of samples taken while computing reflections. More samples count is high,
  70386. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70387. */
  70388. get reflectionSamples(): number;
  70389. /**
  70390. * Sets the number of samples taken while computing reflections. More samples count is high,
  70391. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70392. */
  70393. set reflectionSamples(samples: number);
  70394. /**
  70395. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  70396. * more the post-process will require GPU power and can generate a drop in FPS.
  70397. * Default value (5.0) work pretty well in all cases but can be adjusted.
  70398. */
  70399. get smoothSteps(): number;
  70400. set smoothSteps(steps: number);
  70401. private _updateEffectDefines;
  70402. }
  70403. }
  70404. declare module BABYLON {
  70405. /** @hidden */
  70406. export var standardPixelShader: {
  70407. name: string;
  70408. shader: string;
  70409. };
  70410. }
  70411. declare module BABYLON {
  70412. /**
  70413. * Standard rendering pipeline
  70414. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70415. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  70416. */
  70417. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70418. /**
  70419. * Public members
  70420. */
  70421. /**
  70422. * Post-process which contains the original scene color before the pipeline applies all the effects
  70423. */
  70424. originalPostProcess: Nullable<PostProcess>;
  70425. /**
  70426. * Post-process used to down scale an image x4
  70427. */
  70428. downSampleX4PostProcess: Nullable<PostProcess>;
  70429. /**
  70430. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  70431. */
  70432. brightPassPostProcess: Nullable<PostProcess>;
  70433. /**
  70434. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  70435. */
  70436. blurHPostProcesses: PostProcess[];
  70437. /**
  70438. * Post-process array storing all the vertical blur post-processes used by the pipeline
  70439. */
  70440. blurVPostProcesses: PostProcess[];
  70441. /**
  70442. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  70443. */
  70444. textureAdderPostProcess: Nullable<PostProcess>;
  70445. /**
  70446. * Post-process used to create volumetric lighting effect
  70447. */
  70448. volumetricLightPostProcess: Nullable<PostProcess>;
  70449. /**
  70450. * Post-process used to smooth the previous volumetric light post-process on the X axis
  70451. */
  70452. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  70453. /**
  70454. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  70455. */
  70456. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  70457. /**
  70458. * Post-process used to merge the volumetric light effect and the real scene color
  70459. */
  70460. volumetricLightMergePostProces: Nullable<PostProcess>;
  70461. /**
  70462. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  70463. */
  70464. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  70465. /**
  70466. * Base post-process used to calculate the average luminance of the final image for HDR
  70467. */
  70468. luminancePostProcess: Nullable<PostProcess>;
  70469. /**
  70470. * Post-processes used to create down sample post-processes in order to get
  70471. * the average luminance of the final image for HDR
  70472. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  70473. */
  70474. luminanceDownSamplePostProcesses: PostProcess[];
  70475. /**
  70476. * Post-process used to create a HDR effect (light adaptation)
  70477. */
  70478. hdrPostProcess: Nullable<PostProcess>;
  70479. /**
  70480. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  70481. */
  70482. textureAdderFinalPostProcess: Nullable<PostProcess>;
  70483. /**
  70484. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  70485. */
  70486. lensFlareFinalPostProcess: Nullable<PostProcess>;
  70487. /**
  70488. * Post-process used to merge the final HDR post-process and the real scene color
  70489. */
  70490. hdrFinalPostProcess: Nullable<PostProcess>;
  70491. /**
  70492. * Post-process used to create a lens flare effect
  70493. */
  70494. lensFlarePostProcess: Nullable<PostProcess>;
  70495. /**
  70496. * Post-process that merges the result of the lens flare post-process and the real scene color
  70497. */
  70498. lensFlareComposePostProcess: Nullable<PostProcess>;
  70499. /**
  70500. * Post-process used to create a motion blur effect
  70501. */
  70502. motionBlurPostProcess: Nullable<PostProcess>;
  70503. /**
  70504. * Post-process used to create a depth of field effect
  70505. */
  70506. depthOfFieldPostProcess: Nullable<PostProcess>;
  70507. /**
  70508. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70509. */
  70510. fxaaPostProcess: Nullable<FxaaPostProcess>;
  70511. /**
  70512. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  70513. */
  70514. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  70515. /**
  70516. * Represents the brightness threshold in order to configure the illuminated surfaces
  70517. */
  70518. brightThreshold: number;
  70519. /**
  70520. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  70521. */
  70522. blurWidth: number;
  70523. /**
  70524. * Sets if the blur for highlighted surfaces must be only horizontal
  70525. */
  70526. horizontalBlur: boolean;
  70527. /**
  70528. * Gets the overall exposure used by the pipeline
  70529. */
  70530. get exposure(): number;
  70531. /**
  70532. * Sets the overall exposure used by the pipeline
  70533. */
  70534. set exposure(value: number);
  70535. /**
  70536. * Texture used typically to simulate "dirty" on camera lens
  70537. */
  70538. lensTexture: Nullable<Texture>;
  70539. /**
  70540. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  70541. */
  70542. volumetricLightCoefficient: number;
  70543. /**
  70544. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  70545. */
  70546. volumetricLightPower: number;
  70547. /**
  70548. * Used the set the blur intensity to smooth the volumetric lights
  70549. */
  70550. volumetricLightBlurScale: number;
  70551. /**
  70552. * Light (spot or directional) used to generate the volumetric lights rays
  70553. * The source light must have a shadow generate so the pipeline can get its
  70554. * depth map
  70555. */
  70556. sourceLight: Nullable<SpotLight | DirectionalLight>;
  70557. /**
  70558. * For eye adaptation, represents the minimum luminance the eye can see
  70559. */
  70560. hdrMinimumLuminance: number;
  70561. /**
  70562. * For eye adaptation, represents the decrease luminance speed
  70563. */
  70564. hdrDecreaseRate: number;
  70565. /**
  70566. * For eye adaptation, represents the increase luminance speed
  70567. */
  70568. hdrIncreaseRate: number;
  70569. /**
  70570. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70571. */
  70572. get hdrAutoExposure(): boolean;
  70573. /**
  70574. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70575. */
  70576. set hdrAutoExposure(value: boolean);
  70577. /**
  70578. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  70579. */
  70580. lensColorTexture: Nullable<Texture>;
  70581. /**
  70582. * The overall strengh for the lens flare effect
  70583. */
  70584. lensFlareStrength: number;
  70585. /**
  70586. * Dispersion coefficient for lens flare ghosts
  70587. */
  70588. lensFlareGhostDispersal: number;
  70589. /**
  70590. * Main lens flare halo width
  70591. */
  70592. lensFlareHaloWidth: number;
  70593. /**
  70594. * Based on the lens distortion effect, defines how much the lens flare result
  70595. * is distorted
  70596. */
  70597. lensFlareDistortionStrength: number;
  70598. /**
  70599. * Configures the blur intensity used for for lens flare (halo)
  70600. */
  70601. lensFlareBlurWidth: number;
  70602. /**
  70603. * Lens star texture must be used to simulate rays on the flares and is available
  70604. * in the documentation
  70605. */
  70606. lensStarTexture: Nullable<Texture>;
  70607. /**
  70608. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  70609. * flare effect by taking account of the dirt texture
  70610. */
  70611. lensFlareDirtTexture: Nullable<Texture>;
  70612. /**
  70613. * Represents the focal length for the depth of field effect
  70614. */
  70615. depthOfFieldDistance: number;
  70616. /**
  70617. * Represents the blur intensity for the blurred part of the depth of field effect
  70618. */
  70619. depthOfFieldBlurWidth: number;
  70620. /**
  70621. * Gets how much the image is blurred by the movement while using the motion blur post-process
  70622. */
  70623. get motionStrength(): number;
  70624. /**
  70625. * Sets how much the image is blurred by the movement while using the motion blur post-process
  70626. */
  70627. set motionStrength(strength: number);
  70628. /**
  70629. * Gets wether or not the motion blur post-process is object based or screen based.
  70630. */
  70631. get objectBasedMotionBlur(): boolean;
  70632. /**
  70633. * Sets wether or not the motion blur post-process should be object based or screen based
  70634. */
  70635. set objectBasedMotionBlur(value: boolean);
  70636. /**
  70637. * List of animations for the pipeline (IAnimatable implementation)
  70638. */
  70639. animations: Animation[];
  70640. /**
  70641. * Private members
  70642. */
  70643. private _scene;
  70644. private _currentDepthOfFieldSource;
  70645. private _basePostProcess;
  70646. private _fixedExposure;
  70647. private _currentExposure;
  70648. private _hdrAutoExposure;
  70649. private _hdrCurrentLuminance;
  70650. private _motionStrength;
  70651. private _isObjectBasedMotionBlur;
  70652. private _floatTextureType;
  70653. private _camerasToBeAttached;
  70654. private _ratio;
  70655. private _bloomEnabled;
  70656. private _depthOfFieldEnabled;
  70657. private _vlsEnabled;
  70658. private _lensFlareEnabled;
  70659. private _hdrEnabled;
  70660. private _motionBlurEnabled;
  70661. private _fxaaEnabled;
  70662. private _screenSpaceReflectionsEnabled;
  70663. private _motionBlurSamples;
  70664. private _volumetricLightStepsCount;
  70665. private _samples;
  70666. /**
  70667. * @ignore
  70668. * Specifies if the bloom pipeline is enabled
  70669. */
  70670. get BloomEnabled(): boolean;
  70671. set BloomEnabled(enabled: boolean);
  70672. /**
  70673. * @ignore
  70674. * Specifies if the depth of field pipeline is enabed
  70675. */
  70676. get DepthOfFieldEnabled(): boolean;
  70677. set DepthOfFieldEnabled(enabled: boolean);
  70678. /**
  70679. * @ignore
  70680. * Specifies if the lens flare pipeline is enabed
  70681. */
  70682. get LensFlareEnabled(): boolean;
  70683. set LensFlareEnabled(enabled: boolean);
  70684. /**
  70685. * @ignore
  70686. * Specifies if the HDR pipeline is enabled
  70687. */
  70688. get HDREnabled(): boolean;
  70689. set HDREnabled(enabled: boolean);
  70690. /**
  70691. * @ignore
  70692. * Specifies if the volumetric lights scattering effect is enabled
  70693. */
  70694. get VLSEnabled(): boolean;
  70695. set VLSEnabled(enabled: boolean);
  70696. /**
  70697. * @ignore
  70698. * Specifies if the motion blur effect is enabled
  70699. */
  70700. get MotionBlurEnabled(): boolean;
  70701. set MotionBlurEnabled(enabled: boolean);
  70702. /**
  70703. * Specifies if anti-aliasing is enabled
  70704. */
  70705. get fxaaEnabled(): boolean;
  70706. set fxaaEnabled(enabled: boolean);
  70707. /**
  70708. * Specifies if screen space reflections are enabled.
  70709. */
  70710. get screenSpaceReflectionsEnabled(): boolean;
  70711. set screenSpaceReflectionsEnabled(enabled: boolean);
  70712. /**
  70713. * Specifies the number of steps used to calculate the volumetric lights
  70714. * Typically in interval [50, 200]
  70715. */
  70716. get volumetricLightStepsCount(): number;
  70717. set volumetricLightStepsCount(count: number);
  70718. /**
  70719. * Specifies the number of samples used for the motion blur effect
  70720. * Typically in interval [16, 64]
  70721. */
  70722. get motionBlurSamples(): number;
  70723. set motionBlurSamples(samples: number);
  70724. /**
  70725. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70726. */
  70727. get samples(): number;
  70728. set samples(sampleCount: number);
  70729. /**
  70730. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70731. * @constructor
  70732. * @param name The rendering pipeline name
  70733. * @param scene The scene linked to this pipeline
  70734. * @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)
  70735. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  70736. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70737. */
  70738. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  70739. private _buildPipeline;
  70740. private _createDownSampleX4PostProcess;
  70741. private _createBrightPassPostProcess;
  70742. private _createBlurPostProcesses;
  70743. private _createTextureAdderPostProcess;
  70744. private _createVolumetricLightPostProcess;
  70745. private _createLuminancePostProcesses;
  70746. private _createHdrPostProcess;
  70747. private _createLensFlarePostProcess;
  70748. private _createDepthOfFieldPostProcess;
  70749. private _createMotionBlurPostProcess;
  70750. private _getDepthTexture;
  70751. private _disposePostProcesses;
  70752. /**
  70753. * Dispose of the pipeline and stop all post processes
  70754. */
  70755. dispose(): void;
  70756. /**
  70757. * Serialize the rendering pipeline (Used when exporting)
  70758. * @returns the serialized object
  70759. */
  70760. serialize(): any;
  70761. /**
  70762. * Parse the serialized pipeline
  70763. * @param source Source pipeline.
  70764. * @param scene The scene to load the pipeline to.
  70765. * @param rootUrl The URL of the serialized pipeline.
  70766. * @returns An instantiated pipeline from the serialized object.
  70767. */
  70768. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  70769. /**
  70770. * Luminance steps
  70771. */
  70772. static LuminanceSteps: number;
  70773. }
  70774. }
  70775. declare module BABYLON {
  70776. /** @hidden */
  70777. export var stereoscopicInterlacePixelShader: {
  70778. name: string;
  70779. shader: string;
  70780. };
  70781. }
  70782. declare module BABYLON {
  70783. /**
  70784. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  70785. */
  70786. export class StereoscopicInterlacePostProcessI extends PostProcess {
  70787. private _stepSize;
  70788. private _passedProcess;
  70789. /**
  70790. * Initializes a StereoscopicInterlacePostProcessI
  70791. * @param name The name of the effect.
  70792. * @param rigCameras The rig cameras to be appled to the post process
  70793. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  70794. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  70795. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70796. * @param engine The engine which the post process will be applied. (default: current engine)
  70797. * @param reusable If the post process can be reused on the same frame. (default: false)
  70798. */
  70799. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70800. }
  70801. /**
  70802. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  70803. */
  70804. export class StereoscopicInterlacePostProcess extends PostProcess {
  70805. private _stepSize;
  70806. private _passedProcess;
  70807. /**
  70808. * Initializes a StereoscopicInterlacePostProcess
  70809. * @param name The name of the effect.
  70810. * @param rigCameras The rig cameras to be appled to the post process
  70811. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  70812. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70813. * @param engine The engine which the post process will be applied. (default: current engine)
  70814. * @param reusable If the post process can be reused on the same frame. (default: false)
  70815. */
  70816. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70817. }
  70818. }
  70819. declare module BABYLON {
  70820. /** @hidden */
  70821. export var tonemapPixelShader: {
  70822. name: string;
  70823. shader: string;
  70824. };
  70825. }
  70826. declare module BABYLON {
  70827. /** Defines operator used for tonemapping */
  70828. export enum TonemappingOperator {
  70829. /** Hable */
  70830. Hable = 0,
  70831. /** Reinhard */
  70832. Reinhard = 1,
  70833. /** HejiDawson */
  70834. HejiDawson = 2,
  70835. /** Photographic */
  70836. Photographic = 3
  70837. }
  70838. /**
  70839. * Defines a post process to apply tone mapping
  70840. */
  70841. export class TonemapPostProcess extends PostProcess {
  70842. private _operator;
  70843. /** Defines the required exposure adjustement */
  70844. exposureAdjustment: number;
  70845. /**
  70846. * Creates a new TonemapPostProcess
  70847. * @param name defines the name of the postprocess
  70848. * @param _operator defines the operator to use
  70849. * @param exposureAdjustment defines the required exposure adjustement
  70850. * @param camera defines the camera to use (can be null)
  70851. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  70852. * @param engine defines the hosting engine (can be ignore if camera is set)
  70853. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  70854. */
  70855. constructor(name: string, _operator: TonemappingOperator,
  70856. /** Defines the required exposure adjustement */
  70857. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  70858. }
  70859. }
  70860. declare module BABYLON {
  70861. /** @hidden */
  70862. export var volumetricLightScatteringPixelShader: {
  70863. name: string;
  70864. shader: string;
  70865. };
  70866. }
  70867. declare module BABYLON {
  70868. /** @hidden */
  70869. export var volumetricLightScatteringPassVertexShader: {
  70870. name: string;
  70871. shader: string;
  70872. };
  70873. }
  70874. declare module BABYLON {
  70875. /** @hidden */
  70876. export var volumetricLightScatteringPassPixelShader: {
  70877. name: string;
  70878. shader: string;
  70879. };
  70880. }
  70881. declare module BABYLON {
  70882. /**
  70883. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  70884. */
  70885. export class VolumetricLightScatteringPostProcess extends PostProcess {
  70886. private _volumetricLightScatteringPass;
  70887. private _volumetricLightScatteringRTT;
  70888. private _viewPort;
  70889. private _screenCoordinates;
  70890. private _cachedDefines;
  70891. /**
  70892. * If not undefined, the mesh position is computed from the attached node position
  70893. */
  70894. attachedNode: {
  70895. position: Vector3;
  70896. };
  70897. /**
  70898. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  70899. */
  70900. customMeshPosition: Vector3;
  70901. /**
  70902. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  70903. */
  70904. useCustomMeshPosition: boolean;
  70905. /**
  70906. * If the post-process should inverse the light scattering direction
  70907. */
  70908. invert: boolean;
  70909. /**
  70910. * The internal mesh used by the post-process
  70911. */
  70912. mesh: Mesh;
  70913. /**
  70914. * @hidden
  70915. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  70916. */
  70917. get useDiffuseColor(): boolean;
  70918. set useDiffuseColor(useDiffuseColor: boolean);
  70919. /**
  70920. * Array containing the excluded meshes not rendered in the internal pass
  70921. */
  70922. excludedMeshes: AbstractMesh[];
  70923. /**
  70924. * Controls the overall intensity of the post-process
  70925. */
  70926. exposure: number;
  70927. /**
  70928. * Dissipates each sample's contribution in range [0, 1]
  70929. */
  70930. decay: number;
  70931. /**
  70932. * Controls the overall intensity of each sample
  70933. */
  70934. weight: number;
  70935. /**
  70936. * Controls the density of each sample
  70937. */
  70938. density: number;
  70939. /**
  70940. * @constructor
  70941. * @param name The post-process name
  70942. * @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)
  70943. * @param camera The camera that the post-process will be attached to
  70944. * @param mesh The mesh used to create the light scattering
  70945. * @param samples The post-process quality, default 100
  70946. * @param samplingModeThe post-process filtering mode
  70947. * @param engine The babylon engine
  70948. * @param reusable If the post-process is reusable
  70949. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  70950. */
  70951. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  70952. /**
  70953. * Returns the string "VolumetricLightScatteringPostProcess"
  70954. * @returns "VolumetricLightScatteringPostProcess"
  70955. */
  70956. getClassName(): string;
  70957. private _isReady;
  70958. /**
  70959. * Sets the new light position for light scattering effect
  70960. * @param position The new custom light position
  70961. */
  70962. setCustomMeshPosition(position: Vector3): void;
  70963. /**
  70964. * Returns the light position for light scattering effect
  70965. * @return Vector3 The custom light position
  70966. */
  70967. getCustomMeshPosition(): Vector3;
  70968. /**
  70969. * Disposes the internal assets and detaches the post-process from the camera
  70970. */
  70971. dispose(camera: Camera): void;
  70972. /**
  70973. * Returns the render target texture used by the post-process
  70974. * @return the render target texture used by the post-process
  70975. */
  70976. getPass(): RenderTargetTexture;
  70977. private _meshExcluded;
  70978. private _createPass;
  70979. private _updateMeshScreenCoordinates;
  70980. /**
  70981. * Creates a default mesh for the Volumeric Light Scattering post-process
  70982. * @param name The mesh name
  70983. * @param scene The scene where to create the mesh
  70984. * @return the default mesh
  70985. */
  70986. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  70987. }
  70988. }
  70989. declare module BABYLON {
  70990. /** @hidden */
  70991. export var screenSpaceCurvaturePixelShader: {
  70992. name: string;
  70993. shader: string;
  70994. };
  70995. }
  70996. declare module BABYLON {
  70997. /**
  70998. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  70999. */
  71000. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  71001. /**
  71002. * Defines how much ridge the curvature effect displays.
  71003. */
  71004. ridge: number;
  71005. /**
  71006. * Defines how much valley the curvature effect displays.
  71007. */
  71008. valley: number;
  71009. private _geometryBufferRenderer;
  71010. /**
  71011. * Creates a new instance ScreenSpaceCurvaturePostProcess
  71012. * @param name The name of the effect.
  71013. * @param scene The scene containing the objects to blur according to their velocity.
  71014. * @param options The required width/height ratio to downsize to before computing the render pass.
  71015. * @param camera The camera to apply the render pass to.
  71016. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71017. * @param engine The engine which the post process will be applied. (default: current engine)
  71018. * @param reusable If the post process can be reused on the same frame. (default: false)
  71019. * @param textureType Type of textures used when performing the post process. (default: 0)
  71020. * @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)
  71021. */
  71022. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71023. /**
  71024. * Support test.
  71025. */
  71026. static get IsSupported(): boolean;
  71027. }
  71028. }
  71029. declare module BABYLON {
  71030. interface Scene {
  71031. /** @hidden (Backing field) */
  71032. _boundingBoxRenderer: BoundingBoxRenderer;
  71033. /** @hidden (Backing field) */
  71034. _forceShowBoundingBoxes: boolean;
  71035. /**
  71036. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  71037. */
  71038. forceShowBoundingBoxes: boolean;
  71039. /**
  71040. * Gets the bounding box renderer associated with the scene
  71041. * @returns a BoundingBoxRenderer
  71042. */
  71043. getBoundingBoxRenderer(): BoundingBoxRenderer;
  71044. }
  71045. interface AbstractMesh {
  71046. /** @hidden (Backing field) */
  71047. _showBoundingBox: boolean;
  71048. /**
  71049. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  71050. */
  71051. showBoundingBox: boolean;
  71052. }
  71053. /**
  71054. * Component responsible of rendering the bounding box of the meshes in a scene.
  71055. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  71056. */
  71057. export class BoundingBoxRenderer implements ISceneComponent {
  71058. /**
  71059. * The component name helpfull to identify the component in the list of scene components.
  71060. */
  71061. readonly name: string;
  71062. /**
  71063. * The scene the component belongs to.
  71064. */
  71065. scene: Scene;
  71066. /**
  71067. * Color of the bounding box lines placed in front of an object
  71068. */
  71069. frontColor: Color3;
  71070. /**
  71071. * Color of the bounding box lines placed behind an object
  71072. */
  71073. backColor: Color3;
  71074. /**
  71075. * Defines if the renderer should show the back lines or not
  71076. */
  71077. showBackLines: boolean;
  71078. /**
  71079. * Observable raised before rendering a bounding box
  71080. */
  71081. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  71082. /**
  71083. * Observable raised after rendering a bounding box
  71084. */
  71085. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  71086. /**
  71087. * @hidden
  71088. */
  71089. renderList: SmartArray<BoundingBox>;
  71090. private _colorShader;
  71091. private _vertexBuffers;
  71092. private _indexBuffer;
  71093. private _fillIndexBuffer;
  71094. private _fillIndexData;
  71095. /**
  71096. * Instantiates a new bounding box renderer in a scene.
  71097. * @param scene the scene the renderer renders in
  71098. */
  71099. constructor(scene: Scene);
  71100. /**
  71101. * Registers the component in a given scene
  71102. */
  71103. register(): void;
  71104. private _evaluateSubMesh;
  71105. private _activeMesh;
  71106. private _prepareRessources;
  71107. private _createIndexBuffer;
  71108. /**
  71109. * Rebuilds the elements related to this component in case of
  71110. * context lost for instance.
  71111. */
  71112. rebuild(): void;
  71113. /**
  71114. * @hidden
  71115. */
  71116. reset(): void;
  71117. /**
  71118. * Render the bounding boxes of a specific rendering group
  71119. * @param renderingGroupId defines the rendering group to render
  71120. */
  71121. render(renderingGroupId: number): void;
  71122. /**
  71123. * In case of occlusion queries, we can render the occlusion bounding box through this method
  71124. * @param mesh Define the mesh to render the occlusion bounding box for
  71125. */
  71126. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  71127. /**
  71128. * Dispose and release the resources attached to this renderer.
  71129. */
  71130. dispose(): void;
  71131. }
  71132. }
  71133. declare module BABYLON {
  71134. interface Scene {
  71135. /** @hidden (Backing field) */
  71136. _depthRenderer: {
  71137. [id: string]: DepthRenderer;
  71138. };
  71139. /**
  71140. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  71141. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  71142. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  71143. * @returns the created depth renderer
  71144. */
  71145. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  71146. /**
  71147. * Disables a depth renderer for a given camera
  71148. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  71149. */
  71150. disableDepthRenderer(camera?: Nullable<Camera>): void;
  71151. }
  71152. /**
  71153. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  71154. * in several rendering techniques.
  71155. */
  71156. export class DepthRendererSceneComponent implements ISceneComponent {
  71157. /**
  71158. * The component name helpfull to identify the component in the list of scene components.
  71159. */
  71160. readonly name: string;
  71161. /**
  71162. * The scene the component belongs to.
  71163. */
  71164. scene: Scene;
  71165. /**
  71166. * Creates a new instance of the component for the given scene
  71167. * @param scene Defines the scene to register the component in
  71168. */
  71169. constructor(scene: Scene);
  71170. /**
  71171. * Registers the component in a given scene
  71172. */
  71173. register(): void;
  71174. /**
  71175. * Rebuilds the elements related to this component in case of
  71176. * context lost for instance.
  71177. */
  71178. rebuild(): void;
  71179. /**
  71180. * Disposes the component and the associated ressources
  71181. */
  71182. dispose(): void;
  71183. private _gatherRenderTargets;
  71184. private _gatherActiveCameraRenderTargets;
  71185. }
  71186. }
  71187. declare module BABYLON {
  71188. interface AbstractScene {
  71189. /** @hidden (Backing field) */
  71190. _prePassRenderer: Nullable<PrePassRenderer>;
  71191. /**
  71192. * Gets or Sets the current prepass renderer associated to the scene.
  71193. */
  71194. prePassRenderer: Nullable<PrePassRenderer>;
  71195. /**
  71196. * Enables the prepass and associates it with the scene
  71197. * @returns the PrePassRenderer
  71198. */
  71199. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  71200. /**
  71201. * Disables the prepass associated with the scene
  71202. */
  71203. disablePrePassRenderer(): void;
  71204. }
  71205. /**
  71206. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  71207. * in several rendering techniques.
  71208. */
  71209. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  71210. /**
  71211. * The component name helpful to identify the component in the list of scene components.
  71212. */
  71213. readonly name: string;
  71214. /**
  71215. * The scene the component belongs to.
  71216. */
  71217. scene: Scene;
  71218. /**
  71219. * Creates a new instance of the component for the given scene
  71220. * @param scene Defines the scene to register the component in
  71221. */
  71222. constructor(scene: Scene);
  71223. /**
  71224. * Registers the component in a given scene
  71225. */
  71226. register(): void;
  71227. private _beforeCameraDraw;
  71228. private _afterCameraDraw;
  71229. private _beforeClearStage;
  71230. /**
  71231. * Serializes the component data to the specified json object
  71232. * @param serializationObject The object to serialize to
  71233. */
  71234. serialize(serializationObject: any): void;
  71235. /**
  71236. * Adds all the elements from the container to the scene
  71237. * @param container the container holding the elements
  71238. */
  71239. addFromContainer(container: AbstractScene): void;
  71240. /**
  71241. * Removes all the elements in the container from the scene
  71242. * @param container contains the elements to remove
  71243. * @param dispose if the removed element should be disposed (default: false)
  71244. */
  71245. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  71246. /**
  71247. * Rebuilds the elements related to this component in case of
  71248. * context lost for instance.
  71249. */
  71250. rebuild(): void;
  71251. /**
  71252. * Disposes the component and the associated ressources
  71253. */
  71254. dispose(): void;
  71255. }
  71256. }
  71257. declare module BABYLON {
  71258. /** @hidden */
  71259. export var outlinePixelShader: {
  71260. name: string;
  71261. shader: string;
  71262. };
  71263. }
  71264. declare module BABYLON {
  71265. /** @hidden */
  71266. export var outlineVertexShader: {
  71267. name: string;
  71268. shader: string;
  71269. };
  71270. }
  71271. declare module BABYLON {
  71272. interface Scene {
  71273. /** @hidden */
  71274. _outlineRenderer: OutlineRenderer;
  71275. /**
  71276. * Gets the outline renderer associated with the scene
  71277. * @returns a OutlineRenderer
  71278. */
  71279. getOutlineRenderer(): OutlineRenderer;
  71280. }
  71281. interface AbstractMesh {
  71282. /** @hidden (Backing field) */
  71283. _renderOutline: boolean;
  71284. /**
  71285. * Gets or sets a boolean indicating if the outline must be rendered as well
  71286. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  71287. */
  71288. renderOutline: boolean;
  71289. /** @hidden (Backing field) */
  71290. _renderOverlay: boolean;
  71291. /**
  71292. * Gets or sets a boolean indicating if the overlay must be rendered as well
  71293. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  71294. */
  71295. renderOverlay: boolean;
  71296. }
  71297. /**
  71298. * This class is responsible to draw bothe outline/overlay of meshes.
  71299. * It should not be used directly but through the available method on mesh.
  71300. */
  71301. export class OutlineRenderer implements ISceneComponent {
  71302. /**
  71303. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  71304. */
  71305. private static _StencilReference;
  71306. /**
  71307. * The name of the component. Each component must have a unique name.
  71308. */
  71309. name: string;
  71310. /**
  71311. * The scene the component belongs to.
  71312. */
  71313. scene: Scene;
  71314. /**
  71315. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  71316. */
  71317. zOffset: number;
  71318. private _engine;
  71319. private _effect;
  71320. private _cachedDefines;
  71321. private _savedDepthWrite;
  71322. /**
  71323. * Instantiates a new outline renderer. (There could be only one per scene).
  71324. * @param scene Defines the scene it belongs to
  71325. */
  71326. constructor(scene: Scene);
  71327. /**
  71328. * Register the component to one instance of a scene.
  71329. */
  71330. register(): void;
  71331. /**
  71332. * Rebuilds the elements related to this component in case of
  71333. * context lost for instance.
  71334. */
  71335. rebuild(): void;
  71336. /**
  71337. * Disposes the component and the associated ressources.
  71338. */
  71339. dispose(): void;
  71340. /**
  71341. * Renders the outline in the canvas.
  71342. * @param subMesh Defines the sumesh to render
  71343. * @param batch Defines the batch of meshes in case of instances
  71344. * @param useOverlay Defines if the rendering is for the overlay or the outline
  71345. */
  71346. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  71347. /**
  71348. * Returns whether or not the outline renderer is ready for a given submesh.
  71349. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  71350. * @param subMesh Defines the submesh to check readyness for
  71351. * @param useInstances Defines wheter wee are trying to render instances or not
  71352. * @returns true if ready otherwise false
  71353. */
  71354. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  71355. private _beforeRenderingMesh;
  71356. private _afterRenderingMesh;
  71357. }
  71358. }
  71359. declare module BABYLON {
  71360. /**
  71361. * Defines the basic options interface of a Sprite Frame Source Size.
  71362. */
  71363. export interface ISpriteJSONSpriteSourceSize {
  71364. /**
  71365. * number of the original width of the Frame
  71366. */
  71367. w: number;
  71368. /**
  71369. * number of the original height of the Frame
  71370. */
  71371. h: number;
  71372. }
  71373. /**
  71374. * Defines the basic options interface of a Sprite Frame Data.
  71375. */
  71376. export interface ISpriteJSONSpriteFrameData {
  71377. /**
  71378. * number of the x offset of the Frame
  71379. */
  71380. x: number;
  71381. /**
  71382. * number of the y offset of the Frame
  71383. */
  71384. y: number;
  71385. /**
  71386. * number of the width of the Frame
  71387. */
  71388. w: number;
  71389. /**
  71390. * number of the height of the Frame
  71391. */
  71392. h: number;
  71393. }
  71394. /**
  71395. * Defines the basic options interface of a JSON Sprite.
  71396. */
  71397. export interface ISpriteJSONSprite {
  71398. /**
  71399. * string name of the Frame
  71400. */
  71401. filename: string;
  71402. /**
  71403. * ISpriteJSONSpriteFrame basic object of the frame data
  71404. */
  71405. frame: ISpriteJSONSpriteFrameData;
  71406. /**
  71407. * boolean to flag is the frame was rotated.
  71408. */
  71409. rotated: boolean;
  71410. /**
  71411. * boolean to flag is the frame was trimmed.
  71412. */
  71413. trimmed: boolean;
  71414. /**
  71415. * ISpriteJSONSpriteFrame basic object of the source data
  71416. */
  71417. spriteSourceSize: ISpriteJSONSpriteFrameData;
  71418. /**
  71419. * ISpriteJSONSpriteFrame basic object of the source data
  71420. */
  71421. sourceSize: ISpriteJSONSpriteSourceSize;
  71422. }
  71423. /**
  71424. * Defines the basic options interface of a JSON atlas.
  71425. */
  71426. export interface ISpriteJSONAtlas {
  71427. /**
  71428. * Array of objects that contain the frame data.
  71429. */
  71430. frames: Array<ISpriteJSONSprite>;
  71431. /**
  71432. * object basic object containing the sprite meta data.
  71433. */
  71434. meta?: object;
  71435. }
  71436. }
  71437. declare module BABYLON {
  71438. /** @hidden */
  71439. export var spriteMapPixelShader: {
  71440. name: string;
  71441. shader: string;
  71442. };
  71443. }
  71444. declare module BABYLON {
  71445. /** @hidden */
  71446. export var spriteMapVertexShader: {
  71447. name: string;
  71448. shader: string;
  71449. };
  71450. }
  71451. declare module BABYLON {
  71452. /**
  71453. * Defines the basic options interface of a SpriteMap
  71454. */
  71455. export interface ISpriteMapOptions {
  71456. /**
  71457. * Vector2 of the number of cells in the grid.
  71458. */
  71459. stageSize?: Vector2;
  71460. /**
  71461. * Vector2 of the size of the output plane in World Units.
  71462. */
  71463. outputSize?: Vector2;
  71464. /**
  71465. * Vector3 of the position of the output plane in World Units.
  71466. */
  71467. outputPosition?: Vector3;
  71468. /**
  71469. * Vector3 of the rotation of the output plane.
  71470. */
  71471. outputRotation?: Vector3;
  71472. /**
  71473. * number of layers that the system will reserve in resources.
  71474. */
  71475. layerCount?: number;
  71476. /**
  71477. * number of max animation frames a single cell will reserve in resources.
  71478. */
  71479. maxAnimationFrames?: number;
  71480. /**
  71481. * number cell index of the base tile when the system compiles.
  71482. */
  71483. baseTile?: number;
  71484. /**
  71485. * boolean flip the sprite after its been repositioned by the framing data.
  71486. */
  71487. flipU?: boolean;
  71488. /**
  71489. * Vector3 scalar of the global RGB values of the SpriteMap.
  71490. */
  71491. colorMultiply?: Vector3;
  71492. }
  71493. /**
  71494. * Defines the IDisposable interface in order to be cleanable from resources.
  71495. */
  71496. export interface ISpriteMap extends IDisposable {
  71497. /**
  71498. * String name of the SpriteMap.
  71499. */
  71500. name: string;
  71501. /**
  71502. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  71503. */
  71504. atlasJSON: ISpriteJSONAtlas;
  71505. /**
  71506. * Texture of the SpriteMap.
  71507. */
  71508. spriteSheet: Texture;
  71509. /**
  71510. * The parameters to initialize the SpriteMap with.
  71511. */
  71512. options: ISpriteMapOptions;
  71513. }
  71514. /**
  71515. * Class used to manage a grid restricted sprite deployment on an Output plane.
  71516. */
  71517. export class SpriteMap implements ISpriteMap {
  71518. /** The Name of the spriteMap */
  71519. name: string;
  71520. /** The JSON file with the frame and meta data */
  71521. atlasJSON: ISpriteJSONAtlas;
  71522. /** The systems Sprite Sheet Texture */
  71523. spriteSheet: Texture;
  71524. /** Arguments passed with the Constructor */
  71525. options: ISpriteMapOptions;
  71526. /** Public Sprite Storage array, parsed from atlasJSON */
  71527. sprites: Array<ISpriteJSONSprite>;
  71528. /** Returns the Number of Sprites in the System */
  71529. get spriteCount(): number;
  71530. /** Returns the Position of Output Plane*/
  71531. get position(): Vector3;
  71532. /** Returns the Position of Output Plane*/
  71533. set position(v: Vector3);
  71534. /** Returns the Rotation of Output Plane*/
  71535. get rotation(): Vector3;
  71536. /** Returns the Rotation of Output Plane*/
  71537. set rotation(v: Vector3);
  71538. /** Sets the AnimationMap*/
  71539. get animationMap(): RawTexture;
  71540. /** Sets the AnimationMap*/
  71541. set animationMap(v: RawTexture);
  71542. /** Scene that the SpriteMap was created in */
  71543. private _scene;
  71544. /** Texture Buffer of Float32 that holds tile frame data*/
  71545. private _frameMap;
  71546. /** Texture Buffers of Float32 that holds tileMap data*/
  71547. private _tileMaps;
  71548. /** Texture Buffer of Float32 that holds Animation Data*/
  71549. private _animationMap;
  71550. /** Custom ShaderMaterial Central to the System*/
  71551. private _material;
  71552. /** Custom ShaderMaterial Central to the System*/
  71553. private _output;
  71554. /** Systems Time Ticker*/
  71555. private _time;
  71556. /**
  71557. * Creates a new SpriteMap
  71558. * @param name defines the SpriteMaps Name
  71559. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  71560. * @param spriteSheet is the Texture that the Sprites are on.
  71561. * @param options a basic deployment configuration
  71562. * @param scene The Scene that the map is deployed on
  71563. */
  71564. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  71565. /**
  71566. * Returns tileID location
  71567. * @returns Vector2 the cell position ID
  71568. */
  71569. getTileID(): Vector2;
  71570. /**
  71571. * Gets the UV location of the mouse over the SpriteMap.
  71572. * @returns Vector2 the UV position of the mouse interaction
  71573. */
  71574. getMousePosition(): Vector2;
  71575. /**
  71576. * Creates the "frame" texture Buffer
  71577. * -------------------------------------
  71578. * Structure of frames
  71579. * "filename": "Falling-Water-2.png",
  71580. * "frame": {"x":69,"y":103,"w":24,"h":32},
  71581. * "rotated": true,
  71582. * "trimmed": true,
  71583. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  71584. * "sourceSize": {"w":32,"h":32}
  71585. * @returns RawTexture of the frameMap
  71586. */
  71587. private _createFrameBuffer;
  71588. /**
  71589. * Creates the tileMap texture Buffer
  71590. * @param buffer normally and array of numbers, or a false to generate from scratch
  71591. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  71592. * @returns RawTexture of the tileMap
  71593. */
  71594. private _createTileBuffer;
  71595. /**
  71596. * Modifies the data of the tileMaps
  71597. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  71598. * @param pos is the iVector2 Coordinates of the Tile
  71599. * @param tile The SpriteIndex of the new Tile
  71600. */
  71601. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  71602. /**
  71603. * Creates the animationMap texture Buffer
  71604. * @param buffer normally and array of numbers, or a false to generate from scratch
  71605. * @returns RawTexture of the animationMap
  71606. */
  71607. private _createTileAnimationBuffer;
  71608. /**
  71609. * Modifies the data of the animationMap
  71610. * @param cellID is the Index of the Sprite
  71611. * @param _frame is the target Animation frame
  71612. * @param toCell is the Target Index of the next frame of the animation
  71613. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  71614. * @param speed is a global scalar of the time variable on the map.
  71615. */
  71616. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  71617. /**
  71618. * Exports the .tilemaps file
  71619. */
  71620. saveTileMaps(): void;
  71621. /**
  71622. * Imports the .tilemaps file
  71623. * @param url of the .tilemaps file
  71624. */
  71625. loadTileMaps(url: string): void;
  71626. /**
  71627. * Release associated resources
  71628. */
  71629. dispose(): void;
  71630. }
  71631. }
  71632. declare module BABYLON {
  71633. /**
  71634. * Class used to manage multiple sprites of different sizes on the same spritesheet
  71635. * @see https://doc.babylonjs.com/babylon101/sprites
  71636. */
  71637. export class SpritePackedManager extends SpriteManager {
  71638. /** defines the packed manager's name */
  71639. name: string;
  71640. /**
  71641. * Creates a new sprite manager from a packed sprite sheet
  71642. * @param name defines the manager's name
  71643. * @param imgUrl defines the sprite sheet url
  71644. * @param capacity defines the maximum allowed number of sprites
  71645. * @param scene defines the hosting scene
  71646. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  71647. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71648. * @param samplingMode defines the smapling mode to use with spritesheet
  71649. * @param fromPacked set to true; do not alter
  71650. */
  71651. constructor(
  71652. /** defines the packed manager's name */
  71653. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  71654. }
  71655. }
  71656. declare module BABYLON {
  71657. /**
  71658. * Defines the list of states available for a task inside a AssetsManager
  71659. */
  71660. export enum AssetTaskState {
  71661. /**
  71662. * Initialization
  71663. */
  71664. INIT = 0,
  71665. /**
  71666. * Running
  71667. */
  71668. RUNNING = 1,
  71669. /**
  71670. * Done
  71671. */
  71672. DONE = 2,
  71673. /**
  71674. * Error
  71675. */
  71676. ERROR = 3
  71677. }
  71678. /**
  71679. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  71680. */
  71681. export abstract class AbstractAssetTask {
  71682. /**
  71683. * Task name
  71684. */ name: string;
  71685. /**
  71686. * Callback called when the task is successful
  71687. */
  71688. onSuccess: (task: any) => void;
  71689. /**
  71690. * Callback called when the task is not successful
  71691. */
  71692. onError: (task: any, message?: string, exception?: any) => void;
  71693. /**
  71694. * Creates a new AssetsManager
  71695. * @param name defines the name of the task
  71696. */
  71697. constructor(
  71698. /**
  71699. * Task name
  71700. */ name: string);
  71701. private _isCompleted;
  71702. private _taskState;
  71703. private _errorObject;
  71704. /**
  71705. * Get if the task is completed
  71706. */
  71707. get isCompleted(): boolean;
  71708. /**
  71709. * Gets the current state of the task
  71710. */
  71711. get taskState(): AssetTaskState;
  71712. /**
  71713. * Gets the current error object (if task is in error)
  71714. */
  71715. get errorObject(): {
  71716. message?: string;
  71717. exception?: any;
  71718. };
  71719. /**
  71720. * Internal only
  71721. * @hidden
  71722. */
  71723. _setErrorObject(message?: string, exception?: any): void;
  71724. /**
  71725. * Execute the current task
  71726. * @param scene defines the scene where you want your assets to be loaded
  71727. * @param onSuccess is a callback called when the task is successfully executed
  71728. * @param onError is a callback called if an error occurs
  71729. */
  71730. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71731. /**
  71732. * Execute the current task
  71733. * @param scene defines the scene where you want your assets to be loaded
  71734. * @param onSuccess is a callback called when the task is successfully executed
  71735. * @param onError is a callback called if an error occurs
  71736. */
  71737. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71738. /**
  71739. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  71740. * This can be used with failed tasks that have the reason for failure fixed.
  71741. */
  71742. reset(): void;
  71743. private onErrorCallback;
  71744. private onDoneCallback;
  71745. }
  71746. /**
  71747. * Define the interface used by progress events raised during assets loading
  71748. */
  71749. export interface IAssetsProgressEvent {
  71750. /**
  71751. * Defines the number of remaining tasks to process
  71752. */
  71753. remainingCount: number;
  71754. /**
  71755. * Defines the total number of tasks
  71756. */
  71757. totalCount: number;
  71758. /**
  71759. * Defines the task that was just processed
  71760. */
  71761. task: AbstractAssetTask;
  71762. }
  71763. /**
  71764. * Class used to share progress information about assets loading
  71765. */
  71766. export class AssetsProgressEvent implements IAssetsProgressEvent {
  71767. /**
  71768. * Defines the number of remaining tasks to process
  71769. */
  71770. remainingCount: number;
  71771. /**
  71772. * Defines the total number of tasks
  71773. */
  71774. totalCount: number;
  71775. /**
  71776. * Defines the task that was just processed
  71777. */
  71778. task: AbstractAssetTask;
  71779. /**
  71780. * Creates a AssetsProgressEvent
  71781. * @param remainingCount defines the number of remaining tasks to process
  71782. * @param totalCount defines the total number of tasks
  71783. * @param task defines the task that was just processed
  71784. */
  71785. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  71786. }
  71787. /**
  71788. * Define a task used by AssetsManager to load meshes
  71789. */
  71790. export class MeshAssetTask extends AbstractAssetTask {
  71791. /**
  71792. * Defines the name of the task
  71793. */
  71794. name: string;
  71795. /**
  71796. * Defines the list of mesh's names you want to load
  71797. */
  71798. meshesNames: any;
  71799. /**
  71800. * Defines the root url to use as a base to load your meshes and associated resources
  71801. */
  71802. rootUrl: string;
  71803. /**
  71804. * Defines the filename or File of the scene to load from
  71805. */
  71806. sceneFilename: string | File;
  71807. /**
  71808. * Gets the list of loaded meshes
  71809. */
  71810. loadedMeshes: Array<AbstractMesh>;
  71811. /**
  71812. * Gets the list of loaded particle systems
  71813. */
  71814. loadedParticleSystems: Array<IParticleSystem>;
  71815. /**
  71816. * Gets the list of loaded skeletons
  71817. */
  71818. loadedSkeletons: Array<Skeleton>;
  71819. /**
  71820. * Gets the list of loaded animation groups
  71821. */
  71822. loadedAnimationGroups: Array<AnimationGroup>;
  71823. /**
  71824. * Callback called when the task is successful
  71825. */
  71826. onSuccess: (task: MeshAssetTask) => void;
  71827. /**
  71828. * Callback called when the task is successful
  71829. */
  71830. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  71831. /**
  71832. * Creates a new MeshAssetTask
  71833. * @param name defines the name of the task
  71834. * @param meshesNames defines the list of mesh's names you want to load
  71835. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  71836. * @param sceneFilename defines the filename or File of the scene to load from
  71837. */
  71838. constructor(
  71839. /**
  71840. * Defines the name of the task
  71841. */
  71842. name: string,
  71843. /**
  71844. * Defines the list of mesh's names you want to load
  71845. */
  71846. meshesNames: any,
  71847. /**
  71848. * Defines the root url to use as a base to load your meshes and associated resources
  71849. */
  71850. rootUrl: string,
  71851. /**
  71852. * Defines the filename or File of the scene to load from
  71853. */
  71854. sceneFilename: string | File);
  71855. /**
  71856. * Execute the current task
  71857. * @param scene defines the scene where you want your assets to be loaded
  71858. * @param onSuccess is a callback called when the task is successfully executed
  71859. * @param onError is a callback called if an error occurs
  71860. */
  71861. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71862. }
  71863. /**
  71864. * Define a task used by AssetsManager to load text content
  71865. */
  71866. export class TextFileAssetTask extends AbstractAssetTask {
  71867. /**
  71868. * Defines the name of the task
  71869. */
  71870. name: string;
  71871. /**
  71872. * Defines the location of the file to load
  71873. */
  71874. url: string;
  71875. /**
  71876. * Gets the loaded text string
  71877. */
  71878. text: string;
  71879. /**
  71880. * Callback called when the task is successful
  71881. */
  71882. onSuccess: (task: TextFileAssetTask) => void;
  71883. /**
  71884. * Callback called when the task is successful
  71885. */
  71886. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  71887. /**
  71888. * Creates a new TextFileAssetTask object
  71889. * @param name defines the name of the task
  71890. * @param url defines the location of the file to load
  71891. */
  71892. constructor(
  71893. /**
  71894. * Defines the name of the task
  71895. */
  71896. name: string,
  71897. /**
  71898. * Defines the location of the file to load
  71899. */
  71900. url: string);
  71901. /**
  71902. * Execute the current task
  71903. * @param scene defines the scene where you want your assets to be loaded
  71904. * @param onSuccess is a callback called when the task is successfully executed
  71905. * @param onError is a callback called if an error occurs
  71906. */
  71907. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71908. }
  71909. /**
  71910. * Define a task used by AssetsManager to load binary data
  71911. */
  71912. export class BinaryFileAssetTask extends AbstractAssetTask {
  71913. /**
  71914. * Defines the name of the task
  71915. */
  71916. name: string;
  71917. /**
  71918. * Defines the location of the file to load
  71919. */
  71920. url: string;
  71921. /**
  71922. * Gets the lodaded data (as an array buffer)
  71923. */
  71924. data: ArrayBuffer;
  71925. /**
  71926. * Callback called when the task is successful
  71927. */
  71928. onSuccess: (task: BinaryFileAssetTask) => void;
  71929. /**
  71930. * Callback called when the task is successful
  71931. */
  71932. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  71933. /**
  71934. * Creates a new BinaryFileAssetTask object
  71935. * @param name defines the name of the new task
  71936. * @param url defines the location of the file to load
  71937. */
  71938. constructor(
  71939. /**
  71940. * Defines the name of the task
  71941. */
  71942. name: string,
  71943. /**
  71944. * Defines the location of the file to load
  71945. */
  71946. url: string);
  71947. /**
  71948. * Execute the current task
  71949. * @param scene defines the scene where you want your assets to be loaded
  71950. * @param onSuccess is a callback called when the task is successfully executed
  71951. * @param onError is a callback called if an error occurs
  71952. */
  71953. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71954. }
  71955. /**
  71956. * Define a task used by AssetsManager to load images
  71957. */
  71958. export class ImageAssetTask extends AbstractAssetTask {
  71959. /**
  71960. * Defines the name of the task
  71961. */
  71962. name: string;
  71963. /**
  71964. * Defines the location of the image to load
  71965. */
  71966. url: string;
  71967. /**
  71968. * Gets the loaded images
  71969. */
  71970. image: HTMLImageElement;
  71971. /**
  71972. * Callback called when the task is successful
  71973. */
  71974. onSuccess: (task: ImageAssetTask) => void;
  71975. /**
  71976. * Callback called when the task is successful
  71977. */
  71978. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  71979. /**
  71980. * Creates a new ImageAssetTask
  71981. * @param name defines the name of the task
  71982. * @param url defines the location of the image to load
  71983. */
  71984. constructor(
  71985. /**
  71986. * Defines the name of the task
  71987. */
  71988. name: string,
  71989. /**
  71990. * Defines the location of the image to load
  71991. */
  71992. url: string);
  71993. /**
  71994. * Execute the current task
  71995. * @param scene defines the scene where you want your assets to be loaded
  71996. * @param onSuccess is a callback called when the task is successfully executed
  71997. * @param onError is a callback called if an error occurs
  71998. */
  71999. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72000. }
  72001. /**
  72002. * Defines the interface used by texture loading tasks
  72003. */
  72004. export interface ITextureAssetTask<TEX extends BaseTexture> {
  72005. /**
  72006. * Gets the loaded texture
  72007. */
  72008. texture: TEX;
  72009. }
  72010. /**
  72011. * Define a task used by AssetsManager to load 2D textures
  72012. */
  72013. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  72014. /**
  72015. * Defines the name of the task
  72016. */
  72017. name: string;
  72018. /**
  72019. * Defines the location of the file to load
  72020. */
  72021. url: string;
  72022. /**
  72023. * Defines if mipmap should not be generated (default is false)
  72024. */
  72025. noMipmap?: boolean | undefined;
  72026. /**
  72027. * Defines if texture must be inverted on Y axis (default is true)
  72028. */
  72029. invertY: boolean;
  72030. /**
  72031. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72032. */
  72033. samplingMode: number;
  72034. /**
  72035. * Gets the loaded texture
  72036. */
  72037. texture: Texture;
  72038. /**
  72039. * Callback called when the task is successful
  72040. */
  72041. onSuccess: (task: TextureAssetTask) => void;
  72042. /**
  72043. * Callback called when the task is successful
  72044. */
  72045. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  72046. /**
  72047. * Creates a new TextureAssetTask object
  72048. * @param name defines the name of the task
  72049. * @param url defines the location of the file to load
  72050. * @param noMipmap defines if mipmap should not be generated (default is false)
  72051. * @param invertY defines if texture must be inverted on Y axis (default is true)
  72052. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72053. */
  72054. constructor(
  72055. /**
  72056. * Defines the name of the task
  72057. */
  72058. name: string,
  72059. /**
  72060. * Defines the location of the file to load
  72061. */
  72062. url: string,
  72063. /**
  72064. * Defines if mipmap should not be generated (default is false)
  72065. */
  72066. noMipmap?: boolean | undefined,
  72067. /**
  72068. * Defines if texture must be inverted on Y axis (default is true)
  72069. */
  72070. invertY?: boolean,
  72071. /**
  72072. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72073. */
  72074. samplingMode?: number);
  72075. /**
  72076. * Execute the current task
  72077. * @param scene defines the scene where you want your assets to be loaded
  72078. * @param onSuccess is a callback called when the task is successfully executed
  72079. * @param onError is a callback called if an error occurs
  72080. */
  72081. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72082. }
  72083. /**
  72084. * Define a task used by AssetsManager to load cube textures
  72085. */
  72086. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  72087. /**
  72088. * Defines the name of the task
  72089. */
  72090. name: string;
  72091. /**
  72092. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72093. */
  72094. url: string;
  72095. /**
  72096. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72097. */
  72098. extensions?: string[] | undefined;
  72099. /**
  72100. * Defines if mipmaps should not be generated (default is false)
  72101. */
  72102. noMipmap?: boolean | undefined;
  72103. /**
  72104. * Defines the explicit list of files (undefined by default)
  72105. */
  72106. files?: string[] | undefined;
  72107. /**
  72108. * Gets the loaded texture
  72109. */
  72110. texture: CubeTexture;
  72111. /**
  72112. * Callback called when the task is successful
  72113. */
  72114. onSuccess: (task: CubeTextureAssetTask) => void;
  72115. /**
  72116. * Callback called when the task is successful
  72117. */
  72118. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  72119. /**
  72120. * Creates a new CubeTextureAssetTask
  72121. * @param name defines the name of the task
  72122. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72123. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72124. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72125. * @param files defines the explicit list of files (undefined by default)
  72126. */
  72127. constructor(
  72128. /**
  72129. * Defines the name of the task
  72130. */
  72131. name: string,
  72132. /**
  72133. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72134. */
  72135. url: string,
  72136. /**
  72137. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72138. */
  72139. extensions?: string[] | undefined,
  72140. /**
  72141. * Defines if mipmaps should not be generated (default is false)
  72142. */
  72143. noMipmap?: boolean | undefined,
  72144. /**
  72145. * Defines the explicit list of files (undefined by default)
  72146. */
  72147. files?: string[] | undefined);
  72148. /**
  72149. * Execute the current task
  72150. * @param scene defines the scene where you want your assets to be loaded
  72151. * @param onSuccess is a callback called when the task is successfully executed
  72152. * @param onError is a callback called if an error occurs
  72153. */
  72154. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72155. }
  72156. /**
  72157. * Define a task used by AssetsManager to load HDR cube textures
  72158. */
  72159. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  72160. /**
  72161. * Defines the name of the task
  72162. */
  72163. name: string;
  72164. /**
  72165. * Defines the location of the file to load
  72166. */
  72167. url: string;
  72168. /**
  72169. * Defines the desired size (the more it increases the longer the generation will be)
  72170. */
  72171. size: number;
  72172. /**
  72173. * Defines if mipmaps should not be generated (default is false)
  72174. */
  72175. noMipmap: boolean;
  72176. /**
  72177. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72178. */
  72179. generateHarmonics: boolean;
  72180. /**
  72181. * 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)
  72182. */
  72183. gammaSpace: boolean;
  72184. /**
  72185. * Internal Use Only
  72186. */
  72187. reserved: boolean;
  72188. /**
  72189. * Gets the loaded texture
  72190. */
  72191. texture: HDRCubeTexture;
  72192. /**
  72193. * Callback called when the task is successful
  72194. */
  72195. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  72196. /**
  72197. * Callback called when the task is successful
  72198. */
  72199. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  72200. /**
  72201. * Creates a new HDRCubeTextureAssetTask object
  72202. * @param name defines the name of the task
  72203. * @param url defines the location of the file to load
  72204. * @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.
  72205. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72206. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72207. * @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)
  72208. * @param reserved Internal use only
  72209. */
  72210. constructor(
  72211. /**
  72212. * Defines the name of the task
  72213. */
  72214. name: string,
  72215. /**
  72216. * Defines the location of the file to load
  72217. */
  72218. url: string,
  72219. /**
  72220. * Defines the desired size (the more it increases the longer the generation will be)
  72221. */
  72222. size: number,
  72223. /**
  72224. * Defines if mipmaps should not be generated (default is false)
  72225. */
  72226. noMipmap?: boolean,
  72227. /**
  72228. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72229. */
  72230. generateHarmonics?: boolean,
  72231. /**
  72232. * 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)
  72233. */
  72234. gammaSpace?: boolean,
  72235. /**
  72236. * Internal Use Only
  72237. */
  72238. reserved?: boolean);
  72239. /**
  72240. * Execute the current task
  72241. * @param scene defines the scene where you want your assets to be loaded
  72242. * @param onSuccess is a callback called when the task is successfully executed
  72243. * @param onError is a callback called if an error occurs
  72244. */
  72245. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72246. }
  72247. /**
  72248. * Define a task used by AssetsManager to load Equirectangular cube textures
  72249. */
  72250. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  72251. /**
  72252. * Defines the name of the task
  72253. */
  72254. name: string;
  72255. /**
  72256. * Defines the location of the file to load
  72257. */
  72258. url: string;
  72259. /**
  72260. * Defines the desired size (the more it increases the longer the generation will be)
  72261. */
  72262. size: number;
  72263. /**
  72264. * Defines if mipmaps should not be generated (default is false)
  72265. */
  72266. noMipmap: boolean;
  72267. /**
  72268. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72269. * but the standard material would require them in Gamma space) (default is true)
  72270. */
  72271. gammaSpace: boolean;
  72272. /**
  72273. * Gets the loaded texture
  72274. */
  72275. texture: EquiRectangularCubeTexture;
  72276. /**
  72277. * Callback called when the task is successful
  72278. */
  72279. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  72280. /**
  72281. * Callback called when the task is successful
  72282. */
  72283. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  72284. /**
  72285. * Creates a new EquiRectangularCubeTextureAssetTask object
  72286. * @param name defines the name of the task
  72287. * @param url defines the location of the file to load
  72288. * @param size defines the desired size (the more it increases the longer the generation will be)
  72289. * If the size is omitted this implies you are using a preprocessed cubemap.
  72290. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72291. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  72292. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  72293. * (default is true)
  72294. */
  72295. constructor(
  72296. /**
  72297. * Defines the name of the task
  72298. */
  72299. name: string,
  72300. /**
  72301. * Defines the location of the file to load
  72302. */
  72303. url: string,
  72304. /**
  72305. * Defines the desired size (the more it increases the longer the generation will be)
  72306. */
  72307. size: number,
  72308. /**
  72309. * Defines if mipmaps should not be generated (default is false)
  72310. */
  72311. noMipmap?: boolean,
  72312. /**
  72313. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72314. * but the standard material would require them in Gamma space) (default is true)
  72315. */
  72316. gammaSpace?: boolean);
  72317. /**
  72318. * Execute the current task
  72319. * @param scene defines the scene where you want your assets to be loaded
  72320. * @param onSuccess is a callback called when the task is successfully executed
  72321. * @param onError is a callback called if an error occurs
  72322. */
  72323. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72324. }
  72325. /**
  72326. * This class can be used to easily import assets into a scene
  72327. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  72328. */
  72329. export class AssetsManager {
  72330. private _scene;
  72331. private _isLoading;
  72332. protected _tasks: AbstractAssetTask[];
  72333. protected _waitingTasksCount: number;
  72334. protected _totalTasksCount: number;
  72335. /**
  72336. * Callback called when all tasks are processed
  72337. */
  72338. onFinish: (tasks: AbstractAssetTask[]) => void;
  72339. /**
  72340. * Callback called when a task is successful
  72341. */
  72342. onTaskSuccess: (task: AbstractAssetTask) => void;
  72343. /**
  72344. * Callback called when a task had an error
  72345. */
  72346. onTaskError: (task: AbstractAssetTask) => void;
  72347. /**
  72348. * Callback called when a task is done (whatever the result is)
  72349. */
  72350. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  72351. /**
  72352. * Observable called when all tasks are processed
  72353. */
  72354. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  72355. /**
  72356. * Observable called when a task had an error
  72357. */
  72358. onTaskErrorObservable: Observable<AbstractAssetTask>;
  72359. /**
  72360. * Observable called when all tasks were executed
  72361. */
  72362. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  72363. /**
  72364. * Observable called when a task is done (whatever the result is)
  72365. */
  72366. onProgressObservable: Observable<IAssetsProgressEvent>;
  72367. /**
  72368. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  72369. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  72370. */
  72371. useDefaultLoadingScreen: boolean;
  72372. /**
  72373. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  72374. * when all assets have been downloaded.
  72375. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  72376. */
  72377. autoHideLoadingUI: boolean;
  72378. /**
  72379. * Creates a new AssetsManager
  72380. * @param scene defines the scene to work on
  72381. */
  72382. constructor(scene: Scene);
  72383. /**
  72384. * Add a MeshAssetTask to the list of active tasks
  72385. * @param taskName defines the name of the new task
  72386. * @param meshesNames defines the name of meshes to load
  72387. * @param rootUrl defines the root url to use to locate files
  72388. * @param sceneFilename defines the filename of the scene file
  72389. * @returns a new MeshAssetTask object
  72390. */
  72391. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  72392. /**
  72393. * Add a TextFileAssetTask to the list of active tasks
  72394. * @param taskName defines the name of the new task
  72395. * @param url defines the url of the file to load
  72396. * @returns a new TextFileAssetTask object
  72397. */
  72398. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  72399. /**
  72400. * Add a BinaryFileAssetTask to the list of active tasks
  72401. * @param taskName defines the name of the new task
  72402. * @param url defines the url of the file to load
  72403. * @returns a new BinaryFileAssetTask object
  72404. */
  72405. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  72406. /**
  72407. * Add a ImageAssetTask to the list of active tasks
  72408. * @param taskName defines the name of the new task
  72409. * @param url defines the url of the file to load
  72410. * @returns a new ImageAssetTask object
  72411. */
  72412. addImageTask(taskName: string, url: string): ImageAssetTask;
  72413. /**
  72414. * Add a TextureAssetTask to the list of active tasks
  72415. * @param taskName defines the name of the new task
  72416. * @param url defines the url of the file to load
  72417. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72418. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  72419. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  72420. * @returns a new TextureAssetTask object
  72421. */
  72422. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  72423. /**
  72424. * Add a CubeTextureAssetTask to the list of active tasks
  72425. * @param taskName defines the name of the new task
  72426. * @param url defines the url of the file to load
  72427. * @param extensions defines the extension to use to load the cube map (can be null)
  72428. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72429. * @param files defines the list of files to load (can be null)
  72430. * @returns a new CubeTextureAssetTask object
  72431. */
  72432. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  72433. /**
  72434. *
  72435. * Add a HDRCubeTextureAssetTask to the list of active tasks
  72436. * @param taskName defines the name of the new task
  72437. * @param url defines the url of the file to load
  72438. * @param size defines the size you want for the cubemap (can be null)
  72439. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72440. * @param generateHarmonics defines if you want to automatically generate (true by default)
  72441. * @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)
  72442. * @param reserved Internal use only
  72443. * @returns a new HDRCubeTextureAssetTask object
  72444. */
  72445. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  72446. /**
  72447. *
  72448. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  72449. * @param taskName defines the name of the new task
  72450. * @param url defines the url of the file to load
  72451. * @param size defines the size you want for the cubemap (can be null)
  72452. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72453. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  72454. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  72455. * @returns a new EquiRectangularCubeTextureAssetTask object
  72456. */
  72457. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  72458. /**
  72459. * Remove a task from the assets manager.
  72460. * @param task the task to remove
  72461. */
  72462. removeTask(task: AbstractAssetTask): void;
  72463. private _decreaseWaitingTasksCount;
  72464. private _runTask;
  72465. /**
  72466. * Reset the AssetsManager and remove all tasks
  72467. * @return the current instance of the AssetsManager
  72468. */
  72469. reset(): AssetsManager;
  72470. /**
  72471. * Start the loading process
  72472. * @return the current instance of the AssetsManager
  72473. */
  72474. load(): AssetsManager;
  72475. /**
  72476. * Start the loading process as an async operation
  72477. * @return a promise returning the list of failed tasks
  72478. */
  72479. loadAsync(): Promise<void>;
  72480. }
  72481. }
  72482. declare module BABYLON {
  72483. /**
  72484. * Wrapper class for promise with external resolve and reject.
  72485. */
  72486. export class Deferred<T> {
  72487. /**
  72488. * The promise associated with this deferred object.
  72489. */
  72490. readonly promise: Promise<T>;
  72491. private _resolve;
  72492. private _reject;
  72493. /**
  72494. * The resolve method of the promise associated with this deferred object.
  72495. */
  72496. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  72497. /**
  72498. * The reject method of the promise associated with this deferred object.
  72499. */
  72500. get reject(): (reason?: any) => void;
  72501. /**
  72502. * Constructor for this deferred object.
  72503. */
  72504. constructor();
  72505. }
  72506. }
  72507. declare module BABYLON {
  72508. /**
  72509. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  72510. */
  72511. export class MeshExploder {
  72512. private _centerMesh;
  72513. private _meshes;
  72514. private _meshesOrigins;
  72515. private _toCenterVectors;
  72516. private _scaledDirection;
  72517. private _newPosition;
  72518. private _centerPosition;
  72519. /**
  72520. * Explodes meshes from a center mesh.
  72521. * @param meshes The meshes to explode.
  72522. * @param centerMesh The mesh to be center of explosion.
  72523. */
  72524. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  72525. private _setCenterMesh;
  72526. /**
  72527. * Get class name
  72528. * @returns "MeshExploder"
  72529. */
  72530. getClassName(): string;
  72531. /**
  72532. * "Exploded meshes"
  72533. * @returns Array of meshes with the centerMesh at index 0.
  72534. */
  72535. getMeshes(): Array<Mesh>;
  72536. /**
  72537. * Explodes meshes giving a specific direction
  72538. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  72539. */
  72540. explode(direction?: number): void;
  72541. }
  72542. }
  72543. declare module BABYLON {
  72544. /**
  72545. * Class used to help managing file picking and drag'n'drop
  72546. */
  72547. export class FilesInput {
  72548. /**
  72549. * List of files ready to be loaded
  72550. */
  72551. static get FilesToLoad(): {
  72552. [key: string]: File;
  72553. };
  72554. /**
  72555. * Callback called when a file is processed
  72556. */
  72557. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  72558. private _engine;
  72559. private _currentScene;
  72560. private _sceneLoadedCallback;
  72561. private _progressCallback;
  72562. private _additionalRenderLoopLogicCallback;
  72563. private _textureLoadingCallback;
  72564. private _startingProcessingFilesCallback;
  72565. private _onReloadCallback;
  72566. private _errorCallback;
  72567. private _elementToMonitor;
  72568. private _sceneFileToLoad;
  72569. private _filesToLoad;
  72570. /**
  72571. * Creates a new FilesInput
  72572. * @param engine defines the rendering engine
  72573. * @param scene defines the hosting scene
  72574. * @param sceneLoadedCallback callback called when scene is loaded
  72575. * @param progressCallback callback called to track progress
  72576. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  72577. * @param textureLoadingCallback callback called when a texture is loading
  72578. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  72579. * @param onReloadCallback callback called when a reload is requested
  72580. * @param errorCallback callback call if an error occurs
  72581. */
  72582. 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>);
  72583. private _dragEnterHandler;
  72584. private _dragOverHandler;
  72585. private _dropHandler;
  72586. /**
  72587. * Calls this function to listen to drag'n'drop events on a specific DOM element
  72588. * @param elementToMonitor defines the DOM element to track
  72589. */
  72590. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  72591. /** Gets the current list of files to load */
  72592. get filesToLoad(): File[];
  72593. /**
  72594. * Release all associated resources
  72595. */
  72596. dispose(): void;
  72597. private renderFunction;
  72598. private drag;
  72599. private drop;
  72600. private _traverseFolder;
  72601. private _processFiles;
  72602. /**
  72603. * Load files from a drop event
  72604. * @param event defines the drop event to use as source
  72605. */
  72606. loadFiles(event: any): void;
  72607. private _processReload;
  72608. /**
  72609. * Reload the current scene from the loaded files
  72610. */
  72611. reload(): void;
  72612. }
  72613. }
  72614. declare module BABYLON {
  72615. /**
  72616. * Defines the root class used to create scene optimization to use with SceneOptimizer
  72617. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72618. */
  72619. export class SceneOptimization {
  72620. /**
  72621. * Defines the priority of this optimization (0 by default which means first in the list)
  72622. */
  72623. priority: number;
  72624. /**
  72625. * Gets a string describing the action executed by the current optimization
  72626. * @returns description string
  72627. */
  72628. getDescription(): string;
  72629. /**
  72630. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72631. * @param scene defines the current scene where to apply this optimization
  72632. * @param optimizer defines the current optimizer
  72633. * @returns true if everything that can be done was applied
  72634. */
  72635. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72636. /**
  72637. * Creates the SceneOptimization object
  72638. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72639. * @param desc defines the description associated with the optimization
  72640. */
  72641. constructor(
  72642. /**
  72643. * Defines the priority of this optimization (0 by default which means first in the list)
  72644. */
  72645. priority?: number);
  72646. }
  72647. /**
  72648. * Defines an optimization used to reduce the size of render target textures
  72649. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72650. */
  72651. export class TextureOptimization extends SceneOptimization {
  72652. /**
  72653. * Defines the priority of this optimization (0 by default which means first in the list)
  72654. */
  72655. priority: number;
  72656. /**
  72657. * 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
  72658. */
  72659. maximumSize: number;
  72660. /**
  72661. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72662. */
  72663. step: number;
  72664. /**
  72665. * Gets a string describing the action executed by the current optimization
  72666. * @returns description string
  72667. */
  72668. getDescription(): string;
  72669. /**
  72670. * Creates the TextureOptimization object
  72671. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72672. * @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
  72673. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72674. */
  72675. constructor(
  72676. /**
  72677. * Defines the priority of this optimization (0 by default which means first in the list)
  72678. */
  72679. priority?: number,
  72680. /**
  72681. * 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
  72682. */
  72683. maximumSize?: number,
  72684. /**
  72685. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72686. */
  72687. step?: number);
  72688. /**
  72689. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72690. * @param scene defines the current scene where to apply this optimization
  72691. * @param optimizer defines the current optimizer
  72692. * @returns true if everything that can be done was applied
  72693. */
  72694. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72695. }
  72696. /**
  72697. * Defines an optimization used to increase or decrease the rendering resolution
  72698. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72699. */
  72700. export class HardwareScalingOptimization extends SceneOptimization {
  72701. /**
  72702. * Defines the priority of this optimization (0 by default which means first in the list)
  72703. */
  72704. priority: number;
  72705. /**
  72706. * Defines the maximum scale to use (2 by default)
  72707. */
  72708. maximumScale: number;
  72709. /**
  72710. * Defines the step to use between two passes (0.5 by default)
  72711. */
  72712. step: number;
  72713. private _currentScale;
  72714. private _directionOffset;
  72715. /**
  72716. * Gets a string describing the action executed by the current optimization
  72717. * @return description string
  72718. */
  72719. getDescription(): string;
  72720. /**
  72721. * Creates the HardwareScalingOptimization object
  72722. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72723. * @param maximumScale defines the maximum scale to use (2 by default)
  72724. * @param step defines the step to use between two passes (0.5 by default)
  72725. */
  72726. constructor(
  72727. /**
  72728. * Defines the priority of this optimization (0 by default which means first in the list)
  72729. */
  72730. priority?: number,
  72731. /**
  72732. * Defines the maximum scale to use (2 by default)
  72733. */
  72734. maximumScale?: number,
  72735. /**
  72736. * Defines the step to use between two passes (0.5 by default)
  72737. */
  72738. step?: number);
  72739. /**
  72740. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72741. * @param scene defines the current scene where to apply this optimization
  72742. * @param optimizer defines the current optimizer
  72743. * @returns true if everything that can be done was applied
  72744. */
  72745. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72746. }
  72747. /**
  72748. * Defines an optimization used to remove shadows
  72749. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72750. */
  72751. export class ShadowsOptimization extends SceneOptimization {
  72752. /**
  72753. * Gets a string describing the action executed by the current optimization
  72754. * @return description string
  72755. */
  72756. getDescription(): string;
  72757. /**
  72758. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72759. * @param scene defines the current scene where to apply this optimization
  72760. * @param optimizer defines the current optimizer
  72761. * @returns true if everything that can be done was applied
  72762. */
  72763. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72764. }
  72765. /**
  72766. * Defines an optimization used to turn post-processes off
  72767. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72768. */
  72769. export class PostProcessesOptimization extends SceneOptimization {
  72770. /**
  72771. * Gets a string describing the action executed by the current optimization
  72772. * @return description string
  72773. */
  72774. getDescription(): string;
  72775. /**
  72776. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72777. * @param scene defines the current scene where to apply this optimization
  72778. * @param optimizer defines the current optimizer
  72779. * @returns true if everything that can be done was applied
  72780. */
  72781. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72782. }
  72783. /**
  72784. * Defines an optimization used to turn lens flares off
  72785. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72786. */
  72787. export class LensFlaresOptimization extends SceneOptimization {
  72788. /**
  72789. * Gets a string describing the action executed by the current optimization
  72790. * @return description string
  72791. */
  72792. getDescription(): string;
  72793. /**
  72794. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72795. * @param scene defines the current scene where to apply this optimization
  72796. * @param optimizer defines the current optimizer
  72797. * @returns true if everything that can be done was applied
  72798. */
  72799. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72800. }
  72801. /**
  72802. * Defines an optimization based on user defined callback.
  72803. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72804. */
  72805. export class CustomOptimization extends SceneOptimization {
  72806. /**
  72807. * Callback called to apply the custom optimization.
  72808. */
  72809. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  72810. /**
  72811. * Callback called to get custom description
  72812. */
  72813. onGetDescription: () => string;
  72814. /**
  72815. * Gets a string describing the action executed by the current optimization
  72816. * @returns description string
  72817. */
  72818. getDescription(): string;
  72819. /**
  72820. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72821. * @param scene defines the current scene where to apply this optimization
  72822. * @param optimizer defines the current optimizer
  72823. * @returns true if everything that can be done was applied
  72824. */
  72825. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72826. }
  72827. /**
  72828. * Defines an optimization used to turn particles off
  72829. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72830. */
  72831. export class ParticlesOptimization extends SceneOptimization {
  72832. /**
  72833. * Gets a string describing the action executed by the current optimization
  72834. * @return description string
  72835. */
  72836. getDescription(): string;
  72837. /**
  72838. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72839. * @param scene defines the current scene where to apply this optimization
  72840. * @param optimizer defines the current optimizer
  72841. * @returns true if everything that can be done was applied
  72842. */
  72843. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72844. }
  72845. /**
  72846. * Defines an optimization used to turn render targets off
  72847. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72848. */
  72849. export class RenderTargetsOptimization extends SceneOptimization {
  72850. /**
  72851. * Gets a string describing the action executed by the current optimization
  72852. * @return description string
  72853. */
  72854. getDescription(): string;
  72855. /**
  72856. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72857. * @param scene defines the current scene where to apply this optimization
  72858. * @param optimizer defines the current optimizer
  72859. * @returns true if everything that can be done was applied
  72860. */
  72861. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72862. }
  72863. /**
  72864. * Defines an optimization used to merge meshes with compatible materials
  72865. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72866. */
  72867. export class MergeMeshesOptimization extends SceneOptimization {
  72868. private static _UpdateSelectionTree;
  72869. /**
  72870. * Gets or sets a boolean which defines if optimization octree has to be updated
  72871. */
  72872. static get UpdateSelectionTree(): boolean;
  72873. /**
  72874. * Gets or sets a boolean which defines if optimization octree has to be updated
  72875. */
  72876. static set UpdateSelectionTree(value: boolean);
  72877. /**
  72878. * Gets a string describing the action executed by the current optimization
  72879. * @return description string
  72880. */
  72881. getDescription(): string;
  72882. private _canBeMerged;
  72883. /**
  72884. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72885. * @param scene defines the current scene where to apply this optimization
  72886. * @param optimizer defines the current optimizer
  72887. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  72888. * @returns true if everything that can be done was applied
  72889. */
  72890. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  72891. }
  72892. /**
  72893. * Defines a list of options used by SceneOptimizer
  72894. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72895. */
  72896. export class SceneOptimizerOptions {
  72897. /**
  72898. * Defines the target frame rate to reach (60 by default)
  72899. */
  72900. targetFrameRate: number;
  72901. /**
  72902. * Defines the interval between two checkes (2000ms by default)
  72903. */
  72904. trackerDuration: number;
  72905. /**
  72906. * Gets the list of optimizations to apply
  72907. */
  72908. optimizations: SceneOptimization[];
  72909. /**
  72910. * Creates a new list of options used by SceneOptimizer
  72911. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  72912. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  72913. */
  72914. constructor(
  72915. /**
  72916. * Defines the target frame rate to reach (60 by default)
  72917. */
  72918. targetFrameRate?: number,
  72919. /**
  72920. * Defines the interval between two checkes (2000ms by default)
  72921. */
  72922. trackerDuration?: number);
  72923. /**
  72924. * Add a new optimization
  72925. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  72926. * @returns the current SceneOptimizerOptions
  72927. */
  72928. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  72929. /**
  72930. * Add a new custom optimization
  72931. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  72932. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  72933. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72934. * @returns the current SceneOptimizerOptions
  72935. */
  72936. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  72937. /**
  72938. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  72939. * @param targetFrameRate defines the target frame rate (60 by default)
  72940. * @returns a SceneOptimizerOptions object
  72941. */
  72942. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72943. /**
  72944. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  72945. * @param targetFrameRate defines the target frame rate (60 by default)
  72946. * @returns a SceneOptimizerOptions object
  72947. */
  72948. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72949. /**
  72950. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  72951. * @param targetFrameRate defines the target frame rate (60 by default)
  72952. * @returns a SceneOptimizerOptions object
  72953. */
  72954. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72955. }
  72956. /**
  72957. * Class used to run optimizations in order to reach a target frame rate
  72958. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72959. */
  72960. export class SceneOptimizer implements IDisposable {
  72961. private _isRunning;
  72962. private _options;
  72963. private _scene;
  72964. private _currentPriorityLevel;
  72965. private _targetFrameRate;
  72966. private _trackerDuration;
  72967. private _currentFrameRate;
  72968. private _sceneDisposeObserver;
  72969. private _improvementMode;
  72970. /**
  72971. * Defines an observable called when the optimizer reaches the target frame rate
  72972. */
  72973. onSuccessObservable: Observable<SceneOptimizer>;
  72974. /**
  72975. * Defines an observable called when the optimizer enables an optimization
  72976. */
  72977. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  72978. /**
  72979. * Defines an observable called when the optimizer is not able to reach the target frame rate
  72980. */
  72981. onFailureObservable: Observable<SceneOptimizer>;
  72982. /**
  72983. * Gets a boolean indicating if the optimizer is in improvement mode
  72984. */
  72985. get isInImprovementMode(): boolean;
  72986. /**
  72987. * Gets the current priority level (0 at start)
  72988. */
  72989. get currentPriorityLevel(): number;
  72990. /**
  72991. * Gets the current frame rate checked by the SceneOptimizer
  72992. */
  72993. get currentFrameRate(): number;
  72994. /**
  72995. * Gets or sets the current target frame rate (60 by default)
  72996. */
  72997. get targetFrameRate(): number;
  72998. /**
  72999. * Gets or sets the current target frame rate (60 by default)
  73000. */
  73001. set targetFrameRate(value: number);
  73002. /**
  73003. * Gets or sets the current interval between two checks (every 2000ms by default)
  73004. */
  73005. get trackerDuration(): number;
  73006. /**
  73007. * Gets or sets the current interval between two checks (every 2000ms by default)
  73008. */
  73009. set trackerDuration(value: number);
  73010. /**
  73011. * Gets the list of active optimizations
  73012. */
  73013. get optimizations(): SceneOptimization[];
  73014. /**
  73015. * Creates a new SceneOptimizer
  73016. * @param scene defines the scene to work on
  73017. * @param options defines the options to use with the SceneOptimizer
  73018. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  73019. * @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)
  73020. */
  73021. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  73022. /**
  73023. * Stops the current optimizer
  73024. */
  73025. stop(): void;
  73026. /**
  73027. * Reset the optimizer to initial step (current priority level = 0)
  73028. */
  73029. reset(): void;
  73030. /**
  73031. * Start the optimizer. By default it will try to reach a specific framerate
  73032. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  73033. */
  73034. start(): void;
  73035. private _checkCurrentState;
  73036. /**
  73037. * Release all resources
  73038. */
  73039. dispose(): void;
  73040. /**
  73041. * Helper function to create a SceneOptimizer with one single line of code
  73042. * @param scene defines the scene to work on
  73043. * @param options defines the options to use with the SceneOptimizer
  73044. * @param onSuccess defines a callback to call on success
  73045. * @param onFailure defines a callback to call on failure
  73046. * @returns the new SceneOptimizer object
  73047. */
  73048. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  73049. }
  73050. }
  73051. declare module BABYLON {
  73052. /**
  73053. * Class used to serialize a scene into a string
  73054. */
  73055. export class SceneSerializer {
  73056. /**
  73057. * Clear cache used by a previous serialization
  73058. */
  73059. static ClearCache(): void;
  73060. /**
  73061. * Serialize a scene into a JSON compatible object
  73062. * @param scene defines the scene to serialize
  73063. * @returns a JSON compatible object
  73064. */
  73065. static Serialize(scene: Scene): any;
  73066. /**
  73067. * Serialize a mesh into a JSON compatible object
  73068. * @param toSerialize defines the mesh to serialize
  73069. * @param withParents defines if parents must be serialized as well
  73070. * @param withChildren defines if children must be serialized as well
  73071. * @returns a JSON compatible object
  73072. */
  73073. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  73074. }
  73075. }
  73076. declare module BABYLON {
  73077. /**
  73078. * Class used to host texture specific utilities
  73079. */
  73080. export class TextureTools {
  73081. /**
  73082. * Uses the GPU to create a copy texture rescaled at a given size
  73083. * @param texture Texture to copy from
  73084. * @param width defines the desired width
  73085. * @param height defines the desired height
  73086. * @param useBilinearMode defines if bilinear mode has to be used
  73087. * @return the generated texture
  73088. */
  73089. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  73090. }
  73091. }
  73092. declare module BABYLON {
  73093. /**
  73094. * This represents the different options available for the video capture.
  73095. */
  73096. export interface VideoRecorderOptions {
  73097. /** Defines the mime type of the video. */
  73098. mimeType: string;
  73099. /** Defines the FPS the video should be recorded at. */
  73100. fps: number;
  73101. /** Defines the chunk size for the recording data. */
  73102. recordChunckSize: number;
  73103. /** The audio tracks to attach to the recording. */
  73104. audioTracks?: MediaStreamTrack[];
  73105. }
  73106. /**
  73107. * This can help with recording videos from BabylonJS.
  73108. * This is based on the available WebRTC functionalities of the browser.
  73109. *
  73110. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  73111. */
  73112. export class VideoRecorder {
  73113. private static readonly _defaultOptions;
  73114. /**
  73115. * Returns whether or not the VideoRecorder is available in your browser.
  73116. * @param engine Defines the Babylon Engine.
  73117. * @returns true if supported otherwise false.
  73118. */
  73119. static IsSupported(engine: Engine): boolean;
  73120. private readonly _options;
  73121. private _canvas;
  73122. private _mediaRecorder;
  73123. private _recordedChunks;
  73124. private _fileName;
  73125. private _resolve;
  73126. private _reject;
  73127. /**
  73128. * True when a recording is already in progress.
  73129. */
  73130. get isRecording(): boolean;
  73131. /**
  73132. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  73133. * @param engine Defines the BabylonJS Engine you wish to record.
  73134. * @param options Defines options that can be used to customize the capture.
  73135. */
  73136. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  73137. /**
  73138. * Stops the current recording before the default capture timeout passed in the startRecording function.
  73139. */
  73140. stopRecording(): void;
  73141. /**
  73142. * Starts recording the canvas for a max duration specified in parameters.
  73143. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  73144. * If null no automatic download will start and you can rely on the promise to get the data back.
  73145. * @param maxDuration Defines the maximum recording time in seconds.
  73146. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  73147. * @return A promise callback at the end of the recording with the video data in Blob.
  73148. */
  73149. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  73150. /**
  73151. * Releases internal resources used during the recording.
  73152. */
  73153. dispose(): void;
  73154. private _handleDataAvailable;
  73155. private _handleError;
  73156. private _handleStop;
  73157. }
  73158. }
  73159. declare module BABYLON {
  73160. /**
  73161. * Class containing a set of static utilities functions for screenshots
  73162. */
  73163. export class ScreenshotTools {
  73164. /**
  73165. * Captures a screenshot of the current rendering
  73166. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73167. * @param engine defines the rendering engine
  73168. * @param camera defines the source camera
  73169. * @param size This parameter can be set to a single number or to an object with the
  73170. * following (optional) properties: precision, width, height. If a single number is passed,
  73171. * it will be used for both width and height. If an object is passed, the screenshot size
  73172. * will be derived from the parameters. The precision property is a multiplier allowing
  73173. * rendering at a higher or lower resolution
  73174. * @param successCallback defines the callback receives a single parameter which contains the
  73175. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  73176. * src parameter of an <img> to display it
  73177. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  73178. * Check your browser for supported MIME types
  73179. */
  73180. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  73181. /**
  73182. * Captures a screenshot of the current rendering
  73183. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73184. * @param engine defines the rendering engine
  73185. * @param camera defines the source camera
  73186. * @param size This parameter can be set to a single number or to an object with the
  73187. * following (optional) properties: precision, width, height. If a single number is passed,
  73188. * it will be used for both width and height. If an object is passed, the screenshot size
  73189. * will be derived from the parameters. The precision property is a multiplier allowing
  73190. * rendering at a higher or lower resolution
  73191. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  73192. * Check your browser for supported MIME types
  73193. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73194. * to the src parameter of an <img> to display it
  73195. */
  73196. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  73197. /**
  73198. * Generates an image screenshot from the specified camera.
  73199. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73200. * @param engine The engine to use for rendering
  73201. * @param camera The camera to use for rendering
  73202. * @param size This parameter can be set to a single number or to an object with the
  73203. * following (optional) properties: precision, width, height. If a single number is passed,
  73204. * it will be used for both width and height. If an object is passed, the screenshot size
  73205. * will be derived from the parameters. The precision property is a multiplier allowing
  73206. * rendering at a higher or lower resolution
  73207. * @param successCallback The callback receives a single parameter which contains the
  73208. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  73209. * src parameter of an <img> to display it
  73210. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73211. * Check your browser for supported MIME types
  73212. * @param samples Texture samples (default: 1)
  73213. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73214. * @param fileName A name for for the downloaded file.
  73215. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73216. */
  73217. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  73218. /**
  73219. * Generates an image screenshot from the specified camera.
  73220. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73221. * @param engine The engine to use for rendering
  73222. * @param camera The camera to use for rendering
  73223. * @param size This parameter can be set to a single number or to an object with the
  73224. * following (optional) properties: precision, width, height. If a single number is passed,
  73225. * it will be used for both width and height. If an object is passed, the screenshot size
  73226. * will be derived from the parameters. The precision property is a multiplier allowing
  73227. * rendering at a higher or lower resolution
  73228. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73229. * Check your browser for supported MIME types
  73230. * @param samples Texture samples (default: 1)
  73231. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73232. * @param fileName A name for for the downloaded file.
  73233. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73234. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73235. * to the src parameter of an <img> to display it
  73236. */
  73237. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  73238. /**
  73239. * Gets height and width for screenshot size
  73240. * @private
  73241. */
  73242. private static _getScreenshotSize;
  73243. }
  73244. }
  73245. declare module BABYLON {
  73246. /**
  73247. * Interface for a data buffer
  73248. */
  73249. export interface IDataBuffer {
  73250. /**
  73251. * Reads bytes from the data buffer.
  73252. * @param byteOffset The byte offset to read
  73253. * @param byteLength The byte length to read
  73254. * @returns A promise that resolves when the bytes are read
  73255. */
  73256. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  73257. /**
  73258. * The byte length of the buffer.
  73259. */
  73260. readonly byteLength: number;
  73261. }
  73262. /**
  73263. * Utility class for reading from a data buffer
  73264. */
  73265. export class DataReader {
  73266. /**
  73267. * The data buffer associated with this data reader.
  73268. */
  73269. readonly buffer: IDataBuffer;
  73270. /**
  73271. * The current byte offset from the beginning of the data buffer.
  73272. */
  73273. byteOffset: number;
  73274. private _dataView;
  73275. private _dataByteOffset;
  73276. /**
  73277. * Constructor
  73278. * @param buffer The buffer to read
  73279. */
  73280. constructor(buffer: IDataBuffer);
  73281. /**
  73282. * Loads the given byte length.
  73283. * @param byteLength The byte length to load
  73284. * @returns A promise that resolves when the load is complete
  73285. */
  73286. loadAsync(byteLength: number): Promise<void>;
  73287. /**
  73288. * Read a unsigned 32-bit integer from the currently loaded data range.
  73289. * @returns The 32-bit integer read
  73290. */
  73291. readUint32(): number;
  73292. /**
  73293. * Read a byte array from the currently loaded data range.
  73294. * @param byteLength The byte length to read
  73295. * @returns The byte array read
  73296. */
  73297. readUint8Array(byteLength: number): Uint8Array;
  73298. /**
  73299. * Read a string from the currently loaded data range.
  73300. * @param byteLength The byte length to read
  73301. * @returns The string read
  73302. */
  73303. readString(byteLength: number): string;
  73304. /**
  73305. * Skips the given byte length the currently loaded data range.
  73306. * @param byteLength The byte length to skip
  73307. */
  73308. skipBytes(byteLength: number): void;
  73309. }
  73310. }
  73311. declare module BABYLON {
  73312. /**
  73313. * Class for storing data to local storage if available or in-memory storage otherwise
  73314. */
  73315. export class DataStorage {
  73316. private static _Storage;
  73317. private static _GetStorage;
  73318. /**
  73319. * Reads a string from the data storage
  73320. * @param key The key to read
  73321. * @param defaultValue The value if the key doesn't exist
  73322. * @returns The string value
  73323. */
  73324. static ReadString(key: string, defaultValue: string): string;
  73325. /**
  73326. * Writes a string to the data storage
  73327. * @param key The key to write
  73328. * @param value The value to write
  73329. */
  73330. static WriteString(key: string, value: string): void;
  73331. /**
  73332. * Reads a boolean from the data storage
  73333. * @param key The key to read
  73334. * @param defaultValue The value if the key doesn't exist
  73335. * @returns The boolean value
  73336. */
  73337. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  73338. /**
  73339. * Writes a boolean to the data storage
  73340. * @param key The key to write
  73341. * @param value The value to write
  73342. */
  73343. static WriteBoolean(key: string, value: boolean): void;
  73344. /**
  73345. * Reads a number from the data storage
  73346. * @param key The key to read
  73347. * @param defaultValue The value if the key doesn't exist
  73348. * @returns The number value
  73349. */
  73350. static ReadNumber(key: string, defaultValue: number): number;
  73351. /**
  73352. * Writes a number to the data storage
  73353. * @param key The key to write
  73354. * @param value The value to write
  73355. */
  73356. static WriteNumber(key: string, value: number): void;
  73357. }
  73358. }
  73359. declare module BABYLON {
  73360. /**
  73361. * An interface for all Hit test features
  73362. */
  73363. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  73364. /**
  73365. * Triggered when new babylon (transformed) hit test results are available
  73366. */
  73367. onHitTestResultObservable: Observable<T[]>;
  73368. }
  73369. /**
  73370. * Options used for hit testing
  73371. */
  73372. export interface IWebXRLegacyHitTestOptions {
  73373. /**
  73374. * Only test when user interacted with the scene. Default - hit test every frame
  73375. */
  73376. testOnPointerDownOnly?: boolean;
  73377. /**
  73378. * The node to use to transform the local results to world coordinates
  73379. */
  73380. worldParentNode?: TransformNode;
  73381. }
  73382. /**
  73383. * Interface defining the babylon result of raycasting/hit-test
  73384. */
  73385. export interface IWebXRLegacyHitResult {
  73386. /**
  73387. * Transformation matrix that can be applied to a node that will put it in the hit point location
  73388. */
  73389. transformationMatrix: Matrix;
  73390. /**
  73391. * The native hit test result
  73392. */
  73393. xrHitResult: XRHitResult | XRHitTestResult;
  73394. }
  73395. /**
  73396. * The currently-working hit-test module.
  73397. * Hit test (or Ray-casting) is used to interact with the real world.
  73398. * For further information read here - https://github.com/immersive-web/hit-test
  73399. */
  73400. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  73401. /**
  73402. * options to use when constructing this feature
  73403. */
  73404. readonly options: IWebXRLegacyHitTestOptions;
  73405. private _direction;
  73406. private _mat;
  73407. private _onSelectEnabled;
  73408. private _origin;
  73409. /**
  73410. * The module's name
  73411. */
  73412. static readonly Name: string;
  73413. /**
  73414. * The (Babylon) version of this module.
  73415. * This is an integer representing the implementation version.
  73416. * This number does not correspond to the WebXR specs version
  73417. */
  73418. static readonly Version: number;
  73419. /**
  73420. * Populated with the last native XR Hit Results
  73421. */
  73422. lastNativeXRHitResults: XRHitResult[];
  73423. /**
  73424. * Triggered when new babylon (transformed) hit test results are available
  73425. */
  73426. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  73427. /**
  73428. * Creates a new instance of the (legacy version) hit test feature
  73429. * @param _xrSessionManager an instance of WebXRSessionManager
  73430. * @param options options to use when constructing this feature
  73431. */
  73432. constructor(_xrSessionManager: WebXRSessionManager,
  73433. /**
  73434. * options to use when constructing this feature
  73435. */
  73436. options?: IWebXRLegacyHitTestOptions);
  73437. /**
  73438. * execute a hit test with an XR Ray
  73439. *
  73440. * @param xrSession a native xrSession that will execute this hit test
  73441. * @param xrRay the ray (position and direction) to use for ray-casting
  73442. * @param referenceSpace native XR reference space to use for the hit-test
  73443. * @param filter filter function that will filter the results
  73444. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73445. */
  73446. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  73447. /**
  73448. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  73449. * @param event the (select) event to use to select with
  73450. * @param referenceSpace the reference space to use for this hit test
  73451. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73452. */
  73453. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  73454. /**
  73455. * attach this feature
  73456. * Will usually be called by the features manager
  73457. *
  73458. * @returns true if successful.
  73459. */
  73460. attach(): boolean;
  73461. /**
  73462. * detach this feature.
  73463. * Will usually be called by the features manager
  73464. *
  73465. * @returns true if successful.
  73466. */
  73467. detach(): boolean;
  73468. /**
  73469. * Dispose this feature and all of the resources attached
  73470. */
  73471. dispose(): void;
  73472. protected _onXRFrame(frame: XRFrame): void;
  73473. private _onHitTestResults;
  73474. private _onSelect;
  73475. }
  73476. }
  73477. declare module BABYLON {
  73478. /**
  73479. * Options used for hit testing (version 2)
  73480. */
  73481. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  73482. /**
  73483. * Do not create a permanent hit test. Will usually be used when only
  73484. * transient inputs are needed.
  73485. */
  73486. disablePermanentHitTest?: boolean;
  73487. /**
  73488. * Enable transient (for example touch-based) hit test inspections
  73489. */
  73490. enableTransientHitTest?: boolean;
  73491. /**
  73492. * Offset ray for the permanent hit test
  73493. */
  73494. offsetRay?: Vector3;
  73495. /**
  73496. * Offset ray for the transient hit test
  73497. */
  73498. transientOffsetRay?: Vector3;
  73499. /**
  73500. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  73501. */
  73502. useReferenceSpace?: boolean;
  73503. }
  73504. /**
  73505. * Interface defining the babylon result of hit-test
  73506. */
  73507. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  73508. /**
  73509. * The input source that generated this hit test (if transient)
  73510. */
  73511. inputSource?: XRInputSource;
  73512. /**
  73513. * Is this a transient hit test
  73514. */
  73515. isTransient?: boolean;
  73516. /**
  73517. * Position of the hit test result
  73518. */
  73519. position: Vector3;
  73520. /**
  73521. * Rotation of the hit test result
  73522. */
  73523. rotationQuaternion: Quaternion;
  73524. /**
  73525. * The native hit test result
  73526. */
  73527. xrHitResult: XRHitTestResult;
  73528. }
  73529. /**
  73530. * The currently-working hit-test module.
  73531. * Hit test (or Ray-casting) is used to interact with the real world.
  73532. * For further information read here - https://github.com/immersive-web/hit-test
  73533. *
  73534. * Tested on chrome (mobile) 80.
  73535. */
  73536. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  73537. /**
  73538. * options to use when constructing this feature
  73539. */
  73540. readonly options: IWebXRHitTestOptions;
  73541. private _tmpMat;
  73542. private _tmpPos;
  73543. private _tmpQuat;
  73544. private _transientXrHitTestSource;
  73545. private _xrHitTestSource;
  73546. private initHitTestSource;
  73547. /**
  73548. * The module's name
  73549. */
  73550. static readonly Name: string;
  73551. /**
  73552. * The (Babylon) version of this module.
  73553. * This is an integer representing the implementation version.
  73554. * This number does not correspond to the WebXR specs version
  73555. */
  73556. static readonly Version: number;
  73557. /**
  73558. * When set to true, each hit test will have its own position/rotation objects
  73559. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  73560. * the developers will clone them or copy them as they see fit.
  73561. */
  73562. autoCloneTransformation: boolean;
  73563. /**
  73564. * Triggered when new babylon (transformed) hit test results are available
  73565. */
  73566. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  73567. /**
  73568. * Use this to temporarily pause hit test checks.
  73569. */
  73570. paused: boolean;
  73571. /**
  73572. * Creates a new instance of the hit test feature
  73573. * @param _xrSessionManager an instance of WebXRSessionManager
  73574. * @param options options to use when constructing this feature
  73575. */
  73576. constructor(_xrSessionManager: WebXRSessionManager,
  73577. /**
  73578. * options to use when constructing this feature
  73579. */
  73580. options?: IWebXRHitTestOptions);
  73581. /**
  73582. * attach this feature
  73583. * Will usually be called by the features manager
  73584. *
  73585. * @returns true if successful.
  73586. */
  73587. attach(): boolean;
  73588. /**
  73589. * detach this feature.
  73590. * Will usually be called by the features manager
  73591. *
  73592. * @returns true if successful.
  73593. */
  73594. detach(): boolean;
  73595. /**
  73596. * Dispose this feature and all of the resources attached
  73597. */
  73598. dispose(): void;
  73599. protected _onXRFrame(frame: XRFrame): void;
  73600. private _processWebXRHitTestResult;
  73601. }
  73602. }
  73603. declare module BABYLON {
  73604. /**
  73605. * Configuration options of the anchor system
  73606. */
  73607. export interface IWebXRAnchorSystemOptions {
  73608. /**
  73609. * a node that will be used to convert local to world coordinates
  73610. */
  73611. worldParentNode?: TransformNode;
  73612. /**
  73613. * If set to true a reference of the created anchors will be kept until the next session starts
  73614. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  73615. */
  73616. doNotRemoveAnchorsOnSessionEnded?: boolean;
  73617. }
  73618. /**
  73619. * A babylon container for an XR Anchor
  73620. */
  73621. export interface IWebXRAnchor {
  73622. /**
  73623. * A babylon-assigned ID for this anchor
  73624. */
  73625. id: number;
  73626. /**
  73627. * Transformation matrix to apply to an object attached to this anchor
  73628. */
  73629. transformationMatrix: Matrix;
  73630. /**
  73631. * The native anchor object
  73632. */
  73633. xrAnchor: XRAnchor;
  73634. /**
  73635. * if defined, this object will be constantly updated by the anchor's position and rotation
  73636. */
  73637. attachedNode?: TransformNode;
  73638. }
  73639. /**
  73640. * An implementation of the anchor system for WebXR.
  73641. * For further information see https://github.com/immersive-web/anchors/
  73642. */
  73643. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  73644. private _options;
  73645. private _lastFrameDetected;
  73646. private _trackedAnchors;
  73647. private _referenceSpaceForFrameAnchors;
  73648. private _futureAnchors;
  73649. /**
  73650. * The module's name
  73651. */
  73652. static readonly Name: string;
  73653. /**
  73654. * The (Babylon) version of this module.
  73655. * This is an integer representing the implementation version.
  73656. * This number does not correspond to the WebXR specs version
  73657. */
  73658. static readonly Version: number;
  73659. /**
  73660. * Observers registered here will be executed when a new anchor was added to the session
  73661. */
  73662. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  73663. /**
  73664. * Observers registered here will be executed when an anchor was removed from the session
  73665. */
  73666. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  73667. /**
  73668. * Observers registered here will be executed when an existing anchor updates
  73669. * This can execute N times every frame
  73670. */
  73671. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  73672. /**
  73673. * Set the reference space to use for anchor creation, when not using a hit test.
  73674. * Will default to the session's reference space if not defined
  73675. */
  73676. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  73677. /**
  73678. * constructs a new anchor system
  73679. * @param _xrSessionManager an instance of WebXRSessionManager
  73680. * @param _options configuration object for this feature
  73681. */
  73682. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  73683. private _tmpVector;
  73684. private _tmpQuaternion;
  73685. private _populateTmpTransformation;
  73686. /**
  73687. * Create a new anchor point using a hit test result at a specific point in the scene
  73688. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  73689. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  73690. *
  73691. * @param hitTestResult The hit test result to use for this anchor creation
  73692. * @param position an optional position offset for this anchor
  73693. * @param rotationQuaternion an optional rotation offset for this anchor
  73694. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  73695. */
  73696. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  73697. /**
  73698. * Add a new anchor at a specific position and rotation
  73699. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  73700. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  73701. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  73702. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  73703. *
  73704. * @param position the position in which to add an anchor
  73705. * @param rotationQuaternion an optional rotation for the anchor transformation
  73706. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  73707. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  73708. */
  73709. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  73710. /**
  73711. * detach this feature.
  73712. * Will usually be called by the features manager
  73713. *
  73714. * @returns true if successful.
  73715. */
  73716. detach(): boolean;
  73717. /**
  73718. * Dispose this feature and all of the resources attached
  73719. */
  73720. dispose(): void;
  73721. protected _onXRFrame(frame: XRFrame): void;
  73722. /**
  73723. * avoiding using Array.find for global support.
  73724. * @param xrAnchor the plane to find in the array
  73725. */
  73726. private _findIndexInAnchorArray;
  73727. private _updateAnchorWithXRFrame;
  73728. private _createAnchorAtTransformation;
  73729. }
  73730. }
  73731. declare module BABYLON {
  73732. /**
  73733. * Options used in the plane detector module
  73734. */
  73735. export interface IWebXRPlaneDetectorOptions {
  73736. /**
  73737. * The node to use to transform the local results to world coordinates
  73738. */
  73739. worldParentNode?: TransformNode;
  73740. /**
  73741. * If set to true a reference of the created planes will be kept until the next session starts
  73742. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  73743. */
  73744. doNotRemovePlanesOnSessionEnded?: boolean;
  73745. }
  73746. /**
  73747. * A babylon interface for a WebXR plane.
  73748. * A Plane is actually a polygon, built from N points in space
  73749. *
  73750. * Supported in chrome 79, not supported in canary 81 ATM
  73751. */
  73752. export interface IWebXRPlane {
  73753. /**
  73754. * a babylon-assigned ID for this polygon
  73755. */
  73756. id: number;
  73757. /**
  73758. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  73759. */
  73760. polygonDefinition: Array<Vector3>;
  73761. /**
  73762. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  73763. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  73764. */
  73765. transformationMatrix: Matrix;
  73766. /**
  73767. * the native xr-plane object
  73768. */
  73769. xrPlane: XRPlane;
  73770. }
  73771. /**
  73772. * The plane detector is used to detect planes in the real world when in AR
  73773. * For more information see https://github.com/immersive-web/real-world-geometry/
  73774. */
  73775. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  73776. private _options;
  73777. private _detectedPlanes;
  73778. private _enabled;
  73779. private _lastFrameDetected;
  73780. /**
  73781. * The module's name
  73782. */
  73783. static readonly Name: string;
  73784. /**
  73785. * The (Babylon) version of this module.
  73786. * This is an integer representing the implementation version.
  73787. * This number does not correspond to the WebXR specs version
  73788. */
  73789. static readonly Version: number;
  73790. /**
  73791. * Observers registered here will be executed when a new plane was added to the session
  73792. */
  73793. onPlaneAddedObservable: Observable<IWebXRPlane>;
  73794. /**
  73795. * Observers registered here will be executed when a plane is no longer detected in the session
  73796. */
  73797. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  73798. /**
  73799. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  73800. * This can execute N times every frame
  73801. */
  73802. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  73803. /**
  73804. * construct a new Plane Detector
  73805. * @param _xrSessionManager an instance of xr Session manager
  73806. * @param _options configuration to use when constructing this feature
  73807. */
  73808. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  73809. /**
  73810. * detach this feature.
  73811. * Will usually be called by the features manager
  73812. *
  73813. * @returns true if successful.
  73814. */
  73815. detach(): boolean;
  73816. /**
  73817. * Dispose this feature and all of the resources attached
  73818. */
  73819. dispose(): void;
  73820. protected _onXRFrame(frame: XRFrame): void;
  73821. private _init;
  73822. private _updatePlaneWithXRPlane;
  73823. /**
  73824. * avoiding using Array.find for global support.
  73825. * @param xrPlane the plane to find in the array
  73826. */
  73827. private findIndexInPlaneArray;
  73828. }
  73829. }
  73830. declare module BABYLON {
  73831. /**
  73832. * Options interface for the background remover plugin
  73833. */
  73834. export interface IWebXRBackgroundRemoverOptions {
  73835. /**
  73836. * Further background meshes to disable when entering AR
  73837. */
  73838. backgroundMeshes?: AbstractMesh[];
  73839. /**
  73840. * flags to configure the removal of the environment helper.
  73841. * If not set, the entire background will be removed. If set, flags should be set as well.
  73842. */
  73843. environmentHelperRemovalFlags?: {
  73844. /**
  73845. * Should the skybox be removed (default false)
  73846. */
  73847. skyBox?: boolean;
  73848. /**
  73849. * Should the ground be removed (default false)
  73850. */
  73851. ground?: boolean;
  73852. };
  73853. /**
  73854. * don't disable the environment helper
  73855. */
  73856. ignoreEnvironmentHelper?: boolean;
  73857. }
  73858. /**
  73859. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  73860. */
  73861. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  73862. /**
  73863. * read-only options to be used in this module
  73864. */
  73865. readonly options: IWebXRBackgroundRemoverOptions;
  73866. /**
  73867. * The module's name
  73868. */
  73869. static readonly Name: string;
  73870. /**
  73871. * The (Babylon) version of this module.
  73872. * This is an integer representing the implementation version.
  73873. * This number does not correspond to the WebXR specs version
  73874. */
  73875. static readonly Version: number;
  73876. /**
  73877. * registered observers will be triggered when the background state changes
  73878. */
  73879. onBackgroundStateChangedObservable: Observable<boolean>;
  73880. /**
  73881. * constructs a new background remover module
  73882. * @param _xrSessionManager the session manager for this module
  73883. * @param options read-only options to be used in this module
  73884. */
  73885. constructor(_xrSessionManager: WebXRSessionManager,
  73886. /**
  73887. * read-only options to be used in this module
  73888. */
  73889. options?: IWebXRBackgroundRemoverOptions);
  73890. /**
  73891. * attach this feature
  73892. * Will usually be called by the features manager
  73893. *
  73894. * @returns true if successful.
  73895. */
  73896. attach(): boolean;
  73897. /**
  73898. * detach this feature.
  73899. * Will usually be called by the features manager
  73900. *
  73901. * @returns true if successful.
  73902. */
  73903. detach(): boolean;
  73904. /**
  73905. * Dispose this feature and all of the resources attached
  73906. */
  73907. dispose(): void;
  73908. protected _onXRFrame(_xrFrame: XRFrame): void;
  73909. private _setBackgroundState;
  73910. }
  73911. }
  73912. declare module BABYLON {
  73913. /**
  73914. * Options for the controller physics feature
  73915. */
  73916. export class IWebXRControllerPhysicsOptions {
  73917. /**
  73918. * Should the headset get its own impostor
  73919. */
  73920. enableHeadsetImpostor?: boolean;
  73921. /**
  73922. * Optional parameters for the headset impostor
  73923. */
  73924. headsetImpostorParams?: {
  73925. /**
  73926. * The type of impostor to create. Default is sphere
  73927. */
  73928. impostorType: number;
  73929. /**
  73930. * the size of the impostor. Defaults to 10cm
  73931. */
  73932. impostorSize?: number | {
  73933. width: number;
  73934. height: number;
  73935. depth: number;
  73936. };
  73937. /**
  73938. * Friction definitions
  73939. */
  73940. friction?: number;
  73941. /**
  73942. * Restitution
  73943. */
  73944. restitution?: number;
  73945. };
  73946. /**
  73947. * The physics properties of the future impostors
  73948. */
  73949. physicsProperties?: {
  73950. /**
  73951. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  73952. * Note that this requires a physics engine that supports mesh impostors!
  73953. */
  73954. useControllerMesh?: boolean;
  73955. /**
  73956. * The type of impostor to create. Default is sphere
  73957. */
  73958. impostorType?: number;
  73959. /**
  73960. * the size of the impostor. Defaults to 10cm
  73961. */
  73962. impostorSize?: number | {
  73963. width: number;
  73964. height: number;
  73965. depth: number;
  73966. };
  73967. /**
  73968. * Friction definitions
  73969. */
  73970. friction?: number;
  73971. /**
  73972. * Restitution
  73973. */
  73974. restitution?: number;
  73975. };
  73976. /**
  73977. * the xr input to use with this pointer selection
  73978. */
  73979. xrInput: WebXRInput;
  73980. }
  73981. /**
  73982. * Add physics impostor to your webxr controllers,
  73983. * including naive calculation of their linear and angular velocity
  73984. */
  73985. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  73986. private readonly _options;
  73987. private _attachController;
  73988. private _controllers;
  73989. private _debugMode;
  73990. private _delta;
  73991. private _headsetImpostor?;
  73992. private _headsetMesh?;
  73993. private _lastTimestamp;
  73994. private _tmpQuaternion;
  73995. private _tmpVector;
  73996. /**
  73997. * The module's name
  73998. */
  73999. static readonly Name: string;
  74000. /**
  74001. * The (Babylon) version of this module.
  74002. * This is an integer representing the implementation version.
  74003. * This number does not correspond to the webxr specs version
  74004. */
  74005. static readonly Version: number;
  74006. /**
  74007. * Construct a new Controller Physics Feature
  74008. * @param _xrSessionManager the corresponding xr session manager
  74009. * @param _options options to create this feature with
  74010. */
  74011. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  74012. /**
  74013. * @hidden
  74014. * enable debugging - will show console outputs and the impostor mesh
  74015. */
  74016. _enablePhysicsDebug(): void;
  74017. /**
  74018. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  74019. * @param xrController the controller to add
  74020. */
  74021. addController(xrController: WebXRInputSource): void;
  74022. /**
  74023. * attach this feature
  74024. * Will usually be called by the features manager
  74025. *
  74026. * @returns true if successful.
  74027. */
  74028. attach(): boolean;
  74029. /**
  74030. * detach this feature.
  74031. * Will usually be called by the features manager
  74032. *
  74033. * @returns true if successful.
  74034. */
  74035. detach(): boolean;
  74036. /**
  74037. * Get the headset impostor, if enabled
  74038. * @returns the impostor
  74039. */
  74040. getHeadsetImpostor(): PhysicsImpostor | undefined;
  74041. /**
  74042. * Get the physics impostor of a specific controller.
  74043. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  74044. * @param controller the controller or the controller id of which to get the impostor
  74045. * @returns the impostor or null
  74046. */
  74047. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  74048. /**
  74049. * Update the physics properties provided in the constructor
  74050. * @param newProperties the new properties object
  74051. */
  74052. setPhysicsProperties(newProperties: {
  74053. impostorType?: number;
  74054. impostorSize?: number | {
  74055. width: number;
  74056. height: number;
  74057. depth: number;
  74058. };
  74059. friction?: number;
  74060. restitution?: number;
  74061. }): void;
  74062. protected _onXRFrame(_xrFrame: any): void;
  74063. private _detachController;
  74064. }
  74065. }
  74066. declare module BABYLON {
  74067. /**
  74068. * The motion controller class for all microsoft mixed reality controllers
  74069. */
  74070. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  74071. protected readonly _mapping: {
  74072. defaultButton: {
  74073. valueNodeName: string;
  74074. unpressedNodeName: string;
  74075. pressedNodeName: string;
  74076. };
  74077. defaultAxis: {
  74078. valueNodeName: string;
  74079. minNodeName: string;
  74080. maxNodeName: string;
  74081. };
  74082. buttons: {
  74083. "xr-standard-trigger": {
  74084. rootNodeName: string;
  74085. componentProperty: string;
  74086. states: string[];
  74087. };
  74088. "xr-standard-squeeze": {
  74089. rootNodeName: string;
  74090. componentProperty: string;
  74091. states: string[];
  74092. };
  74093. "xr-standard-touchpad": {
  74094. rootNodeName: string;
  74095. labelAnchorNodeName: string;
  74096. touchPointNodeName: string;
  74097. };
  74098. "xr-standard-thumbstick": {
  74099. rootNodeName: string;
  74100. componentProperty: string;
  74101. states: string[];
  74102. };
  74103. };
  74104. axes: {
  74105. "xr-standard-touchpad": {
  74106. "x-axis": {
  74107. rootNodeName: string;
  74108. };
  74109. "y-axis": {
  74110. rootNodeName: string;
  74111. };
  74112. };
  74113. "xr-standard-thumbstick": {
  74114. "x-axis": {
  74115. rootNodeName: string;
  74116. };
  74117. "y-axis": {
  74118. rootNodeName: string;
  74119. };
  74120. };
  74121. };
  74122. };
  74123. /**
  74124. * The base url used to load the left and right controller models
  74125. */
  74126. static MODEL_BASE_URL: string;
  74127. /**
  74128. * The name of the left controller model file
  74129. */
  74130. static MODEL_LEFT_FILENAME: string;
  74131. /**
  74132. * The name of the right controller model file
  74133. */
  74134. static MODEL_RIGHT_FILENAME: string;
  74135. profileId: string;
  74136. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  74137. protected _getFilenameAndPath(): {
  74138. filename: string;
  74139. path: string;
  74140. };
  74141. protected _getModelLoadingConstraints(): boolean;
  74142. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74143. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74144. protected _updateModel(): void;
  74145. }
  74146. }
  74147. declare module BABYLON {
  74148. /**
  74149. * The motion controller class for oculus touch (quest, rift).
  74150. * This class supports legacy mapping as well the standard xr mapping
  74151. */
  74152. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  74153. private _forceLegacyControllers;
  74154. private _modelRootNode;
  74155. /**
  74156. * The base url used to load the left and right controller models
  74157. */
  74158. static MODEL_BASE_URL: string;
  74159. /**
  74160. * The name of the left controller model file
  74161. */
  74162. static MODEL_LEFT_FILENAME: string;
  74163. /**
  74164. * The name of the right controller model file
  74165. */
  74166. static MODEL_RIGHT_FILENAME: string;
  74167. /**
  74168. * Base Url for the Quest controller model.
  74169. */
  74170. static QUEST_MODEL_BASE_URL: string;
  74171. profileId: string;
  74172. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  74173. protected _getFilenameAndPath(): {
  74174. filename: string;
  74175. path: string;
  74176. };
  74177. protected _getModelLoadingConstraints(): boolean;
  74178. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74179. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74180. protected _updateModel(): void;
  74181. /**
  74182. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  74183. * between the touch and touch 2.
  74184. */
  74185. private _isQuest;
  74186. }
  74187. }
  74188. declare module BABYLON {
  74189. /**
  74190. * The motion controller class for the standard HTC-Vive controllers
  74191. */
  74192. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  74193. private _modelRootNode;
  74194. /**
  74195. * The base url used to load the left and right controller models
  74196. */
  74197. static MODEL_BASE_URL: string;
  74198. /**
  74199. * File name for the controller model.
  74200. */
  74201. static MODEL_FILENAME: string;
  74202. profileId: string;
  74203. /**
  74204. * Create a new Vive motion controller object
  74205. * @param scene the scene to use to create this controller
  74206. * @param gamepadObject the corresponding gamepad object
  74207. * @param handedness the handedness of the controller
  74208. */
  74209. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  74210. protected _getFilenameAndPath(): {
  74211. filename: string;
  74212. path: string;
  74213. };
  74214. protected _getModelLoadingConstraints(): boolean;
  74215. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74216. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74217. protected _updateModel(): void;
  74218. }
  74219. }
  74220. declare module BABYLON {
  74221. /**
  74222. * A cursor which tracks a point on a path
  74223. */
  74224. export class PathCursor {
  74225. private path;
  74226. /**
  74227. * Stores path cursor callbacks for when an onchange event is triggered
  74228. */
  74229. private _onchange;
  74230. /**
  74231. * The value of the path cursor
  74232. */
  74233. value: number;
  74234. /**
  74235. * The animation array of the path cursor
  74236. */
  74237. animations: Animation[];
  74238. /**
  74239. * Initializes the path cursor
  74240. * @param path The path to track
  74241. */
  74242. constructor(path: Path2);
  74243. /**
  74244. * Gets the cursor point on the path
  74245. * @returns A point on the path cursor at the cursor location
  74246. */
  74247. getPoint(): Vector3;
  74248. /**
  74249. * Moves the cursor ahead by the step amount
  74250. * @param step The amount to move the cursor forward
  74251. * @returns This path cursor
  74252. */
  74253. moveAhead(step?: number): PathCursor;
  74254. /**
  74255. * Moves the cursor behind by the step amount
  74256. * @param step The amount to move the cursor back
  74257. * @returns This path cursor
  74258. */
  74259. moveBack(step?: number): PathCursor;
  74260. /**
  74261. * Moves the cursor by the step amount
  74262. * If the step amount is greater than one, an exception is thrown
  74263. * @param step The amount to move the cursor
  74264. * @returns This path cursor
  74265. */
  74266. move(step: number): PathCursor;
  74267. /**
  74268. * Ensures that the value is limited between zero and one
  74269. * @returns This path cursor
  74270. */
  74271. private ensureLimits;
  74272. /**
  74273. * Runs onchange callbacks on change (used by the animation engine)
  74274. * @returns This path cursor
  74275. */
  74276. private raiseOnChange;
  74277. /**
  74278. * Executes a function on change
  74279. * @param f A path cursor onchange callback
  74280. * @returns This path cursor
  74281. */
  74282. onchange(f: (cursor: PathCursor) => void): PathCursor;
  74283. }
  74284. }
  74285. declare module BABYLON {
  74286. /** @hidden */
  74287. export var blurPixelShader: {
  74288. name: string;
  74289. shader: string;
  74290. };
  74291. }
  74292. declare module BABYLON {
  74293. /** @hidden */
  74294. export var pointCloudVertexDeclaration: {
  74295. name: string;
  74296. shader: string;
  74297. };
  74298. }
  74299. // Mixins
  74300. interface Window {
  74301. mozIndexedDB: IDBFactory;
  74302. webkitIndexedDB: IDBFactory;
  74303. msIndexedDB: IDBFactory;
  74304. webkitURL: typeof URL;
  74305. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  74306. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  74307. WebGLRenderingContext: WebGLRenderingContext;
  74308. MSGesture: MSGesture;
  74309. CANNON: any;
  74310. AudioContext: AudioContext;
  74311. webkitAudioContext: AudioContext;
  74312. PointerEvent: any;
  74313. Math: Math;
  74314. Uint8Array: Uint8ArrayConstructor;
  74315. Float32Array: Float32ArrayConstructor;
  74316. mozURL: typeof URL;
  74317. msURL: typeof URL;
  74318. VRFrameData: any; // WebVR, from specs 1.1
  74319. DracoDecoderModule: any;
  74320. setImmediate(handler: (...args: any[]) => void): number;
  74321. }
  74322. interface HTMLCanvasElement {
  74323. requestPointerLock(): void;
  74324. msRequestPointerLock?(): void;
  74325. mozRequestPointerLock?(): void;
  74326. webkitRequestPointerLock?(): void;
  74327. /** Track wether a record is in progress */
  74328. isRecording: boolean;
  74329. /** Capture Stream method defined by some browsers */
  74330. captureStream(fps?: number): MediaStream;
  74331. }
  74332. interface CanvasRenderingContext2D {
  74333. msImageSmoothingEnabled: boolean;
  74334. }
  74335. interface MouseEvent {
  74336. mozMovementX: number;
  74337. mozMovementY: number;
  74338. webkitMovementX: number;
  74339. webkitMovementY: number;
  74340. msMovementX: number;
  74341. msMovementY: number;
  74342. }
  74343. interface Navigator {
  74344. mozGetVRDevices: (any: any) => any;
  74345. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  74346. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  74347. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  74348. webkitGetGamepads(): Gamepad[];
  74349. msGetGamepads(): Gamepad[];
  74350. webkitGamepads(): Gamepad[];
  74351. }
  74352. interface HTMLVideoElement {
  74353. mozSrcObject: any;
  74354. }
  74355. interface Math {
  74356. fround(x: number): number;
  74357. imul(a: number, b: number): number;
  74358. }
  74359. interface WebGLRenderingContext {
  74360. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  74361. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  74362. vertexAttribDivisor(index: number, divisor: number): void;
  74363. createVertexArray(): any;
  74364. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  74365. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  74366. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  74367. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  74368. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  74369. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  74370. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  74371. // Queries
  74372. createQuery(): WebGLQuery;
  74373. deleteQuery(query: WebGLQuery): void;
  74374. beginQuery(target: number, query: WebGLQuery): void;
  74375. endQuery(target: number): void;
  74376. getQueryParameter(query: WebGLQuery, pname: number): any;
  74377. getQuery(target: number, pname: number): any;
  74378. MAX_SAMPLES: number;
  74379. RGBA8: number;
  74380. READ_FRAMEBUFFER: number;
  74381. DRAW_FRAMEBUFFER: number;
  74382. UNIFORM_BUFFER: number;
  74383. HALF_FLOAT_OES: number;
  74384. RGBA16F: number;
  74385. RGBA32F: number;
  74386. R32F: number;
  74387. RG32F: number;
  74388. RGB32F: number;
  74389. R16F: number;
  74390. RG16F: number;
  74391. RGB16F: number;
  74392. RED: number;
  74393. RG: number;
  74394. R8: number;
  74395. RG8: number;
  74396. UNSIGNED_INT_24_8: number;
  74397. DEPTH24_STENCIL8: number;
  74398. MIN: number;
  74399. MAX: number;
  74400. /* Multiple Render Targets */
  74401. drawBuffers(buffers: number[]): void;
  74402. readBuffer(src: number): void;
  74403. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  74404. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  74405. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  74406. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  74407. // Occlusion Query
  74408. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  74409. ANY_SAMPLES_PASSED: number;
  74410. QUERY_RESULT_AVAILABLE: number;
  74411. QUERY_RESULT: number;
  74412. }
  74413. interface WebGLProgram {
  74414. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  74415. }
  74416. interface EXT_disjoint_timer_query {
  74417. QUERY_COUNTER_BITS_EXT: number;
  74418. TIME_ELAPSED_EXT: number;
  74419. TIMESTAMP_EXT: number;
  74420. GPU_DISJOINT_EXT: number;
  74421. QUERY_RESULT_EXT: number;
  74422. QUERY_RESULT_AVAILABLE_EXT: number;
  74423. queryCounterEXT(query: WebGLQuery, target: number): void;
  74424. createQueryEXT(): WebGLQuery;
  74425. beginQueryEXT(target: number, query: WebGLQuery): void;
  74426. endQueryEXT(target: number): void;
  74427. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  74428. deleteQueryEXT(query: WebGLQuery): void;
  74429. }
  74430. interface WebGLUniformLocation {
  74431. _currentState: any;
  74432. }
  74433. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  74434. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  74435. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  74436. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  74437. interface WebGLRenderingContext {
  74438. readonly RASTERIZER_DISCARD: number;
  74439. readonly DEPTH_COMPONENT24: number;
  74440. readonly TEXTURE_3D: number;
  74441. readonly TEXTURE_2D_ARRAY: number;
  74442. readonly TEXTURE_COMPARE_FUNC: number;
  74443. readonly TEXTURE_COMPARE_MODE: number;
  74444. readonly COMPARE_REF_TO_TEXTURE: number;
  74445. readonly TEXTURE_WRAP_R: number;
  74446. readonly HALF_FLOAT: number;
  74447. readonly RGB8: number;
  74448. readonly RED_INTEGER: number;
  74449. readonly RG_INTEGER: number;
  74450. readonly RGB_INTEGER: number;
  74451. readonly RGBA_INTEGER: number;
  74452. readonly R8_SNORM: number;
  74453. readonly RG8_SNORM: number;
  74454. readonly RGB8_SNORM: number;
  74455. readonly RGBA8_SNORM: number;
  74456. readonly R8I: number;
  74457. readonly RG8I: number;
  74458. readonly RGB8I: number;
  74459. readonly RGBA8I: number;
  74460. readonly R8UI: number;
  74461. readonly RG8UI: number;
  74462. readonly RGB8UI: number;
  74463. readonly RGBA8UI: number;
  74464. readonly R16I: number;
  74465. readonly RG16I: number;
  74466. readonly RGB16I: number;
  74467. readonly RGBA16I: number;
  74468. readonly R16UI: number;
  74469. readonly RG16UI: number;
  74470. readonly RGB16UI: number;
  74471. readonly RGBA16UI: number;
  74472. readonly R32I: number;
  74473. readonly RG32I: number;
  74474. readonly RGB32I: number;
  74475. readonly RGBA32I: number;
  74476. readonly R32UI: number;
  74477. readonly RG32UI: number;
  74478. readonly RGB32UI: number;
  74479. readonly RGBA32UI: number;
  74480. readonly RGB10_A2UI: number;
  74481. readonly R11F_G11F_B10F: number;
  74482. readonly RGB9_E5: number;
  74483. readonly RGB10_A2: number;
  74484. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  74485. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  74486. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  74487. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  74488. readonly DEPTH_COMPONENT32F: number;
  74489. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  74490. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  74491. 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;
  74492. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  74493. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  74494. readonly TRANSFORM_FEEDBACK: number;
  74495. readonly INTERLEAVED_ATTRIBS: number;
  74496. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  74497. createTransformFeedback(): WebGLTransformFeedback;
  74498. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  74499. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  74500. beginTransformFeedback(primitiveMode: number): void;
  74501. endTransformFeedback(): void;
  74502. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  74503. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  74504. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  74505. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  74506. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  74507. }
  74508. interface ImageBitmap {
  74509. readonly width: number;
  74510. readonly height: number;
  74511. close(): void;
  74512. }
  74513. interface WebGLQuery extends WebGLObject {
  74514. }
  74515. declare var WebGLQuery: {
  74516. prototype: WebGLQuery;
  74517. new(): WebGLQuery;
  74518. };
  74519. interface WebGLSampler extends WebGLObject {
  74520. }
  74521. declare var WebGLSampler: {
  74522. prototype: WebGLSampler;
  74523. new(): WebGLSampler;
  74524. };
  74525. interface WebGLSync extends WebGLObject {
  74526. }
  74527. declare var WebGLSync: {
  74528. prototype: WebGLSync;
  74529. new(): WebGLSync;
  74530. };
  74531. interface WebGLTransformFeedback extends WebGLObject {
  74532. }
  74533. declare var WebGLTransformFeedback: {
  74534. prototype: WebGLTransformFeedback;
  74535. new(): WebGLTransformFeedback;
  74536. };
  74537. interface WebGLVertexArrayObject extends WebGLObject {
  74538. }
  74539. declare var WebGLVertexArrayObject: {
  74540. prototype: WebGLVertexArrayObject;
  74541. new(): WebGLVertexArrayObject;
  74542. };
  74543. // Type definitions for WebVR API
  74544. // Project: https://w3c.github.io/webvr/
  74545. // Definitions by: six a <https://github.com/lostfictions>
  74546. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  74547. interface VRDisplay extends EventTarget {
  74548. /**
  74549. * Dictionary of capabilities describing the VRDisplay.
  74550. */
  74551. readonly capabilities: VRDisplayCapabilities;
  74552. /**
  74553. * z-depth defining the far plane of the eye view frustum
  74554. * enables mapping of values in the render target depth
  74555. * attachment to scene coordinates. Initially set to 10000.0.
  74556. */
  74557. depthFar: number;
  74558. /**
  74559. * z-depth defining the near plane of the eye view frustum
  74560. * enables mapping of values in the render target depth
  74561. * attachment to scene coordinates. Initially set to 0.01.
  74562. */
  74563. depthNear: number;
  74564. /**
  74565. * An identifier for this distinct VRDisplay. Used as an
  74566. * association point in the Gamepad API.
  74567. */
  74568. readonly displayId: number;
  74569. /**
  74570. * A display name, a user-readable name identifying it.
  74571. */
  74572. readonly displayName: string;
  74573. readonly isConnected: boolean;
  74574. readonly isPresenting: boolean;
  74575. /**
  74576. * If this VRDisplay supports room-scale experiences, the optional
  74577. * stage attribute contains details on the room-scale parameters.
  74578. */
  74579. readonly stageParameters: VRStageParameters | null;
  74580. /**
  74581. * Passing the value returned by `requestAnimationFrame` to
  74582. * `cancelAnimationFrame` will unregister the callback.
  74583. * @param handle Define the hanle of the request to cancel
  74584. */
  74585. cancelAnimationFrame(handle: number): void;
  74586. /**
  74587. * Stops presenting to the VRDisplay.
  74588. * @returns a promise to know when it stopped
  74589. */
  74590. exitPresent(): Promise<void>;
  74591. /**
  74592. * Return the current VREyeParameters for the given eye.
  74593. * @param whichEye Define the eye we want the parameter for
  74594. * @returns the eye parameters
  74595. */
  74596. getEyeParameters(whichEye: string): VREyeParameters;
  74597. /**
  74598. * Populates the passed VRFrameData with the information required to render
  74599. * the current frame.
  74600. * @param frameData Define the data structure to populate
  74601. * @returns true if ok otherwise false
  74602. */
  74603. getFrameData(frameData: VRFrameData): boolean;
  74604. /**
  74605. * Get the layers currently being presented.
  74606. * @returns the list of VR layers
  74607. */
  74608. getLayers(): VRLayer[];
  74609. /**
  74610. * Return a VRPose containing the future predicted pose of the VRDisplay
  74611. * when the current frame will be presented. The value returned will not
  74612. * change until JavaScript has returned control to the browser.
  74613. *
  74614. * The VRPose will contain the position, orientation, velocity,
  74615. * and acceleration of each of these properties.
  74616. * @returns the pose object
  74617. */
  74618. getPose(): VRPose;
  74619. /**
  74620. * Return the current instantaneous pose of the VRDisplay, with no
  74621. * prediction applied.
  74622. * @returns the current instantaneous pose
  74623. */
  74624. getImmediatePose(): VRPose;
  74625. /**
  74626. * The callback passed to `requestAnimationFrame` will be called
  74627. * any time a new frame should be rendered. When the VRDisplay is
  74628. * presenting the callback will be called at the native refresh
  74629. * rate of the HMD. When not presenting this function acts
  74630. * identically to how window.requestAnimationFrame acts. Content should
  74631. * make no assumptions of frame rate or vsync behavior as the HMD runs
  74632. * asynchronously from other displays and at differing refresh rates.
  74633. * @param callback Define the eaction to run next frame
  74634. * @returns the request handle it
  74635. */
  74636. requestAnimationFrame(callback: FrameRequestCallback): number;
  74637. /**
  74638. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  74639. * Repeat calls while already presenting will update the VRLayers being displayed.
  74640. * @param layers Define the list of layer to present
  74641. * @returns a promise to know when the request has been fulfilled
  74642. */
  74643. requestPresent(layers: VRLayer[]): Promise<void>;
  74644. /**
  74645. * Reset the pose for this display, treating its current position and
  74646. * orientation as the "origin/zero" values. VRPose.position,
  74647. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  74648. * updated when calling resetPose(). This should be called in only
  74649. * sitting-space experiences.
  74650. */
  74651. resetPose(): void;
  74652. /**
  74653. * The VRLayer provided to the VRDisplay will be captured and presented
  74654. * in the HMD. Calling this function has the same effect on the source
  74655. * canvas as any other operation that uses its source image, and canvases
  74656. * created without preserveDrawingBuffer set to true will be cleared.
  74657. * @param pose Define the pose to submit
  74658. */
  74659. submitFrame(pose?: VRPose): void;
  74660. }
  74661. declare var VRDisplay: {
  74662. prototype: VRDisplay;
  74663. new(): VRDisplay;
  74664. };
  74665. interface VRLayer {
  74666. leftBounds?: number[] | Float32Array | null;
  74667. rightBounds?: number[] | Float32Array | null;
  74668. source?: HTMLCanvasElement | null;
  74669. }
  74670. interface VRDisplayCapabilities {
  74671. readonly canPresent: boolean;
  74672. readonly hasExternalDisplay: boolean;
  74673. readonly hasOrientation: boolean;
  74674. readonly hasPosition: boolean;
  74675. readonly maxLayers: number;
  74676. }
  74677. interface VREyeParameters {
  74678. /** @deprecated */
  74679. readonly fieldOfView: VRFieldOfView;
  74680. readonly offset: Float32Array;
  74681. readonly renderHeight: number;
  74682. readonly renderWidth: number;
  74683. }
  74684. interface VRFieldOfView {
  74685. readonly downDegrees: number;
  74686. readonly leftDegrees: number;
  74687. readonly rightDegrees: number;
  74688. readonly upDegrees: number;
  74689. }
  74690. interface VRFrameData {
  74691. readonly leftProjectionMatrix: Float32Array;
  74692. readonly leftViewMatrix: Float32Array;
  74693. readonly pose: VRPose;
  74694. readonly rightProjectionMatrix: Float32Array;
  74695. readonly rightViewMatrix: Float32Array;
  74696. readonly timestamp: number;
  74697. }
  74698. interface VRPose {
  74699. readonly angularAcceleration: Float32Array | null;
  74700. readonly angularVelocity: Float32Array | null;
  74701. readonly linearAcceleration: Float32Array | null;
  74702. readonly linearVelocity: Float32Array | null;
  74703. readonly orientation: Float32Array | null;
  74704. readonly position: Float32Array | null;
  74705. readonly timestamp: number;
  74706. }
  74707. interface VRStageParameters {
  74708. sittingToStandingTransform?: Float32Array;
  74709. sizeX?: number;
  74710. sizeY?: number;
  74711. }
  74712. interface Navigator {
  74713. getVRDisplays(): Promise<VRDisplay[]>;
  74714. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  74715. }
  74716. interface Window {
  74717. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  74718. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  74719. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  74720. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  74721. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  74722. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  74723. }
  74724. interface Gamepad {
  74725. readonly displayId: number;
  74726. }
  74727. type XRSessionMode =
  74728. | "inline"
  74729. | "immersive-vr"
  74730. | "immersive-ar";
  74731. type XRReferenceSpaceType =
  74732. | "viewer"
  74733. | "local"
  74734. | "local-floor"
  74735. | "bounded-floor"
  74736. | "unbounded";
  74737. type XREnvironmentBlendMode =
  74738. | "opaque"
  74739. | "additive"
  74740. | "alpha-blend";
  74741. type XRVisibilityState =
  74742. | "visible"
  74743. | "visible-blurred"
  74744. | "hidden";
  74745. type XRHandedness =
  74746. | "none"
  74747. | "left"
  74748. | "right";
  74749. type XRTargetRayMode =
  74750. | "gaze"
  74751. | "tracked-pointer"
  74752. | "screen";
  74753. type XREye =
  74754. | "none"
  74755. | "left"
  74756. | "right";
  74757. type XREventType =
  74758. | "devicechange"
  74759. | "visibilitychange"
  74760. | "end"
  74761. | "inputsourceschange"
  74762. | "select"
  74763. | "selectstart"
  74764. | "selectend"
  74765. | "squeeze"
  74766. | "squeezestart"
  74767. | "squeezeend"
  74768. | "reset";
  74769. interface XRSpace extends EventTarget {
  74770. }
  74771. interface XRRenderState {
  74772. depthNear?: number;
  74773. depthFar?: number;
  74774. inlineVerticalFieldOfView?: number;
  74775. baseLayer?: XRWebGLLayer;
  74776. }
  74777. interface XRInputSource {
  74778. handedness: XRHandedness;
  74779. targetRayMode: XRTargetRayMode;
  74780. targetRaySpace: XRSpace;
  74781. gripSpace: XRSpace | undefined;
  74782. gamepad: Gamepad | undefined;
  74783. profiles: Array<string>;
  74784. }
  74785. interface XRSessionInit {
  74786. optionalFeatures?: string[];
  74787. requiredFeatures?: string[];
  74788. }
  74789. interface XRSession {
  74790. addEventListener: Function;
  74791. removeEventListener: Function;
  74792. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  74793. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  74794. requestAnimationFrame: Function;
  74795. end(): Promise<void>;
  74796. renderState: XRRenderState;
  74797. inputSources: Array<XRInputSource>;
  74798. // hit test
  74799. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  74800. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  74801. // legacy AR hit test
  74802. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  74803. // legacy plane detection
  74804. updateWorldTrackingState(options: {
  74805. planeDetectionState?: { enabled: boolean; }
  74806. }): void;
  74807. }
  74808. interface XRReferenceSpace extends XRSpace {
  74809. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  74810. onreset: any;
  74811. }
  74812. type XRPlaneSet = Set<XRPlane>;
  74813. type XRAnchorSet = Set<XRAnchor>;
  74814. interface XRFrame {
  74815. session: XRSession;
  74816. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  74817. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  74818. // AR
  74819. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  74820. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  74821. // Anchors
  74822. trackedAnchors?: XRAnchorSet;
  74823. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  74824. // Planes
  74825. worldInformation: {
  74826. detectedPlanes?: XRPlaneSet;
  74827. };
  74828. }
  74829. interface XRViewerPose extends XRPose {
  74830. views: Array<XRView>;
  74831. }
  74832. interface XRPose {
  74833. transform: XRRigidTransform;
  74834. emulatedPosition: boolean;
  74835. }
  74836. interface XRWebGLLayerOptions {
  74837. antialias?: boolean;
  74838. depth?: boolean;
  74839. stencil?: boolean;
  74840. alpha?: boolean;
  74841. multiview?: boolean;
  74842. framebufferScaleFactor?: number;
  74843. }
  74844. declare var XRWebGLLayer: {
  74845. prototype: XRWebGLLayer;
  74846. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  74847. };
  74848. interface XRWebGLLayer {
  74849. framebuffer: WebGLFramebuffer;
  74850. framebufferWidth: number;
  74851. framebufferHeight: number;
  74852. getViewport: Function;
  74853. }
  74854. declare class XRRigidTransform {
  74855. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  74856. position: DOMPointReadOnly;
  74857. orientation: DOMPointReadOnly;
  74858. matrix: Float32Array;
  74859. inverse: XRRigidTransform;
  74860. }
  74861. interface XRView {
  74862. eye: XREye;
  74863. projectionMatrix: Float32Array;
  74864. transform: XRRigidTransform;
  74865. }
  74866. interface XRInputSourceChangeEvent {
  74867. session: XRSession;
  74868. removed: Array<XRInputSource>;
  74869. added: Array<XRInputSource>;
  74870. }
  74871. interface XRInputSourceEvent extends Event {
  74872. readonly frame: XRFrame;
  74873. readonly inputSource: XRInputSource;
  74874. }
  74875. // Experimental(er) features
  74876. declare class XRRay {
  74877. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  74878. origin: DOMPointReadOnly;
  74879. direction: DOMPointReadOnly;
  74880. matrix: Float32Array;
  74881. }
  74882. declare enum XRHitTestTrackableType {
  74883. "point",
  74884. "plane"
  74885. }
  74886. interface XRHitResult {
  74887. hitMatrix: Float32Array;
  74888. }
  74889. interface XRTransientInputHitTestResult {
  74890. readonly inputSource: XRInputSource;
  74891. readonly results: Array<XRHitTestResult>;
  74892. }
  74893. interface XRHitTestResult {
  74894. getPose(baseSpace: XRSpace): XRPose | undefined;
  74895. // When anchor system is enabled
  74896. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  74897. }
  74898. interface XRHitTestSource {
  74899. cancel(): void;
  74900. }
  74901. interface XRTransientInputHitTestSource {
  74902. cancel(): void;
  74903. }
  74904. interface XRHitTestOptionsInit {
  74905. space: XRSpace;
  74906. entityTypes?: Array<XRHitTestTrackableType>;
  74907. offsetRay?: XRRay;
  74908. }
  74909. interface XRTransientInputHitTestOptionsInit {
  74910. profile: string;
  74911. entityTypes?: Array<XRHitTestTrackableType>;
  74912. offsetRay?: XRRay;
  74913. }
  74914. interface XRAnchor {
  74915. anchorSpace: XRSpace;
  74916. delete(): void;
  74917. }
  74918. interface XRPlane {
  74919. orientation: "Horizontal" | "Vertical";
  74920. planeSpace: XRSpace;
  74921. polygon: Array<DOMPointReadOnly>;
  74922. lastChangedTime: number;
  74923. }
  74924. /**
  74925. * @ignore
  74926. */
  74927. declare module BABYLON.GLTF2.Exporter {
  74928. }
  74929. /**
  74930. * @ignore
  74931. */
  74932. declare module BABYLON.GLTF1 {
  74933. }
  74934. declare module BABYLON.GUI {
  74935. /**
  74936. * Class used to specific a value and its associated unit
  74937. */
  74938. export class ValueAndUnit {
  74939. /** defines the unit to store */
  74940. unit: number;
  74941. /** defines a boolean indicating if the value can be negative */
  74942. negativeValueAllowed: boolean;
  74943. private _value;
  74944. private _originalUnit;
  74945. /**
  74946. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  74947. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74948. */
  74949. ignoreAdaptiveScaling: boolean;
  74950. /**
  74951. * Creates a new ValueAndUnit
  74952. * @param value defines the value to store
  74953. * @param unit defines the unit to store
  74954. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  74955. */
  74956. constructor(value: number,
  74957. /** defines the unit to store */
  74958. unit?: number,
  74959. /** defines a boolean indicating if the value can be negative */
  74960. negativeValueAllowed?: boolean);
  74961. /** Gets a boolean indicating if the value is a percentage */
  74962. get isPercentage(): boolean;
  74963. /** Gets a boolean indicating if the value is store as pixel */
  74964. get isPixel(): boolean;
  74965. /** Gets direct internal value */
  74966. get internalValue(): number;
  74967. /**
  74968. * Gets value as pixel
  74969. * @param host defines the root host
  74970. * @param refValue defines the reference value for percentages
  74971. * @returns the value as pixel
  74972. */
  74973. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  74974. /**
  74975. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  74976. * @param value defines the value to store
  74977. * @param unit defines the unit to store
  74978. * @returns the current ValueAndUnit
  74979. */
  74980. updateInPlace(value: number, unit?: number): ValueAndUnit;
  74981. /**
  74982. * Gets the value accordingly to its unit
  74983. * @param host defines the root host
  74984. * @returns the value
  74985. */
  74986. getValue(host: AdvancedDynamicTexture): number;
  74987. /**
  74988. * Gets a string representation of the value
  74989. * @param host defines the root host
  74990. * @param decimals defines an optional number of decimals to display
  74991. * @returns a string
  74992. */
  74993. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  74994. /**
  74995. * Store a value parsed from a string
  74996. * @param source defines the source string
  74997. * @returns true if the value was successfully parsed
  74998. */
  74999. fromString(source: string | number): boolean;
  75000. private static _Regex;
  75001. private static _UNITMODE_PERCENTAGE;
  75002. private static _UNITMODE_PIXEL;
  75003. /** UNITMODE_PERCENTAGE */
  75004. static get UNITMODE_PERCENTAGE(): number;
  75005. /** UNITMODE_PIXEL */
  75006. static get UNITMODE_PIXEL(): number;
  75007. }
  75008. }
  75009. declare module BABYLON.GUI {
  75010. /**
  75011. * Define a style used by control to automatically setup properties based on a template.
  75012. * Only support font related properties so far
  75013. */
  75014. export class Style implements BABYLON.IDisposable {
  75015. private _fontFamily;
  75016. private _fontStyle;
  75017. private _fontWeight;
  75018. /** @hidden */
  75019. _host: AdvancedDynamicTexture;
  75020. /** @hidden */
  75021. _fontSize: ValueAndUnit;
  75022. /**
  75023. * BABYLON.Observable raised when the style values are changed
  75024. */
  75025. onChangedObservable: BABYLON.Observable<Style>;
  75026. /**
  75027. * Creates a new style object
  75028. * @param host defines the AdvancedDynamicTexture which hosts this style
  75029. */
  75030. constructor(host: AdvancedDynamicTexture);
  75031. /**
  75032. * Gets or sets the font size
  75033. */
  75034. get fontSize(): string | number;
  75035. set fontSize(value: string | number);
  75036. /**
  75037. * Gets or sets the font family
  75038. */
  75039. get fontFamily(): string;
  75040. set fontFamily(value: string);
  75041. /**
  75042. * Gets or sets the font style
  75043. */
  75044. get fontStyle(): string;
  75045. set fontStyle(value: string);
  75046. /** Gets or sets font weight */
  75047. get fontWeight(): string;
  75048. set fontWeight(value: string);
  75049. /** Dispose all associated resources */
  75050. dispose(): void;
  75051. }
  75052. }
  75053. declare module BABYLON.GUI {
  75054. /**
  75055. * Class used to transport BABYLON.Vector2 information for pointer events
  75056. */
  75057. export class Vector2WithInfo extends BABYLON.Vector2 {
  75058. /** defines the current mouse button index */
  75059. buttonIndex: number;
  75060. /**
  75061. * Creates a new Vector2WithInfo
  75062. * @param source defines the vector2 data to transport
  75063. * @param buttonIndex defines the current mouse button index
  75064. */
  75065. constructor(source: BABYLON.Vector2,
  75066. /** defines the current mouse button index */
  75067. buttonIndex?: number);
  75068. }
  75069. /** Class used to provide 2D matrix features */
  75070. export class Matrix2D {
  75071. /** Gets the internal array of 6 floats used to store matrix data */
  75072. m: Float32Array;
  75073. /**
  75074. * Creates a new matrix
  75075. * @param m00 defines value for (0, 0)
  75076. * @param m01 defines value for (0, 1)
  75077. * @param m10 defines value for (1, 0)
  75078. * @param m11 defines value for (1, 1)
  75079. * @param m20 defines value for (2, 0)
  75080. * @param m21 defines value for (2, 1)
  75081. */
  75082. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  75083. /**
  75084. * Fills the matrix from direct values
  75085. * @param m00 defines value for (0, 0)
  75086. * @param m01 defines value for (0, 1)
  75087. * @param m10 defines value for (1, 0)
  75088. * @param m11 defines value for (1, 1)
  75089. * @param m20 defines value for (2, 0)
  75090. * @param m21 defines value for (2, 1)
  75091. * @returns the current modified matrix
  75092. */
  75093. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  75094. /**
  75095. * Gets matrix determinant
  75096. * @returns the determinant
  75097. */
  75098. determinant(): number;
  75099. /**
  75100. * Inverses the matrix and stores it in a target matrix
  75101. * @param result defines the target matrix
  75102. * @returns the current matrix
  75103. */
  75104. invertToRef(result: Matrix2D): Matrix2D;
  75105. /**
  75106. * Multiplies the current matrix with another one
  75107. * @param other defines the second operand
  75108. * @param result defines the target matrix
  75109. * @returns the current matrix
  75110. */
  75111. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  75112. /**
  75113. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  75114. * @param x defines the x coordinate to transform
  75115. * @param y defines the x coordinate to transform
  75116. * @param result defines the target vector2
  75117. * @returns the current matrix
  75118. */
  75119. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  75120. /**
  75121. * Creates an identity matrix
  75122. * @returns a new matrix
  75123. */
  75124. static Identity(): Matrix2D;
  75125. /**
  75126. * Creates a translation matrix and stores it in a target matrix
  75127. * @param x defines the x coordinate of the translation
  75128. * @param y defines the y coordinate of the translation
  75129. * @param result defines the target matrix
  75130. */
  75131. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  75132. /**
  75133. * Creates a scaling matrix and stores it in a target matrix
  75134. * @param x defines the x coordinate of the scaling
  75135. * @param y defines the y coordinate of the scaling
  75136. * @param result defines the target matrix
  75137. */
  75138. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  75139. /**
  75140. * Creates a rotation matrix and stores it in a target matrix
  75141. * @param angle defines the rotation angle
  75142. * @param result defines the target matrix
  75143. */
  75144. static RotationToRef(angle: number, result: Matrix2D): void;
  75145. private static _TempPreTranslationMatrix;
  75146. private static _TempPostTranslationMatrix;
  75147. private static _TempRotationMatrix;
  75148. private static _TempScalingMatrix;
  75149. private static _TempCompose0;
  75150. private static _TempCompose1;
  75151. private static _TempCompose2;
  75152. /**
  75153. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  75154. * @param tx defines the x coordinate of the translation
  75155. * @param ty defines the y coordinate of the translation
  75156. * @param angle defines the rotation angle
  75157. * @param scaleX defines the x coordinate of the scaling
  75158. * @param scaleY defines the y coordinate of the scaling
  75159. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  75160. * @param result defines the target matrix
  75161. */
  75162. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  75163. }
  75164. }
  75165. declare module BABYLON.GUI {
  75166. /**
  75167. * Class used to store 2D control sizes
  75168. */
  75169. export class Measure {
  75170. /** defines left coordinate */
  75171. left: number;
  75172. /** defines top coordinate */
  75173. top: number;
  75174. /** defines width dimension */
  75175. width: number;
  75176. /** defines height dimension */
  75177. height: number;
  75178. /**
  75179. * Creates a new measure
  75180. * @param left defines left coordinate
  75181. * @param top defines top coordinate
  75182. * @param width defines width dimension
  75183. * @param height defines height dimension
  75184. */
  75185. constructor(
  75186. /** defines left coordinate */
  75187. left: number,
  75188. /** defines top coordinate */
  75189. top: number,
  75190. /** defines width dimension */
  75191. width: number,
  75192. /** defines height dimension */
  75193. height: number);
  75194. /**
  75195. * Copy from another measure
  75196. * @param other defines the other measure to copy from
  75197. */
  75198. copyFrom(other: Measure): void;
  75199. /**
  75200. * Copy from a group of 4 floats
  75201. * @param left defines left coordinate
  75202. * @param top defines top coordinate
  75203. * @param width defines width dimension
  75204. * @param height defines height dimension
  75205. */
  75206. copyFromFloats(left: number, top: number, width: number, height: number): void;
  75207. /**
  75208. * Computes the axis aligned bounding box measure for two given measures
  75209. * @param a Input measure
  75210. * @param b Input measure
  75211. * @param result the resulting bounding measure
  75212. */
  75213. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  75214. /**
  75215. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  75216. * @param transform the matrix to transform the measure before computing the AABB
  75217. * @param result the resulting AABB
  75218. */
  75219. transformToRef(transform: Matrix2D, result: Measure): void;
  75220. /**
  75221. * Check equality between this measure and another one
  75222. * @param other defines the other measures
  75223. * @returns true if both measures are equals
  75224. */
  75225. isEqualsTo(other: Measure): boolean;
  75226. /**
  75227. * Creates an empty measure
  75228. * @returns a new measure
  75229. */
  75230. static Empty(): Measure;
  75231. }
  75232. }
  75233. declare module BABYLON.GUI {
  75234. /**
  75235. * Interface used to define a control that can receive focus
  75236. */
  75237. export interface IFocusableControl {
  75238. /**
  75239. * Function called when the control receives the focus
  75240. */
  75241. onFocus(): void;
  75242. /**
  75243. * Function called when the control loses the focus
  75244. */
  75245. onBlur(): void;
  75246. /**
  75247. * Function called to let the control handle keyboard events
  75248. * @param evt defines the current keyboard event
  75249. */
  75250. processKeyboard(evt: KeyboardEvent): void;
  75251. /**
  75252. * Function called to get the list of controls that should not steal the focus from this control
  75253. * @returns an array of controls
  75254. */
  75255. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  75256. }
  75257. /**
  75258. * Class used to create texture to support 2D GUI elements
  75259. * @see https://doc.babylonjs.com/how_to/gui
  75260. */
  75261. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  75262. private _isDirty;
  75263. private _renderObserver;
  75264. private _resizeObserver;
  75265. private _preKeyboardObserver;
  75266. private _pointerMoveObserver;
  75267. private _pointerObserver;
  75268. private _canvasPointerOutObserver;
  75269. private _background;
  75270. /** @hidden */
  75271. _rootContainer: Container;
  75272. /** @hidden */
  75273. _lastPickedControl: Control;
  75274. /** @hidden */
  75275. _lastControlOver: {
  75276. [pointerId: number]: Control;
  75277. };
  75278. /** @hidden */
  75279. _lastControlDown: {
  75280. [pointerId: number]: Control;
  75281. };
  75282. /** @hidden */
  75283. _capturingControl: {
  75284. [pointerId: number]: Control;
  75285. };
  75286. /** @hidden */
  75287. _shouldBlockPointer: boolean;
  75288. /** @hidden */
  75289. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  75290. /** @hidden */
  75291. _linkedControls: Control[];
  75292. private _isFullscreen;
  75293. private _fullscreenViewport;
  75294. private _idealWidth;
  75295. private _idealHeight;
  75296. private _useSmallestIdeal;
  75297. private _renderAtIdealSize;
  75298. private _focusedControl;
  75299. private _blockNextFocusCheck;
  75300. private _renderScale;
  75301. private _rootElement;
  75302. private _cursorChanged;
  75303. private _defaultMousePointerId;
  75304. /** @hidden */
  75305. _numLayoutCalls: number;
  75306. /** Gets the number of layout calls made the last time the ADT has been rendered */
  75307. get numLayoutCalls(): number;
  75308. /** @hidden */
  75309. _numRenderCalls: number;
  75310. /** Gets the number of render calls made the last time the ADT has been rendered */
  75311. get numRenderCalls(): number;
  75312. /**
  75313. * Define type to string to ensure compatibility across browsers
  75314. * Safari doesn't support DataTransfer constructor
  75315. */
  75316. private _clipboardData;
  75317. /**
  75318. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  75319. */
  75320. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  75321. /**
  75322. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  75323. */
  75324. onControlPickedObservable: BABYLON.Observable<Control>;
  75325. /**
  75326. * BABYLON.Observable event triggered before layout is evaluated
  75327. */
  75328. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75329. /**
  75330. * BABYLON.Observable event triggered after the layout was evaluated
  75331. */
  75332. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75333. /**
  75334. * BABYLON.Observable event triggered before the texture is rendered
  75335. */
  75336. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75337. /**
  75338. * BABYLON.Observable event triggered after the texture was rendered
  75339. */
  75340. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75341. /**
  75342. * Gets or sets a boolean defining if alpha is stored as premultiplied
  75343. */
  75344. premulAlpha: boolean;
  75345. /**
  75346. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  75347. * Useful when you want more antialiasing
  75348. */
  75349. get renderScale(): number;
  75350. set renderScale(value: number);
  75351. /** Gets or sets the background color */
  75352. get background(): string;
  75353. set background(value: string);
  75354. /**
  75355. * Gets or sets the ideal width used to design controls.
  75356. * The GUI will then rescale everything accordingly
  75357. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75358. */
  75359. get idealWidth(): number;
  75360. set idealWidth(value: number);
  75361. /**
  75362. * Gets or sets the ideal height used to design controls.
  75363. * The GUI will then rescale everything accordingly
  75364. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75365. */
  75366. get idealHeight(): number;
  75367. set idealHeight(value: number);
  75368. /**
  75369. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  75370. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75371. */
  75372. get useSmallestIdeal(): boolean;
  75373. set useSmallestIdeal(value: boolean);
  75374. /**
  75375. * Gets or sets a boolean indicating if adaptive scaling must be used
  75376. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75377. */
  75378. get renderAtIdealSize(): boolean;
  75379. set renderAtIdealSize(value: boolean);
  75380. /**
  75381. * Gets the ratio used when in "ideal mode"
  75382. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75383. * */
  75384. get idealRatio(): number;
  75385. /**
  75386. * Gets the underlying layer used to render the texture when in fullscreen mode
  75387. */
  75388. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  75389. /**
  75390. * Gets the root container control
  75391. */
  75392. get rootContainer(): Container;
  75393. /**
  75394. * Returns an array containing the root container.
  75395. * This is mostly used to let the Inspector introspects the ADT
  75396. * @returns an array containing the rootContainer
  75397. */
  75398. getChildren(): Array<Container>;
  75399. /**
  75400. * Will return all controls that are inside this texture
  75401. * @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
  75402. * @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
  75403. * @return all child controls
  75404. */
  75405. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  75406. /**
  75407. * Gets or sets the current focused control
  75408. */
  75409. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  75410. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  75411. /**
  75412. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  75413. */
  75414. get isForeground(): boolean;
  75415. set isForeground(value: boolean);
  75416. /**
  75417. * Gets or set information about clipboardData
  75418. */
  75419. get clipboardData(): string;
  75420. set clipboardData(value: string);
  75421. /**
  75422. * Creates a new AdvancedDynamicTexture
  75423. * @param name defines the name of the texture
  75424. * @param width defines the width of the texture
  75425. * @param height defines the height of the texture
  75426. * @param scene defines the hosting scene
  75427. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  75428. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  75429. */
  75430. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  75431. /**
  75432. * Get the current class name of the texture useful for serialization or dynamic coding.
  75433. * @returns "AdvancedDynamicTexture"
  75434. */
  75435. getClassName(): string;
  75436. /**
  75437. * Function used to execute a function on all controls
  75438. * @param func defines the function to execute
  75439. * @param container defines the container where controls belong. If null the root container will be used
  75440. */
  75441. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  75442. private _useInvalidateRectOptimization;
  75443. /**
  75444. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  75445. */
  75446. get useInvalidateRectOptimization(): boolean;
  75447. set useInvalidateRectOptimization(value: boolean);
  75448. private _invalidatedRectangle;
  75449. /**
  75450. * Invalidates a rectangle area on the gui texture
  75451. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  75452. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  75453. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  75454. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  75455. */
  75456. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  75457. /**
  75458. * Marks the texture as dirty forcing a complete update
  75459. */
  75460. markAsDirty(): void;
  75461. /**
  75462. * Helper function used to create a new style
  75463. * @returns a new style
  75464. * @see https://doc.babylonjs.com/how_to/gui#styles
  75465. */
  75466. createStyle(): Style;
  75467. /**
  75468. * Adds a new control to the root container
  75469. * @param control defines the control to add
  75470. * @returns the current texture
  75471. */
  75472. addControl(control: Control): AdvancedDynamicTexture;
  75473. /**
  75474. * Removes a control from the root container
  75475. * @param control defines the control to remove
  75476. * @returns the current texture
  75477. */
  75478. removeControl(control: Control): AdvancedDynamicTexture;
  75479. /**
  75480. * Release all resources
  75481. */
  75482. dispose(): void;
  75483. private _onResize;
  75484. /** @hidden */
  75485. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  75486. /**
  75487. * Get screen coordinates for a vector3
  75488. * @param position defines the position to project
  75489. * @param worldMatrix defines the world matrix to use
  75490. * @returns the projected position
  75491. */
  75492. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  75493. private _checkUpdate;
  75494. private _clearMeasure;
  75495. private _render;
  75496. /** @hidden */
  75497. _changeCursor(cursor: string): void;
  75498. /** @hidden */
  75499. _registerLastControlDown(control: Control, pointerId: number): void;
  75500. private _doPicking;
  75501. /** @hidden */
  75502. _cleanControlAfterRemovalFromList(list: {
  75503. [pointerId: number]: Control;
  75504. }, control: Control): void;
  75505. /** @hidden */
  75506. _cleanControlAfterRemoval(control: Control): void;
  75507. /** Attach to all scene events required to support pointer events */
  75508. attach(): void;
  75509. /** @hidden */
  75510. private onClipboardCopy;
  75511. /** @hidden */
  75512. private onClipboardCut;
  75513. /** @hidden */
  75514. private onClipboardPaste;
  75515. /**
  75516. * Register the clipboard Events onto the canvas
  75517. */
  75518. registerClipboardEvents(): void;
  75519. /**
  75520. * Unregister the clipboard Events from the canvas
  75521. */
  75522. unRegisterClipboardEvents(): void;
  75523. /**
  75524. * Connect the texture to a hosting mesh to enable interactions
  75525. * @param mesh defines the mesh to attach to
  75526. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  75527. */
  75528. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  75529. /**
  75530. * Move the focus to a specific control
  75531. * @param control defines the control which will receive the focus
  75532. */
  75533. moveFocusToControl(control: IFocusableControl): void;
  75534. private _manageFocus;
  75535. private _attachToOnPointerOut;
  75536. /**
  75537. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  75538. * @param mesh defines the mesh which will receive the texture
  75539. * @param width defines the texture width (1024 by default)
  75540. * @param height defines the texture height (1024 by default)
  75541. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  75542. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  75543. * @returns a new AdvancedDynamicTexture
  75544. */
  75545. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  75546. /**
  75547. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  75548. * In this mode the texture will rely on a layer for its rendering.
  75549. * This allows it to be treated like any other layer.
  75550. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  75551. * LayerMask is set through advancedTexture.layer.layerMask
  75552. * @param name defines name for the texture
  75553. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  75554. * @param scene defines the hsoting scene
  75555. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  75556. * @returns a new AdvancedDynamicTexture
  75557. */
  75558. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  75559. }
  75560. }
  75561. declare module BABYLON.GUI {
  75562. /**
  75563. * Root class used for all 2D controls
  75564. * @see https://doc.babylonjs.com/how_to/gui#controls
  75565. */
  75566. export class Control {
  75567. /** defines the name of the control */
  75568. name?: string | undefined;
  75569. /**
  75570. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  75571. */
  75572. static AllowAlphaInheritance: boolean;
  75573. private _alpha;
  75574. private _alphaSet;
  75575. private _zIndex;
  75576. /** @hidden */
  75577. _host: AdvancedDynamicTexture;
  75578. /** Gets or sets the control parent */
  75579. parent: BABYLON.Nullable<Container>;
  75580. /** @hidden */
  75581. _currentMeasure: Measure;
  75582. private _fontFamily;
  75583. private _fontStyle;
  75584. private _fontWeight;
  75585. private _fontSize;
  75586. private _font;
  75587. /** @hidden */
  75588. _width: ValueAndUnit;
  75589. /** @hidden */
  75590. _height: ValueAndUnit;
  75591. /** @hidden */
  75592. protected _fontOffset: {
  75593. ascent: number;
  75594. height: number;
  75595. descent: number;
  75596. };
  75597. private _color;
  75598. private _style;
  75599. private _styleObserver;
  75600. /** @hidden */
  75601. protected _horizontalAlignment: number;
  75602. /** @hidden */
  75603. protected _verticalAlignment: number;
  75604. /** @hidden */
  75605. protected _isDirty: boolean;
  75606. /** @hidden */
  75607. protected _wasDirty: boolean;
  75608. /** @hidden */
  75609. _tempParentMeasure: Measure;
  75610. /** @hidden */
  75611. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  75612. /** @hidden */
  75613. protected _cachedParentMeasure: Measure;
  75614. private _paddingLeft;
  75615. private _paddingRight;
  75616. private _paddingTop;
  75617. private _paddingBottom;
  75618. /** @hidden */
  75619. _left: ValueAndUnit;
  75620. /** @hidden */
  75621. _top: ValueAndUnit;
  75622. private _scaleX;
  75623. private _scaleY;
  75624. private _rotation;
  75625. private _transformCenterX;
  75626. private _transformCenterY;
  75627. /** @hidden */
  75628. _transformMatrix: Matrix2D;
  75629. /** @hidden */
  75630. protected _invertTransformMatrix: Matrix2D;
  75631. /** @hidden */
  75632. protected _transformedPosition: BABYLON.Vector2;
  75633. private _isMatrixDirty;
  75634. private _cachedOffsetX;
  75635. private _cachedOffsetY;
  75636. private _isVisible;
  75637. private _isHighlighted;
  75638. /** @hidden */
  75639. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  75640. private _fontSet;
  75641. private _dummyVector2;
  75642. private _downCount;
  75643. private _enterCount;
  75644. private _doNotRender;
  75645. private _downPointerIds;
  75646. protected _isEnabled: boolean;
  75647. protected _disabledColor: string;
  75648. protected _disabledColorItem: string;
  75649. /** @hidden */
  75650. protected _rebuildLayout: boolean;
  75651. /** @hidden */
  75652. _customData: any;
  75653. /** @hidden */
  75654. _isClipped: boolean;
  75655. /** @hidden */
  75656. _automaticSize: boolean;
  75657. /** @hidden */
  75658. _tag: any;
  75659. /**
  75660. * 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
  75661. */
  75662. uniqueId: number;
  75663. /**
  75664. * Gets or sets an object used to store user defined information for the node
  75665. */
  75666. metadata: any;
  75667. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  75668. isHitTestVisible: boolean;
  75669. /** Gets or sets a boolean indicating if the control can block pointer events */
  75670. isPointerBlocker: boolean;
  75671. /** Gets or sets a boolean indicating if the control can be focusable */
  75672. isFocusInvisible: boolean;
  75673. /**
  75674. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  75675. * 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
  75676. */
  75677. clipChildren: boolean;
  75678. /**
  75679. * Gets or sets a boolean indicating that control content must be clipped
  75680. * 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
  75681. */
  75682. clipContent: boolean;
  75683. /**
  75684. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  75685. */
  75686. useBitmapCache: boolean;
  75687. private _cacheData;
  75688. private _shadowOffsetX;
  75689. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  75690. get shadowOffsetX(): number;
  75691. set shadowOffsetX(value: number);
  75692. private _shadowOffsetY;
  75693. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  75694. get shadowOffsetY(): number;
  75695. set shadowOffsetY(value: number);
  75696. private _shadowBlur;
  75697. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  75698. get shadowBlur(): number;
  75699. set shadowBlur(value: number);
  75700. private _shadowColor;
  75701. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  75702. get shadowColor(): string;
  75703. set shadowColor(value: string);
  75704. /** Gets or sets the cursor to use when the control is hovered */
  75705. hoverCursor: string;
  75706. /** @hidden */
  75707. protected _linkOffsetX: ValueAndUnit;
  75708. /** @hidden */
  75709. protected _linkOffsetY: ValueAndUnit;
  75710. /** Gets the control type name */
  75711. get typeName(): string;
  75712. /**
  75713. * Get the current class name of the control.
  75714. * @returns current class name
  75715. */
  75716. getClassName(): string;
  75717. /**
  75718. * An event triggered when pointer wheel is scrolled
  75719. */
  75720. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  75721. /**
  75722. * An event triggered when the pointer move over the control.
  75723. */
  75724. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  75725. /**
  75726. * An event triggered when the pointer move out of the control.
  75727. */
  75728. onPointerOutObservable: BABYLON.Observable<Control>;
  75729. /**
  75730. * An event triggered when the pointer taps the control
  75731. */
  75732. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  75733. /**
  75734. * An event triggered when pointer up
  75735. */
  75736. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  75737. /**
  75738. * An event triggered when a control is clicked on
  75739. */
  75740. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  75741. /**
  75742. * An event triggered when pointer enters the control
  75743. */
  75744. onPointerEnterObservable: BABYLON.Observable<Control>;
  75745. /**
  75746. * An event triggered when the control is marked as dirty
  75747. */
  75748. onDirtyObservable: BABYLON.Observable<Control>;
  75749. /**
  75750. * An event triggered before drawing the control
  75751. */
  75752. onBeforeDrawObservable: BABYLON.Observable<Control>;
  75753. /**
  75754. * An event triggered after the control was drawn
  75755. */
  75756. onAfterDrawObservable: BABYLON.Observable<Control>;
  75757. /**
  75758. * An event triggered when the control has been disposed
  75759. */
  75760. onDisposeObservable: BABYLON.Observable<Control>;
  75761. /**
  75762. * Get the hosting AdvancedDynamicTexture
  75763. */
  75764. get host(): AdvancedDynamicTexture;
  75765. /** Gets or set information about font offsets (used to render and align text) */
  75766. get fontOffset(): {
  75767. ascent: number;
  75768. height: number;
  75769. descent: number;
  75770. };
  75771. set fontOffset(offset: {
  75772. ascent: number;
  75773. height: number;
  75774. descent: number;
  75775. });
  75776. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  75777. get alpha(): number;
  75778. set alpha(value: number);
  75779. /**
  75780. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  75781. */
  75782. get isHighlighted(): boolean;
  75783. set isHighlighted(value: boolean);
  75784. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  75785. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75786. */
  75787. get scaleX(): number;
  75788. set scaleX(value: number);
  75789. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  75790. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75791. */
  75792. get scaleY(): number;
  75793. set scaleY(value: number);
  75794. /** Gets or sets the rotation angle (0 by default)
  75795. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75796. */
  75797. get rotation(): number;
  75798. set rotation(value: number);
  75799. /** Gets or sets the transformation center on Y axis (0 by default)
  75800. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75801. */
  75802. get transformCenterY(): number;
  75803. set transformCenterY(value: number);
  75804. /** Gets or sets the transformation center on X axis (0 by default)
  75805. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75806. */
  75807. get transformCenterX(): number;
  75808. set transformCenterX(value: number);
  75809. /**
  75810. * Gets or sets the horizontal alignment
  75811. * @see https://doc.babylonjs.com/how_to/gui#alignments
  75812. */
  75813. get horizontalAlignment(): number;
  75814. set horizontalAlignment(value: number);
  75815. /**
  75816. * Gets or sets the vertical alignment
  75817. * @see https://doc.babylonjs.com/how_to/gui#alignments
  75818. */
  75819. get verticalAlignment(): number;
  75820. set verticalAlignment(value: number);
  75821. /**
  75822. * Gets or sets control width
  75823. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75824. */
  75825. get width(): string | number;
  75826. set width(value: string | number);
  75827. /**
  75828. * Gets or sets the control width in pixel
  75829. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75830. */
  75831. get widthInPixels(): number;
  75832. set widthInPixels(value: number);
  75833. /**
  75834. * Gets or sets control height
  75835. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75836. */
  75837. get height(): string | number;
  75838. set height(value: string | number);
  75839. /**
  75840. * Gets or sets control height in pixel
  75841. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75842. */
  75843. get heightInPixels(): number;
  75844. set heightInPixels(value: number);
  75845. /** Gets or set font family */
  75846. get fontFamily(): string;
  75847. set fontFamily(value: string);
  75848. /** Gets or sets font style */
  75849. get fontStyle(): string;
  75850. set fontStyle(value: string);
  75851. /** Gets or sets font weight */
  75852. get fontWeight(): string;
  75853. set fontWeight(value: string);
  75854. /**
  75855. * Gets or sets style
  75856. * @see https://doc.babylonjs.com/how_to/gui#styles
  75857. */
  75858. get style(): BABYLON.Nullable<Style>;
  75859. set style(value: BABYLON.Nullable<Style>);
  75860. /** @hidden */
  75861. get _isFontSizeInPercentage(): boolean;
  75862. /** Gets or sets font size in pixels */
  75863. get fontSizeInPixels(): number;
  75864. set fontSizeInPixels(value: number);
  75865. /** Gets or sets font size */
  75866. get fontSize(): string | number;
  75867. set fontSize(value: string | number);
  75868. /** Gets or sets foreground color */
  75869. get color(): string;
  75870. set color(value: string);
  75871. /** Gets or sets z index which is used to reorder controls on the z axis */
  75872. get zIndex(): number;
  75873. set zIndex(value: number);
  75874. /** Gets or sets a boolean indicating if the control can be rendered */
  75875. get notRenderable(): boolean;
  75876. set notRenderable(value: boolean);
  75877. /** Gets or sets a boolean indicating if the control is visible */
  75878. get isVisible(): boolean;
  75879. set isVisible(value: boolean);
  75880. /** Gets a boolean indicating that the control needs to update its rendering */
  75881. get isDirty(): boolean;
  75882. /**
  75883. * Gets the current linked mesh (or null if none)
  75884. */
  75885. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  75886. /**
  75887. * Gets or sets a value indicating the padding to use on the left of the control
  75888. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75889. */
  75890. get paddingLeft(): string | number;
  75891. set paddingLeft(value: string | number);
  75892. /**
  75893. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  75894. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75895. */
  75896. get paddingLeftInPixels(): number;
  75897. set paddingLeftInPixels(value: number);
  75898. /**
  75899. * Gets or sets a value indicating the padding to use on the right of the control
  75900. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75901. */
  75902. get paddingRight(): string | number;
  75903. set paddingRight(value: string | number);
  75904. /**
  75905. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  75906. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75907. */
  75908. get paddingRightInPixels(): number;
  75909. set paddingRightInPixels(value: number);
  75910. /**
  75911. * Gets or sets a value indicating the padding to use on the top of the control
  75912. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75913. */
  75914. get paddingTop(): string | number;
  75915. set paddingTop(value: string | number);
  75916. /**
  75917. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  75918. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75919. */
  75920. get paddingTopInPixels(): number;
  75921. set paddingTopInPixels(value: number);
  75922. /**
  75923. * Gets or sets a value indicating the padding to use on the bottom of the control
  75924. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75925. */
  75926. get paddingBottom(): string | number;
  75927. set paddingBottom(value: string | number);
  75928. /**
  75929. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  75930. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75931. */
  75932. get paddingBottomInPixels(): number;
  75933. set paddingBottomInPixels(value: number);
  75934. /**
  75935. * Gets or sets a value indicating the left coordinate of the control
  75936. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75937. */
  75938. get left(): string | number;
  75939. set left(value: string | number);
  75940. /**
  75941. * Gets or sets a value indicating the left coordinate in pixels of the control
  75942. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75943. */
  75944. get leftInPixels(): number;
  75945. set leftInPixels(value: number);
  75946. /**
  75947. * Gets or sets a value indicating the top coordinate of the control
  75948. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75949. */
  75950. get top(): string | number;
  75951. set top(value: string | number);
  75952. /**
  75953. * Gets or sets a value indicating the top coordinate in pixels of the control
  75954. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75955. */
  75956. get topInPixels(): number;
  75957. set topInPixels(value: number);
  75958. /**
  75959. * Gets or sets a value indicating the offset on X axis to the linked mesh
  75960. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  75961. */
  75962. get linkOffsetX(): string | number;
  75963. set linkOffsetX(value: string | number);
  75964. /**
  75965. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  75966. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  75967. */
  75968. get linkOffsetXInPixels(): number;
  75969. set linkOffsetXInPixels(value: number);
  75970. /**
  75971. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  75972. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  75973. */
  75974. get linkOffsetY(): string | number;
  75975. set linkOffsetY(value: string | number);
  75976. /**
  75977. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  75978. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  75979. */
  75980. get linkOffsetYInPixels(): number;
  75981. set linkOffsetYInPixels(value: number);
  75982. /** Gets the center coordinate on X axis */
  75983. get centerX(): number;
  75984. /** Gets the center coordinate on Y axis */
  75985. get centerY(): number;
  75986. /** Gets or sets if control is Enabled*/
  75987. get isEnabled(): boolean;
  75988. set isEnabled(value: boolean);
  75989. /** Gets or sets background color of control if it's disabled*/
  75990. get disabledColor(): string;
  75991. set disabledColor(value: string);
  75992. /** Gets or sets front color of control if it's disabled*/
  75993. get disabledColorItem(): string;
  75994. set disabledColorItem(value: string);
  75995. /**
  75996. * Creates a new control
  75997. * @param name defines the name of the control
  75998. */
  75999. constructor(
  76000. /** defines the name of the control */
  76001. name?: string | undefined);
  76002. /** @hidden */
  76003. protected _getTypeName(): string;
  76004. /**
  76005. * Gets the first ascendant in the hierarchy of the given type
  76006. * @param className defines the required type
  76007. * @returns the ascendant or null if not found
  76008. */
  76009. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  76010. /** @hidden */
  76011. _resetFontCache(): void;
  76012. /**
  76013. * Determines if a container is an ascendant of the current control
  76014. * @param container defines the container to look for
  76015. * @returns true if the container is one of the ascendant of the control
  76016. */
  76017. isAscendant(container: Control): boolean;
  76018. /**
  76019. * Gets coordinates in local control space
  76020. * @param globalCoordinates defines the coordinates to transform
  76021. * @returns the new coordinates in local space
  76022. */
  76023. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  76024. /**
  76025. * Gets coordinates in local control space
  76026. * @param globalCoordinates defines the coordinates to transform
  76027. * @param result defines the target vector2 where to store the result
  76028. * @returns the current control
  76029. */
  76030. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  76031. /**
  76032. * Gets coordinates in parent local control space
  76033. * @param globalCoordinates defines the coordinates to transform
  76034. * @returns the new coordinates in parent local space
  76035. */
  76036. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  76037. /**
  76038. * Move the current control to a vector3 position projected onto the screen.
  76039. * @param position defines the target position
  76040. * @param scene defines the hosting scene
  76041. */
  76042. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  76043. /**
  76044. * Will store all controls that have this control as ascendant in a given array
  76045. * @param results defines the array where to store the descendants
  76046. * @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
  76047. * @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
  76048. */
  76049. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  76050. /**
  76051. * Will return all controls that have this control as ascendant
  76052. * @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
  76053. * @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
  76054. * @return all child controls
  76055. */
  76056. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  76057. /**
  76058. * Link current control with a target mesh
  76059. * @param mesh defines the mesh to link with
  76060. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  76061. */
  76062. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  76063. /** @hidden */
  76064. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  76065. /** @hidden */
  76066. _offsetLeft(offset: number): void;
  76067. /** @hidden */
  76068. _offsetTop(offset: number): void;
  76069. /** @hidden */
  76070. _markMatrixAsDirty(): void;
  76071. /** @hidden */
  76072. _flagDescendantsAsMatrixDirty(): void;
  76073. /** @hidden */
  76074. _intersectsRect(rect: Measure): boolean;
  76075. /** @hidden */
  76076. protected invalidateRect(): void;
  76077. /** @hidden */
  76078. _markAsDirty(force?: boolean): void;
  76079. /** @hidden */
  76080. _markAllAsDirty(): void;
  76081. /** @hidden */
  76082. _link(host: AdvancedDynamicTexture): void;
  76083. /** @hidden */
  76084. protected _transform(context?: CanvasRenderingContext2D): void;
  76085. /** @hidden */
  76086. _renderHighlight(context: CanvasRenderingContext2D): void;
  76087. /** @hidden */
  76088. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  76089. /** @hidden */
  76090. protected _applyStates(context: CanvasRenderingContext2D): void;
  76091. /** @hidden */
  76092. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  76093. /** @hidden */
  76094. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76095. protected _evaluateClippingState(parentMeasure: Measure): void;
  76096. /** @hidden */
  76097. _measure(): void;
  76098. /** @hidden */
  76099. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76100. /** @hidden */
  76101. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76102. /** @hidden */
  76103. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76104. /** @hidden */
  76105. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  76106. private static _ClipMeasure;
  76107. private _tmpMeasureA;
  76108. private _clip;
  76109. /** @hidden */
  76110. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  76111. /** @hidden */
  76112. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76113. /**
  76114. * Tests if a given coordinates belong to the current control
  76115. * @param x defines x coordinate to test
  76116. * @param y defines y coordinate to test
  76117. * @returns true if the coordinates are inside the control
  76118. */
  76119. contains(x: number, y: number): boolean;
  76120. /** @hidden */
  76121. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76122. /** @hidden */
  76123. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76124. /** @hidden */
  76125. _onPointerEnter(target: Control): boolean;
  76126. /** @hidden */
  76127. _onPointerOut(target: Control, force?: boolean): void;
  76128. /** @hidden */
  76129. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76130. /** @hidden */
  76131. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76132. /** @hidden */
  76133. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  76134. /** @hidden */
  76135. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  76136. /** @hidden */
  76137. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76138. private _prepareFont;
  76139. /** Releases associated resources */
  76140. dispose(): void;
  76141. private static _HORIZONTAL_ALIGNMENT_LEFT;
  76142. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  76143. private static _HORIZONTAL_ALIGNMENT_CENTER;
  76144. private static _VERTICAL_ALIGNMENT_TOP;
  76145. private static _VERTICAL_ALIGNMENT_BOTTOM;
  76146. private static _VERTICAL_ALIGNMENT_CENTER;
  76147. /** HORIZONTAL_ALIGNMENT_LEFT */
  76148. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  76149. /** HORIZONTAL_ALIGNMENT_RIGHT */
  76150. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  76151. /** HORIZONTAL_ALIGNMENT_CENTER */
  76152. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  76153. /** VERTICAL_ALIGNMENT_TOP */
  76154. static get VERTICAL_ALIGNMENT_TOP(): number;
  76155. /** VERTICAL_ALIGNMENT_BOTTOM */
  76156. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  76157. /** VERTICAL_ALIGNMENT_CENTER */
  76158. static get VERTICAL_ALIGNMENT_CENTER(): number;
  76159. private static _FontHeightSizes;
  76160. /** @hidden */
  76161. static _GetFontOffset(font: string): {
  76162. ascent: number;
  76163. height: number;
  76164. descent: number;
  76165. };
  76166. /**
  76167. * Creates a stack panel that can be used to render headers
  76168. * @param control defines the control to associate with the header
  76169. * @param text defines the text of the header
  76170. * @param size defines the size of the header
  76171. * @param options defines options used to configure the header
  76172. * @returns a new StackPanel
  76173. * @ignore
  76174. * @hidden
  76175. */
  76176. static AddHeader: (control: Control, text: string, size: string | number, options: {
  76177. isHorizontal: boolean;
  76178. controlFirst: boolean;
  76179. }) => any;
  76180. /** @hidden */
  76181. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  76182. }
  76183. }
  76184. declare module BABYLON.GUI {
  76185. /**
  76186. * Root class for 2D containers
  76187. * @see https://doc.babylonjs.com/how_to/gui#containers
  76188. */
  76189. export class Container extends Control {
  76190. name?: string | undefined;
  76191. /** @hidden */
  76192. _children: Control[];
  76193. /** @hidden */
  76194. protected _measureForChildren: Measure;
  76195. /** @hidden */
  76196. protected _background: string;
  76197. /** @hidden */
  76198. protected _adaptWidthToChildren: boolean;
  76199. /** @hidden */
  76200. protected _adaptHeightToChildren: boolean;
  76201. /**
  76202. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  76203. */
  76204. logLayoutCycleErrors: boolean;
  76205. /**
  76206. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  76207. */
  76208. maxLayoutCycle: number;
  76209. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  76210. get adaptHeightToChildren(): boolean;
  76211. set adaptHeightToChildren(value: boolean);
  76212. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  76213. get adaptWidthToChildren(): boolean;
  76214. set adaptWidthToChildren(value: boolean);
  76215. /** Gets or sets background color */
  76216. get background(): string;
  76217. set background(value: string);
  76218. /** Gets the list of children */
  76219. get children(): Control[];
  76220. /**
  76221. * Creates a new Container
  76222. * @param name defines the name of the container
  76223. */
  76224. constructor(name?: string | undefined);
  76225. protected _getTypeName(): string;
  76226. _flagDescendantsAsMatrixDirty(): void;
  76227. /**
  76228. * Gets a child using its name
  76229. * @param name defines the child name to look for
  76230. * @returns the child control if found
  76231. */
  76232. getChildByName(name: string): BABYLON.Nullable<Control>;
  76233. /**
  76234. * Gets a child using its type and its name
  76235. * @param name defines the child name to look for
  76236. * @param type defines the child type to look for
  76237. * @returns the child control if found
  76238. */
  76239. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  76240. /**
  76241. * Search for a specific control in children
  76242. * @param control defines the control to look for
  76243. * @returns true if the control is in child list
  76244. */
  76245. containsControl(control: Control): boolean;
  76246. /**
  76247. * Adds a new control to the current container
  76248. * @param control defines the control to add
  76249. * @returns the current container
  76250. */
  76251. addControl(control: BABYLON.Nullable<Control>): Container;
  76252. /**
  76253. * Removes all controls from the current container
  76254. * @returns the current container
  76255. */
  76256. clearControls(): Container;
  76257. /**
  76258. * Removes a control from the current container
  76259. * @param control defines the control to remove
  76260. * @returns the current container
  76261. */
  76262. removeControl(control: Control): Container;
  76263. /** @hidden */
  76264. _reOrderControl(control: Control): void;
  76265. /** @hidden */
  76266. _offsetLeft(offset: number): void;
  76267. /** @hidden */
  76268. _offsetTop(offset: number): void;
  76269. /** @hidden */
  76270. _markAllAsDirty(): void;
  76271. /** @hidden */
  76272. protected _localDraw(context: CanvasRenderingContext2D): void;
  76273. /** @hidden */
  76274. _link(host: AdvancedDynamicTexture): void;
  76275. /** @hidden */
  76276. protected _beforeLayout(): void;
  76277. /** @hidden */
  76278. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76279. /** @hidden */
  76280. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  76281. protected _postMeasure(): void;
  76282. /** @hidden */
  76283. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  76284. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  76285. /** @hidden */
  76286. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76287. /** @hidden */
  76288. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76289. /** Releases associated resources */
  76290. dispose(): void;
  76291. }
  76292. }
  76293. declare module BABYLON.GUI {
  76294. /** Class used to create rectangle container */
  76295. export class Rectangle extends Container {
  76296. name?: string | undefined;
  76297. private _thickness;
  76298. private _cornerRadius;
  76299. /** Gets or sets border thickness */
  76300. get thickness(): number;
  76301. set thickness(value: number);
  76302. /** Gets or sets the corner radius angle */
  76303. get cornerRadius(): number;
  76304. set cornerRadius(value: number);
  76305. /**
  76306. * Creates a new Rectangle
  76307. * @param name defines the control name
  76308. */
  76309. constructor(name?: string | undefined);
  76310. protected _getTypeName(): string;
  76311. protected _localDraw(context: CanvasRenderingContext2D): void;
  76312. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76313. private _drawRoundedRect;
  76314. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  76315. }
  76316. }
  76317. declare module BABYLON.GUI {
  76318. /**
  76319. * Enum that determines the text-wrapping mode to use.
  76320. */
  76321. export enum TextWrapping {
  76322. /**
  76323. * Clip the text when it's larger than Control.width; this is the default mode.
  76324. */
  76325. Clip = 0,
  76326. /**
  76327. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  76328. */
  76329. WordWrap = 1,
  76330. /**
  76331. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  76332. */
  76333. Ellipsis = 2
  76334. }
  76335. /**
  76336. * Class used to create text block control
  76337. */
  76338. export class TextBlock extends Control {
  76339. /**
  76340. * Defines the name of the control
  76341. */
  76342. name?: string | undefined;
  76343. private _text;
  76344. private _textWrapping;
  76345. private _textHorizontalAlignment;
  76346. private _textVerticalAlignment;
  76347. private _lines;
  76348. private _resizeToFit;
  76349. private _lineSpacing;
  76350. private _outlineWidth;
  76351. private _outlineColor;
  76352. /**
  76353. * An event triggered after the text is changed
  76354. */
  76355. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  76356. /**
  76357. * An event triggered after the text was broken up into lines
  76358. */
  76359. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  76360. /**
  76361. * Function used to split a string into words. By default, a string is split at each space character found
  76362. */
  76363. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  76364. /**
  76365. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  76366. */
  76367. get lines(): any[];
  76368. /**
  76369. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  76370. */
  76371. get resizeToFit(): boolean;
  76372. /**
  76373. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  76374. */
  76375. set resizeToFit(value: boolean);
  76376. /**
  76377. * Gets or sets a boolean indicating if text must be wrapped
  76378. */
  76379. get textWrapping(): TextWrapping | boolean;
  76380. /**
  76381. * Gets or sets a boolean indicating if text must be wrapped
  76382. */
  76383. set textWrapping(value: TextWrapping | boolean);
  76384. /**
  76385. * Gets or sets text to display
  76386. */
  76387. get text(): string;
  76388. /**
  76389. * Gets or sets text to display
  76390. */
  76391. set text(value: string);
  76392. /**
  76393. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  76394. */
  76395. get textHorizontalAlignment(): number;
  76396. /**
  76397. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  76398. */
  76399. set textHorizontalAlignment(value: number);
  76400. /**
  76401. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  76402. */
  76403. get textVerticalAlignment(): number;
  76404. /**
  76405. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  76406. */
  76407. set textVerticalAlignment(value: number);
  76408. /**
  76409. * Gets or sets line spacing value
  76410. */
  76411. set lineSpacing(value: string | number);
  76412. /**
  76413. * Gets or sets line spacing value
  76414. */
  76415. get lineSpacing(): string | number;
  76416. /**
  76417. * Gets or sets outlineWidth of the text to display
  76418. */
  76419. get outlineWidth(): number;
  76420. /**
  76421. * Gets or sets outlineWidth of the text to display
  76422. */
  76423. set outlineWidth(value: number);
  76424. /**
  76425. * Gets or sets outlineColor of the text to display
  76426. */
  76427. get outlineColor(): string;
  76428. /**
  76429. * Gets or sets outlineColor of the text to display
  76430. */
  76431. set outlineColor(value: string);
  76432. /**
  76433. * Creates a new TextBlock object
  76434. * @param name defines the name of the control
  76435. * @param text defines the text to display (emptry string by default)
  76436. */
  76437. constructor(
  76438. /**
  76439. * Defines the name of the control
  76440. */
  76441. name?: string | undefined, text?: string);
  76442. protected _getTypeName(): string;
  76443. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76444. private _drawText;
  76445. /** @hidden */
  76446. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76447. protected _applyStates(context: CanvasRenderingContext2D): void;
  76448. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  76449. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  76450. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  76451. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  76452. protected _renderLines(context: CanvasRenderingContext2D): void;
  76453. /**
  76454. * Given a width constraint applied on the text block, find the expected height
  76455. * @returns expected height
  76456. */
  76457. computeExpectedHeight(): number;
  76458. dispose(): void;
  76459. }
  76460. }
  76461. declare module BABYLON.GUI {
  76462. /**
  76463. * Class used to create 2D images
  76464. */
  76465. export class Image extends Control {
  76466. name?: string | undefined;
  76467. private _workingCanvas;
  76468. private _domImage;
  76469. private _imageWidth;
  76470. private _imageHeight;
  76471. private _loaded;
  76472. private _stretch;
  76473. private _source;
  76474. private _autoScale;
  76475. private _sourceLeft;
  76476. private _sourceTop;
  76477. private _sourceWidth;
  76478. private _sourceHeight;
  76479. private _svgAttributesComputationCompleted;
  76480. private _isSVG;
  76481. private _cellWidth;
  76482. private _cellHeight;
  76483. private _cellId;
  76484. private _populateNinePatchSlicesFromImage;
  76485. private _sliceLeft;
  76486. private _sliceRight;
  76487. private _sliceTop;
  76488. private _sliceBottom;
  76489. private _detectPointerOnOpaqueOnly;
  76490. /**
  76491. * BABYLON.Observable notified when the content is loaded
  76492. */
  76493. onImageLoadedObservable: BABYLON.Observable<Image>;
  76494. /**
  76495. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  76496. */
  76497. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  76498. /**
  76499. * Gets a boolean indicating that the content is loaded
  76500. */
  76501. get isLoaded(): boolean;
  76502. /**
  76503. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  76504. */
  76505. get populateNinePatchSlicesFromImage(): boolean;
  76506. set populateNinePatchSlicesFromImage(value: boolean);
  76507. /**
  76508. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  76509. * Beware using this as this will comsume more memory as the image has to be stored twice
  76510. */
  76511. get detectPointerOnOpaqueOnly(): boolean;
  76512. set detectPointerOnOpaqueOnly(value: boolean);
  76513. /**
  76514. * Gets or sets the left value for slicing (9-patch)
  76515. */
  76516. get sliceLeft(): number;
  76517. set sliceLeft(value: number);
  76518. /**
  76519. * Gets or sets the right value for slicing (9-patch)
  76520. */
  76521. get sliceRight(): number;
  76522. set sliceRight(value: number);
  76523. /**
  76524. * Gets or sets the top value for slicing (9-patch)
  76525. */
  76526. get sliceTop(): number;
  76527. set sliceTop(value: number);
  76528. /**
  76529. * Gets or sets the bottom value for slicing (9-patch)
  76530. */
  76531. get sliceBottom(): number;
  76532. set sliceBottom(value: number);
  76533. /**
  76534. * Gets or sets the left coordinate in the source image
  76535. */
  76536. get sourceLeft(): number;
  76537. set sourceLeft(value: number);
  76538. /**
  76539. * Gets or sets the top coordinate in the source image
  76540. */
  76541. get sourceTop(): number;
  76542. set sourceTop(value: number);
  76543. /**
  76544. * Gets or sets the width to capture in the source image
  76545. */
  76546. get sourceWidth(): number;
  76547. set sourceWidth(value: number);
  76548. /**
  76549. * Gets or sets the height to capture in the source image
  76550. */
  76551. get sourceHeight(): number;
  76552. set sourceHeight(value: number);
  76553. /** Indicates if the format of the image is SVG */
  76554. get isSVG(): boolean;
  76555. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  76556. get svgAttributesComputationCompleted(): boolean;
  76557. /**
  76558. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  76559. * @see https://doc.babylonjs.com/how_to/gui#image
  76560. */
  76561. get autoScale(): boolean;
  76562. set autoScale(value: boolean);
  76563. /** Gets or sets the streching mode used by the image */
  76564. get stretch(): number;
  76565. set stretch(value: number);
  76566. /** @hidden */
  76567. _rotate90(n: number, preserveProperties?: boolean): Image;
  76568. private _handleRotationForSVGImage;
  76569. private _rotate90SourceProperties;
  76570. /**
  76571. * Gets or sets the internal DOM image used to render the control
  76572. */
  76573. set domImage(value: HTMLImageElement);
  76574. get domImage(): HTMLImageElement;
  76575. private _onImageLoaded;
  76576. private _extractNinePatchSliceDataFromImage;
  76577. /**
  76578. * Gets or sets image source url
  76579. */
  76580. set source(value: BABYLON.Nullable<string>);
  76581. /**
  76582. * Checks for svg document with icon id present
  76583. */
  76584. private _svgCheck;
  76585. /**
  76586. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  76587. * given external svg file and icon id
  76588. */
  76589. private _getSVGAttribs;
  76590. /**
  76591. * Gets or sets the cell width to use when animation sheet is enabled
  76592. * @see https://doc.babylonjs.com/how_to/gui#image
  76593. */
  76594. get cellWidth(): number;
  76595. set cellWidth(value: number);
  76596. /**
  76597. * Gets or sets the cell height to use when animation sheet is enabled
  76598. * @see https://doc.babylonjs.com/how_to/gui#image
  76599. */
  76600. get cellHeight(): number;
  76601. set cellHeight(value: number);
  76602. /**
  76603. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  76604. * @see https://doc.babylonjs.com/how_to/gui#image
  76605. */
  76606. get cellId(): number;
  76607. set cellId(value: number);
  76608. /**
  76609. * Creates a new Image
  76610. * @param name defines the control name
  76611. * @param url defines the image url
  76612. */
  76613. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  76614. /**
  76615. * Tests if a given coordinates belong to the current control
  76616. * @param x defines x coordinate to test
  76617. * @param y defines y coordinate to test
  76618. * @returns true if the coordinates are inside the control
  76619. */
  76620. contains(x: number, y: number): boolean;
  76621. protected _getTypeName(): string;
  76622. /** Force the control to synchronize with its content */
  76623. synchronizeSizeWithContent(): void;
  76624. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76625. private _prepareWorkingCanvasForOpaqueDetection;
  76626. private _drawImage;
  76627. _draw(context: CanvasRenderingContext2D): void;
  76628. private _renderCornerPatch;
  76629. private _renderNinePatch;
  76630. dispose(): void;
  76631. /** STRETCH_NONE */
  76632. static readonly STRETCH_NONE: number;
  76633. /** STRETCH_FILL */
  76634. static readonly STRETCH_FILL: number;
  76635. /** STRETCH_UNIFORM */
  76636. static readonly STRETCH_UNIFORM: number;
  76637. /** STRETCH_EXTEND */
  76638. static readonly STRETCH_EXTEND: number;
  76639. /** NINE_PATCH */
  76640. static readonly STRETCH_NINE_PATCH: number;
  76641. }
  76642. }
  76643. declare module BABYLON.GUI {
  76644. /**
  76645. * Class used to create 2D buttons
  76646. */
  76647. export class Button extends Rectangle {
  76648. name?: string | undefined;
  76649. /**
  76650. * Function called to generate a pointer enter animation
  76651. */
  76652. pointerEnterAnimation: () => void;
  76653. /**
  76654. * Function called to generate a pointer out animation
  76655. */
  76656. pointerOutAnimation: () => void;
  76657. /**
  76658. * Function called to generate a pointer down animation
  76659. */
  76660. pointerDownAnimation: () => void;
  76661. /**
  76662. * Function called to generate a pointer up animation
  76663. */
  76664. pointerUpAnimation: () => void;
  76665. /**
  76666. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  76667. */
  76668. delegatePickingToChildren: boolean;
  76669. private _image;
  76670. /**
  76671. * Returns the image part of the button (if any)
  76672. */
  76673. get image(): BABYLON.Nullable<Image>;
  76674. private _textBlock;
  76675. /**
  76676. * Returns the image part of the button (if any)
  76677. */
  76678. get textBlock(): BABYLON.Nullable<TextBlock>;
  76679. /**
  76680. * Creates a new Button
  76681. * @param name defines the name of the button
  76682. */
  76683. constructor(name?: string | undefined);
  76684. protected _getTypeName(): string;
  76685. /** @hidden */
  76686. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76687. /** @hidden */
  76688. _onPointerEnter(target: Control): boolean;
  76689. /** @hidden */
  76690. _onPointerOut(target: Control, force?: boolean): void;
  76691. /** @hidden */
  76692. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76693. /** @hidden */
  76694. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76695. /**
  76696. * Creates a new button made with an image and a text
  76697. * @param name defines the name of the button
  76698. * @param text defines the text of the button
  76699. * @param imageUrl defines the url of the image
  76700. * @returns a new Button
  76701. */
  76702. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  76703. /**
  76704. * Creates a new button made with an image
  76705. * @param name defines the name of the button
  76706. * @param imageUrl defines the url of the image
  76707. * @returns a new Button
  76708. */
  76709. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  76710. /**
  76711. * Creates a new button made with a text
  76712. * @param name defines the name of the button
  76713. * @param text defines the text of the button
  76714. * @returns a new Button
  76715. */
  76716. static CreateSimpleButton(name: string, text: string): Button;
  76717. /**
  76718. * Creates a new button made with an image and a centered text
  76719. * @param name defines the name of the button
  76720. * @param text defines the text of the button
  76721. * @param imageUrl defines the url of the image
  76722. * @returns a new Button
  76723. */
  76724. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  76725. }
  76726. }
  76727. declare module BABYLON.GUI {
  76728. /**
  76729. * Class used to create a 2D stack panel container
  76730. */
  76731. export class StackPanel extends Container {
  76732. name?: string | undefined;
  76733. private _isVertical;
  76734. private _manualWidth;
  76735. private _manualHeight;
  76736. private _doNotTrackManualChanges;
  76737. /**
  76738. * Gets or sets a boolean indicating that layou warnings should be ignored
  76739. */
  76740. ignoreLayoutWarnings: boolean;
  76741. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  76742. get isVertical(): boolean;
  76743. set isVertical(value: boolean);
  76744. /**
  76745. * Gets or sets panel width.
  76746. * This value should not be set when in horizontal mode as it will be computed automatically
  76747. */
  76748. set width(value: string | number);
  76749. get width(): string | number;
  76750. /**
  76751. * Gets or sets panel height.
  76752. * This value should not be set when in vertical mode as it will be computed automatically
  76753. */
  76754. set height(value: string | number);
  76755. get height(): string | number;
  76756. /**
  76757. * Creates a new StackPanel
  76758. * @param name defines control name
  76759. */
  76760. constructor(name?: string | undefined);
  76761. protected _getTypeName(): string;
  76762. /** @hidden */
  76763. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76764. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76765. protected _postMeasure(): void;
  76766. }
  76767. }
  76768. declare module BABYLON.GUI {
  76769. /**
  76770. * Class used to represent a 2D checkbox
  76771. */
  76772. export class Checkbox extends Control {
  76773. name?: string | undefined;
  76774. private _isChecked;
  76775. private _background;
  76776. private _checkSizeRatio;
  76777. private _thickness;
  76778. /** Gets or sets border thickness */
  76779. get thickness(): number;
  76780. set thickness(value: number);
  76781. /**
  76782. * BABYLON.Observable raised when isChecked property changes
  76783. */
  76784. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  76785. /** Gets or sets a value indicating the ratio between overall size and check size */
  76786. get checkSizeRatio(): number;
  76787. set checkSizeRatio(value: number);
  76788. /** Gets or sets background color */
  76789. get background(): string;
  76790. set background(value: string);
  76791. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  76792. get isChecked(): boolean;
  76793. set isChecked(value: boolean);
  76794. /**
  76795. * Creates a new CheckBox
  76796. * @param name defines the control name
  76797. */
  76798. constructor(name?: string | undefined);
  76799. protected _getTypeName(): string;
  76800. /** @hidden */
  76801. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76802. /** @hidden */
  76803. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76804. /**
  76805. * Utility function to easily create a checkbox with a header
  76806. * @param title defines the label to use for the header
  76807. * @param onValueChanged defines the callback to call when value changes
  76808. * @returns a StackPanel containing the checkbox and a textBlock
  76809. */
  76810. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  76811. }
  76812. }
  76813. declare module BABYLON.GUI {
  76814. /**
  76815. * Class used to store key control properties
  76816. */
  76817. export class KeyPropertySet {
  76818. /** Width */
  76819. width?: string;
  76820. /** Height */
  76821. height?: string;
  76822. /** Left padding */
  76823. paddingLeft?: string;
  76824. /** Right padding */
  76825. paddingRight?: string;
  76826. /** Top padding */
  76827. paddingTop?: string;
  76828. /** Bottom padding */
  76829. paddingBottom?: string;
  76830. /** Foreground color */
  76831. color?: string;
  76832. /** Background color */
  76833. background?: string;
  76834. }
  76835. /**
  76836. * Class used to create virtual keyboard
  76837. */
  76838. export class VirtualKeyboard extends StackPanel {
  76839. /** BABYLON.Observable raised when a key is pressed */
  76840. onKeyPressObservable: BABYLON.Observable<string>;
  76841. /** Gets or sets default key button width */
  76842. defaultButtonWidth: string;
  76843. /** Gets or sets default key button height */
  76844. defaultButtonHeight: string;
  76845. /** Gets or sets default key button left padding */
  76846. defaultButtonPaddingLeft: string;
  76847. /** Gets or sets default key button right padding */
  76848. defaultButtonPaddingRight: string;
  76849. /** Gets or sets default key button top padding */
  76850. defaultButtonPaddingTop: string;
  76851. /** Gets or sets default key button bottom padding */
  76852. defaultButtonPaddingBottom: string;
  76853. /** Gets or sets default key button foreground color */
  76854. defaultButtonColor: string;
  76855. /** Gets or sets default key button background color */
  76856. defaultButtonBackground: string;
  76857. /** Gets or sets shift button foreground color */
  76858. shiftButtonColor: string;
  76859. /** Gets or sets shift button thickness*/
  76860. selectedShiftThickness: number;
  76861. /** Gets shift key state */
  76862. shiftState: number;
  76863. protected _getTypeName(): string;
  76864. private _createKey;
  76865. /**
  76866. * Adds a new row of keys
  76867. * @param keys defines the list of keys to add
  76868. * @param propertySets defines the associated property sets
  76869. */
  76870. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  76871. /**
  76872. * Set the shift key to a specific state
  76873. * @param shiftState defines the new shift state
  76874. */
  76875. applyShiftState(shiftState: number): void;
  76876. private _currentlyConnectedInputText;
  76877. private _connectedInputTexts;
  76878. private _onKeyPressObserver;
  76879. /** Gets the input text control currently attached to the keyboard */
  76880. get connectedInputText(): BABYLON.Nullable<InputText>;
  76881. /**
  76882. * Connects the keyboard with an input text control
  76883. *
  76884. * @param input defines the target control
  76885. */
  76886. connect(input: InputText): void;
  76887. /**
  76888. * Disconnects the keyboard from connected InputText controls
  76889. *
  76890. * @param input optionally defines a target control, otherwise all are disconnected
  76891. */
  76892. disconnect(input?: InputText): void;
  76893. private _removeConnectedInputObservables;
  76894. /**
  76895. * Release all resources
  76896. */
  76897. dispose(): void;
  76898. /**
  76899. * Creates a new keyboard using a default layout
  76900. *
  76901. * @param name defines control name
  76902. * @returns a new VirtualKeyboard
  76903. */
  76904. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  76905. }
  76906. }
  76907. declare module BABYLON.GUI {
  76908. /**
  76909. * Class used to create input text control
  76910. */
  76911. export class InputText extends Control implements IFocusableControl {
  76912. name?: string | undefined;
  76913. private _text;
  76914. private _placeholderText;
  76915. private _background;
  76916. private _focusedBackground;
  76917. private _focusedColor;
  76918. private _placeholderColor;
  76919. private _thickness;
  76920. private _margin;
  76921. private _autoStretchWidth;
  76922. private _maxWidth;
  76923. private _isFocused;
  76924. private _blinkTimeout;
  76925. private _blinkIsEven;
  76926. private _cursorOffset;
  76927. private _scrollLeft;
  76928. private _textWidth;
  76929. private _clickedCoordinate;
  76930. private _deadKey;
  76931. private _addKey;
  76932. private _currentKey;
  76933. private _isTextHighlightOn;
  76934. private _textHighlightColor;
  76935. private _highligherOpacity;
  76936. private _highlightedText;
  76937. private _startHighlightIndex;
  76938. private _endHighlightIndex;
  76939. private _cursorIndex;
  76940. private _onFocusSelectAll;
  76941. private _isPointerDown;
  76942. private _onClipboardObserver;
  76943. private _onPointerDblTapObserver;
  76944. /** @hidden */
  76945. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  76946. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  76947. promptMessage: string;
  76948. /** Force disable prompt on mobile device */
  76949. disableMobilePrompt: boolean;
  76950. /** BABYLON.Observable raised when the text changes */
  76951. onTextChangedObservable: BABYLON.Observable<InputText>;
  76952. /** BABYLON.Observable raised just before an entered character is to be added */
  76953. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  76954. /** BABYLON.Observable raised when the control gets the focus */
  76955. onFocusObservable: BABYLON.Observable<InputText>;
  76956. /** BABYLON.Observable raised when the control loses the focus */
  76957. onBlurObservable: BABYLON.Observable<InputText>;
  76958. /**Observable raised when the text is highlighted */
  76959. onTextHighlightObservable: BABYLON.Observable<InputText>;
  76960. /**Observable raised when copy event is triggered */
  76961. onTextCopyObservable: BABYLON.Observable<InputText>;
  76962. /** BABYLON.Observable raised when cut event is triggered */
  76963. onTextCutObservable: BABYLON.Observable<InputText>;
  76964. /** BABYLON.Observable raised when paste event is triggered */
  76965. onTextPasteObservable: BABYLON.Observable<InputText>;
  76966. /** BABYLON.Observable raised when a key event was processed */
  76967. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  76968. /** Gets or sets the maximum width allowed by the control */
  76969. get maxWidth(): string | number;
  76970. /** Gets the maximum width allowed by the control in pixels */
  76971. get maxWidthInPixels(): number;
  76972. set maxWidth(value: string | number);
  76973. /** Gets or sets the text highlighter transparency; default: 0.4 */
  76974. get highligherOpacity(): number;
  76975. set highligherOpacity(value: number);
  76976. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  76977. get onFocusSelectAll(): boolean;
  76978. set onFocusSelectAll(value: boolean);
  76979. /** Gets or sets the text hightlight color */
  76980. get textHighlightColor(): string;
  76981. set textHighlightColor(value: string);
  76982. /** Gets or sets control margin */
  76983. get margin(): string;
  76984. /** Gets control margin in pixels */
  76985. get marginInPixels(): number;
  76986. set margin(value: string);
  76987. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  76988. get autoStretchWidth(): boolean;
  76989. set autoStretchWidth(value: boolean);
  76990. /** Gets or sets border thickness */
  76991. get thickness(): number;
  76992. set thickness(value: number);
  76993. /** Gets or sets the background color when focused */
  76994. get focusedBackground(): string;
  76995. set focusedBackground(value: string);
  76996. /** Gets or sets the background color when focused */
  76997. get focusedColor(): string;
  76998. set focusedColor(value: string);
  76999. /** Gets or sets the background color */
  77000. get background(): string;
  77001. set background(value: string);
  77002. /** Gets or sets the placeholder color */
  77003. get placeholderColor(): string;
  77004. set placeholderColor(value: string);
  77005. /** Gets or sets the text displayed when the control is empty */
  77006. get placeholderText(): string;
  77007. set placeholderText(value: string);
  77008. /** Gets or sets the dead key flag */
  77009. get deadKey(): boolean;
  77010. set deadKey(flag: boolean);
  77011. /** Gets or sets the highlight text */
  77012. get highlightedText(): string;
  77013. set highlightedText(text: string);
  77014. /** Gets or sets if the current key should be added */
  77015. get addKey(): boolean;
  77016. set addKey(flag: boolean);
  77017. /** Gets or sets the value of the current key being entered */
  77018. get currentKey(): string;
  77019. set currentKey(key: string);
  77020. /** Gets or sets the text displayed in the control */
  77021. get text(): string;
  77022. set text(value: string);
  77023. /** Gets or sets control width */
  77024. get width(): string | number;
  77025. set width(value: string | number);
  77026. /**
  77027. * Creates a new InputText
  77028. * @param name defines the control name
  77029. * @param text defines the text of the control
  77030. */
  77031. constructor(name?: string | undefined, text?: string);
  77032. /** @hidden */
  77033. onBlur(): void;
  77034. /** @hidden */
  77035. onFocus(): void;
  77036. protected _getTypeName(): string;
  77037. /**
  77038. * Function called to get the list of controls that should not steal the focus from this control
  77039. * @returns an array of controls
  77040. */
  77041. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  77042. /** @hidden */
  77043. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  77044. /** @hidden */
  77045. private _updateValueFromCursorIndex;
  77046. /** @hidden */
  77047. private _processDblClick;
  77048. /** @hidden */
  77049. private _selectAllText;
  77050. /**
  77051. * Handles the keyboard event
  77052. * @param evt Defines the KeyboardEvent
  77053. */
  77054. processKeyboard(evt: KeyboardEvent): void;
  77055. /** @hidden */
  77056. private _onCopyText;
  77057. /** @hidden */
  77058. private _onCutText;
  77059. /** @hidden */
  77060. private _onPasteText;
  77061. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77062. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77063. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77064. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77065. protected _beforeRenderText(text: string): string;
  77066. dispose(): void;
  77067. }
  77068. }
  77069. declare module BABYLON.GUI {
  77070. /**
  77071. * Class used to create a 2D grid container
  77072. */
  77073. export class Grid extends Container {
  77074. name?: string | undefined;
  77075. private _rowDefinitions;
  77076. private _columnDefinitions;
  77077. private _cells;
  77078. private _childControls;
  77079. /**
  77080. * Gets the number of columns
  77081. */
  77082. get columnCount(): number;
  77083. /**
  77084. * Gets the number of rows
  77085. */
  77086. get rowCount(): number;
  77087. /** Gets the list of children */
  77088. get children(): Control[];
  77089. /** Gets the list of cells (e.g. the containers) */
  77090. get cells(): {
  77091. [key: string]: Container;
  77092. };
  77093. /**
  77094. * Gets the definition of a specific row
  77095. * @param index defines the index of the row
  77096. * @returns the row definition
  77097. */
  77098. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  77099. /**
  77100. * Gets the definition of a specific column
  77101. * @param index defines the index of the column
  77102. * @returns the column definition
  77103. */
  77104. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  77105. /**
  77106. * Adds a new row to the grid
  77107. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  77108. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  77109. * @returns the current grid
  77110. */
  77111. addRowDefinition(height: number, isPixel?: boolean): Grid;
  77112. /**
  77113. * Adds a new column to the grid
  77114. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  77115. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  77116. * @returns the current grid
  77117. */
  77118. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  77119. /**
  77120. * Update a row definition
  77121. * @param index defines the index of the row to update
  77122. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  77123. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  77124. * @returns the current grid
  77125. */
  77126. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  77127. /**
  77128. * Update a column definition
  77129. * @param index defines the index of the column to update
  77130. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  77131. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  77132. * @returns the current grid
  77133. */
  77134. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  77135. /**
  77136. * Gets the list of children stored in a specific cell
  77137. * @param row defines the row to check
  77138. * @param column defines the column to check
  77139. * @returns the list of controls
  77140. */
  77141. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  77142. /**
  77143. * Gets a string representing the child cell info (row x column)
  77144. * @param child defines the control to get info from
  77145. * @returns a string containing the child cell info (row x column)
  77146. */
  77147. getChildCellInfo(child: Control): string;
  77148. private _removeCell;
  77149. private _offsetCell;
  77150. /**
  77151. * Remove a column definition at specified index
  77152. * @param index defines the index of the column to remove
  77153. * @returns the current grid
  77154. */
  77155. removeColumnDefinition(index: number): Grid;
  77156. /**
  77157. * Remove a row definition at specified index
  77158. * @param index defines the index of the row to remove
  77159. * @returns the current grid
  77160. */
  77161. removeRowDefinition(index: number): Grid;
  77162. /**
  77163. * Adds a new control to the current grid
  77164. * @param control defines the control to add
  77165. * @param row defines the row where to add the control (0 by default)
  77166. * @param column defines the column where to add the control (0 by default)
  77167. * @returns the current grid
  77168. */
  77169. addControl(control: Control, row?: number, column?: number): Grid;
  77170. /**
  77171. * Removes a control from the current container
  77172. * @param control defines the control to remove
  77173. * @returns the current container
  77174. */
  77175. removeControl(control: Control): Container;
  77176. /**
  77177. * Creates a new Grid
  77178. * @param name defines control name
  77179. */
  77180. constructor(name?: string | undefined);
  77181. protected _getTypeName(): string;
  77182. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  77183. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77184. _flagDescendantsAsMatrixDirty(): void;
  77185. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  77186. /** Releases associated resources */
  77187. dispose(): void;
  77188. }
  77189. }
  77190. declare module BABYLON.GUI {
  77191. /** Class used to create color pickers */
  77192. export class ColorPicker extends Control {
  77193. name?: string | undefined;
  77194. private static _Epsilon;
  77195. private _colorWheelCanvas;
  77196. private _value;
  77197. private _tmpColor;
  77198. private _pointerStartedOnSquare;
  77199. private _pointerStartedOnWheel;
  77200. private _squareLeft;
  77201. private _squareTop;
  77202. private _squareSize;
  77203. private _h;
  77204. private _s;
  77205. private _v;
  77206. private _lastPointerDownID;
  77207. /**
  77208. * BABYLON.Observable raised when the value changes
  77209. */
  77210. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  77211. /** Gets or sets the color of the color picker */
  77212. get value(): BABYLON.Color3;
  77213. set value(value: BABYLON.Color3);
  77214. /**
  77215. * Gets or sets control width
  77216. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77217. */
  77218. get width(): string | number;
  77219. set width(value: string | number);
  77220. /**
  77221. * Gets or sets control height
  77222. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77223. */
  77224. get height(): string | number;
  77225. /** Gets or sets control height */
  77226. set height(value: string | number);
  77227. /** Gets or sets control size */
  77228. get size(): string | number;
  77229. set size(value: string | number);
  77230. /**
  77231. * Creates a new ColorPicker
  77232. * @param name defines the control name
  77233. */
  77234. constructor(name?: string | undefined);
  77235. protected _getTypeName(): string;
  77236. /** @hidden */
  77237. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77238. private _updateSquareProps;
  77239. private _drawGradientSquare;
  77240. private _drawCircle;
  77241. private _createColorWheelCanvas;
  77242. /** @hidden */
  77243. _draw(context: CanvasRenderingContext2D): void;
  77244. private _pointerIsDown;
  77245. private _updateValueFromPointer;
  77246. private _isPointOnSquare;
  77247. private _isPointOnWheel;
  77248. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77249. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77250. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77251. /**
  77252. * This function expands the color picker by creating a color picker dialog with manual
  77253. * color value input and the ability to save colors into an array to be used later in
  77254. * subsequent launches of the dialogue.
  77255. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  77256. * @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.
  77257. * @returns picked color as a hex string and the saved colors array as hex strings.
  77258. */
  77259. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  77260. pickerWidth?: string;
  77261. pickerHeight?: string;
  77262. headerHeight?: string;
  77263. lastColor?: string;
  77264. swatchLimit?: number;
  77265. numSwatchesPerLine?: number;
  77266. savedColors?: Array<string>;
  77267. }): Promise<{
  77268. savedColors?: string[];
  77269. pickedColor: string;
  77270. }>;
  77271. }
  77272. }
  77273. declare module BABYLON.GUI {
  77274. /** Class used to create 2D ellipse containers */
  77275. export class Ellipse extends Container {
  77276. name?: string | undefined;
  77277. private _thickness;
  77278. /** Gets or sets border thickness */
  77279. get thickness(): number;
  77280. set thickness(value: number);
  77281. /**
  77282. * Creates a new Ellipse
  77283. * @param name defines the control name
  77284. */
  77285. constructor(name?: string | undefined);
  77286. protected _getTypeName(): string;
  77287. protected _localDraw(context: CanvasRenderingContext2D): void;
  77288. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77289. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  77290. }
  77291. }
  77292. declare module BABYLON.GUI {
  77293. /**
  77294. * Class used to create a password control
  77295. */
  77296. export class InputPassword extends InputText {
  77297. protected _beforeRenderText(text: string): string;
  77298. }
  77299. }
  77300. declare module BABYLON.GUI {
  77301. /** Class used to render 2D lines */
  77302. export class Line extends Control {
  77303. name?: string | undefined;
  77304. private _lineWidth;
  77305. private _x1;
  77306. private _y1;
  77307. private _x2;
  77308. private _y2;
  77309. private _dash;
  77310. private _connectedControl;
  77311. private _connectedControlDirtyObserver;
  77312. /** Gets or sets the dash pattern */
  77313. get dash(): Array<number>;
  77314. set dash(value: Array<number>);
  77315. /** Gets or sets the control connected with the line end */
  77316. get connectedControl(): Control;
  77317. set connectedControl(value: Control);
  77318. /** Gets or sets start coordinates on X axis */
  77319. get x1(): string | number;
  77320. set x1(value: string | number);
  77321. /** Gets or sets start coordinates on Y axis */
  77322. get y1(): string | number;
  77323. set y1(value: string | number);
  77324. /** Gets or sets end coordinates on X axis */
  77325. get x2(): string | number;
  77326. set x2(value: string | number);
  77327. /** Gets or sets end coordinates on Y axis */
  77328. get y2(): string | number;
  77329. set y2(value: string | number);
  77330. /** Gets or sets line width */
  77331. get lineWidth(): number;
  77332. set lineWidth(value: number);
  77333. /** Gets or sets horizontal alignment */
  77334. set horizontalAlignment(value: number);
  77335. /** Gets or sets vertical alignment */
  77336. set verticalAlignment(value: number);
  77337. private get _effectiveX2();
  77338. private get _effectiveY2();
  77339. /**
  77340. * Creates a new Line
  77341. * @param name defines the control name
  77342. */
  77343. constructor(name?: string | undefined);
  77344. protected _getTypeName(): string;
  77345. _draw(context: CanvasRenderingContext2D): void;
  77346. _measure(): void;
  77347. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77348. /**
  77349. * Move one end of the line given 3D cartesian coordinates.
  77350. * @param position Targeted world position
  77351. * @param scene BABYLON.Scene
  77352. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  77353. */
  77354. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  77355. /**
  77356. * Move one end of the line to a position in screen absolute space.
  77357. * @param projectedPosition Position in screen absolute space (X, Y)
  77358. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  77359. */
  77360. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  77361. }
  77362. }
  77363. declare module BABYLON.GUI {
  77364. /**
  77365. * Class used to store a point for a MultiLine object.
  77366. * The point can be pure 2D coordinates, a mesh or a control
  77367. */
  77368. export class MultiLinePoint {
  77369. private _multiLine;
  77370. private _x;
  77371. private _y;
  77372. private _control;
  77373. private _mesh;
  77374. private _controlObserver;
  77375. private _meshObserver;
  77376. /** @hidden */
  77377. _point: BABYLON.Vector2;
  77378. /**
  77379. * Creates a new MultiLinePoint
  77380. * @param multiLine defines the source MultiLine object
  77381. */
  77382. constructor(multiLine: MultiLine);
  77383. /** Gets or sets x coordinate */
  77384. get x(): string | number;
  77385. set x(value: string | number);
  77386. /** Gets or sets y coordinate */
  77387. get y(): string | number;
  77388. set y(value: string | number);
  77389. /** Gets or sets the control associated with this point */
  77390. get control(): BABYLON.Nullable<Control>;
  77391. set control(value: BABYLON.Nullable<Control>);
  77392. /** Gets or sets the mesh associated with this point */
  77393. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77394. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  77395. /** Resets links */
  77396. resetLinks(): void;
  77397. /**
  77398. * Gets a translation vector
  77399. * @returns the translation vector
  77400. */
  77401. translate(): BABYLON.Vector2;
  77402. private _translatePoint;
  77403. /** Release associated resources */
  77404. dispose(): void;
  77405. }
  77406. }
  77407. declare module BABYLON.GUI {
  77408. /**
  77409. * Class used to create multi line control
  77410. */
  77411. export class MultiLine extends Control {
  77412. name?: string | undefined;
  77413. private _lineWidth;
  77414. private _dash;
  77415. private _points;
  77416. private _minX;
  77417. private _minY;
  77418. private _maxX;
  77419. private _maxY;
  77420. /**
  77421. * Creates a new MultiLine
  77422. * @param name defines the control name
  77423. */
  77424. constructor(name?: string | undefined);
  77425. /** Gets or sets dash pattern */
  77426. get dash(): Array<number>;
  77427. set dash(value: Array<number>);
  77428. /**
  77429. * Gets point stored at specified index
  77430. * @param index defines the index to look for
  77431. * @returns the requested point if found
  77432. */
  77433. getAt(index: number): MultiLinePoint;
  77434. /** Function called when a point is updated */
  77435. onPointUpdate: () => void;
  77436. /**
  77437. * Adds new points to the point collection
  77438. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  77439. * @returns the list of created MultiLinePoint
  77440. */
  77441. add(...items: (AbstractMesh | Control | {
  77442. x: string | number;
  77443. y: string | number;
  77444. })[]): MultiLinePoint[];
  77445. /**
  77446. * Adds a new point to the point collection
  77447. * @param item defines the item (mesh, control or 2d coordiantes) to add
  77448. * @returns the created MultiLinePoint
  77449. */
  77450. push(item?: (AbstractMesh | Control | {
  77451. x: string | number;
  77452. y: string | number;
  77453. })): MultiLinePoint;
  77454. /**
  77455. * Remove a specific value or point from the active point collection
  77456. * @param value defines the value or point to remove
  77457. */
  77458. remove(value: number | MultiLinePoint): void;
  77459. /**
  77460. * Resets this object to initial state (no point)
  77461. */
  77462. reset(): void;
  77463. /**
  77464. * Resets all links
  77465. */
  77466. resetLinks(): void;
  77467. /** Gets or sets line width */
  77468. get lineWidth(): number;
  77469. set lineWidth(value: number);
  77470. set horizontalAlignment(value: number);
  77471. set verticalAlignment(value: number);
  77472. protected _getTypeName(): string;
  77473. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77474. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77475. _measure(): void;
  77476. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77477. dispose(): void;
  77478. }
  77479. }
  77480. declare module BABYLON.GUI {
  77481. /**
  77482. * Class used to create radio button controls
  77483. */
  77484. export class RadioButton extends Control {
  77485. name?: string | undefined;
  77486. private _isChecked;
  77487. private _background;
  77488. private _checkSizeRatio;
  77489. private _thickness;
  77490. /** Gets or sets border thickness */
  77491. get thickness(): number;
  77492. set thickness(value: number);
  77493. /** Gets or sets group name */
  77494. group: string;
  77495. /** BABYLON.Observable raised when isChecked is changed */
  77496. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  77497. /** Gets or sets a value indicating the ratio between overall size and check size */
  77498. get checkSizeRatio(): number;
  77499. set checkSizeRatio(value: number);
  77500. /** Gets or sets background color */
  77501. get background(): string;
  77502. set background(value: string);
  77503. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  77504. get isChecked(): boolean;
  77505. set isChecked(value: boolean);
  77506. /**
  77507. * Creates a new RadioButton
  77508. * @param name defines the control name
  77509. */
  77510. constructor(name?: string | undefined);
  77511. protected _getTypeName(): string;
  77512. _draw(context: CanvasRenderingContext2D): void;
  77513. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77514. /**
  77515. * Utility function to easily create a radio button with a header
  77516. * @param title defines the label to use for the header
  77517. * @param group defines the group to use for the radio button
  77518. * @param isChecked defines the initial state of the radio button
  77519. * @param onValueChanged defines the callback to call when value changes
  77520. * @returns a StackPanel containing the radio button and a textBlock
  77521. */
  77522. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  77523. }
  77524. }
  77525. declare module BABYLON.GUI {
  77526. /**
  77527. * Class used to create slider controls
  77528. */
  77529. export class BaseSlider extends Control {
  77530. name?: string | undefined;
  77531. protected _thumbWidth: ValueAndUnit;
  77532. private _minimum;
  77533. private _maximum;
  77534. private _value;
  77535. private _isVertical;
  77536. protected _barOffset: ValueAndUnit;
  77537. private _isThumbClamped;
  77538. protected _displayThumb: boolean;
  77539. private _step;
  77540. private _lastPointerDownID;
  77541. protected _effectiveBarOffset: number;
  77542. protected _renderLeft: number;
  77543. protected _renderTop: number;
  77544. protected _renderWidth: number;
  77545. protected _renderHeight: number;
  77546. protected _backgroundBoxLength: number;
  77547. protected _backgroundBoxThickness: number;
  77548. protected _effectiveThumbThickness: number;
  77549. /** BABYLON.Observable raised when the sldier value changes */
  77550. onValueChangedObservable: BABYLON.Observable<number>;
  77551. /** Gets or sets a boolean indicating if the thumb must be rendered */
  77552. get displayThumb(): boolean;
  77553. set displayThumb(value: boolean);
  77554. /** Gets or sets a step to apply to values (0 by default) */
  77555. get step(): number;
  77556. set step(value: number);
  77557. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  77558. get barOffset(): string | number;
  77559. /** Gets main bar offset in pixels*/
  77560. get barOffsetInPixels(): number;
  77561. set barOffset(value: string | number);
  77562. /** Gets or sets thumb width */
  77563. get thumbWidth(): string | number;
  77564. /** Gets thumb width in pixels */
  77565. get thumbWidthInPixels(): number;
  77566. set thumbWidth(value: string | number);
  77567. /** Gets or sets minimum value */
  77568. get minimum(): number;
  77569. set minimum(value: number);
  77570. /** Gets or sets maximum value */
  77571. get maximum(): number;
  77572. set maximum(value: number);
  77573. /** Gets or sets current value */
  77574. get value(): number;
  77575. set value(value: number);
  77576. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  77577. get isVertical(): boolean;
  77578. set isVertical(value: boolean);
  77579. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  77580. get isThumbClamped(): boolean;
  77581. set isThumbClamped(value: boolean);
  77582. /**
  77583. * Creates a new BaseSlider
  77584. * @param name defines the control name
  77585. */
  77586. constructor(name?: string | undefined);
  77587. protected _getTypeName(): string;
  77588. protected _getThumbPosition(): number;
  77589. protected _getThumbThickness(type: string): number;
  77590. protected _prepareRenderingData(type: string): void;
  77591. private _pointerIsDown;
  77592. /** @hidden */
  77593. protected _updateValueFromPointer(x: number, y: number): void;
  77594. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77595. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77596. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77597. }
  77598. }
  77599. declare module BABYLON.GUI {
  77600. /**
  77601. * Class used to create slider controls
  77602. */
  77603. export class Slider extends BaseSlider {
  77604. name?: string | undefined;
  77605. private _background;
  77606. private _borderColor;
  77607. private _isThumbCircle;
  77608. protected _displayValueBar: boolean;
  77609. /** Gets or sets a boolean indicating if the value bar must be rendered */
  77610. get displayValueBar(): boolean;
  77611. set displayValueBar(value: boolean);
  77612. /** Gets or sets border color */
  77613. get borderColor(): string;
  77614. set borderColor(value: string);
  77615. /** Gets or sets background color */
  77616. get background(): string;
  77617. set background(value: string);
  77618. /** Gets or sets a boolean indicating if the thumb should be round or square */
  77619. get isThumbCircle(): boolean;
  77620. set isThumbCircle(value: boolean);
  77621. /**
  77622. * Creates a new Slider
  77623. * @param name defines the control name
  77624. */
  77625. constructor(name?: string | undefined);
  77626. protected _getTypeName(): string;
  77627. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77628. }
  77629. }
  77630. declare module BABYLON.GUI {
  77631. /** Class used to create a RadioGroup
  77632. * which contains groups of radio buttons
  77633. */
  77634. export class SelectorGroup {
  77635. /** name of SelectorGroup */
  77636. name: string;
  77637. private _groupPanel;
  77638. private _selectors;
  77639. private _groupHeader;
  77640. /**
  77641. * Creates a new SelectorGroup
  77642. * @param name of group, used as a group heading
  77643. */
  77644. constructor(
  77645. /** name of SelectorGroup */
  77646. name: string);
  77647. /** Gets the groupPanel of the SelectorGroup */
  77648. get groupPanel(): StackPanel;
  77649. /** Gets the selectors array */
  77650. get selectors(): StackPanel[];
  77651. /** Gets and sets the group header */
  77652. get header(): string;
  77653. set header(label: string);
  77654. /** @hidden */
  77655. private _addGroupHeader;
  77656. /** @hidden*/
  77657. _getSelector(selectorNb: number): StackPanel | undefined;
  77658. /** Removes the selector at the given position
  77659. * @param selectorNb the position of the selector within the group
  77660. */
  77661. removeSelector(selectorNb: number): void;
  77662. }
  77663. /** Class used to create a CheckboxGroup
  77664. * which contains groups of checkbox buttons
  77665. */
  77666. export class CheckboxGroup extends SelectorGroup {
  77667. /** Adds a checkbox as a control
  77668. * @param text is the label for the selector
  77669. * @param func is the function called when the Selector is checked
  77670. * @param checked is true when Selector is checked
  77671. */
  77672. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  77673. /** @hidden */
  77674. _setSelectorLabel(selectorNb: number, label: string): void;
  77675. /** @hidden */
  77676. _setSelectorLabelColor(selectorNb: number, color: string): void;
  77677. /** @hidden */
  77678. _setSelectorButtonColor(selectorNb: number, color: string): void;
  77679. /** @hidden */
  77680. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  77681. }
  77682. /** Class used to create a RadioGroup
  77683. * which contains groups of radio buttons
  77684. */
  77685. export class RadioGroup extends SelectorGroup {
  77686. private _selectNb;
  77687. /** Adds a radio button as a control
  77688. * @param label is the label for the selector
  77689. * @param func is the function called when the Selector is checked
  77690. * @param checked is true when Selector is checked
  77691. */
  77692. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  77693. /** @hidden */
  77694. _setSelectorLabel(selectorNb: number, label: string): void;
  77695. /** @hidden */
  77696. _setSelectorLabelColor(selectorNb: number, color: string): void;
  77697. /** @hidden */
  77698. _setSelectorButtonColor(selectorNb: number, color: string): void;
  77699. /** @hidden */
  77700. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  77701. }
  77702. /** Class used to create a SliderGroup
  77703. * which contains groups of slider buttons
  77704. */
  77705. export class SliderGroup extends SelectorGroup {
  77706. /**
  77707. * Adds a slider to the SelectorGroup
  77708. * @param label is the label for the SliderBar
  77709. * @param func is the function called when the Slider moves
  77710. * @param unit is a string describing the units used, eg degrees or metres
  77711. * @param min is the minimum value for the Slider
  77712. * @param max is the maximum value for the Slider
  77713. * @param value is the start value for the Slider between min and max
  77714. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  77715. */
  77716. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  77717. /** @hidden */
  77718. _setSelectorLabel(selectorNb: number, label: string): void;
  77719. /** @hidden */
  77720. _setSelectorLabelColor(selectorNb: number, color: string): void;
  77721. /** @hidden */
  77722. _setSelectorButtonColor(selectorNb: number, color: string): void;
  77723. /** @hidden */
  77724. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  77725. }
  77726. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  77727. * @see https://doc.babylonjs.com/how_to/selector
  77728. */
  77729. export class SelectionPanel extends Rectangle {
  77730. /** name of SelectionPanel */
  77731. name: string;
  77732. /** an array of SelectionGroups */
  77733. groups: SelectorGroup[];
  77734. private _panel;
  77735. private _buttonColor;
  77736. private _buttonBackground;
  77737. private _headerColor;
  77738. private _barColor;
  77739. private _barHeight;
  77740. private _spacerHeight;
  77741. private _labelColor;
  77742. private _groups;
  77743. private _bars;
  77744. /**
  77745. * Creates a new SelectionPanel
  77746. * @param name of SelectionPanel
  77747. * @param groups is an array of SelectionGroups
  77748. */
  77749. constructor(
  77750. /** name of SelectionPanel */
  77751. name: string,
  77752. /** an array of SelectionGroups */
  77753. groups?: SelectorGroup[]);
  77754. protected _getTypeName(): string;
  77755. /** Gets or sets the headerColor */
  77756. get headerColor(): string;
  77757. set headerColor(color: string);
  77758. private _setHeaderColor;
  77759. /** Gets or sets the button color */
  77760. get buttonColor(): string;
  77761. set buttonColor(color: string);
  77762. private _setbuttonColor;
  77763. /** Gets or sets the label color */
  77764. get labelColor(): string;
  77765. set labelColor(color: string);
  77766. private _setLabelColor;
  77767. /** Gets or sets the button background */
  77768. get buttonBackground(): string;
  77769. set buttonBackground(color: string);
  77770. private _setButtonBackground;
  77771. /** Gets or sets the color of separator bar */
  77772. get barColor(): string;
  77773. set barColor(color: string);
  77774. private _setBarColor;
  77775. /** Gets or sets the height of separator bar */
  77776. get barHeight(): string;
  77777. set barHeight(value: string);
  77778. private _setBarHeight;
  77779. /** Gets or sets the height of spacers*/
  77780. get spacerHeight(): string;
  77781. set spacerHeight(value: string);
  77782. private _setSpacerHeight;
  77783. /** Adds a bar between groups */
  77784. private _addSpacer;
  77785. /** Add a group to the selection panel
  77786. * @param group is the selector group to add
  77787. */
  77788. addGroup(group: SelectorGroup): void;
  77789. /** Remove the group from the given position
  77790. * @param groupNb is the position of the group in the list
  77791. */
  77792. removeGroup(groupNb: number): void;
  77793. /** Change a group header label
  77794. * @param label is the new group header label
  77795. * @param groupNb is the number of the group to relabel
  77796. * */
  77797. setHeaderName(label: string, groupNb: number): void;
  77798. /** Change selector label to the one given
  77799. * @param label is the new selector label
  77800. * @param groupNb is the number of the groupcontaining the selector
  77801. * @param selectorNb is the number of the selector within a group to relabel
  77802. * */
  77803. relabel(label: string, groupNb: number, selectorNb: number): void;
  77804. /** For a given group position remove the selector at the given position
  77805. * @param groupNb is the number of the group to remove the selector from
  77806. * @param selectorNb is the number of the selector within the group
  77807. */
  77808. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  77809. /** For a given group position of correct type add a checkbox button
  77810. * @param groupNb is the number of the group to remove the selector from
  77811. * @param label is the label for the selector
  77812. * @param func is the function called when the Selector is checked
  77813. * @param checked is true when Selector is checked
  77814. */
  77815. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  77816. /** For a given group position of correct type add a radio button
  77817. * @param groupNb is the number of the group to remove the selector from
  77818. * @param label is the label for the selector
  77819. * @param func is the function called when the Selector is checked
  77820. * @param checked is true when Selector is checked
  77821. */
  77822. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  77823. /**
  77824. * For a given slider group add a slider
  77825. * @param groupNb is the number of the group to add the slider to
  77826. * @param label is the label for the Slider
  77827. * @param func is the function called when the Slider moves
  77828. * @param unit is a string describing the units used, eg degrees or metres
  77829. * @param min is the minimum value for the Slider
  77830. * @param max is the maximum value for the Slider
  77831. * @param value is the start value for the Slider between min and max
  77832. * @param onVal is the function used to format the value displayed, eg radians to degrees
  77833. */
  77834. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  77835. }
  77836. }
  77837. declare module BABYLON.GUI {
  77838. /**
  77839. * Class used to hold a the container for ScrollViewer
  77840. * @hidden
  77841. */
  77842. export class _ScrollViewerWindow extends Container {
  77843. parentClientWidth: number;
  77844. parentClientHeight: number;
  77845. private _freezeControls;
  77846. private _parentMeasure;
  77847. private _oldLeft;
  77848. private _oldTop;
  77849. get freezeControls(): boolean;
  77850. set freezeControls(value: boolean);
  77851. private _bucketWidth;
  77852. private _bucketHeight;
  77853. private _buckets;
  77854. private _bucketLen;
  77855. get bucketWidth(): number;
  77856. get bucketHeight(): number;
  77857. setBucketSizes(width: number, height: number): void;
  77858. private _useBuckets;
  77859. private _makeBuckets;
  77860. private _dispatchInBuckets;
  77861. private _updateMeasures;
  77862. private _updateChildrenMeasures;
  77863. private _restoreMeasures;
  77864. /**
  77865. * Creates a new ScrollViewerWindow
  77866. * @param name of ScrollViewerWindow
  77867. */
  77868. constructor(name?: string);
  77869. protected _getTypeName(): string;
  77870. /** @hidden */
  77871. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77872. /** @hidden */
  77873. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  77874. private _scrollChildren;
  77875. private _scrollChildrenWithBuckets;
  77876. /** @hidden */
  77877. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  77878. protected _postMeasure(): void;
  77879. }
  77880. }
  77881. declare module BABYLON.GUI {
  77882. /**
  77883. * Class used to create slider controls
  77884. */
  77885. export class ScrollBar extends BaseSlider {
  77886. name?: string | undefined;
  77887. private _background;
  77888. private _borderColor;
  77889. private _tempMeasure;
  77890. /** Gets or sets border color */
  77891. get borderColor(): string;
  77892. set borderColor(value: string);
  77893. /** Gets or sets background color */
  77894. get background(): string;
  77895. set background(value: string);
  77896. /**
  77897. * Creates a new Slider
  77898. * @param name defines the control name
  77899. */
  77900. constructor(name?: string | undefined);
  77901. protected _getTypeName(): string;
  77902. protected _getThumbThickness(): number;
  77903. _draw(context: CanvasRenderingContext2D): void;
  77904. private _first;
  77905. private _originX;
  77906. private _originY;
  77907. /** @hidden */
  77908. protected _updateValueFromPointer(x: number, y: number): void;
  77909. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77910. }
  77911. }
  77912. declare module BABYLON.GUI {
  77913. /**
  77914. * Class used to create slider controls
  77915. */
  77916. export class ImageScrollBar extends BaseSlider {
  77917. name?: string | undefined;
  77918. private _backgroundBaseImage;
  77919. private _backgroundImage;
  77920. private _thumbImage;
  77921. private _thumbBaseImage;
  77922. private _thumbLength;
  77923. private _thumbHeight;
  77924. private _barImageHeight;
  77925. private _tempMeasure;
  77926. /** Number of 90° rotation to apply on the images when in vertical mode */
  77927. num90RotationInVerticalMode: number;
  77928. /**
  77929. * Gets or sets the image used to render the background for horizontal bar
  77930. */
  77931. get backgroundImage(): Image;
  77932. set backgroundImage(value: Image);
  77933. /**
  77934. * Gets or sets the image used to render the thumb
  77935. */
  77936. get thumbImage(): Image;
  77937. set thumbImage(value: Image);
  77938. /**
  77939. * Gets or sets the length of the thumb
  77940. */
  77941. get thumbLength(): number;
  77942. set thumbLength(value: number);
  77943. /**
  77944. * Gets or sets the height of the thumb
  77945. */
  77946. get thumbHeight(): number;
  77947. set thumbHeight(value: number);
  77948. /**
  77949. * Gets or sets the height of the bar image
  77950. */
  77951. get barImageHeight(): number;
  77952. set barImageHeight(value: number);
  77953. /**
  77954. * Creates a new ImageScrollBar
  77955. * @param name defines the control name
  77956. */
  77957. constructor(name?: string | undefined);
  77958. protected _getTypeName(): string;
  77959. protected _getThumbThickness(): number;
  77960. _draw(context: CanvasRenderingContext2D): void;
  77961. private _first;
  77962. private _originX;
  77963. private _originY;
  77964. /** @hidden */
  77965. protected _updateValueFromPointer(x: number, y: number): void;
  77966. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77967. }
  77968. }
  77969. declare module BABYLON.GUI {
  77970. /**
  77971. * Class used to hold a viewer window and sliders in a grid
  77972. */
  77973. export class ScrollViewer extends Rectangle {
  77974. private _grid;
  77975. private _horizontalBarSpace;
  77976. private _verticalBarSpace;
  77977. private _dragSpace;
  77978. private _horizontalBar;
  77979. private _verticalBar;
  77980. private _barColor;
  77981. private _barBackground;
  77982. private _barImage;
  77983. private _horizontalBarImage;
  77984. private _verticalBarImage;
  77985. private _barBackgroundImage;
  77986. private _horizontalBarBackgroundImage;
  77987. private _verticalBarBackgroundImage;
  77988. private _barSize;
  77989. private _window;
  77990. private _pointerIsOver;
  77991. private _wheelPrecision;
  77992. private _onWheelObserver;
  77993. private _clientWidth;
  77994. private _clientHeight;
  77995. private _useImageBar;
  77996. private _thumbLength;
  77997. private _thumbHeight;
  77998. private _barImageHeight;
  77999. private _horizontalBarImageHeight;
  78000. private _verticalBarImageHeight;
  78001. private _oldWindowContentsWidth;
  78002. private _oldWindowContentsHeight;
  78003. /**
  78004. * Gets the horizontal scrollbar
  78005. */
  78006. get horizontalBar(): ScrollBar | ImageScrollBar;
  78007. /**
  78008. * Gets the vertical scrollbar
  78009. */
  78010. get verticalBar(): ScrollBar | ImageScrollBar;
  78011. /**
  78012. * Adds a new control to the current container
  78013. * @param control defines the control to add
  78014. * @returns the current container
  78015. */
  78016. addControl(control: BABYLON.Nullable<Control>): Container;
  78017. /**
  78018. * Removes a control from the current container
  78019. * @param control defines the control to remove
  78020. * @returns the current container
  78021. */
  78022. removeControl(control: Control): Container;
  78023. /** Gets the list of children */
  78024. get children(): Control[];
  78025. _flagDescendantsAsMatrixDirty(): void;
  78026. /**
  78027. * Freezes or unfreezes the controls in the window.
  78028. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  78029. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  78030. */
  78031. get freezeControls(): boolean;
  78032. set freezeControls(value: boolean);
  78033. /** Gets the bucket width */
  78034. get bucketWidth(): number;
  78035. /** Gets the bucket height */
  78036. get bucketHeight(): number;
  78037. /**
  78038. * Sets the bucket sizes.
  78039. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  78040. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  78041. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  78042. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  78043. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  78044. * used), that's why it is not enabled by default.
  78045. * @param width width of the bucket
  78046. * @param height height of the bucket
  78047. */
  78048. setBucketSizes(width: number, height: number): void;
  78049. private _forceHorizontalBar;
  78050. private _forceVerticalBar;
  78051. /**
  78052. * Forces the horizontal scroll bar to be displayed
  78053. */
  78054. get forceHorizontalBar(): boolean;
  78055. set forceHorizontalBar(value: boolean);
  78056. /**
  78057. * Forces the vertical scroll bar to be displayed
  78058. */
  78059. get forceVerticalBar(): boolean;
  78060. set forceVerticalBar(value: boolean);
  78061. /**
  78062. * Creates a new ScrollViewer
  78063. * @param name of ScrollViewer
  78064. */
  78065. constructor(name?: string, isImageBased?: boolean);
  78066. /** Reset the scroll viewer window to initial size */
  78067. resetWindow(): void;
  78068. protected _getTypeName(): string;
  78069. private _buildClientSizes;
  78070. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78071. protected _postMeasure(): void;
  78072. /**
  78073. * Gets or sets the mouse wheel precision
  78074. * from 0 to 1 with a default value of 0.05
  78075. * */
  78076. get wheelPrecision(): number;
  78077. set wheelPrecision(value: number);
  78078. /** Gets or sets the scroll bar container background color */
  78079. get scrollBackground(): string;
  78080. set scrollBackground(color: string);
  78081. /** Gets or sets the bar color */
  78082. get barColor(): string;
  78083. set barColor(color: string);
  78084. /** Gets or sets the bar image */
  78085. get thumbImage(): Image;
  78086. set thumbImage(value: Image);
  78087. /** Gets or sets the horizontal bar image */
  78088. get horizontalThumbImage(): Image;
  78089. set horizontalThumbImage(value: Image);
  78090. /** Gets or sets the vertical bar image */
  78091. get verticalThumbImage(): Image;
  78092. set verticalThumbImage(value: Image);
  78093. /** Gets or sets the size of the bar */
  78094. get barSize(): number;
  78095. set barSize(value: number);
  78096. /** Gets or sets the length of the thumb */
  78097. get thumbLength(): number;
  78098. set thumbLength(value: number);
  78099. /** Gets or sets the height of the thumb */
  78100. get thumbHeight(): number;
  78101. set thumbHeight(value: number);
  78102. /** Gets or sets the height of the bar image */
  78103. get barImageHeight(): number;
  78104. set barImageHeight(value: number);
  78105. /** Gets or sets the height of the horizontal bar image */
  78106. get horizontalBarImageHeight(): number;
  78107. set horizontalBarImageHeight(value: number);
  78108. /** Gets or sets the height of the vertical bar image */
  78109. get verticalBarImageHeight(): number;
  78110. set verticalBarImageHeight(value: number);
  78111. /** Gets or sets the bar background */
  78112. get barBackground(): string;
  78113. set barBackground(color: string);
  78114. /** Gets or sets the bar background image */
  78115. get barImage(): Image;
  78116. set barImage(value: Image);
  78117. /** Gets or sets the horizontal bar background image */
  78118. get horizontalBarImage(): Image;
  78119. set horizontalBarImage(value: Image);
  78120. /** Gets or sets the vertical bar background image */
  78121. get verticalBarImage(): Image;
  78122. set verticalBarImage(value: Image);
  78123. private _setWindowPosition;
  78124. /** @hidden */
  78125. private _updateScroller;
  78126. _link(host: AdvancedDynamicTexture): void;
  78127. /** @hidden */
  78128. private _addBar;
  78129. /** @hidden */
  78130. private _attachWheel;
  78131. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  78132. /** Releases associated resources */
  78133. dispose(): void;
  78134. }
  78135. }
  78136. declare module BABYLON.GUI {
  78137. /** Class used to render a grid */
  78138. export class DisplayGrid extends Control {
  78139. name?: string | undefined;
  78140. private _cellWidth;
  78141. private _cellHeight;
  78142. private _minorLineTickness;
  78143. private _minorLineColor;
  78144. private _majorLineTickness;
  78145. private _majorLineColor;
  78146. private _majorLineFrequency;
  78147. private _background;
  78148. private _displayMajorLines;
  78149. private _displayMinorLines;
  78150. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  78151. get displayMinorLines(): boolean;
  78152. set displayMinorLines(value: boolean);
  78153. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  78154. get displayMajorLines(): boolean;
  78155. set displayMajorLines(value: boolean);
  78156. /** Gets or sets background color (Black by default) */
  78157. get background(): string;
  78158. set background(value: string);
  78159. /** Gets or sets the width of each cell (20 by default) */
  78160. get cellWidth(): number;
  78161. set cellWidth(value: number);
  78162. /** Gets or sets the height of each cell (20 by default) */
  78163. get cellHeight(): number;
  78164. set cellHeight(value: number);
  78165. /** Gets or sets the tickness of minor lines (1 by default) */
  78166. get minorLineTickness(): number;
  78167. set minorLineTickness(value: number);
  78168. /** Gets or sets the color of minor lines (DarkGray by default) */
  78169. get minorLineColor(): string;
  78170. set minorLineColor(value: string);
  78171. /** Gets or sets the tickness of major lines (2 by default) */
  78172. get majorLineTickness(): number;
  78173. set majorLineTickness(value: number);
  78174. /** Gets or sets the color of major lines (White by default) */
  78175. get majorLineColor(): string;
  78176. set majorLineColor(value: string);
  78177. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  78178. get majorLineFrequency(): number;
  78179. set majorLineFrequency(value: number);
  78180. /**
  78181. * Creates a new GridDisplayRectangle
  78182. * @param name defines the control name
  78183. */
  78184. constructor(name?: string | undefined);
  78185. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78186. protected _getTypeName(): string;
  78187. }
  78188. }
  78189. declare module BABYLON.GUI {
  78190. /**
  78191. * Class used to create slider controls based on images
  78192. */
  78193. export class ImageBasedSlider extends BaseSlider {
  78194. name?: string | undefined;
  78195. private _backgroundImage;
  78196. private _thumbImage;
  78197. private _valueBarImage;
  78198. private _tempMeasure;
  78199. get displayThumb(): boolean;
  78200. set displayThumb(value: boolean);
  78201. /**
  78202. * Gets or sets the image used to render the background
  78203. */
  78204. get backgroundImage(): Image;
  78205. set backgroundImage(value: Image);
  78206. /**
  78207. * Gets or sets the image used to render the value bar
  78208. */
  78209. get valueBarImage(): Image;
  78210. set valueBarImage(value: Image);
  78211. /**
  78212. * Gets or sets the image used to render the thumb
  78213. */
  78214. get thumbImage(): Image;
  78215. set thumbImage(value: Image);
  78216. /**
  78217. * Creates a new ImageBasedSlider
  78218. * @param name defines the control name
  78219. */
  78220. constructor(name?: string | undefined);
  78221. protected _getTypeName(): string;
  78222. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78223. }
  78224. }
  78225. declare module BABYLON.GUI {
  78226. /**
  78227. * Forcing an export so that this code will execute
  78228. * @hidden
  78229. */
  78230. const name = "Statics";
  78231. }
  78232. declare module BABYLON.GUI {
  78233. /**
  78234. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  78235. */
  78236. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  78237. /**
  78238. * Define the instrumented AdvancedDynamicTexture.
  78239. */
  78240. texture: AdvancedDynamicTexture;
  78241. private _captureRenderTime;
  78242. private _renderTime;
  78243. private _captureLayoutTime;
  78244. private _layoutTime;
  78245. private _onBeginRenderObserver;
  78246. private _onEndRenderObserver;
  78247. private _onBeginLayoutObserver;
  78248. private _onEndLayoutObserver;
  78249. /**
  78250. * Gets the perf counter used to capture render time
  78251. */
  78252. get renderTimeCounter(): BABYLON.PerfCounter;
  78253. /**
  78254. * Gets the perf counter used to capture layout time
  78255. */
  78256. get layoutTimeCounter(): BABYLON.PerfCounter;
  78257. /**
  78258. * Enable or disable the render time capture
  78259. */
  78260. get captureRenderTime(): boolean;
  78261. set captureRenderTime(value: boolean);
  78262. /**
  78263. * Enable or disable the layout time capture
  78264. */
  78265. get captureLayoutTime(): boolean;
  78266. set captureLayoutTime(value: boolean);
  78267. /**
  78268. * Instantiates a new advanced dynamic texture instrumentation.
  78269. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  78270. * @param texture Defines the AdvancedDynamicTexture to instrument
  78271. */
  78272. constructor(
  78273. /**
  78274. * Define the instrumented AdvancedDynamicTexture.
  78275. */
  78276. texture: AdvancedDynamicTexture);
  78277. /**
  78278. * Dispose and release associated resources.
  78279. */
  78280. dispose(): void;
  78281. }
  78282. }
  78283. declare module BABYLON.GUI {
  78284. /**
  78285. * Class used to load GUI via XML.
  78286. */
  78287. export class XmlLoader {
  78288. private _nodes;
  78289. private _nodeTypes;
  78290. private _isLoaded;
  78291. private _objectAttributes;
  78292. private _parentClass;
  78293. /**
  78294. * Create a new xml loader
  78295. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  78296. */
  78297. constructor(parentClass?: null);
  78298. private _getChainElement;
  78299. private _getClassAttribute;
  78300. private _createGuiElement;
  78301. private _parseGrid;
  78302. private _parseElement;
  78303. private _prepareSourceElement;
  78304. private _parseElementsFromSource;
  78305. private _parseXml;
  78306. /**
  78307. * Gets if the loading has finished.
  78308. * @returns whether the loading has finished or not
  78309. */
  78310. isLoaded(): boolean;
  78311. /**
  78312. * Gets a loaded node / control by id.
  78313. * @param id the Controls id set in the xml
  78314. * @returns element of type Control
  78315. */
  78316. getNodeById(id: string): any;
  78317. /**
  78318. * Gets all loaded nodes / controls
  78319. * @returns Array of controls
  78320. */
  78321. getNodes(): any;
  78322. /**
  78323. * Initiates the xml layout loading
  78324. * @param xmlFile defines the xml layout to load
  78325. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  78326. * @param callback defines the callback called on layout load.
  78327. */
  78328. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  78329. }
  78330. }
  78331. declare module BABYLON.GUI {
  78332. /**
  78333. * Class used to create containers for controls
  78334. */
  78335. export class Container3D extends Control3D {
  78336. private _blockLayout;
  78337. /**
  78338. * Gets the list of child controls
  78339. */
  78340. protected _children: Control3D[];
  78341. /**
  78342. * Gets the list of child controls
  78343. */
  78344. get children(): Array<Control3D>;
  78345. /**
  78346. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  78347. * This is helpful to optimize layout operation when adding multiple children in a row
  78348. */
  78349. get blockLayout(): boolean;
  78350. set blockLayout(value: boolean);
  78351. /**
  78352. * Creates a new container
  78353. * @param name defines the container name
  78354. */
  78355. constructor(name?: string);
  78356. /**
  78357. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  78358. * @returns the current container
  78359. */
  78360. updateLayout(): Container3D;
  78361. /**
  78362. * Gets a boolean indicating if the given control is in the children of this control
  78363. * @param control defines the control to check
  78364. * @returns true if the control is in the child list
  78365. */
  78366. containsControl(control: Control3D): boolean;
  78367. /**
  78368. * Adds a control to the children of this control
  78369. * @param control defines the control to add
  78370. * @returns the current container
  78371. */
  78372. addControl(control: Control3D): Container3D;
  78373. /**
  78374. * This function will be called everytime a new control is added
  78375. */
  78376. protected _arrangeChildren(): void;
  78377. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  78378. /**
  78379. * Removes a control from the children of this control
  78380. * @param control defines the control to remove
  78381. * @returns the current container
  78382. */
  78383. removeControl(control: Control3D): Container3D;
  78384. protected _getTypeName(): string;
  78385. /**
  78386. * Releases all associated resources
  78387. */
  78388. dispose(): void;
  78389. /** Control rotation will remain unchanged */
  78390. static readonly UNSET_ORIENTATION: number;
  78391. /** Control will rotate to make it look at sphere central axis */
  78392. static readonly FACEORIGIN_ORIENTATION: number;
  78393. /** Control will rotate to make it look back at sphere central axis */
  78394. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  78395. /** Control will rotate to look at z axis (0, 0, 1) */
  78396. static readonly FACEFORWARD_ORIENTATION: number;
  78397. /** Control will rotate to look at negative z axis (0, 0, -1) */
  78398. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  78399. }
  78400. }
  78401. declare module BABYLON.GUI {
  78402. /**
  78403. * Class used to manage 3D user interface
  78404. * @see https://doc.babylonjs.com/how_to/gui3d
  78405. */
  78406. export class GUI3DManager implements BABYLON.IDisposable {
  78407. private _scene;
  78408. private _sceneDisposeObserver;
  78409. private _utilityLayer;
  78410. private _rootContainer;
  78411. private _pointerObserver;
  78412. private _pointerOutObserver;
  78413. /** @hidden */
  78414. _lastPickedControl: Control3D;
  78415. /** @hidden */
  78416. _lastControlOver: {
  78417. [pointerId: number]: Control3D;
  78418. };
  78419. /** @hidden */
  78420. _lastControlDown: {
  78421. [pointerId: number]: Control3D;
  78422. };
  78423. /**
  78424. * BABYLON.Observable raised when the point picked by the pointer events changed
  78425. */
  78426. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  78427. /** @hidden */
  78428. _sharedMaterials: {
  78429. [key: string]: BABYLON.Material;
  78430. };
  78431. /** Gets the hosting scene */
  78432. get scene(): BABYLON.Scene;
  78433. /** Gets associated utility layer */
  78434. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  78435. /**
  78436. * Creates a new GUI3DManager
  78437. * @param scene
  78438. */
  78439. constructor(scene?: BABYLON.Scene);
  78440. private _handlePointerOut;
  78441. private _doPicking;
  78442. /**
  78443. * Gets the root container
  78444. */
  78445. get rootContainer(): Container3D;
  78446. /**
  78447. * Gets a boolean indicating if the given control is in the root child list
  78448. * @param control defines the control to check
  78449. * @returns true if the control is in the root child list
  78450. */
  78451. containsControl(control: Control3D): boolean;
  78452. /**
  78453. * Adds a control to the root child list
  78454. * @param control defines the control to add
  78455. * @returns the current manager
  78456. */
  78457. addControl(control: Control3D): GUI3DManager;
  78458. /**
  78459. * Removes a control from the root child list
  78460. * @param control defines the control to remove
  78461. * @returns the current container
  78462. */
  78463. removeControl(control: Control3D): GUI3DManager;
  78464. /**
  78465. * Releases all associated resources
  78466. */
  78467. dispose(): void;
  78468. }
  78469. }
  78470. declare module BABYLON.GUI {
  78471. /**
  78472. * Class used to transport BABYLON.Vector3 information for pointer events
  78473. */
  78474. export class Vector3WithInfo extends BABYLON.Vector3 {
  78475. /** defines the current mouse button index */
  78476. buttonIndex: number;
  78477. /**
  78478. * Creates a new Vector3WithInfo
  78479. * @param source defines the vector3 data to transport
  78480. * @param buttonIndex defines the current mouse button index
  78481. */
  78482. constructor(source: BABYLON.Vector3,
  78483. /** defines the current mouse button index */
  78484. buttonIndex?: number);
  78485. }
  78486. }
  78487. declare module BABYLON.GUI {
  78488. /**
  78489. * Class used as base class for controls
  78490. */
  78491. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  78492. /** Defines the control name */
  78493. name?: string | undefined;
  78494. /** @hidden */
  78495. _host: GUI3DManager;
  78496. private _node;
  78497. private _downCount;
  78498. private _enterCount;
  78499. private _downPointerIds;
  78500. private _isVisible;
  78501. /** Gets or sets the control position in world space */
  78502. get position(): BABYLON.Vector3;
  78503. set position(value: BABYLON.Vector3);
  78504. /** Gets or sets the control scaling in world space */
  78505. get scaling(): BABYLON.Vector3;
  78506. set scaling(value: BABYLON.Vector3);
  78507. /** Callback used to start pointer enter animation */
  78508. pointerEnterAnimation: () => void;
  78509. /** Callback used to start pointer out animation */
  78510. pointerOutAnimation: () => void;
  78511. /** Callback used to start pointer down animation */
  78512. pointerDownAnimation: () => void;
  78513. /** Callback used to start pointer up animation */
  78514. pointerUpAnimation: () => void;
  78515. /**
  78516. * An event triggered when the pointer move over the control
  78517. */
  78518. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  78519. /**
  78520. * An event triggered when the pointer move out of the control
  78521. */
  78522. onPointerOutObservable: BABYLON.Observable<Control3D>;
  78523. /**
  78524. * An event triggered when the pointer taps the control
  78525. */
  78526. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  78527. /**
  78528. * An event triggered when pointer is up
  78529. */
  78530. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  78531. /**
  78532. * An event triggered when a control is clicked on (with a mouse)
  78533. */
  78534. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  78535. /**
  78536. * An event triggered when pointer enters the control
  78537. */
  78538. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  78539. /**
  78540. * Gets or sets the parent container
  78541. */
  78542. parent: BABYLON.Nullable<Container3D>;
  78543. private _behaviors;
  78544. /**
  78545. * Gets the list of attached behaviors
  78546. * @see https://doc.babylonjs.com/features/behaviour
  78547. */
  78548. get behaviors(): BABYLON.Behavior<Control3D>[];
  78549. /**
  78550. * Attach a behavior to the control
  78551. * @see https://doc.babylonjs.com/features/behaviour
  78552. * @param behavior defines the behavior to attach
  78553. * @returns the current control
  78554. */
  78555. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  78556. /**
  78557. * Remove an attached behavior
  78558. * @see https://doc.babylonjs.com/features/behaviour
  78559. * @param behavior defines the behavior to attach
  78560. * @returns the current control
  78561. */
  78562. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  78563. /**
  78564. * Gets an attached behavior by name
  78565. * @param name defines the name of the behavior to look for
  78566. * @see https://doc.babylonjs.com/features/behaviour
  78567. * @returns null if behavior was not found else the requested behavior
  78568. */
  78569. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  78570. /** Gets or sets a boolean indicating if the control is visible */
  78571. get isVisible(): boolean;
  78572. set isVisible(value: boolean);
  78573. /**
  78574. * Creates a new control
  78575. * @param name defines the control name
  78576. */
  78577. constructor(
  78578. /** Defines the control name */
  78579. name?: string | undefined);
  78580. /**
  78581. * Gets a string representing the class name
  78582. */
  78583. get typeName(): string;
  78584. /**
  78585. * Get the current class name of the control.
  78586. * @returns current class name
  78587. */
  78588. getClassName(): string;
  78589. protected _getTypeName(): string;
  78590. /**
  78591. * Gets the transform node used by this control
  78592. */
  78593. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  78594. /**
  78595. * Gets the mesh used to render this control
  78596. */
  78597. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  78598. /**
  78599. * Link the control as child of the given node
  78600. * @param node defines the node to link to. Use null to unlink the control
  78601. * @returns the current control
  78602. */
  78603. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  78604. /** @hidden **/
  78605. _prepareNode(scene: BABYLON.Scene): void;
  78606. /**
  78607. * Node creation.
  78608. * Can be overriden by children
  78609. * @param scene defines the scene where the node must be attached
  78610. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  78611. */
  78612. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  78613. /**
  78614. * Affect a material to the given mesh
  78615. * @param mesh defines the mesh which will represent the control
  78616. */
  78617. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  78618. /** @hidden */
  78619. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  78620. /** @hidden */
  78621. _onPointerEnter(target: Control3D): boolean;
  78622. /** @hidden */
  78623. _onPointerOut(target: Control3D): void;
  78624. /** @hidden */
  78625. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  78626. /** @hidden */
  78627. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78628. /** @hidden */
  78629. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  78630. /** @hidden */
  78631. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  78632. /** @hidden */
  78633. _disposeNode(): void;
  78634. /**
  78635. * Releases all associated resources
  78636. */
  78637. dispose(): void;
  78638. }
  78639. }
  78640. declare module BABYLON.GUI {
  78641. /**
  78642. * Class used as a root to all buttons
  78643. */
  78644. export class AbstractButton3D extends Control3D {
  78645. /**
  78646. * Creates a new button
  78647. * @param name defines the control name
  78648. */
  78649. constructor(name?: string);
  78650. protected _getTypeName(): string;
  78651. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78652. }
  78653. }
  78654. declare module BABYLON.GUI {
  78655. /**
  78656. * Class used to create a button in 3D
  78657. */
  78658. export class Button3D extends AbstractButton3D {
  78659. /** @hidden */
  78660. protected _currentMaterial: BABYLON.Material;
  78661. private _facadeTexture;
  78662. private _content;
  78663. private _contentResolution;
  78664. private _contentScaleRatio;
  78665. /**
  78666. * Gets or sets the texture resolution used to render content (512 by default)
  78667. */
  78668. get contentResolution(): BABYLON.int;
  78669. set contentResolution(value: BABYLON.int);
  78670. /**
  78671. * Gets or sets the texture scale ratio used to render content (2 by default)
  78672. */
  78673. get contentScaleRatio(): number;
  78674. set contentScaleRatio(value: number);
  78675. protected _disposeFacadeTexture(): void;
  78676. protected _resetContent(): void;
  78677. /**
  78678. * Creates a new button
  78679. * @param name defines the control name
  78680. */
  78681. constructor(name?: string);
  78682. /**
  78683. * Gets or sets the GUI 2D content used to display the button's facade
  78684. */
  78685. get content(): Control;
  78686. set content(value: Control);
  78687. /**
  78688. * Apply the facade texture (created from the content property).
  78689. * This function can be overloaded by child classes
  78690. * @param facadeTexture defines the AdvancedDynamicTexture to use
  78691. */
  78692. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  78693. protected _getTypeName(): string;
  78694. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78695. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  78696. /**
  78697. * Releases all associated resources
  78698. */
  78699. dispose(): void;
  78700. }
  78701. }
  78702. declare module BABYLON.GUI {
  78703. /**
  78704. * Abstract class used to create a container panel deployed on the surface of a volume
  78705. */
  78706. export abstract class VolumeBasedPanel extends Container3D {
  78707. private _columns;
  78708. private _rows;
  78709. private _rowThenColum;
  78710. private _orientation;
  78711. protected _cellWidth: number;
  78712. protected _cellHeight: number;
  78713. /**
  78714. * Gets or sets the distance between elements
  78715. */
  78716. margin: number;
  78717. /**
  78718. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  78719. * | Value | Type | Description |
  78720. * | ----- | ----------------------------------- | ----------- |
  78721. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  78722. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  78723. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  78724. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  78725. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  78726. */
  78727. get orientation(): number;
  78728. set orientation(value: number);
  78729. /**
  78730. * Gets or sets the number of columns requested (10 by default).
  78731. * The panel will automatically compute the number of rows based on number of child controls.
  78732. */
  78733. get columns(): BABYLON.int;
  78734. set columns(value: BABYLON.int);
  78735. /**
  78736. * Gets or sets a the number of rows requested.
  78737. * The panel will automatically compute the number of columns based on number of child controls.
  78738. */
  78739. get rows(): BABYLON.int;
  78740. set rows(value: BABYLON.int);
  78741. /**
  78742. * Creates new VolumeBasedPanel
  78743. */
  78744. constructor();
  78745. protected _arrangeChildren(): void;
  78746. /** Child classes must implement this function to provide correct control positioning */
  78747. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78748. /** Child classes can implement this function to provide additional processing */
  78749. protected _finalProcessing(): void;
  78750. }
  78751. }
  78752. declare module BABYLON.GUI {
  78753. /**
  78754. * Class used to create a container panel deployed on the surface of a cylinder
  78755. */
  78756. export class CylinderPanel extends VolumeBasedPanel {
  78757. private _radius;
  78758. /**
  78759. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  78760. */
  78761. get radius(): BABYLON.float;
  78762. set radius(value: BABYLON.float);
  78763. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78764. private _cylindricalMapping;
  78765. }
  78766. }
  78767. declare module BABYLON.GUI {
  78768. /** @hidden */
  78769. export var fluentVertexShader: {
  78770. name: string;
  78771. shader: string;
  78772. };
  78773. }
  78774. declare module BABYLON.GUI {
  78775. /** @hidden */
  78776. export var fluentPixelShader: {
  78777. name: string;
  78778. shader: string;
  78779. };
  78780. }
  78781. declare module BABYLON.GUI {
  78782. /** @hidden */
  78783. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  78784. INNERGLOW: boolean;
  78785. BORDER: boolean;
  78786. HOVERLIGHT: boolean;
  78787. TEXTURE: boolean;
  78788. constructor();
  78789. }
  78790. /**
  78791. * Class used to render controls with fluent desgin
  78792. */
  78793. export class FluentMaterial extends BABYLON.PushMaterial {
  78794. /**
  78795. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  78796. */
  78797. innerGlowColorIntensity: number;
  78798. /**
  78799. * Gets or sets the inner glow color (white by default)
  78800. */
  78801. innerGlowColor: BABYLON.Color3;
  78802. /**
  78803. * Gets or sets alpha value (default is 1.0)
  78804. */
  78805. alpha: number;
  78806. /**
  78807. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  78808. */
  78809. albedoColor: BABYLON.Color3;
  78810. /**
  78811. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  78812. */
  78813. renderBorders: boolean;
  78814. /**
  78815. * Gets or sets border width (default is 0.5)
  78816. */
  78817. borderWidth: number;
  78818. /**
  78819. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  78820. */
  78821. edgeSmoothingValue: number;
  78822. /**
  78823. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  78824. */
  78825. borderMinValue: number;
  78826. /**
  78827. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  78828. */
  78829. renderHoverLight: boolean;
  78830. /**
  78831. * Gets or sets the radius used to render the hover light (default is 1.0)
  78832. */
  78833. hoverRadius: number;
  78834. /**
  78835. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  78836. */
  78837. hoverColor: BABYLON.Color4;
  78838. /**
  78839. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  78840. */
  78841. hoverPosition: BABYLON.Vector3;
  78842. private _albedoTexture;
  78843. /** Gets or sets the texture to use for albedo color */
  78844. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78845. /**
  78846. * Creates a new Fluent material
  78847. * @param name defines the name of the material
  78848. * @param scene defines the hosting scene
  78849. */
  78850. constructor(name: string, scene: BABYLON.Scene);
  78851. needAlphaBlending(): boolean;
  78852. needAlphaTesting(): boolean;
  78853. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78854. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78855. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78856. getActiveTextures(): BABYLON.BaseTexture[];
  78857. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78858. dispose(forceDisposeEffect?: boolean): void;
  78859. clone(name: string): FluentMaterial;
  78860. serialize(): any;
  78861. getClassName(): string;
  78862. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  78863. }
  78864. }
  78865. declare module BABYLON.GUI {
  78866. /**
  78867. * Class used to create a holographic button in 3D
  78868. */
  78869. export class HolographicButton extends Button3D {
  78870. private _backPlate;
  78871. private _textPlate;
  78872. private _frontPlate;
  78873. private _text;
  78874. private _imageUrl;
  78875. private _shareMaterials;
  78876. private _frontMaterial;
  78877. private _backMaterial;
  78878. private _plateMaterial;
  78879. private _pickedPointObserver;
  78880. private _tooltipFade;
  78881. private _tooltipTextBlock;
  78882. private _tooltipTexture;
  78883. private _tooltipMesh;
  78884. private _tooltipHoverObserver;
  78885. private _tooltipOutObserver;
  78886. private _disposeTooltip;
  78887. /**
  78888. * Rendering ground id of all the mesh in the button
  78889. */
  78890. set renderingGroupId(id: number);
  78891. get renderingGroupId(): number;
  78892. /**
  78893. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  78894. */
  78895. set tooltipText(text: BABYLON.Nullable<string>);
  78896. get tooltipText(): BABYLON.Nullable<string>;
  78897. /**
  78898. * Gets or sets text for the button
  78899. */
  78900. get text(): string;
  78901. set text(value: string);
  78902. /**
  78903. * Gets or sets the image url for the button
  78904. */
  78905. get imageUrl(): string;
  78906. set imageUrl(value: string);
  78907. /**
  78908. * Gets the back material used by this button
  78909. */
  78910. get backMaterial(): FluentMaterial;
  78911. /**
  78912. * Gets the front material used by this button
  78913. */
  78914. get frontMaterial(): FluentMaterial;
  78915. /**
  78916. * Gets the plate material used by this button
  78917. */
  78918. get plateMaterial(): BABYLON.StandardMaterial;
  78919. /**
  78920. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  78921. */
  78922. get shareMaterials(): boolean;
  78923. /**
  78924. * Creates a new button
  78925. * @param name defines the control name
  78926. */
  78927. constructor(name?: string, shareMaterials?: boolean);
  78928. protected _getTypeName(): string;
  78929. private _rebuildContent;
  78930. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78931. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  78932. private _createBackMaterial;
  78933. private _createFrontMaterial;
  78934. private _createPlateMaterial;
  78935. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  78936. /**
  78937. * Releases all associated resources
  78938. */
  78939. dispose(): void;
  78940. }
  78941. }
  78942. declare module BABYLON.GUI {
  78943. /**
  78944. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  78945. */
  78946. export class MeshButton3D extends Button3D {
  78947. /** @hidden */
  78948. protected _currentMesh: BABYLON.Mesh;
  78949. /**
  78950. * Creates a new 3D button based on a mesh
  78951. * @param mesh mesh to become a 3D button
  78952. * @param name defines the control name
  78953. */
  78954. constructor(mesh: BABYLON.Mesh, name?: string);
  78955. protected _getTypeName(): string;
  78956. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78957. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  78958. }
  78959. }
  78960. declare module BABYLON.GUI {
  78961. /**
  78962. * Class used to create a container panel deployed on the surface of a plane
  78963. */
  78964. export class PlanePanel extends VolumeBasedPanel {
  78965. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78966. }
  78967. }
  78968. declare module BABYLON.GUI {
  78969. /**
  78970. * Class used to create a container panel where items get randomized planar mapping
  78971. */
  78972. export class ScatterPanel extends VolumeBasedPanel {
  78973. private _iteration;
  78974. /**
  78975. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  78976. */
  78977. get iteration(): BABYLON.float;
  78978. set iteration(value: BABYLON.float);
  78979. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78980. private _scatterMapping;
  78981. protected _finalProcessing(): void;
  78982. }
  78983. }
  78984. declare module BABYLON.GUI {
  78985. /**
  78986. * Class used to create a container panel deployed on the surface of a sphere
  78987. */
  78988. export class SpherePanel extends VolumeBasedPanel {
  78989. private _radius;
  78990. /**
  78991. * Gets or sets the radius of the sphere where to project controls (5 by default)
  78992. */
  78993. get radius(): BABYLON.float;
  78994. set radius(value: BABYLON.float);
  78995. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78996. private _sphericalMapping;
  78997. }
  78998. }
  78999. declare module BABYLON.GUI {
  79000. /**
  79001. * Class used to create a stack panel in 3D on XY plane
  79002. */
  79003. export class StackPanel3D extends Container3D {
  79004. private _isVertical;
  79005. /**
  79006. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  79007. */
  79008. get isVertical(): boolean;
  79009. set isVertical(value: boolean);
  79010. /**
  79011. * Gets or sets the distance between elements
  79012. */
  79013. margin: number;
  79014. /**
  79015. * Creates new StackPanel
  79016. * @param isVertical
  79017. */
  79018. constructor(isVertical?: boolean);
  79019. protected _arrangeChildren(): void;
  79020. }
  79021. }
  79022. declare module BABYLON {
  79023. /**
  79024. * Configuration for glTF validation
  79025. */
  79026. export interface IGLTFValidationConfiguration {
  79027. /**
  79028. * The url of the glTF validator.
  79029. */
  79030. url: string;
  79031. }
  79032. /**
  79033. * glTF validation
  79034. */
  79035. export class GLTFValidation {
  79036. /**
  79037. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  79038. */
  79039. static Configuration: IGLTFValidationConfiguration;
  79040. private static _LoadScriptPromise;
  79041. /**
  79042. * Validate a glTF asset using the glTF-Validator.
  79043. * @param data The JSON of a glTF or the array buffer of a binary glTF
  79044. * @param rootUrl The root url for the glTF
  79045. * @param fileName The file name for the glTF
  79046. * @param getExternalResource The callback to get external resources for the glTF validator
  79047. * @returns A promise that resolves with the glTF validation results once complete
  79048. */
  79049. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  79050. }
  79051. }
  79052. declare module BABYLON {
  79053. /**
  79054. * Mode that determines the coordinate system to use.
  79055. */
  79056. export enum GLTFLoaderCoordinateSystemMode {
  79057. /**
  79058. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  79059. */
  79060. AUTO = 0,
  79061. /**
  79062. * Sets the useRightHandedSystem flag on the scene.
  79063. */
  79064. FORCE_RIGHT_HANDED = 1
  79065. }
  79066. /**
  79067. * Mode that determines what animations will start.
  79068. */
  79069. export enum GLTFLoaderAnimationStartMode {
  79070. /**
  79071. * No animation will start.
  79072. */
  79073. NONE = 0,
  79074. /**
  79075. * The first animation will start.
  79076. */
  79077. FIRST = 1,
  79078. /**
  79079. * All animations will start.
  79080. */
  79081. ALL = 2
  79082. }
  79083. /**
  79084. * Interface that contains the data for the glTF asset.
  79085. */
  79086. export interface IGLTFLoaderData {
  79087. /**
  79088. * The object that represents the glTF JSON.
  79089. */
  79090. json: Object;
  79091. /**
  79092. * The BIN chunk of a binary glTF.
  79093. */
  79094. bin: Nullable<IDataBuffer>;
  79095. }
  79096. /**
  79097. * Interface for extending the loader.
  79098. */
  79099. export interface IGLTFLoaderExtension {
  79100. /**
  79101. * The name of this extension.
  79102. */
  79103. readonly name: string;
  79104. /**
  79105. * Defines whether this extension is enabled.
  79106. */
  79107. enabled: boolean;
  79108. /**
  79109. * Defines the order of this extension.
  79110. * The loader sorts the extensions using these values when loading.
  79111. */
  79112. order?: number;
  79113. }
  79114. /**
  79115. * Loader state.
  79116. */
  79117. export enum GLTFLoaderState {
  79118. /**
  79119. * The asset is loading.
  79120. */
  79121. LOADING = 0,
  79122. /**
  79123. * The asset is ready for rendering.
  79124. */
  79125. READY = 1,
  79126. /**
  79127. * The asset is completely loaded.
  79128. */
  79129. COMPLETE = 2
  79130. }
  79131. /** @hidden */
  79132. export interface IImportMeshAsyncOutput {
  79133. meshes: AbstractMesh[];
  79134. particleSystems: IParticleSystem[];
  79135. skeletons: Skeleton[];
  79136. animationGroups: AnimationGroup[];
  79137. lights: Light[];
  79138. transformNodes: TransformNode[];
  79139. }
  79140. /** @hidden */
  79141. export interface IGLTFLoader extends IDisposable {
  79142. readonly state: Nullable<GLTFLoaderState>;
  79143. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  79144. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  79145. }
  79146. /**
  79147. * File loader for loading glTF files into a scene.
  79148. */
  79149. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  79150. /** @hidden */
  79151. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  79152. /** @hidden */
  79153. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  79154. /**
  79155. * Raised when the asset has been parsed
  79156. */
  79157. onParsedObservable: Observable<IGLTFLoaderData>;
  79158. private _onParsedObserver;
  79159. /**
  79160. * Raised when the asset has been parsed
  79161. */
  79162. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  79163. /**
  79164. * 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.
  79165. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  79166. * Defaults to true.
  79167. * @hidden
  79168. */
  79169. static IncrementalLoading: boolean;
  79170. /**
  79171. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  79172. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  79173. * @hidden
  79174. */
  79175. static HomogeneousCoordinates: boolean;
  79176. /**
  79177. * The coordinate system mode. Defaults to AUTO.
  79178. */
  79179. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  79180. /**
  79181. * The animation start mode. Defaults to FIRST.
  79182. */
  79183. animationStartMode: GLTFLoaderAnimationStartMode;
  79184. /**
  79185. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  79186. */
  79187. compileMaterials: boolean;
  79188. /**
  79189. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  79190. */
  79191. useClipPlane: boolean;
  79192. /**
  79193. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  79194. */
  79195. compileShadowGenerators: boolean;
  79196. /**
  79197. * Defines if the Alpha blended materials are only applied as coverage.
  79198. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  79199. * If true, no extra effects are applied to transparent pixels.
  79200. */
  79201. transparencyAsCoverage: boolean;
  79202. /**
  79203. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  79204. * Enabling will disable offline support and glTF validator.
  79205. * Defaults to false.
  79206. */
  79207. useRangeRequests: boolean;
  79208. /**
  79209. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  79210. */
  79211. createInstances: boolean;
  79212. /**
  79213. * 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.
  79214. */
  79215. alwaysComputeBoundingBox: boolean;
  79216. /**
  79217. * Function called before loading a url referenced by the asset.
  79218. */
  79219. preprocessUrlAsync: (url: string) => Promise<string>;
  79220. /**
  79221. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  79222. */
  79223. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  79224. private _onMeshLoadedObserver;
  79225. /**
  79226. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  79227. */
  79228. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  79229. /**
  79230. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  79231. */
  79232. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  79233. private _onTextureLoadedObserver;
  79234. /**
  79235. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  79236. */
  79237. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  79238. /**
  79239. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  79240. */
  79241. readonly onMaterialLoadedObservable: Observable<Material>;
  79242. private _onMaterialLoadedObserver;
  79243. /**
  79244. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  79245. */
  79246. set onMaterialLoaded(callback: (material: Material) => void);
  79247. /**
  79248. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  79249. */
  79250. readonly onCameraLoadedObservable: Observable<Camera>;
  79251. private _onCameraLoadedObserver;
  79252. /**
  79253. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  79254. */
  79255. set onCameraLoaded(callback: (camera: Camera) => void);
  79256. /**
  79257. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  79258. * For assets with LODs, raised when all of the LODs are complete.
  79259. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  79260. */
  79261. readonly onCompleteObservable: Observable<void>;
  79262. private _onCompleteObserver;
  79263. /**
  79264. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  79265. * For assets with LODs, raised when all of the LODs are complete.
  79266. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  79267. */
  79268. set onComplete(callback: () => void);
  79269. /**
  79270. * Observable raised when an error occurs.
  79271. */
  79272. readonly onErrorObservable: Observable<any>;
  79273. private _onErrorObserver;
  79274. /**
  79275. * Callback raised when an error occurs.
  79276. */
  79277. set onError(callback: (reason: any) => void);
  79278. /**
  79279. * Observable raised after the loader is disposed.
  79280. */
  79281. readonly onDisposeObservable: Observable<void>;
  79282. private _onDisposeObserver;
  79283. /**
  79284. * Callback raised after the loader is disposed.
  79285. */
  79286. set onDispose(callback: () => void);
  79287. /**
  79288. * Observable raised after a loader extension is created.
  79289. * Set additional options for a loader extension in this event.
  79290. */
  79291. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  79292. private _onExtensionLoadedObserver;
  79293. /**
  79294. * Callback raised after a loader extension is created.
  79295. */
  79296. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  79297. /**
  79298. * Defines if the loader logging is enabled.
  79299. */
  79300. get loggingEnabled(): boolean;
  79301. set loggingEnabled(value: boolean);
  79302. /**
  79303. * Defines if the loader should capture performance counters.
  79304. */
  79305. get capturePerformanceCounters(): boolean;
  79306. set capturePerformanceCounters(value: boolean);
  79307. /**
  79308. * Defines if the loader should validate the asset.
  79309. */
  79310. validate: boolean;
  79311. /**
  79312. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  79313. */
  79314. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  79315. private _onValidatedObserver;
  79316. /**
  79317. * Callback raised after a loader extension is created.
  79318. */
  79319. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  79320. private _loader;
  79321. private _progressCallback?;
  79322. private _requests;
  79323. private static magicBase64Encoded;
  79324. /**
  79325. * Name of the loader ("gltf")
  79326. */
  79327. name: string;
  79328. /** @hidden */
  79329. extensions: ISceneLoaderPluginExtensions;
  79330. /**
  79331. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  79332. */
  79333. dispose(): void;
  79334. /** @hidden */
  79335. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  79336. /** @hidden */
  79337. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  79338. /** @hidden */
  79339. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  79340. meshes: AbstractMesh[];
  79341. particleSystems: IParticleSystem[];
  79342. skeletons: Skeleton[];
  79343. animationGroups: AnimationGroup[];
  79344. }>;
  79345. /** @hidden */
  79346. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  79347. /** @hidden */
  79348. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  79349. /** @hidden */
  79350. canDirectLoad(data: string): boolean;
  79351. /** @hidden */
  79352. directLoad(scene: Scene, data: string): Promise<any>;
  79353. /**
  79354. * The callback that allows custom handling of the root url based on the response url.
  79355. * @param rootUrl the original root url
  79356. * @param responseURL the response url if available
  79357. * @returns the new root url
  79358. */
  79359. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  79360. /** @hidden */
  79361. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  79362. /**
  79363. * The loader state or null if the loader is not active.
  79364. */
  79365. get loaderState(): Nullable<GLTFLoaderState>;
  79366. /**
  79367. * Returns a promise that resolves when the asset is completely loaded.
  79368. * @returns a promise that resolves when the asset is completely loaded.
  79369. */
  79370. whenCompleteAsync(): Promise<void>;
  79371. /** @hidden */
  79372. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  79373. /** @hidden */
  79374. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  79375. private _onProgress;
  79376. private _validate;
  79377. private _getLoader;
  79378. private _parseJson;
  79379. private _unpackBinaryAsync;
  79380. private _unpackBinaryV1Async;
  79381. private _unpackBinaryV2Async;
  79382. private static _parseVersion;
  79383. private static _compareVersion;
  79384. private static readonly _logSpaces;
  79385. private _logIndentLevel;
  79386. private _loggingEnabled;
  79387. /** @hidden */
  79388. _log: (message: string) => void;
  79389. /** @hidden */
  79390. _logOpen(message: string): void;
  79391. /** @hidden */
  79392. _logClose(): void;
  79393. private _logEnabled;
  79394. private _logDisabled;
  79395. private _capturePerformanceCounters;
  79396. /** @hidden */
  79397. _startPerformanceCounter: (counterName: string) => void;
  79398. /** @hidden */
  79399. _endPerformanceCounter: (counterName: string) => void;
  79400. private _startPerformanceCounterEnabled;
  79401. private _startPerformanceCounterDisabled;
  79402. private _endPerformanceCounterEnabled;
  79403. private _endPerformanceCounterDisabled;
  79404. }
  79405. }
  79406. declare module BABYLON.GLTF1 {
  79407. /**
  79408. * Enums
  79409. * @hidden
  79410. */
  79411. export enum EComponentType {
  79412. BYTE = 5120,
  79413. UNSIGNED_BYTE = 5121,
  79414. SHORT = 5122,
  79415. UNSIGNED_SHORT = 5123,
  79416. FLOAT = 5126
  79417. }
  79418. /** @hidden */
  79419. export enum EShaderType {
  79420. FRAGMENT = 35632,
  79421. VERTEX = 35633
  79422. }
  79423. /** @hidden */
  79424. export enum EParameterType {
  79425. BYTE = 5120,
  79426. UNSIGNED_BYTE = 5121,
  79427. SHORT = 5122,
  79428. UNSIGNED_SHORT = 5123,
  79429. INT = 5124,
  79430. UNSIGNED_INT = 5125,
  79431. FLOAT = 5126,
  79432. FLOAT_VEC2 = 35664,
  79433. FLOAT_VEC3 = 35665,
  79434. FLOAT_VEC4 = 35666,
  79435. INT_VEC2 = 35667,
  79436. INT_VEC3 = 35668,
  79437. INT_VEC4 = 35669,
  79438. BOOL = 35670,
  79439. BOOL_VEC2 = 35671,
  79440. BOOL_VEC3 = 35672,
  79441. BOOL_VEC4 = 35673,
  79442. FLOAT_MAT2 = 35674,
  79443. FLOAT_MAT3 = 35675,
  79444. FLOAT_MAT4 = 35676,
  79445. SAMPLER_2D = 35678
  79446. }
  79447. /** @hidden */
  79448. export enum ETextureWrapMode {
  79449. CLAMP_TO_EDGE = 33071,
  79450. MIRRORED_REPEAT = 33648,
  79451. REPEAT = 10497
  79452. }
  79453. /** @hidden */
  79454. export enum ETextureFilterType {
  79455. NEAREST = 9728,
  79456. LINEAR = 9728,
  79457. NEAREST_MIPMAP_NEAREST = 9984,
  79458. LINEAR_MIPMAP_NEAREST = 9985,
  79459. NEAREST_MIPMAP_LINEAR = 9986,
  79460. LINEAR_MIPMAP_LINEAR = 9987
  79461. }
  79462. /** @hidden */
  79463. export enum ETextureFormat {
  79464. ALPHA = 6406,
  79465. RGB = 6407,
  79466. RGBA = 6408,
  79467. LUMINANCE = 6409,
  79468. LUMINANCE_ALPHA = 6410
  79469. }
  79470. /** @hidden */
  79471. export enum ECullingType {
  79472. FRONT = 1028,
  79473. BACK = 1029,
  79474. FRONT_AND_BACK = 1032
  79475. }
  79476. /** @hidden */
  79477. export enum EBlendingFunction {
  79478. ZERO = 0,
  79479. ONE = 1,
  79480. SRC_COLOR = 768,
  79481. ONE_MINUS_SRC_COLOR = 769,
  79482. DST_COLOR = 774,
  79483. ONE_MINUS_DST_COLOR = 775,
  79484. SRC_ALPHA = 770,
  79485. ONE_MINUS_SRC_ALPHA = 771,
  79486. DST_ALPHA = 772,
  79487. ONE_MINUS_DST_ALPHA = 773,
  79488. CONSTANT_COLOR = 32769,
  79489. ONE_MINUS_CONSTANT_COLOR = 32770,
  79490. CONSTANT_ALPHA = 32771,
  79491. ONE_MINUS_CONSTANT_ALPHA = 32772,
  79492. SRC_ALPHA_SATURATE = 776
  79493. }
  79494. /** @hidden */
  79495. export interface IGLTFProperty {
  79496. extensions?: {
  79497. [key: string]: any;
  79498. };
  79499. extras?: Object;
  79500. }
  79501. /** @hidden */
  79502. export interface IGLTFChildRootProperty extends IGLTFProperty {
  79503. name?: string;
  79504. }
  79505. /** @hidden */
  79506. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  79507. bufferView: string;
  79508. byteOffset: number;
  79509. byteStride: number;
  79510. count: number;
  79511. type: string;
  79512. componentType: EComponentType;
  79513. max?: number[];
  79514. min?: number[];
  79515. name?: string;
  79516. }
  79517. /** @hidden */
  79518. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  79519. buffer: string;
  79520. byteOffset: number;
  79521. byteLength: number;
  79522. byteStride: number;
  79523. target?: number;
  79524. }
  79525. /** @hidden */
  79526. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  79527. uri: string;
  79528. byteLength?: number;
  79529. type?: string;
  79530. }
  79531. /** @hidden */
  79532. export interface IGLTFShader extends IGLTFChildRootProperty {
  79533. uri: string;
  79534. type: EShaderType;
  79535. }
  79536. /** @hidden */
  79537. export interface IGLTFProgram extends IGLTFChildRootProperty {
  79538. attributes: string[];
  79539. fragmentShader: string;
  79540. vertexShader: string;
  79541. }
  79542. /** @hidden */
  79543. export interface IGLTFTechniqueParameter {
  79544. type: number;
  79545. count?: number;
  79546. semantic?: string;
  79547. node?: string;
  79548. value?: number | boolean | string | Array<any>;
  79549. source?: string;
  79550. babylonValue?: any;
  79551. }
  79552. /** @hidden */
  79553. export interface IGLTFTechniqueCommonProfile {
  79554. lightingModel: string;
  79555. texcoordBindings: Object;
  79556. parameters?: Array<any>;
  79557. }
  79558. /** @hidden */
  79559. export interface IGLTFTechniqueStatesFunctions {
  79560. blendColor?: number[];
  79561. blendEquationSeparate?: number[];
  79562. blendFuncSeparate?: number[];
  79563. colorMask: boolean[];
  79564. cullFace: number[];
  79565. }
  79566. /** @hidden */
  79567. export interface IGLTFTechniqueStates {
  79568. enable: number[];
  79569. functions: IGLTFTechniqueStatesFunctions;
  79570. }
  79571. /** @hidden */
  79572. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  79573. parameters: {
  79574. [key: string]: IGLTFTechniqueParameter;
  79575. };
  79576. program: string;
  79577. attributes: {
  79578. [key: string]: string;
  79579. };
  79580. uniforms: {
  79581. [key: string]: string;
  79582. };
  79583. states: IGLTFTechniqueStates;
  79584. }
  79585. /** @hidden */
  79586. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  79587. technique?: string;
  79588. values: string[];
  79589. }
  79590. /** @hidden */
  79591. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  79592. attributes: {
  79593. [key: string]: string;
  79594. };
  79595. indices: string;
  79596. material: string;
  79597. mode?: number;
  79598. }
  79599. /** @hidden */
  79600. export interface IGLTFMesh extends IGLTFChildRootProperty {
  79601. primitives: IGLTFMeshPrimitive[];
  79602. }
  79603. /** @hidden */
  79604. export interface IGLTFImage extends IGLTFChildRootProperty {
  79605. uri: string;
  79606. }
  79607. /** @hidden */
  79608. export interface IGLTFSampler extends IGLTFChildRootProperty {
  79609. magFilter?: number;
  79610. minFilter?: number;
  79611. wrapS?: number;
  79612. wrapT?: number;
  79613. }
  79614. /** @hidden */
  79615. export interface IGLTFTexture extends IGLTFChildRootProperty {
  79616. sampler: string;
  79617. source: string;
  79618. format?: ETextureFormat;
  79619. internalFormat?: ETextureFormat;
  79620. target?: number;
  79621. type?: number;
  79622. babylonTexture?: Texture;
  79623. }
  79624. /** @hidden */
  79625. export interface IGLTFAmbienLight {
  79626. color?: number[];
  79627. }
  79628. /** @hidden */
  79629. export interface IGLTFDirectionalLight {
  79630. color?: number[];
  79631. }
  79632. /** @hidden */
  79633. export interface IGLTFPointLight {
  79634. color?: number[];
  79635. constantAttenuation?: number;
  79636. linearAttenuation?: number;
  79637. quadraticAttenuation?: number;
  79638. }
  79639. /** @hidden */
  79640. export interface IGLTFSpotLight {
  79641. color?: number[];
  79642. constantAttenuation?: number;
  79643. fallOfAngle?: number;
  79644. fallOffExponent?: number;
  79645. linearAttenuation?: number;
  79646. quadraticAttenuation?: number;
  79647. }
  79648. /** @hidden */
  79649. export interface IGLTFLight extends IGLTFChildRootProperty {
  79650. type: string;
  79651. }
  79652. /** @hidden */
  79653. export interface IGLTFCameraOrthographic {
  79654. xmag: number;
  79655. ymag: number;
  79656. zfar: number;
  79657. znear: number;
  79658. }
  79659. /** @hidden */
  79660. export interface IGLTFCameraPerspective {
  79661. aspectRatio: number;
  79662. yfov: number;
  79663. zfar: number;
  79664. znear: number;
  79665. }
  79666. /** @hidden */
  79667. export interface IGLTFCamera extends IGLTFChildRootProperty {
  79668. type: string;
  79669. }
  79670. /** @hidden */
  79671. export interface IGLTFAnimationChannelTarget {
  79672. id: string;
  79673. path: string;
  79674. }
  79675. /** @hidden */
  79676. export interface IGLTFAnimationChannel {
  79677. sampler: string;
  79678. target: IGLTFAnimationChannelTarget;
  79679. }
  79680. /** @hidden */
  79681. export interface IGLTFAnimationSampler {
  79682. input: string;
  79683. output: string;
  79684. interpolation?: string;
  79685. }
  79686. /** @hidden */
  79687. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  79688. channels?: IGLTFAnimationChannel[];
  79689. parameters?: {
  79690. [key: string]: string;
  79691. };
  79692. samplers?: {
  79693. [key: string]: IGLTFAnimationSampler;
  79694. };
  79695. }
  79696. /** @hidden */
  79697. export interface IGLTFNodeInstanceSkin {
  79698. skeletons: string[];
  79699. skin: string;
  79700. meshes: string[];
  79701. }
  79702. /** @hidden */
  79703. export interface IGLTFSkins extends IGLTFChildRootProperty {
  79704. bindShapeMatrix: number[];
  79705. inverseBindMatrices: string;
  79706. jointNames: string[];
  79707. babylonSkeleton?: Skeleton;
  79708. }
  79709. /** @hidden */
  79710. export interface IGLTFNode extends IGLTFChildRootProperty {
  79711. camera?: string;
  79712. children: string[];
  79713. skin?: string;
  79714. jointName?: string;
  79715. light?: string;
  79716. matrix: number[];
  79717. mesh?: string;
  79718. meshes?: string[];
  79719. rotation?: number[];
  79720. scale?: number[];
  79721. translation?: number[];
  79722. babylonNode?: Node;
  79723. }
  79724. /** @hidden */
  79725. export interface IGLTFScene extends IGLTFChildRootProperty {
  79726. nodes: string[];
  79727. }
  79728. /** @hidden */
  79729. export interface IGLTFRuntime {
  79730. extensions: {
  79731. [key: string]: any;
  79732. };
  79733. accessors: {
  79734. [key: string]: IGLTFAccessor;
  79735. };
  79736. buffers: {
  79737. [key: string]: IGLTFBuffer;
  79738. };
  79739. bufferViews: {
  79740. [key: string]: IGLTFBufferView;
  79741. };
  79742. meshes: {
  79743. [key: string]: IGLTFMesh;
  79744. };
  79745. lights: {
  79746. [key: string]: IGLTFLight;
  79747. };
  79748. cameras: {
  79749. [key: string]: IGLTFCamera;
  79750. };
  79751. nodes: {
  79752. [key: string]: IGLTFNode;
  79753. };
  79754. images: {
  79755. [key: string]: IGLTFImage;
  79756. };
  79757. textures: {
  79758. [key: string]: IGLTFTexture;
  79759. };
  79760. shaders: {
  79761. [key: string]: IGLTFShader;
  79762. };
  79763. programs: {
  79764. [key: string]: IGLTFProgram;
  79765. };
  79766. samplers: {
  79767. [key: string]: IGLTFSampler;
  79768. };
  79769. techniques: {
  79770. [key: string]: IGLTFTechnique;
  79771. };
  79772. materials: {
  79773. [key: string]: IGLTFMaterial;
  79774. };
  79775. animations: {
  79776. [key: string]: IGLTFAnimation;
  79777. };
  79778. skins: {
  79779. [key: string]: IGLTFSkins;
  79780. };
  79781. currentScene?: Object;
  79782. scenes: {
  79783. [key: string]: IGLTFScene;
  79784. };
  79785. extensionsUsed: string[];
  79786. extensionsRequired?: string[];
  79787. buffersCount: number;
  79788. shaderscount: number;
  79789. scene: Scene;
  79790. rootUrl: string;
  79791. loadedBufferCount: number;
  79792. loadedBufferViews: {
  79793. [name: string]: ArrayBufferView;
  79794. };
  79795. loadedShaderCount: number;
  79796. importOnlyMeshes: boolean;
  79797. importMeshesNames?: string[];
  79798. dummyNodes: Node[];
  79799. forAssetContainer: boolean;
  79800. }
  79801. /** @hidden */
  79802. export interface INodeToRoot {
  79803. bone: Bone;
  79804. node: IGLTFNode;
  79805. id: string;
  79806. }
  79807. /** @hidden */
  79808. export interface IJointNode {
  79809. node: IGLTFNode;
  79810. id: string;
  79811. }
  79812. }
  79813. declare module BABYLON.GLTF1 {
  79814. /**
  79815. * Utils functions for GLTF
  79816. * @hidden
  79817. */
  79818. export class GLTFUtils {
  79819. /**
  79820. * Sets the given "parameter" matrix
  79821. * @param scene: the Scene object
  79822. * @param source: the source node where to pick the matrix
  79823. * @param parameter: the GLTF technique parameter
  79824. * @param uniformName: the name of the shader's uniform
  79825. * @param shaderMaterial: the shader material
  79826. */
  79827. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  79828. /**
  79829. * Sets the given "parameter" matrix
  79830. * @param shaderMaterial: the shader material
  79831. * @param uniform: the name of the shader's uniform
  79832. * @param value: the value of the uniform
  79833. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  79834. */
  79835. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  79836. /**
  79837. * Returns the wrap mode of the texture
  79838. * @param mode: the mode value
  79839. */
  79840. static GetWrapMode(mode: number): number;
  79841. /**
  79842. * Returns the byte stride giving an accessor
  79843. * @param accessor: the GLTF accessor objet
  79844. */
  79845. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  79846. /**
  79847. * Returns the texture filter mode giving a mode value
  79848. * @param mode: the filter mode value
  79849. */
  79850. static GetTextureFilterMode(mode: number): ETextureFilterType;
  79851. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  79852. /**
  79853. * Returns a buffer from its accessor
  79854. * @param gltfRuntime: the GLTF runtime
  79855. * @param accessor: the GLTF accessor
  79856. */
  79857. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  79858. /**
  79859. * Decodes a buffer view into a string
  79860. * @param view: the buffer view
  79861. */
  79862. static DecodeBufferToText(view: ArrayBufferView): string;
  79863. /**
  79864. * Returns the default material of gltf. Related to
  79865. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  79866. * @param scene: the Babylon.js scene
  79867. */
  79868. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  79869. private static _DefaultMaterial;
  79870. }
  79871. }
  79872. declare module BABYLON.GLTF1 {
  79873. /**
  79874. * Implementation of the base glTF spec
  79875. * @hidden
  79876. */
  79877. export class GLTFLoaderBase {
  79878. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  79879. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  79880. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  79881. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  79882. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  79883. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  79884. }
  79885. /**
  79886. * glTF V1 Loader
  79887. * @hidden
  79888. */
  79889. export class GLTFLoader implements IGLTFLoader {
  79890. static Extensions: {
  79891. [name: string]: GLTFLoaderExtension;
  79892. };
  79893. static RegisterExtension(extension: GLTFLoaderExtension): void;
  79894. state: Nullable<GLTFLoaderState>;
  79895. dispose(): void;
  79896. private _importMeshAsync;
  79897. /**
  79898. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  79899. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  79900. * @param scene the scene the meshes should be added to
  79901. * @param forAssetContainer defines if the entities must be stored in the scene
  79902. * @param data gltf data containing information of the meshes in a loaded file
  79903. * @param rootUrl root url to load from
  79904. * @param onProgress event that fires when loading progress has occured
  79905. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  79906. */
  79907. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  79908. private _loadAsync;
  79909. /**
  79910. * Imports all objects from a loaded gltf file and adds them to the scene
  79911. * @param scene the scene the objects should be added to
  79912. * @param data gltf data containing information of the meshes in a loaded file
  79913. * @param rootUrl root url to load from
  79914. * @param onProgress event that fires when loading progress has occured
  79915. * @returns a promise which completes when objects have been loaded to the scene
  79916. */
  79917. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  79918. private _loadShadersAsync;
  79919. private _loadBuffersAsync;
  79920. private _createNodes;
  79921. }
  79922. /** @hidden */
  79923. export abstract class GLTFLoaderExtension {
  79924. private _name;
  79925. constructor(name: string);
  79926. get name(): string;
  79927. /**
  79928. * Defines an override for loading the runtime
  79929. * Return true to stop further extensions from loading the runtime
  79930. */
  79931. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  79932. /**
  79933. * Defines an onverride for creating gltf runtime
  79934. * Return true to stop further extensions from creating the runtime
  79935. */
  79936. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  79937. /**
  79938. * Defines an override for loading buffers
  79939. * Return true to stop further extensions from loading this buffer
  79940. */
  79941. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  79942. /**
  79943. * Defines an override for loading texture buffers
  79944. * Return true to stop further extensions from loading this texture data
  79945. */
  79946. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79947. /**
  79948. * Defines an override for creating textures
  79949. * Return true to stop further extensions from loading this texture
  79950. */
  79951. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  79952. /**
  79953. * Defines an override for loading shader strings
  79954. * Return true to stop further extensions from loading this shader data
  79955. */
  79956. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  79957. /**
  79958. * Defines an override for loading materials
  79959. * Return true to stop further extensions from loading this material
  79960. */
  79961. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  79962. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  79963. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  79964. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  79965. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  79966. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  79967. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  79968. private static LoadTextureBufferAsync;
  79969. private static CreateTextureAsync;
  79970. private static ApplyExtensions;
  79971. }
  79972. }
  79973. declare module BABYLON.GLTF1 {
  79974. /** @hidden */
  79975. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  79976. private _bin;
  79977. constructor();
  79978. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  79979. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79980. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79981. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  79982. }
  79983. }
  79984. declare module BABYLON.GLTF1 {
  79985. /** @hidden */
  79986. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  79987. constructor();
  79988. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  79989. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  79990. private _loadTexture;
  79991. }
  79992. }
  79993. declare module BABYLON.GLTF2.Loader {
  79994. /**
  79995. * Loader interface with an index field.
  79996. */
  79997. export interface IArrayItem {
  79998. /**
  79999. * The index of this item in the array.
  80000. */
  80001. index: number;
  80002. }
  80003. /**
  80004. * Loader interface with additional members.
  80005. */
  80006. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  80007. /** @hidden */
  80008. _data?: Promise<ArrayBufferView>;
  80009. /** @hidden */
  80010. _babylonVertexBuffer?: Promise<VertexBuffer>;
  80011. }
  80012. /**
  80013. * Loader interface with additional members.
  80014. */
  80015. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  80016. }
  80017. /** @hidden */
  80018. export interface _IAnimationSamplerData {
  80019. input: Float32Array;
  80020. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  80021. output: Float32Array;
  80022. }
  80023. /**
  80024. * Loader interface with additional members.
  80025. */
  80026. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  80027. /** @hidden */
  80028. _data?: Promise<_IAnimationSamplerData>;
  80029. }
  80030. /**
  80031. * Loader interface with additional members.
  80032. */
  80033. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  80034. channels: IAnimationChannel[];
  80035. samplers: IAnimationSampler[];
  80036. /** @hidden */
  80037. _babylonAnimationGroup?: AnimationGroup;
  80038. }
  80039. /**
  80040. * Loader interface with additional members.
  80041. */
  80042. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  80043. /** @hidden */
  80044. _data?: Promise<ArrayBufferView>;
  80045. }
  80046. /**
  80047. * Loader interface with additional members.
  80048. */
  80049. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  80050. /** @hidden */
  80051. _data?: Promise<ArrayBufferView>;
  80052. /** @hidden */
  80053. _babylonBuffer?: Promise<Buffer>;
  80054. }
  80055. /**
  80056. * Loader interface with additional members.
  80057. */
  80058. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  80059. }
  80060. /**
  80061. * Loader interface with additional members.
  80062. */
  80063. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  80064. /** @hidden */
  80065. _data?: Promise<ArrayBufferView>;
  80066. }
  80067. /**
  80068. * Loader interface with additional members.
  80069. */
  80070. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  80071. }
  80072. /**
  80073. * Loader interface with additional members.
  80074. */
  80075. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  80076. }
  80077. /**
  80078. * Loader interface with additional members.
  80079. */
  80080. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  80081. baseColorTexture?: ITextureInfo;
  80082. metallicRoughnessTexture?: ITextureInfo;
  80083. }
  80084. /**
  80085. * Loader interface with additional members.
  80086. */
  80087. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  80088. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  80089. normalTexture?: IMaterialNormalTextureInfo;
  80090. occlusionTexture?: IMaterialOcclusionTextureInfo;
  80091. emissiveTexture?: ITextureInfo;
  80092. /** @hidden */
  80093. _data?: {
  80094. [babylonDrawMode: number]: {
  80095. babylonMaterial: Material;
  80096. babylonMeshes: AbstractMesh[];
  80097. promise: Promise<void>;
  80098. };
  80099. };
  80100. }
  80101. /**
  80102. * Loader interface with additional members.
  80103. */
  80104. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  80105. primitives: IMeshPrimitive[];
  80106. }
  80107. /**
  80108. * Loader interface with additional members.
  80109. */
  80110. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  80111. /** @hidden */
  80112. _instanceData?: {
  80113. babylonSourceMesh: Mesh;
  80114. promise: Promise<any>;
  80115. };
  80116. }
  80117. /**
  80118. * Loader interface with additional members.
  80119. */
  80120. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  80121. /**
  80122. * The parent glTF node.
  80123. */
  80124. parent?: INode;
  80125. /** @hidden */
  80126. _babylonTransformNode?: TransformNode;
  80127. /** @hidden */
  80128. _primitiveBabylonMeshes?: AbstractMesh[];
  80129. /** @hidden */
  80130. _babylonBones?: Bone[];
  80131. /** @hidden */
  80132. _numMorphTargets?: number;
  80133. }
  80134. /** @hidden */
  80135. export interface _ISamplerData {
  80136. noMipMaps: boolean;
  80137. samplingMode: number;
  80138. wrapU: number;
  80139. wrapV: number;
  80140. }
  80141. /**
  80142. * Loader interface with additional members.
  80143. */
  80144. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  80145. /** @hidden */
  80146. _data?: _ISamplerData;
  80147. }
  80148. /**
  80149. * Loader interface with additional members.
  80150. */
  80151. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  80152. }
  80153. /**
  80154. * Loader interface with additional members.
  80155. */
  80156. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  80157. /** @hidden */
  80158. _data?: {
  80159. babylonSkeleton: Skeleton;
  80160. promise: Promise<void>;
  80161. };
  80162. }
  80163. /**
  80164. * Loader interface with additional members.
  80165. */
  80166. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  80167. }
  80168. /**
  80169. * Loader interface with additional members.
  80170. */
  80171. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  80172. }
  80173. /**
  80174. * Loader interface with additional members.
  80175. */
  80176. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  80177. accessors?: IAccessor[];
  80178. animations?: IAnimation[];
  80179. buffers?: IBuffer[];
  80180. bufferViews?: IBufferView[];
  80181. cameras?: ICamera[];
  80182. images?: IImage[];
  80183. materials?: IMaterial[];
  80184. meshes?: IMesh[];
  80185. nodes?: INode[];
  80186. samplers?: ISampler[];
  80187. scenes?: IScene[];
  80188. skins?: ISkin[];
  80189. textures?: ITexture[];
  80190. }
  80191. }
  80192. declare module BABYLON.GLTF2 {
  80193. /**
  80194. * Interface for a glTF loader extension.
  80195. */
  80196. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  80197. /**
  80198. * Called after the loader state changes to LOADING.
  80199. */
  80200. onLoading?(): void;
  80201. /**
  80202. * Called after the loader state changes to READY.
  80203. */
  80204. onReady?(): void;
  80205. /**
  80206. * Define this method to modify the default behavior when loading scenes.
  80207. * @param context The context when loading the asset
  80208. * @param scene The glTF scene property
  80209. * @returns A promise that resolves when the load is complete or null if not handled
  80210. */
  80211. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  80212. /**
  80213. * Define this method to modify the default behavior when loading nodes.
  80214. * @param context The context when loading the asset
  80215. * @param node The glTF node property
  80216. * @param assign A function called synchronously after parsing the glTF properties
  80217. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  80218. */
  80219. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80220. /**
  80221. * Define this method to modify the default behavior when loading cameras.
  80222. * @param context The context when loading the asset
  80223. * @param camera The glTF camera property
  80224. * @param assign A function called synchronously after parsing the glTF properties
  80225. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  80226. */
  80227. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  80228. /**
  80229. * @hidden
  80230. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  80231. * @param context The context when loading the asset
  80232. * @param primitive The glTF mesh primitive property
  80233. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  80234. */
  80235. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  80236. /**
  80237. * @hidden
  80238. * Define this method to modify the default behavior when loading data for mesh primitives.
  80239. * @param context The context when loading the asset
  80240. * @param name The mesh name when loading the asset
  80241. * @param node The glTF node when loading the asset
  80242. * @param mesh The glTF mesh when loading the asset
  80243. * @param primitive The glTF mesh primitive property
  80244. * @param assign A function called synchronously after parsing the glTF properties
  80245. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  80246. */
  80247. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  80248. /**
  80249. * @hidden
  80250. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  80251. * @param context The context when loading the asset
  80252. * @param material The glTF material property
  80253. * @param assign A function called synchronously after parsing the glTF properties
  80254. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  80255. */
  80256. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  80257. /**
  80258. * Define this method to modify the default behavior when creating materials.
  80259. * @param context The context when loading the asset
  80260. * @param material The glTF material property
  80261. * @param babylonDrawMode The draw mode for the Babylon material
  80262. * @returns The Babylon material or null if not handled
  80263. */
  80264. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  80265. /**
  80266. * Define this method to modify the default behavior when loading material properties.
  80267. * @param context The context when loading the asset
  80268. * @param material The glTF material property
  80269. * @param babylonMaterial The Babylon material
  80270. * @returns A promise that resolves when the load is complete or null if not handled
  80271. */
  80272. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80273. /**
  80274. * Define this method to modify the default behavior when loading texture infos.
  80275. * @param context The context when loading the asset
  80276. * @param textureInfo The glTF texture info property
  80277. * @param assign A function called synchronously after parsing the glTF properties
  80278. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  80279. */
  80280. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80281. /**
  80282. * @hidden
  80283. * Define this method to modify the default behavior when loading textures.
  80284. * @param context The context when loading the asset
  80285. * @param texture The glTF texture property
  80286. * @param assign A function called synchronously after parsing the glTF properties
  80287. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  80288. */
  80289. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80290. /**
  80291. * Define this method to modify the default behavior when loading animations.
  80292. * @param context The context when loading the asset
  80293. * @param animation The glTF animation property
  80294. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  80295. */
  80296. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  80297. /**
  80298. * @hidden
  80299. * Define this method to modify the default behavior when loading skins.
  80300. * @param context The context when loading the asset
  80301. * @param node The glTF node property
  80302. * @param skin The glTF skin property
  80303. * @returns A promise that resolves when the load is complete or null if not handled
  80304. */
  80305. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  80306. /**
  80307. * @hidden
  80308. * Define this method to modify the default behavior when loading uris.
  80309. * @param context The context when loading the asset
  80310. * @param property The glTF property associated with the uri
  80311. * @param uri The uri to load
  80312. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  80313. */
  80314. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  80315. /**
  80316. * Define this method to modify the default behavior when loading buffer views.
  80317. * @param context The context when loading the asset
  80318. * @param bufferView The glTF buffer view property
  80319. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  80320. */
  80321. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  80322. /**
  80323. * Define this method to modify the default behavior when loading buffers.
  80324. * @param context The context when loading the asset
  80325. * @param buffer The glTF buffer property
  80326. * @param byteOffset The byte offset to load
  80327. * @param byteLength The byte length to load
  80328. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  80329. */
  80330. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  80331. }
  80332. }
  80333. declare module BABYLON.GLTF2 {
  80334. /**
  80335. * Helper class for working with arrays when loading the glTF asset
  80336. */
  80337. export class ArrayItem {
  80338. /**
  80339. * Gets an item from the given array.
  80340. * @param context The context when loading the asset
  80341. * @param array The array to get the item from
  80342. * @param index The index to the array
  80343. * @returns The array item
  80344. */
  80345. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  80346. /**
  80347. * Assign an `index` field to each item of the given array.
  80348. * @param array The array of items
  80349. */
  80350. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  80351. }
  80352. /**
  80353. * The glTF 2.0 loader
  80354. */
  80355. export class GLTFLoader implements IGLTFLoader {
  80356. /** @hidden */
  80357. _completePromises: Promise<any>[];
  80358. /** @hidden */
  80359. _forAssetContainer: boolean;
  80360. /** Storage */
  80361. _babylonLights: Light[];
  80362. /** @hidden */
  80363. _disableInstancedMesh: number;
  80364. private _disposed;
  80365. private _parent;
  80366. private _state;
  80367. private _extensions;
  80368. private _rootUrl;
  80369. private _fileName;
  80370. private _uniqueRootUrl;
  80371. private _gltf;
  80372. private _bin;
  80373. private _babylonScene;
  80374. private _rootBabylonMesh;
  80375. private _defaultBabylonMaterialData;
  80376. private static _RegisteredExtensions;
  80377. /**
  80378. * The default glTF sampler.
  80379. */
  80380. static readonly DefaultSampler: ISampler;
  80381. /**
  80382. * Registers a loader extension.
  80383. * @param name The name of the loader extension.
  80384. * @param factory The factory function that creates the loader extension.
  80385. */
  80386. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  80387. /**
  80388. * Unregisters a loader extension.
  80389. * @param name The name of the loader extension.
  80390. * @returns A boolean indicating whether the extension has been unregistered
  80391. */
  80392. static UnregisterExtension(name: string): boolean;
  80393. /**
  80394. * The loader state.
  80395. */
  80396. get state(): Nullable<GLTFLoaderState>;
  80397. /**
  80398. * The object that represents the glTF JSON.
  80399. */
  80400. get gltf(): IGLTF;
  80401. /**
  80402. * The BIN chunk of a binary glTF.
  80403. */
  80404. get bin(): Nullable<IDataBuffer>;
  80405. /**
  80406. * The parent file loader.
  80407. */
  80408. get parent(): GLTFFileLoader;
  80409. /**
  80410. * The Babylon scene when loading the asset.
  80411. */
  80412. get babylonScene(): Scene;
  80413. /**
  80414. * The root Babylon mesh when loading the asset.
  80415. */
  80416. get rootBabylonMesh(): Mesh;
  80417. /** @hidden */
  80418. constructor(parent: GLTFFileLoader);
  80419. /** @hidden */
  80420. dispose(): void;
  80421. /** @hidden */
  80422. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  80423. /** @hidden */
  80424. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  80425. private _loadAsync;
  80426. private _loadData;
  80427. private _setupData;
  80428. private _loadExtensions;
  80429. private _checkExtensions;
  80430. private _setState;
  80431. private _createRootNode;
  80432. /**
  80433. * Loads a glTF scene.
  80434. * @param context The context when loading the asset
  80435. * @param scene The glTF scene property
  80436. * @returns A promise that resolves when the load is complete
  80437. */
  80438. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  80439. private _forEachPrimitive;
  80440. private _getMeshes;
  80441. private _getTransformNodes;
  80442. private _getSkeletons;
  80443. private _getAnimationGroups;
  80444. private _startAnimations;
  80445. /**
  80446. * Loads a glTF node.
  80447. * @param context The context when loading the asset
  80448. * @param node The glTF node property
  80449. * @param assign A function called synchronously after parsing the glTF properties
  80450. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  80451. */
  80452. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  80453. private _loadMeshAsync;
  80454. /**
  80455. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  80456. * @param context The context when loading the asset
  80457. * @param name The mesh name when loading the asset
  80458. * @param node The glTF node when loading the asset
  80459. * @param mesh The glTF mesh when loading the asset
  80460. * @param primitive The glTF mesh primitive property
  80461. * @param assign A function called synchronously after parsing the glTF properties
  80462. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  80463. */
  80464. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  80465. private _loadVertexDataAsync;
  80466. private _createMorphTargets;
  80467. private _loadMorphTargetsAsync;
  80468. private _loadMorphTargetVertexDataAsync;
  80469. private static _LoadTransform;
  80470. private _loadSkinAsync;
  80471. private _loadBones;
  80472. private _loadBone;
  80473. private _loadSkinInverseBindMatricesDataAsync;
  80474. private _updateBoneMatrices;
  80475. private _getNodeMatrix;
  80476. /**
  80477. * Loads a glTF camera.
  80478. * @param context The context when loading the asset
  80479. * @param camera The glTF camera property
  80480. * @param assign A function called synchronously after parsing the glTF properties
  80481. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  80482. */
  80483. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  80484. private _loadAnimationsAsync;
  80485. /**
  80486. * Loads a glTF animation.
  80487. * @param context The context when loading the asset
  80488. * @param animation The glTF animation property
  80489. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  80490. */
  80491. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  80492. /**
  80493. * @hidden Loads a glTF animation channel.
  80494. * @param context The context when loading the asset
  80495. * @param animationContext The context of the animation when loading the asset
  80496. * @param animation The glTF animation property
  80497. * @param channel The glTF animation channel property
  80498. * @param babylonAnimationGroup The babylon animation group property
  80499. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  80500. * @returns A void promise when the channel load is complete
  80501. */
  80502. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  80503. private _loadAnimationSamplerAsync;
  80504. private _loadBufferAsync;
  80505. /**
  80506. * Loads a glTF buffer view.
  80507. * @param context The context when loading the asset
  80508. * @param bufferView The glTF buffer view property
  80509. * @returns A promise that resolves with the loaded data when the load is complete
  80510. */
  80511. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  80512. private _loadAccessorAsync;
  80513. /** @hidden */
  80514. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  80515. private _loadIndicesAccessorAsync;
  80516. private _loadVertexBufferViewAsync;
  80517. private _loadVertexAccessorAsync;
  80518. private _loadMaterialMetallicRoughnessPropertiesAsync;
  80519. /** @hidden */
  80520. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  80521. private _createDefaultMaterial;
  80522. /**
  80523. * Creates a Babylon material from a glTF material.
  80524. * @param context The context when loading the asset
  80525. * @param material The glTF material property
  80526. * @param babylonDrawMode The draw mode for the Babylon material
  80527. * @returns The Babylon material
  80528. */
  80529. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  80530. /**
  80531. * Loads properties from a glTF material into a Babylon material.
  80532. * @param context The context when loading the asset
  80533. * @param material The glTF material property
  80534. * @param babylonMaterial The Babylon material
  80535. * @returns A promise that resolves when the load is complete
  80536. */
  80537. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  80538. /**
  80539. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  80540. * @param context The context when loading the asset
  80541. * @param material The glTF material property
  80542. * @param babylonMaterial The Babylon material
  80543. * @returns A promise that resolves when the load is complete
  80544. */
  80545. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  80546. /**
  80547. * Loads the alpha properties from a glTF material into a Babylon material.
  80548. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  80549. * @param context The context when loading the asset
  80550. * @param material The glTF material property
  80551. * @param babylonMaterial The Babylon material
  80552. */
  80553. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  80554. /**
  80555. * Loads a glTF texture info.
  80556. * @param context The context when loading the asset
  80557. * @param textureInfo The glTF texture info property
  80558. * @param assign A function called synchronously after parsing the glTF properties
  80559. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  80560. */
  80561. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  80562. /** @hidden */
  80563. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  80564. /** @hidden */
  80565. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  80566. private _loadSampler;
  80567. /**
  80568. * Loads a glTF image.
  80569. * @param context The context when loading the asset
  80570. * @param image The glTF image property
  80571. * @returns A promise that resolves with the loaded data when the load is complete
  80572. */
  80573. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  80574. /**
  80575. * Loads a glTF uri.
  80576. * @param context The context when loading the asset
  80577. * @param property The glTF property associated with the uri
  80578. * @param uri The base64 or relative uri
  80579. * @returns A promise that resolves with the loaded data when the load is complete
  80580. */
  80581. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  80582. /**
  80583. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  80584. * @param babylonObject the Babylon object with metadata
  80585. * @param pointer the JSON pointer
  80586. */
  80587. static AddPointerMetadata(babylonObject: {
  80588. metadata: any;
  80589. }, pointer: string): void;
  80590. private static _GetTextureWrapMode;
  80591. private static _GetTextureSamplingMode;
  80592. private static _GetTypedArrayConstructor;
  80593. private static _GetTypedArray;
  80594. private static _GetNumComponents;
  80595. private static _ValidateUri;
  80596. /** @hidden */
  80597. static _GetDrawMode(context: string, mode: number | undefined): number;
  80598. private _compileMaterialsAsync;
  80599. private _compileShadowGeneratorsAsync;
  80600. private _forEachExtensions;
  80601. private _applyExtensions;
  80602. private _extensionsOnLoading;
  80603. private _extensionsOnReady;
  80604. private _extensionsLoadSceneAsync;
  80605. private _extensionsLoadNodeAsync;
  80606. private _extensionsLoadCameraAsync;
  80607. private _extensionsLoadVertexDataAsync;
  80608. private _extensionsLoadMeshPrimitiveAsync;
  80609. private _extensionsLoadMaterialAsync;
  80610. private _extensionsCreateMaterial;
  80611. private _extensionsLoadMaterialPropertiesAsync;
  80612. private _extensionsLoadTextureInfoAsync;
  80613. private _extensionsLoadTextureAsync;
  80614. private _extensionsLoadAnimationAsync;
  80615. private _extensionsLoadSkinAsync;
  80616. private _extensionsLoadUriAsync;
  80617. private _extensionsLoadBufferViewAsync;
  80618. private _extensionsLoadBufferAsync;
  80619. /**
  80620. * Helper method called by a loader extension to load an glTF extension.
  80621. * @param context The context when loading the asset
  80622. * @param property The glTF property to load the extension from
  80623. * @param extensionName The name of the extension to load
  80624. * @param actionAsync The action to run
  80625. * @returns The promise returned by actionAsync or null if the extension does not exist
  80626. */
  80627. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  80628. /**
  80629. * Helper method called by a loader extension to load a glTF extra.
  80630. * @param context The context when loading the asset
  80631. * @param property The glTF property to load the extra from
  80632. * @param extensionName The name of the extension to load
  80633. * @param actionAsync The action to run
  80634. * @returns The promise returned by actionAsync or null if the extra does not exist
  80635. */
  80636. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  80637. /**
  80638. * Checks for presence of an extension.
  80639. * @param name The name of the extension to check
  80640. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  80641. */
  80642. isExtensionUsed(name: string): boolean;
  80643. /**
  80644. * Increments the indentation level and logs a message.
  80645. * @param message The message to log
  80646. */
  80647. logOpen(message: string): void;
  80648. /**
  80649. * Decrements the indentation level.
  80650. */
  80651. logClose(): void;
  80652. /**
  80653. * Logs a message
  80654. * @param message The message to log
  80655. */
  80656. log(message: string): void;
  80657. /**
  80658. * Starts a performance counter.
  80659. * @param counterName The name of the performance counter
  80660. */
  80661. startPerformanceCounter(counterName: string): void;
  80662. /**
  80663. * Ends a performance counter.
  80664. * @param counterName The name of the performance counter
  80665. */
  80666. endPerformanceCounter(counterName: string): void;
  80667. }
  80668. }
  80669. declare module BABYLON.GLTF2.Loader.Extensions {
  80670. /** @hidden */
  80671. interface IEXTLightsImageBased_LightImageBased {
  80672. _babylonTexture?: BaseTexture;
  80673. _loaded?: Promise<void>;
  80674. }
  80675. /**
  80676. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  80677. */
  80678. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  80679. /**
  80680. * The name of this extension.
  80681. */
  80682. readonly name: string;
  80683. /**
  80684. * Defines whether this extension is enabled.
  80685. */
  80686. enabled: boolean;
  80687. private _loader;
  80688. private _lights?;
  80689. /** @hidden */
  80690. constructor(loader: GLTFLoader);
  80691. /** @hidden */
  80692. dispose(): void;
  80693. /** @hidden */
  80694. onLoading(): void;
  80695. /** @hidden */
  80696. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  80697. private _loadLightAsync;
  80698. }
  80699. }
  80700. declare module BABYLON.GLTF2.Loader.Extensions {
  80701. /**
  80702. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  80703. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  80704. * !!! Experimental Extension Subject to Changes !!!
  80705. */
  80706. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  80707. /**
  80708. * The name of this extension.
  80709. */
  80710. readonly name: string;
  80711. /**
  80712. * Defines whether this extension is enabled.
  80713. */
  80714. enabled: boolean;
  80715. private _loader;
  80716. /** @hidden */
  80717. constructor(loader: GLTFLoader);
  80718. /** @hidden */
  80719. dispose(): void;
  80720. /** @hidden */
  80721. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80722. }
  80723. }
  80724. declare module BABYLON.GLTF2.Loader.Extensions {
  80725. /**
  80726. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  80727. */
  80728. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  80729. /**
  80730. * The name of this extension.
  80731. */
  80732. readonly name: string;
  80733. /**
  80734. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  80735. */
  80736. dracoCompression?: DracoCompression;
  80737. /**
  80738. * Defines whether this extension is enabled.
  80739. */
  80740. enabled: boolean;
  80741. private _loader;
  80742. /** @hidden */
  80743. constructor(loader: GLTFLoader);
  80744. /** @hidden */
  80745. dispose(): void;
  80746. /** @hidden */
  80747. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  80748. }
  80749. }
  80750. declare module BABYLON.GLTF2.Loader.Extensions {
  80751. /**
  80752. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  80753. */
  80754. export class KHR_lights implements IGLTFLoaderExtension {
  80755. /**
  80756. * The name of this extension.
  80757. */
  80758. readonly name: string;
  80759. /**
  80760. * Defines whether this extension is enabled.
  80761. */
  80762. enabled: boolean;
  80763. private _loader;
  80764. private _lights?;
  80765. /** @hidden */
  80766. constructor(loader: GLTFLoader);
  80767. /** @hidden */
  80768. dispose(): void;
  80769. /** @hidden */
  80770. onLoading(): void;
  80771. /** @hidden */
  80772. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80773. }
  80774. }
  80775. declare module BABYLON.GLTF2.Loader.Extensions {
  80776. /**
  80777. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  80778. */
  80779. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  80780. /**
  80781. * The name of this extension.
  80782. */
  80783. readonly name: string;
  80784. /**
  80785. * Defines whether this extension is enabled.
  80786. */
  80787. enabled: boolean;
  80788. /**
  80789. * Defines a number that determines the order the extensions are applied.
  80790. */
  80791. order: number;
  80792. private _loader;
  80793. /** @hidden */
  80794. constructor(loader: GLTFLoader);
  80795. /** @hidden */
  80796. dispose(): void;
  80797. /** @hidden */
  80798. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80799. private _loadSpecularGlossinessPropertiesAsync;
  80800. }
  80801. }
  80802. declare module BABYLON.GLTF2.Loader.Extensions {
  80803. /**
  80804. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  80805. */
  80806. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  80807. /**
  80808. * The name of this extension.
  80809. */
  80810. readonly name: string;
  80811. /**
  80812. * Defines whether this extension is enabled.
  80813. */
  80814. enabled: boolean;
  80815. /**
  80816. * Defines a number that determines the order the extensions are applied.
  80817. */
  80818. order: number;
  80819. private _loader;
  80820. /** @hidden */
  80821. constructor(loader: GLTFLoader);
  80822. /** @hidden */
  80823. dispose(): void;
  80824. /** @hidden */
  80825. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80826. private _loadUnlitPropertiesAsync;
  80827. }
  80828. }
  80829. declare module BABYLON.GLTF2.Loader.Extensions {
  80830. /**
  80831. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  80832. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  80833. * !!! Experimental Extension Subject to Changes !!!
  80834. */
  80835. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  80836. /**
  80837. * The name of this extension.
  80838. */
  80839. readonly name: string;
  80840. /**
  80841. * Defines whether this extension is enabled.
  80842. */
  80843. enabled: boolean;
  80844. /**
  80845. * Defines a number that determines the order the extensions are applied.
  80846. */
  80847. order: number;
  80848. private _loader;
  80849. /** @hidden */
  80850. constructor(loader: GLTFLoader);
  80851. /** @hidden */
  80852. dispose(): void;
  80853. /** @hidden */
  80854. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80855. private _loadClearCoatPropertiesAsync;
  80856. }
  80857. }
  80858. declare module BABYLON.GLTF2.Loader.Extensions {
  80859. /**
  80860. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  80861. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  80862. * !!! Experimental Extension Subject to Changes !!!
  80863. */
  80864. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  80865. /**
  80866. * The name of this extension.
  80867. */
  80868. readonly name: string;
  80869. /**
  80870. * Defines whether this extension is enabled.
  80871. */
  80872. enabled: boolean;
  80873. /**
  80874. * Defines a number that determines the order the extensions are applied.
  80875. */
  80876. order: number;
  80877. private _loader;
  80878. /** @hidden */
  80879. constructor(loader: GLTFLoader);
  80880. /** @hidden */
  80881. dispose(): void;
  80882. /** @hidden */
  80883. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80884. private _loadSheenPropertiesAsync;
  80885. }
  80886. }
  80887. declare module BABYLON.GLTF2.Loader.Extensions {
  80888. /**
  80889. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  80890. * !!! Experimental Extension Subject to Changes !!!
  80891. */
  80892. export class KHR_materials_specular implements IGLTFLoaderExtension {
  80893. /**
  80894. * The name of this extension.
  80895. */
  80896. readonly name: string;
  80897. /**
  80898. * Defines whether this extension is enabled.
  80899. */
  80900. enabled: boolean;
  80901. /**
  80902. * Defines a number that determines the order the extensions are applied.
  80903. */
  80904. order: number;
  80905. private _loader;
  80906. /** @hidden */
  80907. constructor(loader: GLTFLoader);
  80908. /** @hidden */
  80909. dispose(): void;
  80910. /** @hidden */
  80911. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80912. private _loadSpecularPropertiesAsync;
  80913. }
  80914. }
  80915. declare module BABYLON.GLTF2.Loader.Extensions {
  80916. /**
  80917. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  80918. * !!! Experimental Extension Subject to Changes !!!
  80919. */
  80920. export class KHR_materials_ior implements IGLTFLoaderExtension {
  80921. /**
  80922. * Default ior Value from the spec.
  80923. */
  80924. private static readonly _DEFAULT_IOR;
  80925. /**
  80926. * The name of this extension.
  80927. */
  80928. readonly name: string;
  80929. /**
  80930. * Defines whether this extension is enabled.
  80931. */
  80932. enabled: boolean;
  80933. /**
  80934. * Defines a number that determines the order the extensions are applied.
  80935. */
  80936. order: number;
  80937. private _loader;
  80938. /** @hidden */
  80939. constructor(loader: GLTFLoader);
  80940. /** @hidden */
  80941. dispose(): void;
  80942. /** @hidden */
  80943. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80944. private _loadIorPropertiesAsync;
  80945. }
  80946. }
  80947. declare module BABYLON.GLTF2.Loader.Extensions {
  80948. /**
  80949. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  80950. * !!! Experimental Extension Subject to Changes !!!
  80951. */
  80952. export class KHR_materials_variants implements IGLTFLoaderExtension {
  80953. /**
  80954. * The name of this extension.
  80955. */
  80956. readonly name: string;
  80957. /**
  80958. * Defines whether this extension is enabled.
  80959. */
  80960. enabled: boolean;
  80961. private _loader;
  80962. /** @hidden */
  80963. constructor(loader: GLTFLoader);
  80964. /** @hidden */
  80965. dispose(): void;
  80966. /**
  80967. * Gets the list of available variant tag names for this asset.
  80968. * @param rootMesh The glTF root mesh
  80969. * @returns the list of all the variant names for this model
  80970. */
  80971. static GetAvailableVariants(rootMesh: Mesh): string[];
  80972. /**
  80973. * Gets the list of available variant tag names for this asset.
  80974. * @param rootMesh The glTF root mesh
  80975. * @returns the list of all the variant names for this model
  80976. */
  80977. getAvailableVariants(rootMesh: Mesh): string[];
  80978. /**
  80979. * Select a variant given a variant tag name or a list of variant tag names.
  80980. * @param rootMesh The glTF root mesh
  80981. * @param variantName The variant name(s) to select.
  80982. */
  80983. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  80984. /**
  80985. * Select a variant given a variant tag name or a list of variant tag names.
  80986. * @param rootMesh The glTF root mesh
  80987. * @param variantName The variant name(s) to select.
  80988. */
  80989. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  80990. /**
  80991. * Reset back to the original before selecting a variant.
  80992. * @param rootMesh The glTF root mesh
  80993. */
  80994. static Reset(rootMesh: Mesh): void;
  80995. /**
  80996. * Reset back to the original before selecting a variant.
  80997. * @param rootMesh The glTF root mesh
  80998. */
  80999. reset(rootMesh: Mesh): void;
  81000. /**
  81001. * Gets the last selected variant tag name(s) or null if original.
  81002. * @param rootMesh The glTF root mesh
  81003. * @returns The selected variant tag name(s).
  81004. */
  81005. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  81006. /**
  81007. * Gets the last selected variant tag name(s) or null if original.
  81008. * @param rootMesh The glTF root mesh
  81009. * @returns The selected variant tag name(s).
  81010. */
  81011. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  81012. private static _GetExtensionMetadata;
  81013. /** @hidden */
  81014. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  81015. }
  81016. }
  81017. declare module BABYLON.GLTF2.Loader.Extensions {
  81018. /**
  81019. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  81020. * !!! Experimental Extension Subject to Changes !!!
  81021. */
  81022. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  81023. /**
  81024. * The name of this extension.
  81025. */
  81026. readonly name: string;
  81027. /**
  81028. * Defines whether this extension is enabled.
  81029. */
  81030. enabled: boolean;
  81031. /**
  81032. * Defines a number that determines the order the extensions are applied.
  81033. */
  81034. order: number;
  81035. private _loader;
  81036. /** @hidden */
  81037. constructor(loader: GLTFLoader);
  81038. /** @hidden */
  81039. dispose(): void;
  81040. /** @hidden */
  81041. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81042. private _loadTransparentPropertiesAsync;
  81043. }
  81044. }
  81045. declare module BABYLON.GLTF2.Loader.Extensions {
  81046. /**
  81047. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  81048. */
  81049. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  81050. /**
  81051. * The name of this extension.
  81052. */
  81053. readonly name: string;
  81054. /**
  81055. * Defines whether this extension is enabled.
  81056. */
  81057. enabled: boolean;
  81058. /** @hidden */
  81059. constructor(loader: GLTFLoader);
  81060. /** @hidden */
  81061. dispose(): void;
  81062. }
  81063. }
  81064. declare module BABYLON.GLTF2.Loader.Extensions {
  81065. /**
  81066. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  81067. * !!! Experimental Extension Subject to Changes !!!
  81068. */
  81069. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  81070. /** The name of this extension. */
  81071. readonly name: string;
  81072. /** Defines whether this extension is enabled. */
  81073. enabled: boolean;
  81074. private _loader;
  81075. /** @hidden */
  81076. constructor(loader: GLTFLoader);
  81077. /** @hidden */
  81078. dispose(): void;
  81079. /** @hidden */
  81080. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81081. }
  81082. }
  81083. declare module BABYLON.GLTF2.Loader.Extensions {
  81084. /**
  81085. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  81086. */
  81087. export class KHR_texture_transform implements IGLTFLoaderExtension {
  81088. /**
  81089. * The name of this extension.
  81090. */
  81091. readonly name: string;
  81092. /**
  81093. * Defines whether this extension is enabled.
  81094. */
  81095. enabled: boolean;
  81096. private _loader;
  81097. /** @hidden */
  81098. constructor(loader: GLTFLoader);
  81099. /** @hidden */
  81100. dispose(): void;
  81101. /** @hidden */
  81102. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81103. }
  81104. }
  81105. declare module BABYLON.GLTF2.Loader.Extensions {
  81106. /**
  81107. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  81108. * !!! Experimental Extension Subject to Changes !!!
  81109. */
  81110. export class KHR_xmp implements IGLTFLoaderExtension {
  81111. /**
  81112. * The name of this extension.
  81113. */
  81114. readonly name: string;
  81115. /**
  81116. * Defines whether this extension is enabled.
  81117. */
  81118. enabled: boolean;
  81119. /**
  81120. * Defines a number that determines the order the extensions are applied.
  81121. */
  81122. order: number;
  81123. private _loader;
  81124. /** @hidden */
  81125. constructor(loader: GLTFLoader);
  81126. /** @hidden */
  81127. dispose(): void;
  81128. /**
  81129. * Called after the loader state changes to LOADING.
  81130. */
  81131. onLoading(): void;
  81132. }
  81133. }
  81134. declare module BABYLON.GLTF2.Loader.Extensions {
  81135. /**
  81136. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  81137. */
  81138. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  81139. /**
  81140. * The name of this extension.
  81141. */
  81142. readonly name: string;
  81143. /**
  81144. * Defines whether this extension is enabled.
  81145. */
  81146. enabled: boolean;
  81147. private _loader;
  81148. private _clips;
  81149. private _emitters;
  81150. /** @hidden */
  81151. constructor(loader: GLTFLoader);
  81152. /** @hidden */
  81153. dispose(): void;
  81154. /** @hidden */
  81155. onLoading(): void;
  81156. /** @hidden */
  81157. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  81158. /** @hidden */
  81159. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81160. /** @hidden */
  81161. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  81162. private _loadClipAsync;
  81163. private _loadEmitterAsync;
  81164. private _getEventAction;
  81165. private _loadAnimationEventAsync;
  81166. }
  81167. }
  81168. declare module BABYLON.GLTF2.Loader.Extensions {
  81169. /**
  81170. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  81171. */
  81172. export class MSFT_lod implements IGLTFLoaderExtension {
  81173. /**
  81174. * The name of this extension.
  81175. */
  81176. readonly name: string;
  81177. /**
  81178. * Defines whether this extension is enabled.
  81179. */
  81180. enabled: boolean;
  81181. /**
  81182. * Defines a number that determines the order the extensions are applied.
  81183. */
  81184. order: number;
  81185. /**
  81186. * Maximum number of LODs to load, starting from the lowest LOD.
  81187. */
  81188. maxLODsToLoad: number;
  81189. /**
  81190. * Observable raised when all node LODs of one level are loaded.
  81191. * The event data is the index of the loaded LOD starting from zero.
  81192. * Dispose the loader to cancel the loading of the next level of LODs.
  81193. */
  81194. onNodeLODsLoadedObservable: Observable<number>;
  81195. /**
  81196. * Observable raised when all material LODs of one level are loaded.
  81197. * The event data is the index of the loaded LOD starting from zero.
  81198. * Dispose the loader to cancel the loading of the next level of LODs.
  81199. */
  81200. onMaterialLODsLoadedObservable: Observable<number>;
  81201. private _loader;
  81202. private _bufferLODs;
  81203. private _nodeIndexLOD;
  81204. private _nodeSignalLODs;
  81205. private _nodePromiseLODs;
  81206. private _nodeBufferLODs;
  81207. private _materialIndexLOD;
  81208. private _materialSignalLODs;
  81209. private _materialPromiseLODs;
  81210. private _materialBufferLODs;
  81211. /** @hidden */
  81212. constructor(loader: GLTFLoader);
  81213. /** @hidden */
  81214. dispose(): void;
  81215. /** @hidden */
  81216. onReady(): void;
  81217. /** @hidden */
  81218. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  81219. /** @hidden */
  81220. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81221. /** @hidden */
  81222. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  81223. /** @hidden */
  81224. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  81225. /** @hidden */
  81226. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  81227. private _loadBufferLOD;
  81228. /**
  81229. * Gets an array of LOD properties from lowest to highest.
  81230. */
  81231. private _getLODs;
  81232. private _disposeTransformNode;
  81233. private _disposeMaterials;
  81234. }
  81235. }
  81236. declare module BABYLON.GLTF2.Loader.Extensions {
  81237. /** @hidden */
  81238. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  81239. readonly name: string;
  81240. enabled: boolean;
  81241. private _loader;
  81242. constructor(loader: GLTFLoader);
  81243. dispose(): void;
  81244. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81245. }
  81246. }
  81247. declare module BABYLON.GLTF2.Loader.Extensions {
  81248. /** @hidden */
  81249. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  81250. readonly name: string;
  81251. enabled: boolean;
  81252. private _loader;
  81253. constructor(loader: GLTFLoader);
  81254. dispose(): void;
  81255. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81256. }
  81257. }
  81258. declare module BABYLON.GLTF2.Loader.Extensions {
  81259. /**
  81260. * Store glTF extras (if present) in BJS objects' metadata
  81261. */
  81262. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  81263. /**
  81264. * The name of this extension.
  81265. */
  81266. readonly name: string;
  81267. /**
  81268. * Defines whether this extension is enabled.
  81269. */
  81270. enabled: boolean;
  81271. private _loader;
  81272. private _assignExtras;
  81273. /** @hidden */
  81274. constructor(loader: GLTFLoader);
  81275. /** @hidden */
  81276. dispose(): void;
  81277. /** @hidden */
  81278. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81279. /** @hidden */
  81280. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  81281. /** @hidden */
  81282. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  81283. }
  81284. }
  81285. declare module BABYLON {
  81286. /**
  81287. * Class reading and parsing the MTL file bundled with the obj file.
  81288. */
  81289. export class MTLFileLoader {
  81290. /**
  81291. * Invert Y-Axis of referenced textures on load
  81292. */
  81293. static INVERT_TEXTURE_Y: boolean;
  81294. /**
  81295. * All material loaded from the mtl will be set here
  81296. */
  81297. materials: StandardMaterial[];
  81298. /**
  81299. * This function will read the mtl file and create each material described inside
  81300. * This function could be improve by adding :
  81301. * -some component missing (Ni, Tf...)
  81302. * -including the specific options available
  81303. *
  81304. * @param scene defines the scene the material will be created in
  81305. * @param data defines the mtl data to parse
  81306. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  81307. * @param forAssetContainer defines if the material should be registered in the scene
  81308. */
  81309. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  81310. /**
  81311. * Gets the texture for the material.
  81312. *
  81313. * If the material is imported from input file,
  81314. * We sanitize the url to ensure it takes the textre from aside the material.
  81315. *
  81316. * @param rootUrl The root url to load from
  81317. * @param value The value stored in the mtl
  81318. * @return The Texture
  81319. */
  81320. private static _getTexture;
  81321. }
  81322. }
  81323. declare module BABYLON {
  81324. /**
  81325. * Options for loading OBJ/MTL files
  81326. */
  81327. type MeshLoadOptions = {
  81328. /**
  81329. * Defines if UVs are optimized by default during load.
  81330. */
  81331. OptimizeWithUV: boolean;
  81332. /**
  81333. * Defines custom scaling of UV coordinates of loaded meshes.
  81334. */
  81335. UVScaling: Vector2;
  81336. /**
  81337. * Invert model on y-axis (does a model scaling inversion)
  81338. */
  81339. InvertY: boolean;
  81340. /**
  81341. * Invert Y-Axis of referenced textures on load
  81342. */
  81343. InvertTextureY: boolean;
  81344. /**
  81345. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  81346. */
  81347. ImportVertexColors: boolean;
  81348. /**
  81349. * Compute the normals for the model, even if normals are present in the file.
  81350. */
  81351. ComputeNormals: boolean;
  81352. /**
  81353. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  81354. */
  81355. SkipMaterials: boolean;
  81356. /**
  81357. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  81358. */
  81359. MaterialLoadingFailsSilently: boolean;
  81360. };
  81361. /**
  81362. * OBJ file type loader.
  81363. * This is a babylon scene loader plugin.
  81364. */
  81365. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  81366. /**
  81367. * Defines if UVs are optimized by default during load.
  81368. */
  81369. static OPTIMIZE_WITH_UV: boolean;
  81370. /**
  81371. * Invert model on y-axis (does a model scaling inversion)
  81372. */
  81373. static INVERT_Y: boolean;
  81374. /**
  81375. * Invert Y-Axis of referenced textures on load
  81376. */
  81377. static get INVERT_TEXTURE_Y(): boolean;
  81378. static set INVERT_TEXTURE_Y(value: boolean);
  81379. /**
  81380. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  81381. */
  81382. static IMPORT_VERTEX_COLORS: boolean;
  81383. /**
  81384. * Compute the normals for the model, even if normals are present in the file.
  81385. */
  81386. static COMPUTE_NORMALS: boolean;
  81387. /**
  81388. * Defines custom scaling of UV coordinates of loaded meshes.
  81389. */
  81390. static UV_SCALING: Vector2;
  81391. /**
  81392. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  81393. */
  81394. static SKIP_MATERIALS: boolean;
  81395. /**
  81396. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  81397. *
  81398. * Defaults to true for backwards compatibility.
  81399. */
  81400. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  81401. /**
  81402. * Defines the name of the plugin.
  81403. */
  81404. name: string;
  81405. /**
  81406. * Defines the extension the plugin is able to load.
  81407. */
  81408. extensions: string;
  81409. /** @hidden */
  81410. obj: RegExp;
  81411. /** @hidden */
  81412. group: RegExp;
  81413. /** @hidden */
  81414. mtllib: RegExp;
  81415. /** @hidden */
  81416. usemtl: RegExp;
  81417. /** @hidden */
  81418. smooth: RegExp;
  81419. /** @hidden */
  81420. vertexPattern: RegExp;
  81421. /** @hidden */
  81422. normalPattern: RegExp;
  81423. /** @hidden */
  81424. uvPattern: RegExp;
  81425. /** @hidden */
  81426. facePattern1: RegExp;
  81427. /** @hidden */
  81428. facePattern2: RegExp;
  81429. /** @hidden */
  81430. facePattern3: RegExp;
  81431. /** @hidden */
  81432. facePattern4: RegExp;
  81433. /** @hidden */
  81434. facePattern5: RegExp;
  81435. private _forAssetContainer;
  81436. private _meshLoadOptions;
  81437. /**
  81438. * Creates loader for .OBJ files
  81439. *
  81440. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  81441. */
  81442. constructor(meshLoadOptions?: MeshLoadOptions);
  81443. private static get currentMeshLoadOptions();
  81444. /**
  81445. * Calls synchronously the MTL file attached to this obj.
  81446. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  81447. * Without this function materials are not displayed in the first frame (but displayed after).
  81448. * In consequence it is impossible to get material information in your HTML file
  81449. *
  81450. * @param url The URL of the MTL file
  81451. * @param rootUrl
  81452. * @param onSuccess Callback function to be called when the MTL file is loaded
  81453. * @private
  81454. */
  81455. private _loadMTL;
  81456. /**
  81457. * Instantiates a OBJ file loader plugin.
  81458. * @returns the created plugin
  81459. */
  81460. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  81461. /**
  81462. * If the data string can be loaded directly.
  81463. *
  81464. * @param data string containing the file data
  81465. * @returns if the data can be loaded directly
  81466. */
  81467. canDirectLoad(data: string): boolean;
  81468. /**
  81469. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  81470. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  81471. * @param scene the scene the meshes should be added to
  81472. * @param data the OBJ data to load
  81473. * @param rootUrl root url to load from
  81474. * @param onProgress event that fires when loading progress has occured
  81475. * @param fileName Defines the name of the file to load
  81476. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  81477. */
  81478. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  81479. meshes: AbstractMesh[];
  81480. particleSystems: IParticleSystem[];
  81481. skeletons: Skeleton[];
  81482. animationGroups: AnimationGroup[];
  81483. }>;
  81484. /**
  81485. * Imports all objects from the loaded OBJ data and adds them to the scene
  81486. * @param scene the scene the objects should be added to
  81487. * @param data the OBJ data to load
  81488. * @param rootUrl root url to load from
  81489. * @param onProgress event that fires when loading progress has occured
  81490. * @param fileName Defines the name of the file to load
  81491. * @returns a promise which completes when objects have been loaded to the scene
  81492. */
  81493. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  81494. /**
  81495. * Load into an asset container.
  81496. * @param scene The scene to load into
  81497. * @param data The data to import
  81498. * @param rootUrl The root url for scene and resources
  81499. * @param onProgress The callback when the load progresses
  81500. * @param fileName Defines the name of the file to load
  81501. * @returns The loaded asset container
  81502. */
  81503. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  81504. /**
  81505. * Read the OBJ file and create an Array of meshes.
  81506. * Each mesh contains all information given by the OBJ and the MTL file.
  81507. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  81508. *
  81509. * @param meshesNames
  81510. * @param scene Scene The scene where are displayed the data
  81511. * @param data String The content of the obj file
  81512. * @param rootUrl String The path to the folder
  81513. * @returns Array<AbstractMesh>
  81514. * @private
  81515. */
  81516. private _parseSolid;
  81517. }
  81518. }
  81519. declare module BABYLON {
  81520. /**
  81521. * STL file type loader.
  81522. * This is a babylon scene loader plugin.
  81523. */
  81524. export class STLFileLoader implements ISceneLoaderPlugin {
  81525. /** @hidden */
  81526. solidPattern: RegExp;
  81527. /** @hidden */
  81528. facetsPattern: RegExp;
  81529. /** @hidden */
  81530. normalPattern: RegExp;
  81531. /** @hidden */
  81532. vertexPattern: RegExp;
  81533. /**
  81534. * Defines the name of the plugin.
  81535. */
  81536. name: string;
  81537. /**
  81538. * Defines the extensions the stl loader is able to load.
  81539. * force data to come in as an ArrayBuffer
  81540. * we'll convert to string if it looks like it's an ASCII .stl
  81541. */
  81542. extensions: ISceneLoaderPluginExtensions;
  81543. /**
  81544. * Import meshes into a scene.
  81545. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  81546. * @param scene The scene to import into
  81547. * @param data The data to import
  81548. * @param rootUrl The root url for scene and resources
  81549. * @param meshes The meshes array to import into
  81550. * @param particleSystems The particle systems array to import into
  81551. * @param skeletons The skeletons array to import into
  81552. * @param onError The callback when import fails
  81553. * @returns True if successful or false otherwise
  81554. */
  81555. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  81556. /**
  81557. * Load into a scene.
  81558. * @param scene The scene to load into
  81559. * @param data The data to import
  81560. * @param rootUrl The root url for scene and resources
  81561. * @param onError The callback when import fails
  81562. * @returns true if successful or false otherwise
  81563. */
  81564. load(scene: Scene, data: any, rootUrl: string): boolean;
  81565. /**
  81566. * Load into an asset container.
  81567. * @param scene The scene to load into
  81568. * @param data The data to import
  81569. * @param rootUrl The root url for scene and resources
  81570. * @param onError The callback when import fails
  81571. * @returns The loaded asset container
  81572. */
  81573. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  81574. private _isBinary;
  81575. private _parseBinary;
  81576. private _parseASCII;
  81577. }
  81578. }
  81579. declare module BABYLON {
  81580. /**
  81581. * Class for generating OBJ data from a Babylon scene.
  81582. */
  81583. export class OBJExport {
  81584. /**
  81585. * Exports the geometry of a Mesh array in .OBJ file format (text)
  81586. * @param mesh defines the list of meshes to serialize
  81587. * @param materials defines if materials should be exported
  81588. * @param matlibname defines the name of the associated mtl file
  81589. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  81590. * @returns the OBJ content
  81591. */
  81592. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  81593. /**
  81594. * Exports the material(s) of a mesh in .MTL file format (text)
  81595. * @param mesh defines the mesh to extract the material from
  81596. * @returns the mtl content
  81597. */
  81598. static MTL(mesh: Mesh): string;
  81599. }
  81600. }
  81601. declare module BABYLON {
  81602. /** @hidden */
  81603. export var __IGLTFExporterExtension: number;
  81604. /**
  81605. * Interface for extending the exporter
  81606. * @hidden
  81607. */
  81608. export interface IGLTFExporterExtension {
  81609. /**
  81610. * The name of this extension
  81611. */
  81612. readonly name: string;
  81613. /**
  81614. * Defines whether this extension is enabled
  81615. */
  81616. enabled: boolean;
  81617. /**
  81618. * Defines whether this extension is required
  81619. */
  81620. required: boolean;
  81621. }
  81622. }
  81623. declare module BABYLON.GLTF2.Exporter {
  81624. /** @hidden */
  81625. export var __IGLTFExporterExtensionV2: number;
  81626. /**
  81627. * Interface for a glTF exporter extension
  81628. * @hidden
  81629. */
  81630. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  81631. /**
  81632. * Define this method to modify the default behavior before exporting a texture
  81633. * @param context The context when loading the asset
  81634. * @param babylonTexture The Babylon.js texture
  81635. * @param mimeType The mime-type of the generated image
  81636. * @returns A promise that resolves with the exported texture
  81637. */
  81638. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  81639. /**
  81640. * Define this method to get notified when a texture info is created
  81641. * @param context The context when loading the asset
  81642. * @param textureInfo The glTF texture info
  81643. * @param babylonTexture The Babylon.js texture
  81644. */
  81645. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  81646. /**
  81647. * Define this method to modify the default behavior when exporting texture info
  81648. * @param context The context when loading the asset
  81649. * @param meshPrimitive glTF mesh primitive
  81650. * @param babylonSubMesh Babylon submesh
  81651. * @param binaryWriter glTF serializer binary writer instance
  81652. * @returns nullable IMeshPrimitive promise
  81653. */
  81654. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  81655. /**
  81656. * Define this method to modify the default behavior when exporting a node
  81657. * @param context The context when exporting the node
  81658. * @param node glTF node
  81659. * @param babylonNode BabylonJS node
  81660. * @returns nullable INode promise
  81661. */
  81662. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81663. [key: number]: number;
  81664. }): Promise<Nullable<INode>>;
  81665. /**
  81666. * Define this method to modify the default behavior when exporting a material
  81667. * @param material glTF material
  81668. * @param babylonMaterial BabylonJS material
  81669. * @returns nullable IMaterial promise
  81670. */
  81671. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  81672. /**
  81673. * Define this method to return additional textures to export from a material
  81674. * @param material glTF material
  81675. * @param babylonMaterial BabylonJS material
  81676. * @returns List of textures
  81677. */
  81678. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  81679. /** Gets a boolean indicating that this extension was used */
  81680. wasUsed: boolean;
  81681. /** Gets a boolean indicating that this extension is required for the file to work */
  81682. required: boolean;
  81683. /**
  81684. * Called after the exporter state changes to EXPORTING
  81685. */
  81686. onExporting?(): void;
  81687. }
  81688. }
  81689. declare module BABYLON.GLTF2.Exporter {
  81690. /**
  81691. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  81692. * @hidden
  81693. */
  81694. export class _GLTFMaterialExporter {
  81695. /**
  81696. * Represents the dielectric specular values for R, G and B
  81697. */
  81698. private static readonly _DielectricSpecular;
  81699. /**
  81700. * Allows the maximum specular power to be defined for material calculations
  81701. */
  81702. private static readonly _MaxSpecularPower;
  81703. /**
  81704. * Mapping to store textures
  81705. */
  81706. private _textureMap;
  81707. /**
  81708. * Numeric tolerance value
  81709. */
  81710. private static readonly _Epsilon;
  81711. /**
  81712. * Reference to the glTF Exporter
  81713. */
  81714. private _exporter;
  81715. constructor(exporter: _Exporter);
  81716. /**
  81717. * Specifies if two colors are approximately equal in value
  81718. * @param color1 first color to compare to
  81719. * @param color2 second color to compare to
  81720. * @param epsilon threshold value
  81721. */
  81722. private static FuzzyEquals;
  81723. /**
  81724. * Gets the materials from a Babylon scene and converts them to glTF materials
  81725. * @param scene babylonjs scene
  81726. * @param mimeType texture mime type
  81727. * @param images array of images
  81728. * @param textures array of textures
  81729. * @param materials array of materials
  81730. * @param imageData mapping of texture names to base64 textures
  81731. * @param hasTextureCoords specifies if texture coordinates are present on the material
  81732. */
  81733. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  81734. /**
  81735. * Makes a copy of the glTF material without the texture parameters
  81736. * @param originalMaterial original glTF material
  81737. * @returns glTF material without texture parameters
  81738. */
  81739. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  81740. /**
  81741. * Specifies if the material has any texture parameters present
  81742. * @param material glTF Material
  81743. * @returns boolean specifying if texture parameters are present
  81744. */
  81745. _hasTexturesPresent(material: IMaterial): boolean;
  81746. /**
  81747. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  81748. * @param babylonStandardMaterial
  81749. * @returns glTF Metallic Roughness Material representation
  81750. */
  81751. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  81752. /**
  81753. * Computes the metallic factor
  81754. * @param diffuse diffused value
  81755. * @param specular specular value
  81756. * @param oneMinusSpecularStrength one minus the specular strength
  81757. * @returns metallic value
  81758. */
  81759. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  81760. /**
  81761. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  81762. * @param glTFMaterial glTF material
  81763. * @param babylonMaterial Babylon material
  81764. */
  81765. private static _SetAlphaMode;
  81766. /**
  81767. * Converts a Babylon Standard Material to a glTF Material
  81768. * @param babylonStandardMaterial BJS Standard Material
  81769. * @param mimeType mime type to use for the textures
  81770. * @param images array of glTF image interfaces
  81771. * @param textures array of glTF texture interfaces
  81772. * @param materials array of glTF material interfaces
  81773. * @param imageData map of image file name to data
  81774. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81775. */
  81776. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81777. private _finishMaterial;
  81778. /**
  81779. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  81780. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  81781. * @param mimeType mime type to use for the textures
  81782. * @param images array of glTF image interfaces
  81783. * @param textures array of glTF texture interfaces
  81784. * @param materials array of glTF material interfaces
  81785. * @param imageData map of image file name to data
  81786. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81787. */
  81788. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81789. /**
  81790. * Converts an image typed array buffer to a base64 image
  81791. * @param buffer typed array buffer
  81792. * @param width width of the image
  81793. * @param height height of the image
  81794. * @param mimeType mimetype of the image
  81795. * @returns base64 image string
  81796. */
  81797. private _createBase64FromCanvasAsync;
  81798. /**
  81799. * Generates a white texture based on the specified width and height
  81800. * @param width width of the texture in pixels
  81801. * @param height height of the texture in pixels
  81802. * @param scene babylonjs scene
  81803. * @returns white texture
  81804. */
  81805. private _createWhiteTexture;
  81806. /**
  81807. * 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
  81808. * @param texture1 first texture to resize
  81809. * @param texture2 second texture to resize
  81810. * @param scene babylonjs scene
  81811. * @returns resized textures or null
  81812. */
  81813. private _resizeTexturesToSameDimensions;
  81814. /**
  81815. * Converts an array of pixels to a Float32Array
  81816. * Throws an error if the pixel format is not supported
  81817. * @param pixels - array buffer containing pixel values
  81818. * @returns Float32 of pixels
  81819. */
  81820. private _convertPixelArrayToFloat32;
  81821. /**
  81822. * Convert Specular Glossiness Textures to Metallic Roughness
  81823. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  81824. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  81825. * @param diffuseTexture texture used to store diffuse information
  81826. * @param specularGlossinessTexture texture used to store specular and glossiness information
  81827. * @param factors specular glossiness material factors
  81828. * @param mimeType the mime type to use for the texture
  81829. * @returns pbr metallic roughness interface or null
  81830. */
  81831. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  81832. /**
  81833. * Converts specular glossiness material properties to metallic roughness
  81834. * @param specularGlossiness interface with specular glossiness material properties
  81835. * @returns interface with metallic roughness material properties
  81836. */
  81837. private _convertSpecularGlossinessToMetallicRoughness;
  81838. /**
  81839. * Calculates the surface reflectance, independent of lighting conditions
  81840. * @param color Color source to calculate brightness from
  81841. * @returns number representing the perceived brightness, or zero if color is undefined
  81842. */
  81843. private _getPerceivedBrightness;
  81844. /**
  81845. * Returns the maximum color component value
  81846. * @param color
  81847. * @returns maximum color component value, or zero if color is null or undefined
  81848. */
  81849. private _getMaxComponent;
  81850. /**
  81851. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  81852. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81853. * @param mimeType mime type to use for the textures
  81854. * @param images array of glTF image interfaces
  81855. * @param textures array of glTF texture interfaces
  81856. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  81857. * @param imageData map of image file name to data
  81858. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81859. * @returns glTF PBR Metallic Roughness factors
  81860. */
  81861. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  81862. private _getGLTFTextureSampler;
  81863. private _getGLTFTextureWrapMode;
  81864. private _getGLTFTextureWrapModesSampler;
  81865. /**
  81866. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  81867. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81868. * @param mimeType mime type to use for the textures
  81869. * @param images array of glTF image interfaces
  81870. * @param textures array of glTF texture interfaces
  81871. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  81872. * @param imageData map of image file name to data
  81873. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81874. * @returns glTF PBR Metallic Roughness factors
  81875. */
  81876. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  81877. /**
  81878. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  81879. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81880. * @param mimeType mime type to use for the textures
  81881. * @param images array of glTF image interfaces
  81882. * @param textures array of glTF texture interfaces
  81883. * @param materials array of glTF material interfaces
  81884. * @param imageData map of image file name to data
  81885. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81886. */
  81887. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81888. private setMetallicRoughnessPbrMaterial;
  81889. private getPixelsFromTexture;
  81890. /**
  81891. * Extracts a texture from a Babylon texture into file data and glTF data
  81892. * @param babylonTexture Babylon texture to extract
  81893. * @param mimeType Mime Type of the babylonTexture
  81894. * @return glTF texture info, or null if the texture format is not supported
  81895. */
  81896. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  81897. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  81898. /**
  81899. * Builds a texture from base64 string
  81900. * @param base64Texture base64 texture string
  81901. * @param baseTextureName Name to use for the texture
  81902. * @param mimeType image mime type for the texture
  81903. * @param images array of images
  81904. * @param textures array of textures
  81905. * @param imageData map of image data
  81906. * @returns glTF texture info, or null if the texture format is not supported
  81907. */
  81908. private _getTextureInfoFromBase64;
  81909. }
  81910. }
  81911. declare module BABYLON {
  81912. /**
  81913. * Class for holding and downloading glTF file data
  81914. */
  81915. export class GLTFData {
  81916. /**
  81917. * Object which contains the file name as the key and its data as the value
  81918. */
  81919. glTFFiles: {
  81920. [fileName: string]: string | Blob;
  81921. };
  81922. /**
  81923. * Initializes the glTF file object
  81924. */
  81925. constructor();
  81926. /**
  81927. * Downloads the glTF data as files based on their names and data
  81928. */
  81929. downloadFiles(): void;
  81930. }
  81931. }
  81932. declare module BABYLON {
  81933. /**
  81934. * Holds a collection of exporter options and parameters
  81935. */
  81936. export interface IExportOptions {
  81937. /**
  81938. * Function which indicates whether a babylon node should be exported or not
  81939. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  81940. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  81941. */
  81942. shouldExportNode?(node: Node): boolean;
  81943. /**
  81944. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  81945. * @param metadata source metadata to read from
  81946. * @returns the data to store to glTF node extras
  81947. */
  81948. metadataSelector?(metadata: any): any;
  81949. /**
  81950. * The sample rate to bake animation curves
  81951. */
  81952. animationSampleRate?: number;
  81953. /**
  81954. * Begin serialization without waiting for the scene to be ready
  81955. */
  81956. exportWithoutWaitingForScene?: boolean;
  81957. /**
  81958. * Indicates if coordinate system swapping root nodes should be included in export
  81959. */
  81960. includeCoordinateSystemConversionNodes?: boolean;
  81961. }
  81962. /**
  81963. * Class for generating glTF data from a Babylon scene.
  81964. */
  81965. export class GLTF2Export {
  81966. /**
  81967. * Exports the geometry of the scene to .gltf file format asynchronously
  81968. * @param scene Babylon scene with scene hierarchy information
  81969. * @param filePrefix File prefix to use when generating the glTF file
  81970. * @param options Exporter options
  81971. * @returns Returns an object with a .gltf file and associates texture names
  81972. * as keys and their data and paths as values
  81973. */
  81974. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  81975. private static _PreExportAsync;
  81976. private static _PostExportAsync;
  81977. /**
  81978. * Exports the geometry of the scene to .glb file format asychronously
  81979. * @param scene Babylon scene with scene hierarchy information
  81980. * @param filePrefix File prefix to use when generating glb file
  81981. * @param options Exporter options
  81982. * @returns Returns an object with a .glb filename as key and data as value
  81983. */
  81984. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  81985. }
  81986. }
  81987. declare module BABYLON.GLTF2.Exporter {
  81988. /**
  81989. * @hidden
  81990. */
  81991. export class _GLTFUtilities {
  81992. /**
  81993. * Creates a buffer view based on the supplied arguments
  81994. * @param bufferIndex index value of the specified buffer
  81995. * @param byteOffset byte offset value
  81996. * @param byteLength byte length of the bufferView
  81997. * @param byteStride byte distance between conequential elements
  81998. * @param name name of the buffer view
  81999. * @returns bufferView for glTF
  82000. */
  82001. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  82002. /**
  82003. * Creates an accessor based on the supplied arguments
  82004. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  82005. * @param name The name of the accessor
  82006. * @param type The type of the accessor
  82007. * @param componentType The datatype of components in the attribute
  82008. * @param count The number of attributes referenced by this accessor
  82009. * @param byteOffset The offset relative to the start of the bufferView in bytes
  82010. * @param min Minimum value of each component in this attribute
  82011. * @param max Maximum value of each component in this attribute
  82012. * @returns accessor for glTF
  82013. */
  82014. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  82015. /**
  82016. * Calculates the minimum and maximum values of an array of position floats
  82017. * @param positions Positions array of a mesh
  82018. * @param vertexStart Starting vertex offset to calculate min and max values
  82019. * @param vertexCount Number of vertices to check for min and max values
  82020. * @returns min number array and max number array
  82021. */
  82022. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  82023. min: number[];
  82024. max: number[];
  82025. };
  82026. /**
  82027. * Converts a new right-handed Vector3
  82028. * @param vector vector3 array
  82029. * @returns right-handed Vector3
  82030. */
  82031. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  82032. /**
  82033. * Converts a Vector3 to right-handed
  82034. * @param vector Vector3 to convert to right-handed
  82035. */
  82036. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  82037. /**
  82038. * Converts a three element number array to right-handed
  82039. * @param vector number array to convert to right-handed
  82040. */
  82041. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  82042. /**
  82043. * Converts a new right-handed Vector3
  82044. * @param vector vector3 array
  82045. * @returns right-handed Vector3
  82046. */
  82047. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  82048. /**
  82049. * Converts a Vector3 to right-handed
  82050. * @param vector Vector3 to convert to right-handed
  82051. */
  82052. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  82053. /**
  82054. * Converts a three element number array to right-handed
  82055. * @param vector number array to convert to right-handed
  82056. */
  82057. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  82058. /**
  82059. * Converts a Vector4 to right-handed
  82060. * @param vector Vector4 to convert to right-handed
  82061. */
  82062. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  82063. /**
  82064. * Converts a Vector4 to right-handed
  82065. * @param vector Vector4 to convert to right-handed
  82066. */
  82067. static _GetRightHandedArray4FromRef(vector: number[]): void;
  82068. /**
  82069. * Converts a Quaternion to right-handed
  82070. * @param quaternion Source quaternion to convert to right-handed
  82071. */
  82072. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  82073. /**
  82074. * Converts a Quaternion to right-handed
  82075. * @param quaternion Source quaternion to convert to right-handed
  82076. */
  82077. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  82078. static _NormalizeTangentFromRef(tangent: Vector4): void;
  82079. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  82080. }
  82081. }
  82082. declare module BABYLON.GLTF2.Exporter {
  82083. /**
  82084. * Converts Babylon Scene into glTF 2.0.
  82085. * @hidden
  82086. */
  82087. export class _Exporter {
  82088. /**
  82089. * Stores the glTF to export
  82090. */
  82091. _glTF: IGLTF;
  82092. /**
  82093. * Stores all generated buffer views, which represents views into the main glTF buffer data
  82094. */
  82095. _bufferViews: IBufferView[];
  82096. /**
  82097. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  82098. */
  82099. _accessors: IAccessor[];
  82100. /**
  82101. * Stores all the generated nodes, which contains transform and/or mesh information per node
  82102. */
  82103. _nodes: INode[];
  82104. /**
  82105. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  82106. */
  82107. private _scenes;
  82108. /**
  82109. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  82110. */
  82111. private _meshes;
  82112. /**
  82113. * Stores all the generated material information, which represents the appearance of each primitive
  82114. */
  82115. _materials: IMaterial[];
  82116. _materialMap: {
  82117. [materialID: number]: number;
  82118. };
  82119. /**
  82120. * Stores all the generated texture information, which is referenced by glTF materials
  82121. */
  82122. _textures: ITexture[];
  82123. /**
  82124. * Stores all the generated image information, which is referenced by glTF textures
  82125. */
  82126. _images: IImage[];
  82127. /**
  82128. * Stores all the texture samplers
  82129. */
  82130. _samplers: ISampler[];
  82131. /**
  82132. * Stores all the generated glTF skins
  82133. */
  82134. _skins: ISkin[];
  82135. /**
  82136. * Stores all the generated animation samplers, which is referenced by glTF animations
  82137. */
  82138. /**
  82139. * Stores the animations for glTF models
  82140. */
  82141. private _animations;
  82142. /**
  82143. * Stores the total amount of bytes stored in the glTF buffer
  82144. */
  82145. private _totalByteLength;
  82146. /**
  82147. * Stores a reference to the Babylon scene containing the source geometry and material information
  82148. */
  82149. _babylonScene: Scene;
  82150. /**
  82151. * Stores a map of the image data, where the key is the file name and the value
  82152. * is the image data
  82153. */
  82154. _imageData: {
  82155. [fileName: string]: {
  82156. data: Uint8Array;
  82157. mimeType: ImageMimeType;
  82158. };
  82159. };
  82160. /**
  82161. * Stores a map of the unique id of a node to its index in the node array
  82162. */
  82163. _nodeMap: {
  82164. [key: number]: number;
  82165. };
  82166. /**
  82167. * Specifies if the source Babylon scene was left handed, and needed conversion.
  82168. */
  82169. _convertToRightHandedSystem: boolean;
  82170. /**
  82171. * Specifies if a Babylon node should be converted to right-handed on export
  82172. */
  82173. _convertToRightHandedSystemMap: {
  82174. [nodeId: number]: boolean;
  82175. };
  82176. _includeCoordinateSystemConversionNodes: boolean;
  82177. /**
  82178. * Baked animation sample rate
  82179. */
  82180. private _animationSampleRate;
  82181. private _options;
  82182. private _localEngine;
  82183. _glTFMaterialExporter: _GLTFMaterialExporter;
  82184. private _extensions;
  82185. private static _ExtensionNames;
  82186. private static _ExtensionFactories;
  82187. private _applyExtension;
  82188. private _applyExtensions;
  82189. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  82190. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  82191. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  82192. [key: number]: number;
  82193. }): Promise<Nullable<INode>>;
  82194. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  82195. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  82196. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  82197. private _forEachExtensions;
  82198. private _extensionsOnExporting;
  82199. /**
  82200. * Load glTF serializer extensions
  82201. */
  82202. private _loadExtensions;
  82203. /**
  82204. * Creates a glTF Exporter instance, which can accept optional exporter options
  82205. * @param babylonScene Babylon scene object
  82206. * @param options Options to modify the behavior of the exporter
  82207. */
  82208. constructor(babylonScene: Scene, options?: IExportOptions);
  82209. dispose(): void;
  82210. /**
  82211. * Registers a glTF exporter extension
  82212. * @param name Name of the extension to export
  82213. * @param factory The factory function that creates the exporter extension
  82214. */
  82215. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  82216. /**
  82217. * Un-registers an exporter extension
  82218. * @param name The name fo the exporter extension
  82219. * @returns A boolean indicating whether the extension has been un-registered
  82220. */
  82221. static UnregisterExtension(name: string): boolean;
  82222. /**
  82223. * Lazy load a local engine
  82224. */
  82225. _getLocalEngine(): Engine;
  82226. private reorderIndicesBasedOnPrimitiveMode;
  82227. /**
  82228. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  82229. * clock-wise during export to glTF
  82230. * @param submesh BabylonJS submesh
  82231. * @param primitiveMode Primitive mode of the mesh
  82232. * @param sideOrientation the winding order of the submesh
  82233. * @param vertexBufferKind The type of vertex attribute
  82234. * @param meshAttributeArray The vertex attribute data
  82235. * @param byteOffset The offset to the binary data
  82236. * @param binaryWriter The binary data for the glTF file
  82237. * @param convertToRightHandedSystem Converts the values to right-handed
  82238. */
  82239. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  82240. /**
  82241. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  82242. * clock-wise during export to glTF
  82243. * @param submesh BabylonJS submesh
  82244. * @param primitiveMode Primitive mode of the mesh
  82245. * @param sideOrientation the winding order of the submesh
  82246. * @param vertexBufferKind The type of vertex attribute
  82247. * @param meshAttributeArray The vertex attribute data
  82248. * @param byteOffset The offset to the binary data
  82249. * @param binaryWriter The binary data for the glTF file
  82250. * @param convertToRightHandedSystem Converts the values to right-handed
  82251. */
  82252. private reorderTriangleFillMode;
  82253. /**
  82254. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  82255. * clock-wise during export to glTF
  82256. * @param submesh BabylonJS submesh
  82257. * @param primitiveMode Primitive mode of the mesh
  82258. * @param sideOrientation the winding order of the submesh
  82259. * @param vertexBufferKind The type of vertex attribute
  82260. * @param meshAttributeArray The vertex attribute data
  82261. * @param byteOffset The offset to the binary data
  82262. * @param binaryWriter The binary data for the glTF file
  82263. * @param convertToRightHandedSystem Converts the values to right-handed
  82264. */
  82265. private reorderTriangleStripDrawMode;
  82266. /**
  82267. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  82268. * clock-wise during export to glTF
  82269. * @param submesh BabylonJS submesh
  82270. * @param primitiveMode Primitive mode of the mesh
  82271. * @param sideOrientation the winding order of the submesh
  82272. * @param vertexBufferKind The type of vertex attribute
  82273. * @param meshAttributeArray The vertex attribute data
  82274. * @param byteOffset The offset to the binary data
  82275. * @param binaryWriter The binary data for the glTF file
  82276. * @param convertToRightHandedSystem Converts the values to right-handed
  82277. */
  82278. private reorderTriangleFanMode;
  82279. /**
  82280. * Writes the vertex attribute data to binary
  82281. * @param vertices The vertices to write to the binary writer
  82282. * @param byteOffset The offset into the binary writer to overwrite binary data
  82283. * @param vertexAttributeKind The vertex attribute type
  82284. * @param meshAttributeArray The vertex attribute data
  82285. * @param binaryWriter The writer containing the binary data
  82286. * @param convertToRightHandedSystem Converts the values to right-handed
  82287. */
  82288. private writeVertexAttributeData;
  82289. /**
  82290. * Writes mesh attribute data to a data buffer
  82291. * Returns the bytelength of the data
  82292. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  82293. * @param meshAttributeArray Array containing the attribute data
  82294. * @param byteStride Specifies the space between data
  82295. * @param binaryWriter The buffer to write the binary data to
  82296. * @param convertToRightHandedSystem Converts the values to right-handed
  82297. */
  82298. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  82299. /**
  82300. * Generates glTF json data
  82301. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  82302. * @param glTFPrefix Text to use when prefixing a glTF file
  82303. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  82304. * @returns json data as string
  82305. */
  82306. private generateJSON;
  82307. /**
  82308. * Generates data for .gltf and .bin files based on the glTF prefix string
  82309. * @param glTFPrefix Text to use when prefixing a glTF file
  82310. * @param dispose Dispose the exporter
  82311. * @returns GLTFData with glTF file data
  82312. */
  82313. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  82314. /**
  82315. * Creates a binary buffer for glTF
  82316. * @returns array buffer for binary data
  82317. */
  82318. private _generateBinaryAsync;
  82319. /**
  82320. * Pads the number to a multiple of 4
  82321. * @param num number to pad
  82322. * @returns padded number
  82323. */
  82324. private _getPadding;
  82325. /**
  82326. * @hidden
  82327. */
  82328. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  82329. /**
  82330. * Sets the TRS for each node
  82331. * @param node glTF Node for storing the transformation data
  82332. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  82333. * @param convertToRightHandedSystem Converts the values to right-handed
  82334. */
  82335. private setNodeTransformation;
  82336. private getVertexBufferFromMesh;
  82337. /**
  82338. * Creates a bufferview based on the vertices type for the Babylon mesh
  82339. * @param kind Indicates the type of vertices data
  82340. * @param componentType Indicates the numerical type used to store the data
  82341. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  82342. * @param binaryWriter The buffer to write the bufferview data to
  82343. * @param convertToRightHandedSystem Converts the values to right-handed
  82344. */
  82345. private createBufferViewKind;
  82346. /**
  82347. * The primitive mode of the Babylon mesh
  82348. * @param babylonMesh The BabylonJS mesh
  82349. */
  82350. private getMeshPrimitiveMode;
  82351. /**
  82352. * Sets the primitive mode of the glTF mesh primitive
  82353. * @param meshPrimitive glTF mesh primitive
  82354. * @param primitiveMode The primitive mode
  82355. */
  82356. private setPrimitiveMode;
  82357. /**
  82358. * Sets the vertex attribute accessor based of the glTF mesh primitive
  82359. * @param meshPrimitive glTF mesh primitive
  82360. * @param attributeKind vertex attribute
  82361. * @returns boolean specifying if uv coordinates are present
  82362. */
  82363. private setAttributeKind;
  82364. /**
  82365. * Sets data for the primitive attributes of each submesh
  82366. * @param mesh glTF Mesh object to store the primitive attribute information
  82367. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  82368. * @param binaryWriter Buffer to write the attribute data to
  82369. * @param convertToRightHandedSystem Converts the values to right-handed
  82370. */
  82371. private setPrimitiveAttributesAsync;
  82372. /**
  82373. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  82374. * @param node The node to check
  82375. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  82376. */
  82377. private isBabylonCoordinateSystemConvertingNode;
  82378. /**
  82379. * Creates a glTF scene based on the array of meshes
  82380. * Returns the the total byte offset
  82381. * @param babylonScene Babylon scene to get the mesh data from
  82382. * @param binaryWriter Buffer to write binary data to
  82383. */
  82384. private createSceneAsync;
  82385. /**
  82386. * Creates a mapping of Node unique id to node index and handles animations
  82387. * @param babylonScene Babylon Scene
  82388. * @param nodes Babylon transform nodes
  82389. * @param binaryWriter Buffer to write binary data to
  82390. * @returns Node mapping of unique id to index
  82391. */
  82392. private createNodeMapAndAnimationsAsync;
  82393. /**
  82394. * Creates a glTF node from a Babylon mesh
  82395. * @param babylonMesh Source Babylon mesh
  82396. * @param binaryWriter Buffer for storing geometry data
  82397. * @param convertToRightHandedSystem Converts the values to right-handed
  82398. * @param nodeMap Node mapping of unique id to glTF node index
  82399. * @returns glTF node
  82400. */
  82401. private createNodeAsync;
  82402. /**
  82403. * Creates a glTF skin from a Babylon skeleton
  82404. * @param babylonScene Babylon Scene
  82405. * @param nodes Babylon transform nodes
  82406. * @param binaryWriter Buffer to write binary data to
  82407. * @returns Node mapping of unique id to index
  82408. */
  82409. private createSkinsAsync;
  82410. }
  82411. /**
  82412. * @hidden
  82413. *
  82414. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  82415. */
  82416. export class _BinaryWriter {
  82417. /**
  82418. * Array buffer which stores all binary data
  82419. */
  82420. private _arrayBuffer;
  82421. /**
  82422. * View of the array buffer
  82423. */
  82424. private _dataView;
  82425. /**
  82426. * byte offset of data in array buffer
  82427. */
  82428. private _byteOffset;
  82429. /**
  82430. * Initialize binary writer with an initial byte length
  82431. * @param byteLength Initial byte length of the array buffer
  82432. */
  82433. constructor(byteLength: number);
  82434. /**
  82435. * Resize the array buffer to the specified byte length
  82436. * @param byteLength
  82437. */
  82438. private resizeBuffer;
  82439. /**
  82440. * Get an array buffer with the length of the byte offset
  82441. * @returns ArrayBuffer resized to the byte offset
  82442. */
  82443. getArrayBuffer(): ArrayBuffer;
  82444. /**
  82445. * Get the byte offset of the array buffer
  82446. * @returns byte offset
  82447. */
  82448. getByteOffset(): number;
  82449. /**
  82450. * Stores an UInt8 in the array buffer
  82451. * @param entry
  82452. * @param byteOffset If defined, specifies where to set the value as an offset.
  82453. */
  82454. setUInt8(entry: number, byteOffset?: number): void;
  82455. /**
  82456. * Stores an UInt16 in the array buffer
  82457. * @param entry
  82458. * @param byteOffset If defined, specifies where to set the value as an offset.
  82459. */
  82460. setUInt16(entry: number, byteOffset?: number): void;
  82461. /**
  82462. * Gets an UInt32 in the array buffer
  82463. * @param entry
  82464. * @param byteOffset If defined, specifies where to set the value as an offset.
  82465. */
  82466. getUInt32(byteOffset: number): number;
  82467. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  82468. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  82469. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  82470. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  82471. /**
  82472. * Stores a Float32 in the array buffer
  82473. * @param entry
  82474. */
  82475. setFloat32(entry: number, byteOffset?: number): void;
  82476. /**
  82477. * Stores an UInt32 in the array buffer
  82478. * @param entry
  82479. * @param byteOffset If defined, specifies where to set the value as an offset.
  82480. */
  82481. setUInt32(entry: number, byteOffset?: number): void;
  82482. }
  82483. }
  82484. declare module BABYLON.GLTF2.Exporter {
  82485. /**
  82486. * @hidden
  82487. * Interface to store animation data.
  82488. */
  82489. export interface _IAnimationData {
  82490. /**
  82491. * Keyframe data.
  82492. */
  82493. inputs: number[];
  82494. /**
  82495. * Value data.
  82496. */
  82497. outputs: number[][];
  82498. /**
  82499. * Animation interpolation data.
  82500. */
  82501. samplerInterpolation: AnimationSamplerInterpolation;
  82502. /**
  82503. * Minimum keyframe value.
  82504. */
  82505. inputsMin: number;
  82506. /**
  82507. * Maximum keyframe value.
  82508. */
  82509. inputsMax: number;
  82510. }
  82511. /**
  82512. * @hidden
  82513. */
  82514. export interface _IAnimationInfo {
  82515. /**
  82516. * The target channel for the animation
  82517. */
  82518. animationChannelTargetPath: AnimationChannelTargetPath;
  82519. /**
  82520. * The glTF accessor type for the data.
  82521. */
  82522. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  82523. /**
  82524. * Specifies if quaternions should be used.
  82525. */
  82526. useQuaternion: boolean;
  82527. }
  82528. /**
  82529. * @hidden
  82530. * Utility class for generating glTF animation data from BabylonJS.
  82531. */
  82532. export class _GLTFAnimation {
  82533. /**
  82534. * @ignore
  82535. *
  82536. * Creates glTF channel animation from BabylonJS animation.
  82537. * @param babylonTransformNode - BabylonJS mesh.
  82538. * @param animation - animation.
  82539. * @param animationChannelTargetPath - The target animation channel.
  82540. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  82541. * @param useQuaternion - Specifies if quaternions are used.
  82542. * @returns nullable IAnimationData
  82543. */
  82544. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  82545. private static _DeduceAnimationInfo;
  82546. /**
  82547. * @ignore
  82548. * Create node animations from the transform node animations
  82549. * @param babylonNode
  82550. * @param runtimeGLTFAnimation
  82551. * @param idleGLTFAnimations
  82552. * @param nodeMap
  82553. * @param nodes
  82554. * @param binaryWriter
  82555. * @param bufferViews
  82556. * @param accessors
  82557. * @param convertToRightHandedSystem
  82558. * @param animationSampleRate
  82559. */
  82560. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  82561. [key: number]: number;
  82562. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  82563. /**
  82564. * @ignore
  82565. * Create node animations from the animation groups
  82566. * @param babylonScene
  82567. * @param glTFAnimations
  82568. * @param nodeMap
  82569. * @param nodes
  82570. * @param binaryWriter
  82571. * @param bufferViews
  82572. * @param accessors
  82573. * @param convertToRightHandedSystemMap
  82574. * @param animationSampleRate
  82575. */
  82576. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  82577. [key: number]: number;
  82578. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  82579. [nodeId: number]: boolean;
  82580. }, animationSampleRate: number): void;
  82581. private static AddAnimation;
  82582. /**
  82583. * Create a baked animation
  82584. * @param babylonTransformNode BabylonJS mesh
  82585. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  82586. * @param animationChannelTargetPath animation target channel
  82587. * @param minFrame minimum animation frame
  82588. * @param maxFrame maximum animation frame
  82589. * @param fps frames per second of the animation
  82590. * @param inputs input key frames of the animation
  82591. * @param outputs output key frame data of the animation
  82592. * @param convertToRightHandedSystem converts the values to right-handed
  82593. * @param useQuaternion specifies if quaternions should be used
  82594. */
  82595. private static _CreateBakedAnimation;
  82596. private static _ConvertFactorToVector3OrQuaternion;
  82597. private static _SetInterpolatedValue;
  82598. /**
  82599. * Creates linear animation from the animation key frames
  82600. * @param babylonTransformNode BabylonJS mesh
  82601. * @param animation BabylonJS animation
  82602. * @param animationChannelTargetPath The target animation channel
  82603. * @param frameDelta The difference between the last and first frame of the animation
  82604. * @param inputs Array to store the key frame times
  82605. * @param outputs Array to store the key frame data
  82606. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  82607. * @param useQuaternion Specifies if quaternions are used in the animation
  82608. */
  82609. private static _CreateLinearOrStepAnimation;
  82610. /**
  82611. * Creates cubic spline animation from the animation key frames
  82612. * @param babylonTransformNode BabylonJS mesh
  82613. * @param animation BabylonJS animation
  82614. * @param animationChannelTargetPath The target animation channel
  82615. * @param frameDelta The difference between the last and first frame of the animation
  82616. * @param inputs Array to store the key frame times
  82617. * @param outputs Array to store the key frame data
  82618. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  82619. * @param useQuaternion Specifies if quaternions are used in the animation
  82620. */
  82621. private static _CreateCubicSplineAnimation;
  82622. private static _GetBasePositionRotationOrScale;
  82623. /**
  82624. * Adds a key frame value
  82625. * @param keyFrame
  82626. * @param animation
  82627. * @param outputs
  82628. * @param animationChannelTargetPath
  82629. * @param basePositionRotationOrScale
  82630. * @param convertToRightHandedSystem
  82631. * @param useQuaternion
  82632. */
  82633. private static _AddKeyframeValue;
  82634. /**
  82635. * Determine the interpolation based on the key frames
  82636. * @param keyFrames
  82637. * @param animationChannelTargetPath
  82638. * @param useQuaternion
  82639. */
  82640. private static _DeduceInterpolation;
  82641. /**
  82642. * Adds an input tangent or output tangent to the output data
  82643. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  82644. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  82645. * @param outputs The animation data by keyframe
  82646. * @param animationChannelTargetPath The target animation channel
  82647. * @param interpolation The interpolation type
  82648. * @param keyFrame The key frame with the animation data
  82649. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  82650. * @param useQuaternion Specifies if quaternions are used
  82651. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  82652. */
  82653. private static AddSplineTangent;
  82654. /**
  82655. * Get the minimum and maximum key frames' frame values
  82656. * @param keyFrames animation key frames
  82657. * @returns the minimum and maximum key frame value
  82658. */
  82659. private static calculateMinMaxKeyFrames;
  82660. }
  82661. }
  82662. declare module BABYLON.GLTF2.Exporter {
  82663. /** @hidden */
  82664. export var textureTransformPixelShader: {
  82665. name: string;
  82666. shader: string;
  82667. };
  82668. }
  82669. declare module BABYLON.GLTF2.Exporter.Extensions {
  82670. /**
  82671. * @hidden
  82672. */
  82673. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  82674. private _recordedTextures;
  82675. /** Name of this extension */
  82676. readonly name: string;
  82677. /** Defines whether this extension is enabled */
  82678. enabled: boolean;
  82679. /** Defines whether this extension is required */
  82680. required: boolean;
  82681. /** Reference to the glTF exporter */
  82682. private _wasUsed;
  82683. constructor(exporter: _Exporter);
  82684. dispose(): void;
  82685. /** @hidden */
  82686. get wasUsed(): boolean;
  82687. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  82688. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  82689. /**
  82690. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  82691. * @param babylonTexture
  82692. * @param offset
  82693. * @param rotation
  82694. * @param scale
  82695. * @param scene
  82696. */
  82697. private _textureTransformTextureAsync;
  82698. }
  82699. }
  82700. declare module BABYLON.GLTF2.Exporter.Extensions {
  82701. /**
  82702. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  82703. */
  82704. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  82705. /** The name of this extension. */
  82706. readonly name: string;
  82707. /** Defines whether this extension is enabled. */
  82708. enabled: boolean;
  82709. /** Defines whether this extension is required */
  82710. required: boolean;
  82711. /** Reference to the glTF exporter */
  82712. private _exporter;
  82713. private _lights;
  82714. /** @hidden */
  82715. constructor(exporter: _Exporter);
  82716. /** @hidden */
  82717. dispose(): void;
  82718. /** @hidden */
  82719. get wasUsed(): boolean;
  82720. /** @hidden */
  82721. onExporting(): void;
  82722. /**
  82723. * Define this method to modify the default behavior when exporting a node
  82724. * @param context The context when exporting the node
  82725. * @param node glTF node
  82726. * @param babylonNode BabylonJS node
  82727. * @param nodeMap Node mapping of unique id to glTF node index
  82728. * @returns nullable INode promise
  82729. */
  82730. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  82731. [key: number]: number;
  82732. }): Promise<Nullable<INode>>;
  82733. }
  82734. }
  82735. declare module BABYLON.GLTF2.Exporter.Extensions {
  82736. /**
  82737. * @hidden
  82738. */
  82739. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  82740. /** Name of this extension */
  82741. readonly name: string;
  82742. /** Defines whether this extension is enabled */
  82743. enabled: boolean;
  82744. /** Defines whether this extension is required */
  82745. required: boolean;
  82746. /** Reference to the glTF exporter */
  82747. private _textureInfos;
  82748. private _exportedTextures;
  82749. private _wasUsed;
  82750. constructor(exporter: _Exporter);
  82751. dispose(): void;
  82752. /** @hidden */
  82753. get wasUsed(): boolean;
  82754. private _getTextureIndex;
  82755. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  82756. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  82757. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  82758. }
  82759. }
  82760. declare module BABYLON.GLTF2.Exporter.Extensions {
  82761. /**
  82762. * @hidden
  82763. */
  82764. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  82765. /** Name of this extension */
  82766. readonly name: string;
  82767. /** Defines whether this extension is enabled */
  82768. enabled: boolean;
  82769. /** Defines whether this extension is required */
  82770. required: boolean;
  82771. private _wasUsed;
  82772. constructor(exporter: _Exporter);
  82773. /** @hidden */
  82774. get wasUsed(): boolean;
  82775. dispose(): void;
  82776. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  82777. }
  82778. }
  82779. declare module BABYLON {
  82780. /**
  82781. * Class for generating STL data from a Babylon scene.
  82782. */
  82783. export class STLExport {
  82784. /**
  82785. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  82786. * @param meshes list defines the mesh to serialize
  82787. * @param download triggers the automatic download of the file.
  82788. * @param fileName changes the downloads fileName.
  82789. * @param binary changes the STL to a binary type.
  82790. * @param isLittleEndian toggle for binary type exporter.
  82791. * @returns the STL as UTF8 string
  82792. */
  82793. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  82794. }
  82795. }
  82796. declare module "babylonjs-gltf2interface" {
  82797. export = BABYLON.GLTF2;
  82798. }
  82799. /**
  82800. * Module for glTF 2.0 Interface
  82801. */
  82802. declare module BABYLON.GLTF2 {
  82803. /**
  82804. * The datatype of the components in the attribute
  82805. */
  82806. const enum AccessorComponentType {
  82807. /**
  82808. * Byte
  82809. */
  82810. BYTE = 5120,
  82811. /**
  82812. * Unsigned Byte
  82813. */
  82814. UNSIGNED_BYTE = 5121,
  82815. /**
  82816. * Short
  82817. */
  82818. SHORT = 5122,
  82819. /**
  82820. * Unsigned Short
  82821. */
  82822. UNSIGNED_SHORT = 5123,
  82823. /**
  82824. * Unsigned Int
  82825. */
  82826. UNSIGNED_INT = 5125,
  82827. /**
  82828. * Float
  82829. */
  82830. FLOAT = 5126,
  82831. }
  82832. /**
  82833. * Specifies if the attirbute is a scalar, vector, or matrix
  82834. */
  82835. const enum AccessorType {
  82836. /**
  82837. * Scalar
  82838. */
  82839. SCALAR = "SCALAR",
  82840. /**
  82841. * Vector2
  82842. */
  82843. VEC2 = "VEC2",
  82844. /**
  82845. * Vector3
  82846. */
  82847. VEC3 = "VEC3",
  82848. /**
  82849. * Vector4
  82850. */
  82851. VEC4 = "VEC4",
  82852. /**
  82853. * Matrix2x2
  82854. */
  82855. MAT2 = "MAT2",
  82856. /**
  82857. * Matrix3x3
  82858. */
  82859. MAT3 = "MAT3",
  82860. /**
  82861. * Matrix4x4
  82862. */
  82863. MAT4 = "MAT4",
  82864. }
  82865. /**
  82866. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  82867. */
  82868. const enum AnimationChannelTargetPath {
  82869. /**
  82870. * Translation
  82871. */
  82872. TRANSLATION = "translation",
  82873. /**
  82874. * Rotation
  82875. */
  82876. ROTATION = "rotation",
  82877. /**
  82878. * Scale
  82879. */
  82880. SCALE = "scale",
  82881. /**
  82882. * Weights
  82883. */
  82884. WEIGHTS = "weights",
  82885. }
  82886. /**
  82887. * Interpolation algorithm
  82888. */
  82889. const enum AnimationSamplerInterpolation {
  82890. /**
  82891. * The animated values are linearly interpolated between keyframes
  82892. */
  82893. LINEAR = "LINEAR",
  82894. /**
  82895. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  82896. */
  82897. STEP = "STEP",
  82898. /**
  82899. * The animation's interpolation is computed using a cubic spline with specified tangents
  82900. */
  82901. CUBICSPLINE = "CUBICSPLINE",
  82902. }
  82903. /**
  82904. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  82905. */
  82906. const enum CameraType {
  82907. /**
  82908. * A perspective camera containing properties to create a perspective projection matrix
  82909. */
  82910. PERSPECTIVE = "perspective",
  82911. /**
  82912. * An orthographic camera containing properties to create an orthographic projection matrix
  82913. */
  82914. ORTHOGRAPHIC = "orthographic",
  82915. }
  82916. /**
  82917. * The mime-type of the image
  82918. */
  82919. const enum ImageMimeType {
  82920. /**
  82921. * JPEG Mime-type
  82922. */
  82923. JPEG = "image/jpeg",
  82924. /**
  82925. * PNG Mime-type
  82926. */
  82927. PNG = "image/png",
  82928. }
  82929. /**
  82930. * The alpha rendering mode of the material
  82931. */
  82932. const enum MaterialAlphaMode {
  82933. /**
  82934. * The alpha value is ignored and the rendered output is fully opaque
  82935. */
  82936. OPAQUE = "OPAQUE",
  82937. /**
  82938. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  82939. */
  82940. MASK = "MASK",
  82941. /**
  82942. * 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)
  82943. */
  82944. BLEND = "BLEND",
  82945. }
  82946. /**
  82947. * The type of the primitives to render
  82948. */
  82949. const enum MeshPrimitiveMode {
  82950. /**
  82951. * Points
  82952. */
  82953. POINTS = 0,
  82954. /**
  82955. * Lines
  82956. */
  82957. LINES = 1,
  82958. /**
  82959. * Line Loop
  82960. */
  82961. LINE_LOOP = 2,
  82962. /**
  82963. * Line Strip
  82964. */
  82965. LINE_STRIP = 3,
  82966. /**
  82967. * Triangles
  82968. */
  82969. TRIANGLES = 4,
  82970. /**
  82971. * Triangle Strip
  82972. */
  82973. TRIANGLE_STRIP = 5,
  82974. /**
  82975. * Triangle Fan
  82976. */
  82977. TRIANGLE_FAN = 6,
  82978. }
  82979. /**
  82980. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  82981. */
  82982. const enum TextureMagFilter {
  82983. /**
  82984. * Nearest
  82985. */
  82986. NEAREST = 9728,
  82987. /**
  82988. * Linear
  82989. */
  82990. LINEAR = 9729,
  82991. }
  82992. /**
  82993. * Minification filter. All valid values correspond to WebGL enums
  82994. */
  82995. const enum TextureMinFilter {
  82996. /**
  82997. * Nearest
  82998. */
  82999. NEAREST = 9728,
  83000. /**
  83001. * Linear
  83002. */
  83003. LINEAR = 9729,
  83004. /**
  83005. * Nearest Mip-Map Nearest
  83006. */
  83007. NEAREST_MIPMAP_NEAREST = 9984,
  83008. /**
  83009. * Linear Mipmap Nearest
  83010. */
  83011. LINEAR_MIPMAP_NEAREST = 9985,
  83012. /**
  83013. * Nearest Mipmap Linear
  83014. */
  83015. NEAREST_MIPMAP_LINEAR = 9986,
  83016. /**
  83017. * Linear Mipmap Linear
  83018. */
  83019. LINEAR_MIPMAP_LINEAR = 9987,
  83020. }
  83021. /**
  83022. * S (U) wrapping mode. All valid values correspond to WebGL enums
  83023. */
  83024. const enum TextureWrapMode {
  83025. /**
  83026. * Clamp to Edge
  83027. */
  83028. CLAMP_TO_EDGE = 33071,
  83029. /**
  83030. * Mirrored Repeat
  83031. */
  83032. MIRRORED_REPEAT = 33648,
  83033. /**
  83034. * Repeat
  83035. */
  83036. REPEAT = 10497,
  83037. }
  83038. /**
  83039. * glTF Property
  83040. */
  83041. interface IProperty {
  83042. /**
  83043. * Dictionary object with extension-specific objects
  83044. */
  83045. extensions?: {
  83046. [key: string]: any;
  83047. };
  83048. /**
  83049. * Application-Specific data
  83050. */
  83051. extras?: any;
  83052. }
  83053. /**
  83054. * glTF Child of Root Property
  83055. */
  83056. interface IChildRootProperty extends IProperty {
  83057. /**
  83058. * The user-defined name of this object
  83059. */
  83060. name?: string;
  83061. }
  83062. /**
  83063. * Indices of those attributes that deviate from their initialization value
  83064. */
  83065. interface IAccessorSparseIndices extends IProperty {
  83066. /**
  83067. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  83068. */
  83069. bufferView: number;
  83070. /**
  83071. * The offset relative to the start of the bufferView in bytes. Must be aligned
  83072. */
  83073. byteOffset?: number;
  83074. /**
  83075. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  83076. */
  83077. componentType: AccessorComponentType;
  83078. }
  83079. /**
  83080. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  83081. */
  83082. interface IAccessorSparseValues extends IProperty {
  83083. /**
  83084. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  83085. */
  83086. bufferView: number;
  83087. /**
  83088. * The offset relative to the start of the bufferView in bytes. Must be aligned
  83089. */
  83090. byteOffset?: number;
  83091. }
  83092. /**
  83093. * Sparse storage of attributes that deviate from their initialization value
  83094. */
  83095. interface IAccessorSparse extends IProperty {
  83096. /**
  83097. * The number of attributes encoded in this sparse accessor
  83098. */
  83099. count: number;
  83100. /**
  83101. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  83102. */
  83103. indices: IAccessorSparseIndices;
  83104. /**
  83105. * 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
  83106. */
  83107. values: IAccessorSparseValues;
  83108. }
  83109. /**
  83110. * 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
  83111. */
  83112. interface IAccessor extends IChildRootProperty {
  83113. /**
  83114. * The index of the bufferview
  83115. */
  83116. bufferView?: number;
  83117. /**
  83118. * The offset relative to the start of the bufferView in bytes
  83119. */
  83120. byteOffset?: number;
  83121. /**
  83122. * The datatype of components in the attribute
  83123. */
  83124. componentType: AccessorComponentType;
  83125. /**
  83126. * Specifies whether integer data values should be normalized
  83127. */
  83128. normalized?: boolean;
  83129. /**
  83130. * The number of attributes referenced by this accessor
  83131. */
  83132. count: number;
  83133. /**
  83134. * Specifies if the attribute is a scalar, vector, or matrix
  83135. */
  83136. type: AccessorType;
  83137. /**
  83138. * Maximum value of each component in this attribute
  83139. */
  83140. max?: number[];
  83141. /**
  83142. * Minimum value of each component in this attribute
  83143. */
  83144. min?: number[];
  83145. /**
  83146. * Sparse storage of attributes that deviate from their initialization value
  83147. */
  83148. sparse?: IAccessorSparse;
  83149. }
  83150. /**
  83151. * Targets an animation's sampler at a node's property
  83152. */
  83153. interface IAnimationChannel extends IProperty {
  83154. /**
  83155. * The index of a sampler in this animation used to compute the value for the target
  83156. */
  83157. sampler: number;
  83158. /**
  83159. * The index of the node and TRS property to target
  83160. */
  83161. target: IAnimationChannelTarget;
  83162. }
  83163. /**
  83164. * The index of the node and TRS property that an animation channel targets
  83165. */
  83166. interface IAnimationChannelTarget extends IProperty {
  83167. /**
  83168. * The index of the node to target
  83169. */
  83170. node: number;
  83171. /**
  83172. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  83173. */
  83174. path: AnimationChannelTargetPath;
  83175. }
  83176. /**
  83177. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  83178. */
  83179. interface IAnimationSampler extends IProperty {
  83180. /**
  83181. * The index of an accessor containing keyframe input values, e.g., time
  83182. */
  83183. input: number;
  83184. /**
  83185. * Interpolation algorithm
  83186. */
  83187. interpolation?: AnimationSamplerInterpolation;
  83188. /**
  83189. * The index of an accessor, containing keyframe output values
  83190. */
  83191. output: number;
  83192. }
  83193. /**
  83194. * A keyframe animation
  83195. */
  83196. interface IAnimation extends IChildRootProperty {
  83197. /**
  83198. * An array of channels, each of which targets an animation's sampler at a node's property
  83199. */
  83200. channels: IAnimationChannel[];
  83201. /**
  83202. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  83203. */
  83204. samplers: IAnimationSampler[];
  83205. }
  83206. /**
  83207. * Metadata about the glTF asset
  83208. */
  83209. interface IAsset extends IChildRootProperty {
  83210. /**
  83211. * A copyright message suitable for display to credit the content creator
  83212. */
  83213. copyright?: string;
  83214. /**
  83215. * Tool that generated this glTF model. Useful for debugging
  83216. */
  83217. generator?: string;
  83218. /**
  83219. * The glTF version that this asset targets
  83220. */
  83221. version: string;
  83222. /**
  83223. * The minimum glTF version that this asset targets
  83224. */
  83225. minVersion?: string;
  83226. }
  83227. /**
  83228. * A buffer points to binary geometry, animation, or skins
  83229. */
  83230. interface IBuffer extends IChildRootProperty {
  83231. /**
  83232. * 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
  83233. */
  83234. uri?: string;
  83235. /**
  83236. * The length of the buffer in bytes
  83237. */
  83238. byteLength: number;
  83239. }
  83240. /**
  83241. * A view into a buffer generally representing a subset of the buffer
  83242. */
  83243. interface IBufferView extends IChildRootProperty {
  83244. /**
  83245. * The index of the buffer
  83246. */
  83247. buffer: number;
  83248. /**
  83249. * The offset into the buffer in bytes
  83250. */
  83251. byteOffset?: number;
  83252. /**
  83253. * The lenth of the bufferView in bytes
  83254. */
  83255. byteLength: number;
  83256. /**
  83257. * The stride, in bytes
  83258. */
  83259. byteStride?: number;
  83260. }
  83261. /**
  83262. * An orthographic camera containing properties to create an orthographic projection matrix
  83263. */
  83264. interface ICameraOrthographic extends IProperty {
  83265. /**
  83266. * The floating-point horizontal magnification of the view. Must not be zero
  83267. */
  83268. xmag: number;
  83269. /**
  83270. * The floating-point vertical magnification of the view. Must not be zero
  83271. */
  83272. ymag: number;
  83273. /**
  83274. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  83275. */
  83276. zfar: number;
  83277. /**
  83278. * The floating-point distance to the near clipping plane
  83279. */
  83280. znear: number;
  83281. }
  83282. /**
  83283. * A perspective camera containing properties to create a perspective projection matrix
  83284. */
  83285. interface ICameraPerspective extends IProperty {
  83286. /**
  83287. * The floating-point aspect ratio of the field of view
  83288. */
  83289. aspectRatio?: number;
  83290. /**
  83291. * The floating-point vertical field of view in radians
  83292. */
  83293. yfov: number;
  83294. /**
  83295. * The floating-point distance to the far clipping plane
  83296. */
  83297. zfar?: number;
  83298. /**
  83299. * The floating-point distance to the near clipping plane
  83300. */
  83301. znear: number;
  83302. }
  83303. /**
  83304. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  83305. */
  83306. interface ICamera extends IChildRootProperty {
  83307. /**
  83308. * An orthographic camera containing properties to create an orthographic projection matrix
  83309. */
  83310. orthographic?: ICameraOrthographic;
  83311. /**
  83312. * A perspective camera containing properties to create a perspective projection matrix
  83313. */
  83314. perspective?: ICameraPerspective;
  83315. /**
  83316. * Specifies if the camera uses a perspective or orthographic projection
  83317. */
  83318. type: CameraType;
  83319. }
  83320. /**
  83321. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  83322. */
  83323. interface IImage extends IChildRootProperty {
  83324. /**
  83325. * 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
  83326. */
  83327. uri?: string;
  83328. /**
  83329. * The image's MIME type
  83330. */
  83331. mimeType?: ImageMimeType;
  83332. /**
  83333. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  83334. */
  83335. bufferView?: number;
  83336. }
  83337. /**
  83338. * Material Normal Texture Info
  83339. */
  83340. interface IMaterialNormalTextureInfo extends ITextureInfo {
  83341. /**
  83342. * The scalar multiplier applied to each normal vector of the normal texture
  83343. */
  83344. scale?: number;
  83345. }
  83346. /**
  83347. * Material Occlusion Texture Info
  83348. */
  83349. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  83350. /**
  83351. * A scalar multiplier controlling the amount of occlusion applied
  83352. */
  83353. strength?: number;
  83354. }
  83355. /**
  83356. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  83357. */
  83358. interface IMaterialPbrMetallicRoughness {
  83359. /**
  83360. * The material's base color factor
  83361. */
  83362. baseColorFactor?: number[];
  83363. /**
  83364. * The base color texture
  83365. */
  83366. baseColorTexture?: ITextureInfo;
  83367. /**
  83368. * The metalness of the material
  83369. */
  83370. metallicFactor?: number;
  83371. /**
  83372. * The roughness of the material
  83373. */
  83374. roughnessFactor?: number;
  83375. /**
  83376. * The metallic-roughness texture
  83377. */
  83378. metallicRoughnessTexture?: ITextureInfo;
  83379. }
  83380. /**
  83381. * The material appearance of a primitive
  83382. */
  83383. interface IMaterial extends IChildRootProperty {
  83384. /**
  83385. * 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
  83386. */
  83387. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  83388. /**
  83389. * The normal map texture
  83390. */
  83391. normalTexture?: IMaterialNormalTextureInfo;
  83392. /**
  83393. * The occlusion map texture
  83394. */
  83395. occlusionTexture?: IMaterialOcclusionTextureInfo;
  83396. /**
  83397. * The emissive map texture
  83398. */
  83399. emissiveTexture?: ITextureInfo;
  83400. /**
  83401. * 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
  83402. */
  83403. emissiveFactor?: number[];
  83404. /**
  83405. * The alpha rendering mode of the material
  83406. */
  83407. alphaMode?: MaterialAlphaMode;
  83408. /**
  83409. * The alpha cutoff value of the material
  83410. */
  83411. alphaCutoff?: number;
  83412. /**
  83413. * Specifies whether the material is double sided
  83414. */
  83415. doubleSided?: boolean;
  83416. }
  83417. /**
  83418. * Geometry to be rendered with the given material
  83419. */
  83420. interface IMeshPrimitive extends IProperty {
  83421. /**
  83422. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  83423. */
  83424. attributes: {
  83425. [name: string]: number;
  83426. };
  83427. /**
  83428. * The index of the accessor that contains the indices
  83429. */
  83430. indices?: number;
  83431. /**
  83432. * The index of the material to apply to this primitive when rendering
  83433. */
  83434. material?: number;
  83435. /**
  83436. * The type of primitives to render. All valid values correspond to WebGL enums
  83437. */
  83438. mode?: MeshPrimitiveMode;
  83439. /**
  83440. * 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
  83441. */
  83442. targets?: {
  83443. [name: string]: number;
  83444. }[];
  83445. }
  83446. /**
  83447. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  83448. */
  83449. interface IMesh extends IChildRootProperty {
  83450. /**
  83451. * An array of primitives, each defining geometry to be rendered with a material
  83452. */
  83453. primitives: IMeshPrimitive[];
  83454. /**
  83455. * Array of weights to be applied to the Morph Targets
  83456. */
  83457. weights?: number[];
  83458. }
  83459. /**
  83460. * A node in the node hierarchy
  83461. */
  83462. interface INode extends IChildRootProperty {
  83463. /**
  83464. * The index of the camera referenced by this node
  83465. */
  83466. camera?: number;
  83467. /**
  83468. * The indices of this node's children
  83469. */
  83470. children?: number[];
  83471. /**
  83472. * The index of the skin referenced by this node
  83473. */
  83474. skin?: number;
  83475. /**
  83476. * A floating-point 4x4 transformation matrix stored in column-major order
  83477. */
  83478. matrix?: number[];
  83479. /**
  83480. * The index of the mesh in this node
  83481. */
  83482. mesh?: number;
  83483. /**
  83484. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  83485. */
  83486. rotation?: number[];
  83487. /**
  83488. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  83489. */
  83490. scale?: number[];
  83491. /**
  83492. * The node's translation along the x, y, and z axes
  83493. */
  83494. translation?: number[];
  83495. /**
  83496. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  83497. */
  83498. weights?: number[];
  83499. }
  83500. /**
  83501. * Texture sampler properties for filtering and wrapping modes
  83502. */
  83503. interface ISampler extends IChildRootProperty {
  83504. /**
  83505. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  83506. */
  83507. magFilter?: TextureMagFilter;
  83508. /**
  83509. * Minification filter. All valid values correspond to WebGL enums
  83510. */
  83511. minFilter?: TextureMinFilter;
  83512. /**
  83513. * S (U) wrapping mode. All valid values correspond to WebGL enums
  83514. */
  83515. wrapS?: TextureWrapMode;
  83516. /**
  83517. * T (V) wrapping mode. All valid values correspond to WebGL enums
  83518. */
  83519. wrapT?: TextureWrapMode;
  83520. }
  83521. /**
  83522. * The root nodes of a scene
  83523. */
  83524. interface IScene extends IChildRootProperty {
  83525. /**
  83526. * The indices of each root node
  83527. */
  83528. nodes: number[];
  83529. }
  83530. /**
  83531. * Joints and matrices defining a skin
  83532. */
  83533. interface ISkin extends IChildRootProperty {
  83534. /**
  83535. * 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
  83536. */
  83537. inverseBindMatrices?: number;
  83538. /**
  83539. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  83540. */
  83541. skeleton?: number;
  83542. /**
  83543. * 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)
  83544. */
  83545. joints: number[];
  83546. }
  83547. /**
  83548. * A texture and its sampler
  83549. */
  83550. interface ITexture extends IChildRootProperty {
  83551. /**
  83552. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  83553. */
  83554. sampler?: number;
  83555. /**
  83556. * The index of the image used by this texture
  83557. */
  83558. source: number;
  83559. }
  83560. /**
  83561. * Reference to a texture
  83562. */
  83563. interface ITextureInfo extends IProperty {
  83564. /**
  83565. * The index of the texture
  83566. */
  83567. index: number;
  83568. /**
  83569. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  83570. */
  83571. texCoord?: number;
  83572. }
  83573. /**
  83574. * The root object for a glTF asset
  83575. */
  83576. interface IGLTF extends IProperty {
  83577. /**
  83578. * An array of accessors. An accessor is a typed view into a bufferView
  83579. */
  83580. accessors?: IAccessor[];
  83581. /**
  83582. * An array of keyframe animations
  83583. */
  83584. animations?: IAnimation[];
  83585. /**
  83586. * Metadata about the glTF asset
  83587. */
  83588. asset: IAsset;
  83589. /**
  83590. * An array of buffers. A buffer points to binary geometry, animation, or skins
  83591. */
  83592. buffers?: IBuffer[];
  83593. /**
  83594. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  83595. */
  83596. bufferViews?: IBufferView[];
  83597. /**
  83598. * An array of cameras
  83599. */
  83600. cameras?: ICamera[];
  83601. /**
  83602. * Names of glTF extensions used somewhere in this asset
  83603. */
  83604. extensionsUsed?: string[];
  83605. /**
  83606. * Names of glTF extensions required to properly load this asset
  83607. */
  83608. extensionsRequired?: string[];
  83609. /**
  83610. * An array of images. An image defines data used to create a texture
  83611. */
  83612. images?: IImage[];
  83613. /**
  83614. * An array of materials. A material defines the appearance of a primitive
  83615. */
  83616. materials?: IMaterial[];
  83617. /**
  83618. * An array of meshes. A mesh is a set of primitives to be rendered
  83619. */
  83620. meshes?: IMesh[];
  83621. /**
  83622. * An array of nodes
  83623. */
  83624. nodes?: INode[];
  83625. /**
  83626. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  83627. */
  83628. samplers?: ISampler[];
  83629. /**
  83630. * The index of the default scene
  83631. */
  83632. scene?: number;
  83633. /**
  83634. * An array of scenes
  83635. */
  83636. scenes?: IScene[];
  83637. /**
  83638. * An array of skins. A skin is defined by joints and matrices
  83639. */
  83640. skins?: ISkin[];
  83641. /**
  83642. * An array of textures
  83643. */
  83644. textures?: ITexture[];
  83645. }
  83646. /**
  83647. * The glTF validation results
  83648. * @ignore
  83649. */
  83650. interface IGLTFValidationResults {
  83651. info: {
  83652. generator: string;
  83653. hasAnimations: boolean;
  83654. hasDefaultScene: boolean;
  83655. hasMaterials: boolean;
  83656. hasMorphTargets: boolean;
  83657. hasSkins: boolean;
  83658. hasTextures: boolean;
  83659. maxAttributesUsed: number;
  83660. primitivesCount: number
  83661. };
  83662. issues: {
  83663. messages: Array<string>;
  83664. numErrors: number;
  83665. numHints: number;
  83666. numInfos: number;
  83667. numWarnings: number;
  83668. truncated: boolean
  83669. };
  83670. mimeType: string;
  83671. uri: string;
  83672. validatedAt: string;
  83673. validatorVersion: string;
  83674. }
  83675. /**
  83676. * The glTF validation options
  83677. */
  83678. interface IGLTFValidationOptions {
  83679. /** Uri to use */
  83680. uri?: string;
  83681. /** Function used to load external resources */
  83682. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  83683. /** Boolean indicating that we need to validate accessor data */
  83684. validateAccessorData?: boolean;
  83685. /** max number of issues allowed */
  83686. maxIssues?: number;
  83687. /** Ignored issues */
  83688. ignoredIssues?: Array<string>;
  83689. /** Value to override severy settings */
  83690. severityOverrides?: Object;
  83691. }
  83692. /**
  83693. * The glTF validator object
  83694. * @ignore
  83695. */
  83696. interface IGLTFValidator {
  83697. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  83698. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  83699. }
  83700. /**
  83701. * Interfaces from the EXT_lights_image_based extension
  83702. */
  83703. /** @hidden */
  83704. interface IEXTLightsImageBased_LightReferenceImageBased {
  83705. light: number;
  83706. }
  83707. /** @hidden */
  83708. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  83709. intensity: number;
  83710. rotation: number[];
  83711. specularImageSize: number;
  83712. specularImages: number[][];
  83713. irradianceCoefficients: number[][];
  83714. }
  83715. /** @hidden */
  83716. interface IEXTLightsImageBased {
  83717. lights: IEXTLightsImageBased_LightImageBased[];
  83718. }
  83719. /**
  83720. * Interfaces from the EXT_mesh_gpu_instancing extension
  83721. * !!! Experimental Extension Subject to Changes !!!
  83722. */
  83723. /** @hidden */
  83724. interface IEXTMeshGpuInstancing {
  83725. mesh?: number;
  83726. attributes: { [name: string]: number };
  83727. }
  83728. /**
  83729. * Interfaces from the KHR_draco_mesh_compression extension
  83730. */
  83731. /** @hidden */
  83732. interface IKHRDracoMeshCompression {
  83733. bufferView: number;
  83734. attributes: { [name: string]: number };
  83735. }
  83736. /**
  83737. * Interfaces from the KHR_lights_punctual extension
  83738. */
  83739. /** @hidden */
  83740. const enum IKHRLightsPunctual_LightType {
  83741. DIRECTIONAL = "directional",
  83742. POINT = "point",
  83743. SPOT = "spot"
  83744. }
  83745. /** @hidden */
  83746. interface IKHRLightsPunctual_LightReference {
  83747. light: number;
  83748. }
  83749. /** @hidden */
  83750. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  83751. type: IKHRLightsPunctual_LightType;
  83752. color?: number[];
  83753. intensity?: number;
  83754. range?: number;
  83755. spot?: {
  83756. innerConeAngle?: number;
  83757. outerConeAngle?: number;
  83758. };
  83759. }
  83760. /** @hidden */
  83761. interface IKHRLightsPunctual {
  83762. lights: IKHRLightsPunctual_Light[];
  83763. }
  83764. /**
  83765. * Interfaces from the KHR_materials_clearcoat extension
  83766. * !!! Experimental Extension Subject to Changes !!!
  83767. */
  83768. /** @hidden */
  83769. interface IKHRMaterialsClearcoat {
  83770. clearcoatFactor: number;
  83771. clearcoatTexture: ITextureInfo;
  83772. clearcoatRoughnessFactor: number;
  83773. clearcoatRoughnessTexture: ITextureInfo;
  83774. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  83775. }
  83776. /**
  83777. * Interfaces from the KHR_materials_ior extension
  83778. * !!! Experimental Extension Subject to Changes !!!
  83779. */
  83780. /** @hidden */
  83781. interface IKHRMaterialsIor {
  83782. ior: number;
  83783. }
  83784. /**
  83785. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  83786. */
  83787. /** @hidden */
  83788. interface IKHRMaterialsPbrSpecularGlossiness {
  83789. diffuseFactor: number[];
  83790. diffuseTexture: ITextureInfo;
  83791. specularFactor: number[];
  83792. glossinessFactor: number;
  83793. specularGlossinessTexture: ITextureInfo;
  83794. }
  83795. /**
  83796. * Interfaces from the KHR_materials_sheen extension
  83797. * !!! Experimental Extension Subject to Changes !!!
  83798. */
  83799. /** @hidden */
  83800. interface IKHRMaterialsSheen {
  83801. sheenColorFactor?: number[];
  83802. sheenTexture?: ITextureInfo;
  83803. sheenRoughnessFactor?: number;
  83804. }
  83805. /**
  83806. * Interfaces from the KHR_materials_specular extension
  83807. * !!! Experimental Extension Subject to Changes !!!
  83808. */
  83809. /** @hidden */
  83810. interface IKHRMaterialsSpecular {
  83811. specularFactor: number;
  83812. specularColorFactor: number[];
  83813. specularTexture: ITextureInfo;
  83814. }
  83815. /**
  83816. * Interfaces from the KHR_materials_transmission extension
  83817. * !!! Experimental Extension Subject to Changes !!!
  83818. */
  83819. /** @hidden */
  83820. interface IKHRMaterialsTransmission {
  83821. transmissionFactor?: number;
  83822. transmissionTexture?: ITextureInfo;
  83823. }
  83824. /**
  83825. * Interfaces from the KHR_materials_variants extension
  83826. * !!! Experimental Extension Subject to Changes !!!
  83827. */
  83828. /** @hidden */
  83829. interface IKHRMaterialVariants_Mapping {
  83830. tags: string[];
  83831. material: number;
  83832. }
  83833. /** @hidden */
  83834. interface IKHRMaterialVariants {
  83835. mapping: IKHRMaterialVariants_Mapping[];
  83836. }
  83837. /**
  83838. * Interfaces from the KHR_texture_basisu extension
  83839. * !!! Experimental Extension Subject to Changes !!!
  83840. */
  83841. /** @hidden */
  83842. interface IKHRTextureBasisU {
  83843. source: number;
  83844. }
  83845. /**
  83846. * Interfaces from the KHR_texture_transform extension
  83847. */
  83848. /** @hidden */
  83849. interface IKHRTextureTransform {
  83850. offset?: number[];
  83851. rotation?: number;
  83852. scale?: number[];
  83853. texCoord?: number;
  83854. }
  83855. /**
  83856. * Interfaces from the KHR_xmp extension
  83857. * !!! Experimental Extension Subject to Changes !!!
  83858. */
  83859. /** @hidden */
  83860. interface IKHRXmp_Data {
  83861. [key: string]: unknown;
  83862. }
  83863. /** @hidden */
  83864. interface IKHRXmp_Gltf {
  83865. packets: IKHRXmp_Data[];
  83866. }
  83867. /** @hidden */
  83868. interface IKHRXmp_Node {
  83869. packet: number;
  83870. }
  83871. /**
  83872. * Interfaces from the MSFT_audio_emitter extension
  83873. */
  83874. /** @hidden */
  83875. interface IMSFTAudioEmitter_ClipReference {
  83876. clip: number;
  83877. weight?: number;
  83878. }
  83879. /** @hidden */
  83880. interface IMSFTAudioEmitter_EmittersReference {
  83881. emitters: number[];
  83882. }
  83883. /** @hidden */
  83884. const enum IMSFTAudioEmitter_DistanceModel {
  83885. linear = "linear",
  83886. inverse = "inverse",
  83887. exponential = "exponential",
  83888. }
  83889. /** @hidden */
  83890. interface IMSFTAudioEmitter_Emitter {
  83891. name?: string;
  83892. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  83893. refDistance?: number;
  83894. maxDistance?: number;
  83895. rolloffFactor?: number;
  83896. innerAngle?: number;
  83897. outerAngle?: number;
  83898. loop?: boolean;
  83899. volume?: number;
  83900. clips: IMSFTAudioEmitter_ClipReference[];
  83901. }
  83902. /** @hidden */
  83903. const enum IMSFTAudioEmitter_AudioMimeType {
  83904. WAV = "audio/wav",
  83905. }
  83906. /** @hidden */
  83907. interface IMSFTAudioEmitter_Clip extends IProperty {
  83908. uri?: string;
  83909. bufferView?: number;
  83910. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  83911. }
  83912. /** @hidden */
  83913. const enum IMSFTAudioEmitter_AnimationEventAction {
  83914. play = "play",
  83915. pause = "pause",
  83916. stop = "stop",
  83917. }
  83918. /** @hidden */
  83919. interface IMSFTAudioEmitter_AnimationEvent {
  83920. action: IMSFTAudioEmitter_AnimationEventAction;
  83921. emitter: number;
  83922. time: number;
  83923. startOffset?: number;
  83924. }
  83925. /**
  83926. * Interfaces from the MSFT_lod extension
  83927. */
  83928. /** @hidden */
  83929. interface IMSFTLOD {
  83930. ids: number[];
  83931. }
  83932. }
  83933. declare module BABYLON {
  83934. /** @hidden */
  83935. export var cellPixelShader: {
  83936. name: string;
  83937. shader: string;
  83938. };
  83939. }
  83940. declare module BABYLON {
  83941. /** @hidden */
  83942. export var cellVertexShader: {
  83943. name: string;
  83944. shader: string;
  83945. };
  83946. }
  83947. declare module BABYLON {
  83948. export class CellMaterial extends BABYLON.PushMaterial {
  83949. private _diffuseTexture;
  83950. diffuseTexture: BABYLON.BaseTexture;
  83951. diffuseColor: BABYLON.Color3;
  83952. _computeHighLevel: boolean;
  83953. computeHighLevel: boolean;
  83954. private _disableLighting;
  83955. disableLighting: boolean;
  83956. private _maxSimultaneousLights;
  83957. maxSimultaneousLights: number;
  83958. constructor(name: string, scene: BABYLON.Scene);
  83959. needAlphaBlending(): boolean;
  83960. needAlphaTesting(): boolean;
  83961. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83962. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83963. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83964. getAnimatables(): BABYLON.IAnimatable[];
  83965. getActiveTextures(): BABYLON.BaseTexture[];
  83966. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83967. dispose(forceDisposeEffect?: boolean): void;
  83968. getClassName(): string;
  83969. clone(name: string): CellMaterial;
  83970. serialize(): any;
  83971. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  83972. }
  83973. }
  83974. declare module BABYLON {
  83975. export class CustomShaderStructure {
  83976. FragmentStore: string;
  83977. VertexStore: string;
  83978. constructor();
  83979. }
  83980. export class ShaderSpecialParts {
  83981. constructor();
  83982. Fragment_Begin: string;
  83983. Fragment_Definitions: string;
  83984. Fragment_MainBegin: string;
  83985. Fragment_Custom_Diffuse: string;
  83986. Fragment_Before_Lights: string;
  83987. Fragment_Before_Fog: string;
  83988. Fragment_Custom_Alpha: string;
  83989. Fragment_Before_FragColor: string;
  83990. Vertex_Begin: string;
  83991. Vertex_Definitions: string;
  83992. Vertex_MainBegin: string;
  83993. Vertex_Before_PositionUpdated: string;
  83994. Vertex_Before_NormalUpdated: string;
  83995. Vertex_After_WorldPosComputed: string;
  83996. Vertex_MainEnd: string;
  83997. }
  83998. export class CustomMaterial extends BABYLON.StandardMaterial {
  83999. static ShaderIndexer: number;
  84000. CustomParts: ShaderSpecialParts;
  84001. _isCreatedShader: boolean;
  84002. _createdShaderName: string;
  84003. _customUniform: string[];
  84004. _newUniforms: string[];
  84005. _newUniformInstances: {
  84006. [name: string]: any;
  84007. };
  84008. _newSamplerInstances: {
  84009. [name: string]: BABYLON.Texture;
  84010. };
  84011. _customAttributes: string[];
  84012. FragmentShader: string;
  84013. VertexShader: string;
  84014. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  84015. ReviewUniform(name: string, arr: string[]): string[];
  84016. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  84017. constructor(name: string, scene: BABYLON.Scene);
  84018. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  84019. AddAttribute(name: string): CustomMaterial;
  84020. Fragment_Begin(shaderPart: string): CustomMaterial;
  84021. Fragment_Definitions(shaderPart: string): CustomMaterial;
  84022. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  84023. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  84024. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  84025. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  84026. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  84027. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  84028. Vertex_Begin(shaderPart: string): CustomMaterial;
  84029. Vertex_Definitions(shaderPart: string): CustomMaterial;
  84030. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  84031. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  84032. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  84033. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  84034. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  84035. }
  84036. }
  84037. declare module BABYLON {
  84038. export class ShaderAlebdoParts {
  84039. constructor();
  84040. Fragment_Begin: string;
  84041. Fragment_Definitions: string;
  84042. Fragment_MainBegin: string;
  84043. Fragment_Custom_Albedo: string;
  84044. Fragment_Before_Lights: string;
  84045. Fragment_Custom_MetallicRoughness: string;
  84046. Fragment_Custom_MicroSurface: string;
  84047. Fragment_Before_Fog: string;
  84048. Fragment_Custom_Alpha: string;
  84049. Fragment_Before_FragColor: string;
  84050. Vertex_Begin: string;
  84051. Vertex_Definitions: string;
  84052. Vertex_MainBegin: string;
  84053. Vertex_Before_PositionUpdated: string;
  84054. Vertex_Before_NormalUpdated: string;
  84055. Vertex_After_WorldPosComputed: string;
  84056. Vertex_MainEnd: string;
  84057. }
  84058. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  84059. static ShaderIndexer: number;
  84060. CustomParts: ShaderAlebdoParts;
  84061. _isCreatedShader: boolean;
  84062. _createdShaderName: string;
  84063. _customUniform: string[];
  84064. _newUniforms: string[];
  84065. _newUniformInstances: {
  84066. [name: string]: any;
  84067. };
  84068. _newSamplerInstances: {
  84069. [name: string]: BABYLON.Texture;
  84070. };
  84071. _customAttributes: string[];
  84072. FragmentShader: string;
  84073. VertexShader: string;
  84074. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  84075. ReviewUniform(name: string, arr: string[]): string[];
  84076. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  84077. constructor(name: string, scene: BABYLON.Scene);
  84078. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  84079. AddAttribute(name: string): PBRCustomMaterial;
  84080. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  84081. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  84082. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  84083. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  84084. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  84085. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  84086. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  84087. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  84088. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  84089. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  84090. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  84091. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  84092. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  84093. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  84094. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  84095. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  84096. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  84097. }
  84098. }
  84099. declare module BABYLON {
  84100. /** @hidden */
  84101. export var firePixelShader: {
  84102. name: string;
  84103. shader: string;
  84104. };
  84105. }
  84106. declare module BABYLON {
  84107. /** @hidden */
  84108. export var fireVertexShader: {
  84109. name: string;
  84110. shader: string;
  84111. };
  84112. }
  84113. declare module BABYLON {
  84114. export class FireMaterial extends BABYLON.PushMaterial {
  84115. private _diffuseTexture;
  84116. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  84117. private _distortionTexture;
  84118. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  84119. private _opacityTexture;
  84120. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  84121. diffuseColor: BABYLON.Color3;
  84122. speed: number;
  84123. private _scaledDiffuse;
  84124. private _lastTime;
  84125. constructor(name: string, scene: BABYLON.Scene);
  84126. needAlphaBlending(): boolean;
  84127. needAlphaTesting(): boolean;
  84128. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84129. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84130. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84131. getAnimatables(): BABYLON.IAnimatable[];
  84132. getActiveTextures(): BABYLON.BaseTexture[];
  84133. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84134. getClassName(): string;
  84135. dispose(forceDisposeEffect?: boolean): void;
  84136. clone(name: string): FireMaterial;
  84137. serialize(): any;
  84138. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  84139. }
  84140. }
  84141. declare module BABYLON {
  84142. /** @hidden */
  84143. export var furPixelShader: {
  84144. name: string;
  84145. shader: string;
  84146. };
  84147. }
  84148. declare module BABYLON {
  84149. /** @hidden */
  84150. export var furVertexShader: {
  84151. name: string;
  84152. shader: string;
  84153. };
  84154. }
  84155. declare module BABYLON {
  84156. export class FurMaterial extends BABYLON.PushMaterial {
  84157. private _diffuseTexture;
  84158. diffuseTexture: BABYLON.BaseTexture;
  84159. private _heightTexture;
  84160. heightTexture: BABYLON.BaseTexture;
  84161. diffuseColor: BABYLON.Color3;
  84162. furLength: number;
  84163. furAngle: number;
  84164. furColor: BABYLON.Color3;
  84165. furOffset: number;
  84166. furSpacing: number;
  84167. furGravity: BABYLON.Vector3;
  84168. furSpeed: number;
  84169. furDensity: number;
  84170. furOcclusion: number;
  84171. furTexture: BABYLON.DynamicTexture;
  84172. private _disableLighting;
  84173. disableLighting: boolean;
  84174. private _maxSimultaneousLights;
  84175. maxSimultaneousLights: number;
  84176. highLevelFur: boolean;
  84177. _meshes: BABYLON.AbstractMesh[];
  84178. private _furTime;
  84179. constructor(name: string, scene: BABYLON.Scene);
  84180. get furTime(): number;
  84181. set furTime(furTime: number);
  84182. needAlphaBlending(): boolean;
  84183. needAlphaTesting(): boolean;
  84184. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84185. updateFur(): void;
  84186. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84187. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84188. getAnimatables(): BABYLON.IAnimatable[];
  84189. getActiveTextures(): BABYLON.BaseTexture[];
  84190. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84191. dispose(forceDisposeEffect?: boolean): void;
  84192. clone(name: string): FurMaterial;
  84193. serialize(): any;
  84194. getClassName(): string;
  84195. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  84196. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  84197. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  84198. }
  84199. }
  84200. declare module BABYLON {
  84201. /** @hidden */
  84202. export var gradientPixelShader: {
  84203. name: string;
  84204. shader: string;
  84205. };
  84206. }
  84207. declare module BABYLON {
  84208. /** @hidden */
  84209. export var gradientVertexShader: {
  84210. name: string;
  84211. shader: string;
  84212. };
  84213. }
  84214. declare module BABYLON {
  84215. export class GradientMaterial extends BABYLON.PushMaterial {
  84216. private _maxSimultaneousLights;
  84217. maxSimultaneousLights: number;
  84218. topColor: BABYLON.Color3;
  84219. topColorAlpha: number;
  84220. bottomColor: BABYLON.Color3;
  84221. bottomColorAlpha: number;
  84222. offset: number;
  84223. scale: number;
  84224. smoothness: number;
  84225. private _disableLighting;
  84226. disableLighting: boolean;
  84227. constructor(name: string, scene: BABYLON.Scene);
  84228. needAlphaBlending(): boolean;
  84229. needAlphaTesting(): boolean;
  84230. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84231. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84232. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84233. getAnimatables(): BABYLON.IAnimatable[];
  84234. dispose(forceDisposeEffect?: boolean): void;
  84235. clone(name: string): GradientMaterial;
  84236. serialize(): any;
  84237. getClassName(): string;
  84238. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  84239. }
  84240. }
  84241. declare module BABYLON {
  84242. /** @hidden */
  84243. export var gridPixelShader: {
  84244. name: string;
  84245. shader: string;
  84246. };
  84247. }
  84248. declare module BABYLON {
  84249. /** @hidden */
  84250. export var gridVertexShader: {
  84251. name: string;
  84252. shader: string;
  84253. };
  84254. }
  84255. declare module BABYLON {
  84256. /**
  84257. * The grid materials allows you to wrap any shape with a grid.
  84258. * Colors are customizable.
  84259. */
  84260. export class GridMaterial extends BABYLON.PushMaterial {
  84261. /**
  84262. * Main color of the grid (e.g. between lines)
  84263. */
  84264. mainColor: BABYLON.Color3;
  84265. /**
  84266. * Color of the grid lines.
  84267. */
  84268. lineColor: BABYLON.Color3;
  84269. /**
  84270. * The scale of the grid compared to unit.
  84271. */
  84272. gridRatio: number;
  84273. /**
  84274. * Allows setting an offset for the grid lines.
  84275. */
  84276. gridOffset: BABYLON.Vector3;
  84277. /**
  84278. * The frequency of thicker lines.
  84279. */
  84280. majorUnitFrequency: number;
  84281. /**
  84282. * The visibility of minor units in the grid.
  84283. */
  84284. minorUnitVisibility: number;
  84285. /**
  84286. * The grid opacity outside of the lines.
  84287. */
  84288. opacity: number;
  84289. /**
  84290. * Determine RBG output is premultiplied by alpha value.
  84291. */
  84292. preMultiplyAlpha: boolean;
  84293. private _opacityTexture;
  84294. opacityTexture: BABYLON.BaseTexture;
  84295. private _gridControl;
  84296. /**
  84297. * constructor
  84298. * @param name The name given to the material in order to identify it afterwards.
  84299. * @param scene The scene the material is used in.
  84300. */
  84301. constructor(name: string, scene: BABYLON.Scene);
  84302. /**
  84303. * Returns wehter or not the grid requires alpha blending.
  84304. */
  84305. needAlphaBlending(): boolean;
  84306. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  84307. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84308. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84309. /**
  84310. * Dispose the material and its associated resources.
  84311. * @param forceDisposeEffect will also dispose the used effect when true
  84312. */
  84313. dispose(forceDisposeEffect?: boolean): void;
  84314. clone(name: string): GridMaterial;
  84315. serialize(): any;
  84316. getClassName(): string;
  84317. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  84318. }
  84319. }
  84320. declare module BABYLON {
  84321. /** @hidden */
  84322. export var lavaPixelShader: {
  84323. name: string;
  84324. shader: string;
  84325. };
  84326. }
  84327. declare module BABYLON {
  84328. /** @hidden */
  84329. export var lavaVertexShader: {
  84330. name: string;
  84331. shader: string;
  84332. };
  84333. }
  84334. declare module BABYLON {
  84335. export class LavaMaterial extends BABYLON.PushMaterial {
  84336. private _diffuseTexture;
  84337. diffuseTexture: BABYLON.BaseTexture;
  84338. noiseTexture: BABYLON.BaseTexture;
  84339. fogColor: BABYLON.Color3;
  84340. speed: number;
  84341. movingSpeed: number;
  84342. lowFrequencySpeed: number;
  84343. fogDensity: number;
  84344. private _lastTime;
  84345. diffuseColor: BABYLON.Color3;
  84346. private _disableLighting;
  84347. disableLighting: boolean;
  84348. private _unlit;
  84349. unlit: boolean;
  84350. private _maxSimultaneousLights;
  84351. maxSimultaneousLights: number;
  84352. private _scaledDiffuse;
  84353. constructor(name: string, scene: BABYLON.Scene);
  84354. needAlphaBlending(): boolean;
  84355. needAlphaTesting(): boolean;
  84356. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84357. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84358. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84359. getAnimatables(): BABYLON.IAnimatable[];
  84360. getActiveTextures(): BABYLON.BaseTexture[];
  84361. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84362. dispose(forceDisposeEffect?: boolean): void;
  84363. clone(name: string): LavaMaterial;
  84364. serialize(): any;
  84365. getClassName(): string;
  84366. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  84367. }
  84368. }
  84369. declare module BABYLON {
  84370. /** @hidden */
  84371. export var mixPixelShader: {
  84372. name: string;
  84373. shader: string;
  84374. };
  84375. }
  84376. declare module BABYLON {
  84377. /** @hidden */
  84378. export var mixVertexShader: {
  84379. name: string;
  84380. shader: string;
  84381. };
  84382. }
  84383. declare module BABYLON {
  84384. export class MixMaterial extends BABYLON.PushMaterial {
  84385. /**
  84386. * Mix textures
  84387. */
  84388. private _mixTexture1;
  84389. mixTexture1: BABYLON.BaseTexture;
  84390. private _mixTexture2;
  84391. mixTexture2: BABYLON.BaseTexture;
  84392. /**
  84393. * Diffuse textures
  84394. */
  84395. private _diffuseTexture1;
  84396. diffuseTexture1: BABYLON.Texture;
  84397. private _diffuseTexture2;
  84398. diffuseTexture2: BABYLON.Texture;
  84399. private _diffuseTexture3;
  84400. diffuseTexture3: BABYLON.Texture;
  84401. private _diffuseTexture4;
  84402. diffuseTexture4: BABYLON.Texture;
  84403. private _diffuseTexture5;
  84404. diffuseTexture5: BABYLON.Texture;
  84405. private _diffuseTexture6;
  84406. diffuseTexture6: BABYLON.Texture;
  84407. private _diffuseTexture7;
  84408. diffuseTexture7: BABYLON.Texture;
  84409. private _diffuseTexture8;
  84410. diffuseTexture8: BABYLON.Texture;
  84411. /**
  84412. * Uniforms
  84413. */
  84414. diffuseColor: BABYLON.Color3;
  84415. specularColor: BABYLON.Color3;
  84416. specularPower: number;
  84417. private _disableLighting;
  84418. disableLighting: boolean;
  84419. private _maxSimultaneousLights;
  84420. maxSimultaneousLights: number;
  84421. constructor(name: string, scene: BABYLON.Scene);
  84422. needAlphaBlending(): boolean;
  84423. needAlphaTesting(): boolean;
  84424. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84425. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84426. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84427. getAnimatables(): BABYLON.IAnimatable[];
  84428. getActiveTextures(): BABYLON.BaseTexture[];
  84429. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84430. dispose(forceDisposeEffect?: boolean): void;
  84431. clone(name: string): MixMaterial;
  84432. serialize(): any;
  84433. getClassName(): string;
  84434. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  84435. }
  84436. }
  84437. declare module BABYLON {
  84438. /** @hidden */
  84439. export var normalPixelShader: {
  84440. name: string;
  84441. shader: string;
  84442. };
  84443. }
  84444. declare module BABYLON {
  84445. /** @hidden */
  84446. export var normalVertexShader: {
  84447. name: string;
  84448. shader: string;
  84449. };
  84450. }
  84451. declare module BABYLON {
  84452. export class NormalMaterial extends BABYLON.PushMaterial {
  84453. private _diffuseTexture;
  84454. diffuseTexture: BABYLON.BaseTexture;
  84455. diffuseColor: BABYLON.Color3;
  84456. private _disableLighting;
  84457. disableLighting: boolean;
  84458. private _maxSimultaneousLights;
  84459. maxSimultaneousLights: number;
  84460. constructor(name: string, scene: BABYLON.Scene);
  84461. needAlphaBlending(): boolean;
  84462. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  84463. needAlphaTesting(): boolean;
  84464. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84465. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84466. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84467. getAnimatables(): BABYLON.IAnimatable[];
  84468. getActiveTextures(): BABYLON.BaseTexture[];
  84469. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84470. dispose(forceDisposeEffect?: boolean): void;
  84471. clone(name: string): NormalMaterial;
  84472. serialize(): any;
  84473. getClassName(): string;
  84474. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  84475. }
  84476. }
  84477. declare module BABYLON {
  84478. /** @hidden */
  84479. export var shadowOnlyPixelShader: {
  84480. name: string;
  84481. shader: string;
  84482. };
  84483. }
  84484. declare module BABYLON {
  84485. /** @hidden */
  84486. export var shadowOnlyVertexShader: {
  84487. name: string;
  84488. shader: string;
  84489. };
  84490. }
  84491. declare module BABYLON {
  84492. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  84493. private _activeLight;
  84494. private _needAlphaBlending;
  84495. constructor(name: string, scene: BABYLON.Scene);
  84496. shadowColor: BABYLON.Color3;
  84497. needAlphaBlending(): boolean;
  84498. needAlphaTesting(): boolean;
  84499. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84500. get activeLight(): BABYLON.IShadowLight;
  84501. set activeLight(light: BABYLON.IShadowLight);
  84502. private _getFirstShadowLightForMesh;
  84503. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84504. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84505. clone(name: string): ShadowOnlyMaterial;
  84506. serialize(): any;
  84507. getClassName(): string;
  84508. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  84509. }
  84510. }
  84511. declare module BABYLON {
  84512. /** @hidden */
  84513. export var simplePixelShader: {
  84514. name: string;
  84515. shader: string;
  84516. };
  84517. }
  84518. declare module BABYLON {
  84519. /** @hidden */
  84520. export var simpleVertexShader: {
  84521. name: string;
  84522. shader: string;
  84523. };
  84524. }
  84525. declare module BABYLON {
  84526. export class SimpleMaterial extends BABYLON.PushMaterial {
  84527. private _diffuseTexture;
  84528. diffuseTexture: BABYLON.BaseTexture;
  84529. diffuseColor: BABYLON.Color3;
  84530. private _disableLighting;
  84531. disableLighting: boolean;
  84532. private _maxSimultaneousLights;
  84533. maxSimultaneousLights: number;
  84534. constructor(name: string, scene: BABYLON.Scene);
  84535. needAlphaBlending(): boolean;
  84536. needAlphaTesting(): boolean;
  84537. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84538. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84539. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84540. getAnimatables(): BABYLON.IAnimatable[];
  84541. getActiveTextures(): BABYLON.BaseTexture[];
  84542. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84543. dispose(forceDisposeEffect?: boolean): void;
  84544. clone(name: string): SimpleMaterial;
  84545. serialize(): any;
  84546. getClassName(): string;
  84547. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  84548. }
  84549. }
  84550. declare module BABYLON {
  84551. /** @hidden */
  84552. export var skyPixelShader: {
  84553. name: string;
  84554. shader: string;
  84555. };
  84556. }
  84557. declare module BABYLON {
  84558. /** @hidden */
  84559. export var skyVertexShader: {
  84560. name: string;
  84561. shader: string;
  84562. };
  84563. }
  84564. declare module BABYLON {
  84565. /**
  84566. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  84567. * @see https://doc.babylonjs.com/extensions/sky
  84568. */
  84569. export class SkyMaterial extends BABYLON.PushMaterial {
  84570. /**
  84571. * Defines the overall luminance of sky in interval ]0, 1[.
  84572. */
  84573. luminance: number;
  84574. /**
  84575. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  84576. */
  84577. turbidity: number;
  84578. /**
  84579. * Defines the sky appearance (light intensity).
  84580. */
  84581. rayleigh: number;
  84582. /**
  84583. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  84584. */
  84585. mieCoefficient: number;
  84586. /**
  84587. * Defines the amount of haze particles following the Mie scattering theory.
  84588. */
  84589. mieDirectionalG: number;
  84590. /**
  84591. * Defines the distance of the sun according to the active scene camera.
  84592. */
  84593. distance: number;
  84594. /**
  84595. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  84596. * "inclined".
  84597. */
  84598. inclination: number;
  84599. /**
  84600. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  84601. * an object direction and a reference direction.
  84602. */
  84603. azimuth: number;
  84604. /**
  84605. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  84606. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  84607. */
  84608. sunPosition: BABYLON.Vector3;
  84609. /**
  84610. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  84611. * .sunPosition property.
  84612. */
  84613. useSunPosition: boolean;
  84614. /**
  84615. * Defines an offset vector used to get a horizon offset.
  84616. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  84617. */
  84618. cameraOffset: BABYLON.Vector3;
  84619. private _cameraPosition;
  84620. /**
  84621. * Instantiates a new sky material.
  84622. * This material allows to create dynamic and texture free
  84623. * effects for skyboxes by taking care of the atmosphere state.
  84624. * @see https://doc.babylonjs.com/extensions/sky
  84625. * @param name Define the name of the material in the scene
  84626. * @param scene Define the scene the material belong to
  84627. */
  84628. constructor(name: string, scene: BABYLON.Scene);
  84629. /**
  84630. * Specifies if the material will require alpha blending
  84631. * @returns a boolean specifying if alpha blending is needed
  84632. */
  84633. needAlphaBlending(): boolean;
  84634. /**
  84635. * Specifies if this material should be rendered in alpha test mode
  84636. * @returns false as the sky material doesn't need alpha testing.
  84637. */
  84638. needAlphaTesting(): boolean;
  84639. /**
  84640. * Get the texture used for alpha test purpose.
  84641. * @returns null as the sky material has no texture.
  84642. */
  84643. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84644. /**
  84645. * Get if the submesh is ready to be used and all its information available.
  84646. * Child classes can use it to update shaders
  84647. * @param mesh defines the mesh to check
  84648. * @param subMesh defines which submesh to check
  84649. * @param useInstances specifies that instances should be used
  84650. * @returns a boolean indicating that the submesh is ready or not
  84651. */
  84652. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84653. /**
  84654. * Binds the submesh to this material by preparing the effect and shader to draw
  84655. * @param world defines the world transformation matrix
  84656. * @param mesh defines the mesh containing the submesh
  84657. * @param subMesh defines the submesh to bind the material to
  84658. */
  84659. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84660. /**
  84661. * Get the list of animatables in the material.
  84662. * @returns the list of animatables object used in the material
  84663. */
  84664. getAnimatables(): BABYLON.IAnimatable[];
  84665. /**
  84666. * Disposes the material
  84667. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  84668. */
  84669. dispose(forceDisposeEffect?: boolean): void;
  84670. /**
  84671. * Makes a duplicate of the material, and gives it a new name
  84672. * @param name defines the new name for the duplicated material
  84673. * @returns the cloned material
  84674. */
  84675. clone(name: string): SkyMaterial;
  84676. /**
  84677. * Serializes this material in a JSON representation
  84678. * @returns the serialized material object
  84679. */
  84680. serialize(): any;
  84681. /**
  84682. * Gets the current class name of the material e.g. "SkyMaterial"
  84683. * Mainly use in serialization.
  84684. * @returns the class name
  84685. */
  84686. getClassName(): string;
  84687. /**
  84688. * Creates a sky material from parsed material data
  84689. * @param source defines the JSON representation of the material
  84690. * @param scene defines the hosting scene
  84691. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  84692. * @returns a new sky material
  84693. */
  84694. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  84695. }
  84696. }
  84697. declare module BABYLON {
  84698. /** @hidden */
  84699. export var terrainPixelShader: {
  84700. name: string;
  84701. shader: string;
  84702. };
  84703. }
  84704. declare module BABYLON {
  84705. /** @hidden */
  84706. export var terrainVertexShader: {
  84707. name: string;
  84708. shader: string;
  84709. };
  84710. }
  84711. declare module BABYLON {
  84712. export class TerrainMaterial extends BABYLON.PushMaterial {
  84713. private _mixTexture;
  84714. mixTexture: BABYLON.BaseTexture;
  84715. private _diffuseTexture1;
  84716. diffuseTexture1: BABYLON.Texture;
  84717. private _diffuseTexture2;
  84718. diffuseTexture2: BABYLON.Texture;
  84719. private _diffuseTexture3;
  84720. diffuseTexture3: BABYLON.Texture;
  84721. private _bumpTexture1;
  84722. bumpTexture1: BABYLON.Texture;
  84723. private _bumpTexture2;
  84724. bumpTexture2: BABYLON.Texture;
  84725. private _bumpTexture3;
  84726. bumpTexture3: BABYLON.Texture;
  84727. diffuseColor: BABYLON.Color3;
  84728. specularColor: BABYLON.Color3;
  84729. specularPower: number;
  84730. private _disableLighting;
  84731. disableLighting: boolean;
  84732. private _maxSimultaneousLights;
  84733. maxSimultaneousLights: number;
  84734. constructor(name: string, scene: BABYLON.Scene);
  84735. needAlphaBlending(): boolean;
  84736. needAlphaTesting(): boolean;
  84737. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84738. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84739. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84740. getAnimatables(): BABYLON.IAnimatable[];
  84741. getActiveTextures(): BABYLON.BaseTexture[];
  84742. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84743. dispose(forceDisposeEffect?: boolean): void;
  84744. clone(name: string): TerrainMaterial;
  84745. serialize(): any;
  84746. getClassName(): string;
  84747. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  84748. }
  84749. }
  84750. declare module BABYLON {
  84751. /** @hidden */
  84752. export var triplanarPixelShader: {
  84753. name: string;
  84754. shader: string;
  84755. };
  84756. }
  84757. declare module BABYLON {
  84758. /** @hidden */
  84759. export var triplanarVertexShader: {
  84760. name: string;
  84761. shader: string;
  84762. };
  84763. }
  84764. declare module BABYLON {
  84765. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  84766. mixTexture: BABYLON.BaseTexture;
  84767. private _diffuseTextureX;
  84768. diffuseTextureX: BABYLON.BaseTexture;
  84769. private _diffuseTextureY;
  84770. diffuseTextureY: BABYLON.BaseTexture;
  84771. private _diffuseTextureZ;
  84772. diffuseTextureZ: BABYLON.BaseTexture;
  84773. private _normalTextureX;
  84774. normalTextureX: BABYLON.BaseTexture;
  84775. private _normalTextureY;
  84776. normalTextureY: BABYLON.BaseTexture;
  84777. private _normalTextureZ;
  84778. normalTextureZ: BABYLON.BaseTexture;
  84779. tileSize: number;
  84780. diffuseColor: BABYLON.Color3;
  84781. specularColor: BABYLON.Color3;
  84782. specularPower: number;
  84783. private _disableLighting;
  84784. disableLighting: boolean;
  84785. private _maxSimultaneousLights;
  84786. maxSimultaneousLights: number;
  84787. constructor(name: string, scene: BABYLON.Scene);
  84788. needAlphaBlending(): boolean;
  84789. needAlphaTesting(): boolean;
  84790. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84791. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84792. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84793. getAnimatables(): BABYLON.IAnimatable[];
  84794. getActiveTextures(): BABYLON.BaseTexture[];
  84795. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84796. dispose(forceDisposeEffect?: boolean): void;
  84797. clone(name: string): TriPlanarMaterial;
  84798. serialize(): any;
  84799. getClassName(): string;
  84800. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  84801. }
  84802. }
  84803. declare module BABYLON {
  84804. /** @hidden */
  84805. export var waterPixelShader: {
  84806. name: string;
  84807. shader: string;
  84808. };
  84809. }
  84810. declare module BABYLON {
  84811. /** @hidden */
  84812. export var waterVertexShader: {
  84813. name: string;
  84814. shader: string;
  84815. };
  84816. }
  84817. declare module BABYLON {
  84818. export class WaterMaterial extends BABYLON.PushMaterial {
  84819. renderTargetSize: BABYLON.Vector2;
  84820. private _bumpTexture;
  84821. bumpTexture: BABYLON.BaseTexture;
  84822. diffuseColor: BABYLON.Color3;
  84823. specularColor: BABYLON.Color3;
  84824. specularPower: number;
  84825. private _disableLighting;
  84826. disableLighting: boolean;
  84827. private _maxSimultaneousLights;
  84828. maxSimultaneousLights: number;
  84829. /**
  84830. * @param {number}: Represents the wind force
  84831. */
  84832. windForce: number;
  84833. /**
  84834. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  84835. */
  84836. windDirection: BABYLON.Vector2;
  84837. /**
  84838. * @param {number}: Wave height, represents the height of the waves
  84839. */
  84840. waveHeight: number;
  84841. /**
  84842. * @param {number}: Bump height, represents the bump height related to the bump map
  84843. */
  84844. bumpHeight: number;
  84845. /**
  84846. * @param {boolean}: Add a smaller moving bump to less steady waves.
  84847. */
  84848. private _bumpSuperimpose;
  84849. bumpSuperimpose: boolean;
  84850. /**
  84851. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  84852. */
  84853. private _fresnelSeparate;
  84854. fresnelSeparate: boolean;
  84855. /**
  84856. * @param {boolean}: bump Waves modify the reflection.
  84857. */
  84858. private _bumpAffectsReflection;
  84859. bumpAffectsReflection: boolean;
  84860. /**
  84861. * @param {number}: The water color blended with the refraction (near)
  84862. */
  84863. waterColor: BABYLON.Color3;
  84864. /**
  84865. * @param {number}: The blend factor related to the water color
  84866. */
  84867. colorBlendFactor: number;
  84868. /**
  84869. * @param {number}: The water color blended with the reflection (far)
  84870. */
  84871. waterColor2: BABYLON.Color3;
  84872. /**
  84873. * @param {number}: The blend factor related to the water color (reflection, far)
  84874. */
  84875. colorBlendFactor2: number;
  84876. /**
  84877. * @param {number}: Represents the maximum length of a wave
  84878. */
  84879. waveLength: number;
  84880. /**
  84881. * @param {number}: Defines the waves speed
  84882. */
  84883. waveSpeed: number;
  84884. /**
  84885. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  84886. * will avoid calculating useless pixels in the pixel shader of the water material.
  84887. */
  84888. disableClipPlane: boolean;
  84889. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  84890. private _mesh;
  84891. private _refractionRTT;
  84892. private _reflectionRTT;
  84893. private _reflectionTransform;
  84894. private _lastTime;
  84895. private _lastDeltaTime;
  84896. private _useLogarithmicDepth;
  84897. private _waitingRenderList;
  84898. private _imageProcessingConfiguration;
  84899. private _imageProcessingObserver;
  84900. /**
  84901. * Gets a boolean indicating that current material needs to register RTT
  84902. */
  84903. get hasRenderTargetTextures(): boolean;
  84904. /**
  84905. * Constructor
  84906. */
  84907. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  84908. get useLogarithmicDepth(): boolean;
  84909. set useLogarithmicDepth(value: boolean);
  84910. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  84911. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  84912. addToRenderList(node: any): void;
  84913. enableRenderTargets(enable: boolean): void;
  84914. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  84915. get renderTargetsEnabled(): boolean;
  84916. needAlphaBlending(): boolean;
  84917. needAlphaTesting(): boolean;
  84918. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84919. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84920. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84921. private _createRenderTargets;
  84922. getAnimatables(): BABYLON.IAnimatable[];
  84923. getActiveTextures(): BABYLON.BaseTexture[];
  84924. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84925. dispose(forceDisposeEffect?: boolean): void;
  84926. clone(name: string): WaterMaterial;
  84927. serialize(): any;
  84928. getClassName(): string;
  84929. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  84930. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  84931. }
  84932. }
  84933. declare module BABYLON {
  84934. /** @hidden */
  84935. export var asciiartPixelShader: {
  84936. name: string;
  84937. shader: string;
  84938. };
  84939. }
  84940. declare module BABYLON {
  84941. /**
  84942. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  84943. *
  84944. * It basically takes care rendering the font front the given font size to a texture.
  84945. * This is used later on in the postprocess.
  84946. */
  84947. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  84948. private _font;
  84949. private _text;
  84950. private _charSize;
  84951. /**
  84952. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  84953. */
  84954. get charSize(): number;
  84955. /**
  84956. * Create a new instance of the Ascii Art FontTexture class
  84957. * @param name the name of the texture
  84958. * @param font the font to use, use the W3C CSS notation
  84959. * @param text the caracter set to use in the rendering.
  84960. * @param scene the scene that owns the texture
  84961. */
  84962. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  84963. /**
  84964. * Gets the max char width of a font.
  84965. * @param font the font to use, use the W3C CSS notation
  84966. * @return the max char width
  84967. */
  84968. private getFontWidth;
  84969. /**
  84970. * Gets the max char height of a font.
  84971. * @param font the font to use, use the W3C CSS notation
  84972. * @return the max char height
  84973. */
  84974. private getFontHeight;
  84975. /**
  84976. * Clones the current AsciiArtTexture.
  84977. * @return the clone of the texture.
  84978. */
  84979. clone(): AsciiArtFontTexture;
  84980. /**
  84981. * Parses a json object representing the texture and returns an instance of it.
  84982. * @param source the source JSON representation
  84983. * @param scene the scene to create the texture for
  84984. * @return the parsed texture
  84985. */
  84986. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  84987. }
  84988. /**
  84989. * Option available in the Ascii Art Post Process.
  84990. */
  84991. export interface IAsciiArtPostProcessOptions {
  84992. /**
  84993. * The font to use following the w3c font definition.
  84994. */
  84995. font?: string;
  84996. /**
  84997. * The character set to use in the postprocess.
  84998. */
  84999. characterSet?: string;
  85000. /**
  85001. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  85002. * This number is defined between 0 and 1;
  85003. */
  85004. mixToTile?: number;
  85005. /**
  85006. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  85007. * This number is defined between 0 and 1;
  85008. */
  85009. mixToNormal?: number;
  85010. }
  85011. /**
  85012. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  85013. *
  85014. * Simmply add it to your scene and let the nerd that lives in you have fun.
  85015. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  85016. */
  85017. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  85018. /**
  85019. * The font texture used to render the char in the post process.
  85020. */
  85021. private _asciiArtFontTexture;
  85022. /**
  85023. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  85024. * This number is defined between 0 and 1;
  85025. */
  85026. mixToTile: number;
  85027. /**
  85028. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  85029. * This number is defined between 0 and 1;
  85030. */
  85031. mixToNormal: number;
  85032. /**
  85033. * Instantiates a new Ascii Art Post Process.
  85034. * @param name the name to give to the postprocess
  85035. * @camera the camera to apply the post process to.
  85036. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  85037. */
  85038. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  85039. }
  85040. }
  85041. declare module BABYLON {
  85042. /** @hidden */
  85043. export var digitalrainPixelShader: {
  85044. name: string;
  85045. shader: string;
  85046. };
  85047. }
  85048. declare module BABYLON {
  85049. /**
  85050. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  85051. *
  85052. * It basically takes care rendering the font front the given font size to a texture.
  85053. * This is used later on in the postprocess.
  85054. */
  85055. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  85056. private _font;
  85057. private _text;
  85058. private _charSize;
  85059. /**
  85060. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  85061. */
  85062. get charSize(): number;
  85063. /**
  85064. * Create a new instance of the Digital Rain FontTexture class
  85065. * @param name the name of the texture
  85066. * @param font the font to use, use the W3C CSS notation
  85067. * @param text the caracter set to use in the rendering.
  85068. * @param scene the scene that owns the texture
  85069. */
  85070. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  85071. /**
  85072. * Gets the max char width of a font.
  85073. * @param font the font to use, use the W3C CSS notation
  85074. * @return the max char width
  85075. */
  85076. private getFontWidth;
  85077. /**
  85078. * Gets the max char height of a font.
  85079. * @param font the font to use, use the W3C CSS notation
  85080. * @return the max char height
  85081. */
  85082. private getFontHeight;
  85083. /**
  85084. * Clones the current DigitalRainFontTexture.
  85085. * @return the clone of the texture.
  85086. */
  85087. clone(): DigitalRainFontTexture;
  85088. /**
  85089. * Parses a json object representing the texture and returns an instance of it.
  85090. * @param source the source JSON representation
  85091. * @param scene the scene to create the texture for
  85092. * @return the parsed texture
  85093. */
  85094. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  85095. }
  85096. /**
  85097. * Option available in the Digital Rain Post Process.
  85098. */
  85099. export interface IDigitalRainPostProcessOptions {
  85100. /**
  85101. * The font to use following the w3c font definition.
  85102. */
  85103. font?: string;
  85104. /**
  85105. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  85106. * This number is defined between 0 and 1;
  85107. */
  85108. mixToTile?: number;
  85109. /**
  85110. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  85111. * This number is defined between 0 and 1;
  85112. */
  85113. mixToNormal?: number;
  85114. }
  85115. /**
  85116. * DigitalRainPostProcess helps rendering everithing in digital rain.
  85117. *
  85118. * Simmply add it to your scene and let the nerd that lives in you have fun.
  85119. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  85120. */
  85121. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  85122. /**
  85123. * The font texture used to render the char in the post process.
  85124. */
  85125. private _digitalRainFontTexture;
  85126. /**
  85127. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  85128. * This number is defined between 0 and 1;
  85129. */
  85130. mixToTile: number;
  85131. /**
  85132. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  85133. * This number is defined between 0 and 1;
  85134. */
  85135. mixToNormal: number;
  85136. /**
  85137. * Instantiates a new Digital Rain Post Process.
  85138. * @param name the name to give to the postprocess
  85139. * @camera the camera to apply the post process to.
  85140. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  85141. */
  85142. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  85143. }
  85144. }
  85145. declare module BABYLON {
  85146. /** @hidden */
  85147. export var brickProceduralTexturePixelShader: {
  85148. name: string;
  85149. shader: string;
  85150. };
  85151. }
  85152. declare module BABYLON {
  85153. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  85154. private _numberOfBricksHeight;
  85155. private _numberOfBricksWidth;
  85156. private _jointColor;
  85157. private _brickColor;
  85158. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85159. updateShaderUniforms(): void;
  85160. get numberOfBricksHeight(): number;
  85161. set numberOfBricksHeight(value: number);
  85162. get numberOfBricksWidth(): number;
  85163. set numberOfBricksWidth(value: number);
  85164. get jointColor(): BABYLON.Color3;
  85165. set jointColor(value: BABYLON.Color3);
  85166. get brickColor(): BABYLON.Color3;
  85167. set brickColor(value: BABYLON.Color3);
  85168. /**
  85169. * Serializes this brick procedural texture
  85170. * @returns a serialized brick procedural texture object
  85171. */
  85172. serialize(): any;
  85173. /**
  85174. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  85175. * @param parsedTexture defines parsed texture data
  85176. * @param scene defines the current scene
  85177. * @param rootUrl defines the root URL containing brick procedural texture information
  85178. * @returns a parsed Brick Procedural BABYLON.Texture
  85179. */
  85180. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  85181. }
  85182. }
  85183. declare module BABYLON {
  85184. /** @hidden */
  85185. export var cloudProceduralTexturePixelShader: {
  85186. name: string;
  85187. shader: string;
  85188. };
  85189. }
  85190. declare module BABYLON {
  85191. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  85192. private _skyColor;
  85193. private _cloudColor;
  85194. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85195. updateShaderUniforms(): void;
  85196. get skyColor(): BABYLON.Color4;
  85197. set skyColor(value: BABYLON.Color4);
  85198. get cloudColor(): BABYLON.Color4;
  85199. set cloudColor(value: BABYLON.Color4);
  85200. /**
  85201. * Serializes this cloud procedural texture
  85202. * @returns a serialized cloud procedural texture object
  85203. */
  85204. serialize(): any;
  85205. /**
  85206. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  85207. * @param parsedTexture defines parsed texture data
  85208. * @param scene defines the current scene
  85209. * @param rootUrl defines the root URL containing cloud procedural texture information
  85210. * @returns a parsed Cloud Procedural BABYLON.Texture
  85211. */
  85212. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  85213. }
  85214. }
  85215. declare module BABYLON {
  85216. /** @hidden */
  85217. export var fireProceduralTexturePixelShader: {
  85218. name: string;
  85219. shader: string;
  85220. };
  85221. }
  85222. declare module BABYLON {
  85223. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  85224. private _time;
  85225. private _speed;
  85226. private _autoGenerateTime;
  85227. private _fireColors;
  85228. private _alphaThreshold;
  85229. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85230. updateShaderUniforms(): void;
  85231. render(useCameraPostProcess?: boolean): void;
  85232. static get PurpleFireColors(): BABYLON.Color3[];
  85233. static get GreenFireColors(): BABYLON.Color3[];
  85234. static get RedFireColors(): BABYLON.Color3[];
  85235. static get BlueFireColors(): BABYLON.Color3[];
  85236. get autoGenerateTime(): boolean;
  85237. set autoGenerateTime(value: boolean);
  85238. get fireColors(): BABYLON.Color3[];
  85239. set fireColors(value: BABYLON.Color3[]);
  85240. get time(): number;
  85241. set time(value: number);
  85242. get speed(): BABYLON.Vector2;
  85243. set speed(value: BABYLON.Vector2);
  85244. get alphaThreshold(): number;
  85245. set alphaThreshold(value: number);
  85246. /**
  85247. * Serializes this fire procedural texture
  85248. * @returns a serialized fire procedural texture object
  85249. */
  85250. serialize(): any;
  85251. /**
  85252. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  85253. * @param parsedTexture defines parsed texture data
  85254. * @param scene defines the current scene
  85255. * @param rootUrl defines the root URL containing fire procedural texture information
  85256. * @returns a parsed Fire Procedural BABYLON.Texture
  85257. */
  85258. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  85259. }
  85260. }
  85261. declare module BABYLON {
  85262. /** @hidden */
  85263. export var grassProceduralTexturePixelShader: {
  85264. name: string;
  85265. shader: string;
  85266. };
  85267. }
  85268. declare module BABYLON {
  85269. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  85270. private _grassColors;
  85271. private _groundColor;
  85272. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85273. updateShaderUniforms(): void;
  85274. get grassColors(): BABYLON.Color3[];
  85275. set grassColors(value: BABYLON.Color3[]);
  85276. get groundColor(): BABYLON.Color3;
  85277. set groundColor(value: BABYLON.Color3);
  85278. /**
  85279. * Serializes this grass procedural texture
  85280. * @returns a serialized grass procedural texture object
  85281. */
  85282. serialize(): any;
  85283. /**
  85284. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  85285. * @param parsedTexture defines parsed texture data
  85286. * @param scene defines the current scene
  85287. * @param rootUrl defines the root URL containing grass procedural texture information
  85288. * @returns a parsed Grass Procedural BABYLON.Texture
  85289. */
  85290. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  85291. }
  85292. }
  85293. declare module BABYLON {
  85294. /** @hidden */
  85295. export var marbleProceduralTexturePixelShader: {
  85296. name: string;
  85297. shader: string;
  85298. };
  85299. }
  85300. declare module BABYLON {
  85301. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  85302. private _numberOfTilesHeight;
  85303. private _numberOfTilesWidth;
  85304. private _amplitude;
  85305. private _jointColor;
  85306. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85307. updateShaderUniforms(): void;
  85308. get numberOfTilesHeight(): number;
  85309. set numberOfTilesHeight(value: number);
  85310. get amplitude(): number;
  85311. set amplitude(value: number);
  85312. get numberOfTilesWidth(): number;
  85313. set numberOfTilesWidth(value: number);
  85314. get jointColor(): BABYLON.Color3;
  85315. set jointColor(value: BABYLON.Color3);
  85316. /**
  85317. * Serializes this marble procedural texture
  85318. * @returns a serialized marble procedural texture object
  85319. */
  85320. serialize(): any;
  85321. /**
  85322. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  85323. * @param parsedTexture defines parsed texture data
  85324. * @param scene defines the current scene
  85325. * @param rootUrl defines the root URL containing marble procedural texture information
  85326. * @returns a parsed Marble Procedural BABYLON.Texture
  85327. */
  85328. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  85329. }
  85330. }
  85331. declare module BABYLON {
  85332. /** @hidden */
  85333. export var normalMapProceduralTexturePixelShader: {
  85334. name: string;
  85335. shader: string;
  85336. };
  85337. }
  85338. declare module BABYLON {
  85339. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  85340. private _baseTexture;
  85341. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85342. updateShaderUniforms(): void;
  85343. render(useCameraPostProcess?: boolean): void;
  85344. resize(size: any, generateMipMaps: any): void;
  85345. get baseTexture(): BABYLON.Texture;
  85346. set baseTexture(texture: BABYLON.Texture);
  85347. /**
  85348. * Serializes this normal map procedural texture
  85349. * @returns a serialized normal map procedural texture object
  85350. */
  85351. serialize(): any;
  85352. /**
  85353. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  85354. * @param parsedTexture defines parsed texture data
  85355. * @param scene defines the current scene
  85356. * @param rootUrl defines the root URL containing normal map procedural texture information
  85357. * @returns a parsed Normal Map Procedural BABYLON.Texture
  85358. */
  85359. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  85360. }
  85361. }
  85362. declare module BABYLON {
  85363. /** @hidden */
  85364. export var perlinNoiseProceduralTexturePixelShader: {
  85365. name: string;
  85366. shader: string;
  85367. };
  85368. }
  85369. declare module BABYLON {
  85370. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  85371. time: number;
  85372. timeScale: number;
  85373. translationSpeed: number;
  85374. private _currentTranslation;
  85375. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85376. updateShaderUniforms(): void;
  85377. render(useCameraPostProcess?: boolean): void;
  85378. resize(size: any, generateMipMaps: any): void;
  85379. /**
  85380. * Serializes this perlin noise procedural texture
  85381. * @returns a serialized perlin noise procedural texture object
  85382. */
  85383. serialize(): any;
  85384. /**
  85385. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  85386. * @param parsedTexture defines parsed texture data
  85387. * @param scene defines the current scene
  85388. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  85389. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  85390. */
  85391. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  85392. }
  85393. }
  85394. declare module BABYLON {
  85395. /** @hidden */
  85396. export var roadProceduralTexturePixelShader: {
  85397. name: string;
  85398. shader: string;
  85399. };
  85400. }
  85401. declare module BABYLON {
  85402. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  85403. private _roadColor;
  85404. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85405. updateShaderUniforms(): void;
  85406. get roadColor(): BABYLON.Color3;
  85407. set roadColor(value: BABYLON.Color3);
  85408. /**
  85409. * Serializes this road procedural texture
  85410. * @returns a serialized road procedural texture object
  85411. */
  85412. serialize(): any;
  85413. /**
  85414. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  85415. * @param parsedTexture defines parsed texture data
  85416. * @param scene defines the current scene
  85417. * @param rootUrl defines the root URL containing road procedural texture information
  85418. * @returns a parsed Road Procedural BABYLON.Texture
  85419. */
  85420. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  85421. }
  85422. }
  85423. declare module BABYLON {
  85424. /** @hidden */
  85425. export var starfieldProceduralTexturePixelShader: {
  85426. name: string;
  85427. shader: string;
  85428. };
  85429. }
  85430. declare module BABYLON {
  85431. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  85432. private _time;
  85433. private _alpha;
  85434. private _beta;
  85435. private _zoom;
  85436. private _formuparam;
  85437. private _stepsize;
  85438. private _tile;
  85439. private _brightness;
  85440. private _darkmatter;
  85441. private _distfading;
  85442. private _saturation;
  85443. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85444. updateShaderUniforms(): void;
  85445. get time(): number;
  85446. set time(value: number);
  85447. get alpha(): number;
  85448. set alpha(value: number);
  85449. get beta(): number;
  85450. set beta(value: number);
  85451. get formuparam(): number;
  85452. set formuparam(value: number);
  85453. get stepsize(): number;
  85454. set stepsize(value: number);
  85455. get zoom(): number;
  85456. set zoom(value: number);
  85457. get tile(): number;
  85458. set tile(value: number);
  85459. get brightness(): number;
  85460. set brightness(value: number);
  85461. get darkmatter(): number;
  85462. set darkmatter(value: number);
  85463. get distfading(): number;
  85464. set distfading(value: number);
  85465. get saturation(): number;
  85466. set saturation(value: number);
  85467. /**
  85468. * Serializes this starfield procedural texture
  85469. * @returns a serialized starfield procedural texture object
  85470. */
  85471. serialize(): any;
  85472. /**
  85473. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  85474. * @param parsedTexture defines parsed texture data
  85475. * @param scene defines the current scene
  85476. * @param rootUrl defines the root URL containing startfield procedural texture information
  85477. * @returns a parsed Starfield Procedural BABYLON.Texture
  85478. */
  85479. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  85480. }
  85481. }
  85482. declare module BABYLON {
  85483. /** @hidden */
  85484. export var woodProceduralTexturePixelShader: {
  85485. name: string;
  85486. shader: string;
  85487. };
  85488. }
  85489. declare module BABYLON {
  85490. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  85491. private _ampScale;
  85492. private _woodColor;
  85493. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85494. updateShaderUniforms(): void;
  85495. get ampScale(): number;
  85496. set ampScale(value: number);
  85497. get woodColor(): BABYLON.Color3;
  85498. set woodColor(value: BABYLON.Color3);
  85499. /**
  85500. * Serializes this wood procedural texture
  85501. * @returns a serialized wood procedural texture object
  85502. */
  85503. serialize(): any;
  85504. /**
  85505. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  85506. * @param parsedTexture defines parsed texture data
  85507. * @param scene defines the current scene
  85508. * @param rootUrl defines the root URL containing wood procedural texture information
  85509. * @returns a parsed Wood Procedural BABYLON.Texture
  85510. */
  85511. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  85512. }
  85513. }